mtwebmapper: simplified pyramid tile updater a bit.

This commit is contained in:
Sascha L. Teichmann 2014-09-22 02:37:44 +02:00
parent 11a4b9f471
commit 2bea824153

View File

@ -56,15 +56,6 @@ func (c xz) parent() xzm {
Mask: 1 << (zr<<1 | xr)} Mask: 1 << (zr<<1 | xr)}
} }
func (c xzm) numChanges() (n int) {
for i := uint16(0); i < 4; i++ {
if c.Mask&(1<<i) != 0 {
n++
}
}
return
}
func newTileUpdater(mapDir, redisAddress string, colors *common.Colors, workers int) *tileUpdater { func newTileUpdater(mapDir, redisAddress string, colors *common.Colors, workers int) *tileUpdater {
tu := tileUpdater{ tu := tileUpdater{
mapDir: mapDir, mapDir: mapDir,
@ -177,7 +168,6 @@ func updatePyramidTiles(level int, baseDir string, jobs chan xzm, done *sync.Wai
/* /*
(0,0) (128, 0) (0,0) (128, 0)
(0, 128) (128, 128) (0, 128) (128, 128)
*/ */
@ -206,10 +196,6 @@ func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) er
strconv.Itoa(int(j.P.X)), strconv.Itoa(int(j.P.X)),
fmt.Sprintf("%d.png", j.P.Z)) fmt.Sprintf("%d.png", j.P.Z))
if j.numChanges() < 4 {
orig = common.LoadPNG(origPath)
}
for i := uint16(0); i < 4; i++ { for i := uint16(0); i < 4; i++ {
if j.Mask&(1<<i) != 0 { if j.Mask&(1<<i) != 0 {
//log.Printf("level %d: modified %d", level, i) //log.Printf("level %d: modified %d", level, i)
@ -226,10 +212,14 @@ func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) er
r := sr.Sub(sr.Min).Add(dps[i]) r := sr.Sub(sr.Min).Add(dps[i])
draw.Draw(scratch, r, img, sr.Min, draw.Src) draw.Draw(scratch, r, img, sr.Min, draw.Src)
} else { } else {
// Load lazy
if orig == nil {
orig = common.LoadPNG(origPath)
}
//log.Printf("level %d: copied %d", level, i) //log.Printf("level %d: copied %d", level, i)
min := orig.Bounds().Min.Add(dps[i]) min := orig.Bounds().Min.Add(dps[i])
r := image.Rectangle{min, min.Add(windowSize)} r := image.Rectangle{min, min.Add(windowSize)}
draw.Draw(scratch, r, orig, orig.Bounds().Min.Add(dps[i]), draw.Src) draw.Draw(scratch, r, orig, min, draw.Src)
} }
} }