Simplified mask embedding in parent calculation of pyramid tiles.

This commit is contained in:
Sascha L. Teichmann 2016-05-08 23:07:19 +02:00
parent da2a6a82d4
commit 496a60aa29

View File

@ -54,7 +54,7 @@ type xzc struct {
} }
type xzm struct { type xzm struct {
P xz xz
Mask uint16 Mask uint16
} }
@ -70,8 +70,8 @@ func (c xz) parent() xzm {
xp, xr := c.X>>1, uint16(c.X&1) xp, xr := c.X>>1, uint16(c.X&1)
zp, zr := c.Z>>1, uint16(c.Z&1) zp, zr := c.Z>>1, uint16(c.Z&1)
return xzm{ return xzm{
P: xz{X: xp, Z: zp}, xz{X: xp, Z: zp},
Mask: 1 << (zr<<1 | xr)} 1 << (zr<<1 | xr)}
} }
func newTileUpdater( func newTileUpdater(
@ -224,7 +224,7 @@ func (tu *tileUpdater) doUpdates() {
parentJobs := make(map[xz]uint16) parentJobs := make(map[xz]uint16)
for i := range actChs { for i := range actChs {
pxz := actChs[i].parent() pxz := actChs[i].parent()
parentJobs[pxz.P] |= pxz.Mask parentJobs[pxz.xz] |= pxz.Mask
} }
for level := 7; level >= 0; level-- { for level := 7; level >= 0; level-- {
@ -235,9 +235,9 @@ func (tu *tileUpdater) doUpdates() {
} }
ppJobs := make(map[xz]uint16) ppJobs := make(map[xz]uint16)
for c, mask := range parentJobs { for c, mask := range parentJobs {
pJobs <- xzm{P: c, Mask: mask} pJobs <- xzm{c, mask}
pxz := c.parent() pxz := c.parent()
ppJobs[pxz.P] |= pxz.Mask ppJobs[pxz.xz] |= pxz.Mask
} }
close(pJobs) close(pJobs)
done.Wait() done.Wait()
@ -291,8 +291,8 @@ func (tu *tileUpdater) updatePyramidTile(scratch, resized *image.RGBA, level int
origPath := filepath.Join( origPath := filepath.Join(
tu.mapDir, tu.mapDir,
strconv.Itoa(level), strconv.Itoa(level),
strconv.Itoa(int(j.P.X)), strconv.Itoa(int(j.X)),
strconv.Itoa(int(j.P.Z))+".png") strconv.Itoa(int(j.Z))+".png")
sr := resized.Bounds() sr := resized.Bounds()
levelDir := strconv.Itoa(level + 1) levelDir := strconv.Itoa(level + 1)
@ -300,7 +300,7 @@ func (tu *tileUpdater) updatePyramidTile(scratch, resized *image.RGBA, level int
if j.Mask&(1<<i) != 0 { if j.Mask&(1<<i) != 0 {
//log.Printf("level %d: modified %d\n", level, i) //log.Printf("level %d: modified %d\n", level, i)
o := ofs[i] o := ofs[i]
bx, bz := int(2*j.P.X), int(2*j.P.Z) bx, bz := int(2*j.X), int(2*j.Z)
path := filepath.Join( path := filepath.Join(
tu.mapDir, tu.mapDir,
levelDir, levelDir,