mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
mtwebmapper: simplified pyramid tile updater a bit.
This commit is contained in:
parent
11a4b9f471
commit
2bea824153
@ -56,15 +56,6 @@ func (c xz) parent() xzm {
|
||||
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 {
|
||||
tu := tileUpdater{
|
||||
mapDir: mapDir,
|
||||
@ -177,7 +168,6 @@ func updatePyramidTiles(level int, baseDir string, jobs chan xzm, done *sync.Wai
|
||||
|
||||
/*
|
||||
(0,0) (128, 0)
|
||||
|
||||
(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)),
|
||||
fmt.Sprintf("%d.png", j.P.Z))
|
||||
|
||||
if j.numChanges() < 4 {
|
||||
orig = common.LoadPNG(origPath)
|
||||
}
|
||||
|
||||
for i := uint16(0); i < 4; i++ {
|
||||
if j.Mask&(1<<i) != 0 {
|
||||
//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])
|
||||
draw.Draw(scratch, r, img, sr.Min, draw.Src)
|
||||
} else {
|
||||
// Load lazy
|
||||
if orig == nil {
|
||||
orig = common.LoadPNG(origPath)
|
||||
}
|
||||
//log.Printf("level %d: copied %d", level, i)
|
||||
min := orig.Bounds().Min.Add(dps[i])
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user