diff --git a/server/Makefile b/server/Makefile index 32d8f01..e43c4c8 100644 --- a/server/Makefile +++ b/server/Makefile @@ -39,7 +39,7 @@ build: $(OUT_DIR) # apt install gcc-mingw-w64 GOARCH=386 GOOS=windows CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o $(OUT_DIR)/mapserver-windows-x86.exe GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 go build -o $(OUT_DIR)/mapserver-windows-x86-64.exe - # apt install gcc-5-arm-linux-gnueabihf, TODO: container + # apt install gcc-5-arm-linux-gnueabihf GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-5 CGO_ENABLED=1 go build $(GO_LDFLAGS) -o $(OUT_DIR)/mapserver-linux-arm #go test -cpuprofile cpu.prof -memprofile mem.prof -bench . ./mapblockrenderer/ diff --git a/server/colormapping/colormapping.go b/server/colormapping/colormapping.go index 6cda961..6c6fa64 100644 --- a/server/colormapping/colormapping.go +++ b/server/colormapping/colormapping.go @@ -75,8 +75,6 @@ func (m *ColorMapping) LoadBytes(buffer []byte) (int, error) { return count, nil } -//TODO: colors from fs - func (m *ColorMapping) LoadVFSColors(useLocal bool, filename string) (int, error) { buffer, err := vfs.FSByte(useLocal, "/colors.txt") if err != nil { diff --git a/server/db/accessor.go b/server/db/accessor.go index e5d7028..0909a07 100644 --- a/server/db/accessor.go +++ b/server/db/accessor.go @@ -16,7 +16,7 @@ type InitialBlocksResult struct { List []*Block UnfilteredCount int HasMore bool - Progress float64 + Progress float64 } type DBAccessor interface { diff --git a/server/db/postgres/initialblocks.go b/server/db/postgres/initialblocks.go index 4240ecb..83eb04f 100644 --- a/server/db/postgres/initialblocks.go +++ b/server/db/postgres/initialblocks.go @@ -73,10 +73,10 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers tcr.Pos2.Y = toY fields := logrus.Fields{ - "layerId": lastlayer, - "pos1": tcr.Pos1, - "pos2": tcr.Pos2, - "tile": tc, + "layerId": lastlayer, + "pos1": tcr.Pos1, + "pos2": tcr.Pos2, + "tile": tc, } log.WithFields(fields).Debug("Initial-Query") @@ -112,7 +112,7 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers s.SetInt(SETTING_LAST_Y_BLOCK, lastyblock+1) result := &db.InitialBlocksResult{} - result.Progress = float64(((lastyblock+128) * 256) + (lastxblock+128)) / float64(256*256) + result.Progress = float64(((lastyblock+128)*256)+(lastxblock+128)) / float64(256*256) result.HasMore = true return result, nil } @@ -153,7 +153,7 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers s.SetInt(SETTING_LAST_Y_BLOCK, lastyblock) result := &db.InitialBlocksResult{} - result.Progress = float64(((lastyblock+128) * 256) + (lastxblock+128)) / float64(256*256) + result.Progress = float64(((lastyblock+128)*256)+(lastxblock+128)) / float64(256*256) result.List = blocks result.HasMore = true diff --git a/server/db/sqlite/initialblocks.go b/server/db/sqlite/initialblocks.go index d8ae209..df158a7 100644 --- a/server/db/sqlite/initialblocks.go +++ b/server/db/sqlite/initialblocks.go @@ -9,8 +9,8 @@ import ( ) const ( - SETTING_LAST_POS = "last_pos" - SETTING_TOTAL_LEGACY_COUNT = "total_legacy_count" + SETTING_LAST_POS = "last_pos" + SETTING_TOTAL_LEGACY_COUNT = "total_legacy_count" SETTING_PROCESSED_LEGACY_COUNT = "total_processed_legacy_count" ) @@ -75,7 +75,7 @@ func (this *Sqlite3Accessor) FindNextInitialBlocks(s settings.Settings, layers [ } } - s.SetInt64(SETTING_PROCESSED_LEGACY_COUNT, int64(result.UnfilteredCount) + processedcount) + s.SetInt64(SETTING_PROCESSED_LEGACY_COUNT, int64(result.UnfilteredCount)+processedcount) result.Progress = float64(processedcount) / float64(totallegacycount) result.List = blocks diff --git a/server/main.go b/server/main.go index 1a5fd65..49ecf37 100644 --- a/server/main.go +++ b/server/main.go @@ -69,7 +69,6 @@ func main() { } //Start http server - //TODO: defer, may cause race condition web.Serve(ctx) } diff --git a/server/mapblockaccessor/legacyblocks.go b/server/mapblockaccessor/legacyblocks.go index fa09073..469b7d7 100644 --- a/server/mapblockaccessor/legacyblocks.go +++ b/server/mapblockaccessor/legacyblocks.go @@ -14,7 +14,7 @@ type FindNextLegacyBlocksResult struct { HasMore bool List []*mapblockparser.MapBlock UnfilteredCount int - Progress float64 + Progress float64 } func (a *MapBlockAccessor) FindNextLegacyBlocks(s settings.Settings, layers []*layer.Layer, limit int) (*FindNextLegacyBlocksResult, error) { diff --git a/server/mapblockaccessor/mtime.go b/server/mapblockaccessor/mtime.go index d0f7b33..5b985d0 100644 --- a/server/mapblockaccessor/mtime.go +++ b/server/mapblockaccessor/mtime.go @@ -7,8 +7,8 @@ import ( "mapserver/mapblockparser" cache "github.com/patrickmn/go-cache" - "github.com/sirupsen/logrus" "github.com/prometheus/client_golang/prometheus" + "github.com/sirupsen/logrus" ) type FindMapBlocksByMtimeResult struct { diff --git a/server/mapblockparser/mapdata.go b/server/mapblockparser/mapdata.go index 2c384b5..031f622 100644 --- a/server/mapblockparser/mapdata.go +++ b/server/mapblockparser/mapdata.go @@ -8,8 +8,6 @@ import ( "strconv" ) -//TODO: mapdata struct with accessors - func parseMapdata(mapblock *MapBlock, data []byte) (int, error) { r := bytes.NewReader(data) diff --git a/server/mapblockparser/parse.go b/server/mapblockparser/parse.go index fbed23b..2612cfa 100644 --- a/server/mapblockparser/parse.go +++ b/server/mapblockparser/parse.go @@ -2,9 +2,9 @@ package mapblockparser import ( "errors" + "github.com/prometheus/client_golang/prometheus" "mapserver/coords" "strconv" - "github.com/prometheus/client_golang/prometheus" ) func Parse(data []byte, mtime int64, pos *coords.MapBlockCoords) (*MapBlock, error) { @@ -13,7 +13,7 @@ func Parse(data []byte, mtime int64, pos *coords.MapBlockCoords) (*MapBlock, err } timer := prometheus.NewTimer(parseDuration) - defer timer.ObserveDuration() + defer timer.ObserveDuration() mapblock := NewMapblock() mapblock.Mtime = mtime diff --git a/server/mapblockrenderer/renderer.go b/server/mapblockrenderer/renderer.go index e7b349d..1714bd8 100644 --- a/server/mapblockrenderer/renderer.go +++ b/server/mapblockrenderer/renderer.go @@ -10,8 +10,8 @@ import ( "mapserver/mapblockaccessor" "time" - "github.com/sirupsen/logrus" "github.com/prometheus/client_golang/prometheus" + "github.com/sirupsen/logrus" ) type MapBlockRenderer struct { @@ -82,7 +82,7 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRG renderedMapblocks.Inc() timer := prometheus.NewTimer(renderDuration) - defer timer.ObserveDuration() + defer timer.ObserveDuration() start := time.Now() defer func() { diff --git a/server/tiledb/tiledb.go b/server/tiledb/tiledb.go index 7b223a4..7d6fe50 100644 --- a/server/tiledb/tiledb.go +++ b/server/tiledb/tiledb.go @@ -6,7 +6,6 @@ import ( "github.com/dgraph-io/badger" "github.com/prometheus/client_golang/prometheus" - ) func New(path string) (*TileDB, error) { diff --git a/server/tilerenderer/renderer.go b/server/tilerenderer/renderer.go index 898da2e..12a4f76 100644 --- a/server/tilerenderer/renderer.go +++ b/server/tilerenderer/renderer.go @@ -12,8 +12,8 @@ import ( "mapserver/layer" "mapserver/mapblockrenderer" "mapserver/tiledb" - "time" "strconv" + "time" "github.com/disintegration/imaging" "github.com/sirupsen/logrus" @@ -98,7 +98,7 @@ func (tr *TileRenderer) RenderImage(tc *coords.TileCoords, recursionDepth int) ( log.WithFields(logrus.Fields{"x": tc.X, "y": tc.Y, "zoom": tc.Zoom}).Debug("RenderImage") - renderedTiles.With(prometheus.Labels{"zoom":strconv.Itoa(tc.Zoom)}).Inc() + renderedTiles.With(prometheus.Labels{"zoom": strconv.Itoa(tc.Zoom)}).Inc() timer := prometheus.NewTimer(renderDuration) defer timer.ObserveDuration() diff --git a/server/web/mapobjects.go b/server/web/mapobjects.go index a2c9b66..a1d2091 100644 --- a/server/web/mapobjects.go +++ b/server/web/mapobjects.go @@ -2,13 +2,13 @@ package web import ( "encoding/json" + "github.com/prometheus/client_golang/prometheus" "mapserver/app" "mapserver/coords" "mapserver/mapobjectdb" "net/http" "strconv" "strings" - "github.com/prometheus/client_golang/prometheus" ) type MapObjects struct { diff --git a/server/web/tiles.go b/server/web/tiles.go index 687ff88..914b602 100644 --- a/server/web/tiles.go +++ b/server/web/tiles.go @@ -1,6 +1,7 @@ package web import ( + "github.com/prometheus/client_golang/prometheus" "image/color" "mapserver/app" "mapserver/coords" @@ -8,11 +9,8 @@ import ( "net/http" "strconv" "strings" - "github.com/prometheus/client_golang/prometheus" ) - - type Tiles struct { ctx *app.App blank []byte @@ -35,7 +33,6 @@ func (t *Tiles) ServeHTTP(resp http.ResponseWriter, req *http.Request) { timer := prometheus.NewTimer(tileServeDuration) defer timer.ObserveDuration() - layerid, _ := strconv.Atoi(parts[0]) x, _ := strconv.Atoi(parts[1]) y, _ := strconv.Atoi(parts[2])