mapserver/server/tilerendererjob/common.go

55 lines
1.1 KiB
Go
Raw Normal View History

2019-01-24 17:56:37 +03:00
package tilerendererjob
import (
"mapserver/app"
"mapserver/coords"
"mapserver/mapblockparser"
"strconv"
2019-01-24 22:55:20 +03:00
"github.com/sirupsen/logrus"
2019-01-24 17:56:37 +03:00
)
func getTileKey(tc *coords.TileCoords) string {
2019-02-08 10:11:06 +03:00
return strconv.Itoa(tc.X) + "/" + strconv.Itoa(tc.Y) + "/" +
strconv.Itoa(tc.Zoom) + "/" + strconv.Itoa(tc.LayerId)
2019-01-24 17:56:37 +03:00
}
func renderMapblocks(ctx *app.App, jobs chan *coords.TileCoords, mblist []*mapblockparser.MapBlock) int {
tileRenderedMap := make(map[string]bool)
tilecount := 0
2019-02-08 16:25:07 +03:00
totalRenderedMapblocks.Add(float64(len(mblist)))
2019-01-24 17:56:37 +03:00
2019-01-26 12:35:33 +03:00
for i := 12; i >= 1; i-- {
for _, mb := range mblist {
//13
tc := coords.GetTileCoordsFromMapBlock(mb.Pos, ctx.Config.Layers)
//12-1
tc = tc.ZoomOut(13 - i)
key := getTileKey(tc)
if tileRenderedMap[key] {
continue
}
tileRenderedMap[key] = true
fields := logrus.Fields{
"X": tc.X,
"Y": tc.Y,
"Zoom": tc.Zoom,
"LayerId": tc.LayerId,
}
logrus.WithFields(fields).Debug("Dispatching tile rendering (z12-1)")
tilecount++
2019-01-24 22:55:20 +03:00
//dispatch re-render
2019-01-24 17:56:37 +03:00
jobs <- tc
}
}
return tilecount
}