Use a more general db client factory approach.

This commit is contained in:
Sascha L. Teichmann
2022-03-01 14:47:14 +01:00
parent 834c8a9bc6
commit c507663826
9 changed files with 99 additions and 53 deletions

View File

@ -56,7 +56,7 @@ func createTiles(
}
func createBaseLevel(
dbcc common.DBClientCreator,
dbcf common.DBClientFactory,
xMin, yMin, zMin, xMax, yMax, zMax int,
transparent bool, transparentDim float32,
colorsFile string, bg color.RGBA, outDir string,
@ -81,7 +81,7 @@ func createBaseLevel(
for i := 0; i < numWorkers; i++ {
var client common.DBClient
if client, err = dbcc(); err != nil {
if client, err = dbcf.Create(); err != nil {
return
}
done.Add(1)

View File

@ -68,12 +68,16 @@ func main() {
bg := common.ParseColorDefault(bgColor, common.BackgroundColor)
dbcc := common.CreateDBClientCreator(host, port)
dbcf, err := common.CreateDBClientFactory(host, port)
if err != nil {
log.Fatalf("error: %s\n", err)
}
defer dbcf.Close()
if !skipBaseLevel {
td := common.Clamp32f(float32(transparentDim/100.0), 0.0, 1.0)
if err := createBaseLevel(
dbcc,
dbcf,
xMin, yMin, zMin, xMax, yMax, zMax,
transparent, td,
colorsFile, bg,