mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-08 03:00:26 +01:00
mtwebmapper: Updating the pyramid tiles finally works but the amount of copying from the original can be minimized.
This commit is contained in:
parent
c428756beb
commit
8b6470fc9c
|
@ -53,7 +53,7 @@ func (c xz) parent() xzm {
|
|||
zp, zr := c.Z>>1, uint16(c.Z&1)
|
||||
return xzm{
|
||||
P: xz{X: xp, Z: zp},
|
||||
Mask: 1 << (xr<<1 | zr)}
|
||||
Mask: 1 << (zr<<1 | xr)}
|
||||
}
|
||||
|
||||
func (c xzm) numChanges() (n int) {
|
||||
|
@ -175,11 +175,18 @@ func updatePyramidTiles(level int, baseDir string, jobs chan xzm, done *sync.Wai
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
(0,0) (128, 0)
|
||||
|
||||
(0, 128) (128, 128)
|
||||
*/
|
||||
|
||||
var dps = [4]image.Point{
|
||||
image.Pt(0, 128),
|
||||
image.Pt(0, 0),
|
||||
image.Pt(128, 128),
|
||||
image.Pt(128, 0)}
|
||||
image.Pt(0, 0),
|
||||
image.Pt(128, 0),
|
||||
}
|
||||
|
||||
var ofs = [4][2]int{
|
||||
{0, 0},
|
||||
|
@ -187,6 +194,7 @@ var ofs = [4][2]int{
|
|||
{0, 1},
|
||||
{1, 1}}
|
||||
|
||||
/*
|
||||
func clip8(x int) int {
|
||||
switch {
|
||||
case x < 0:
|
||||
|
@ -202,6 +210,9 @@ func clipRect(r image.Rectangle) image.Rectangle {
|
|||
Min: image.Point{X: clip8(r.Min.X), Y: clip8(r.Min.Y)},
|
||||
Max: image.Point{X: clip8(r.Max.X), Y: clip8(r.Max.Y)}}
|
||||
}
|
||||
*/
|
||||
|
||||
//var windowSize = image.Pt(128, 128)
|
||||
|
||||
func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) error {
|
||||
|
||||
|
@ -212,10 +223,14 @@ func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) er
|
|||
|
||||
if j.numChanges() < 4 {
|
||||
orig = common.LoadPNG(origPath)
|
||||
sr := orig.Bounds()
|
||||
r := sr.Sub(sr.Min)
|
||||
draw.Draw(scratch, r, orig, sr.Min, draw.Src)
|
||||
}
|
||||
|
||||
for i := uint16(0); i < 4; i++ {
|
||||
if j.Mask&(1<<i) != 0 {
|
||||
//log.Printf("level %d: modified %d", level, i)
|
||||
o := ofs[i]
|
||||
bx, bz := int(2*j.P.X), int(2*j.P.Z)
|
||||
path := filepath.Join(
|
||||
|
@ -226,9 +241,12 @@ 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 {
|
||||
sr := clipRect(orig.Bounds())
|
||||
r := sr.Sub(sr.Min).Add(dps[i])
|
||||
draw.Draw(scratch, r, orig, sr.Min, draw.Src)
|
||||
/*
|
||||
log.Printf("level %d: copied %d", level, i)
|
||||
dp := dps[i].Add(scratch.Bounds().Min)
|
||||
r := image.Rectangle{dp, dp.Add(windowSize)}
|
||||
draw.Draw(scratch, r, orig, orig.Bounds().Min.Add(dps[i]), draw.Src)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user