mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-10 12:10:23 +01:00
Prepare tiles updater in webmapper to have unupdated base tiles.
This commit is contained in:
parent
5ee3731a27
commit
4bed73d9e3
|
@ -48,6 +48,11 @@ type xz struct {
|
|||
Z int16
|
||||
}
|
||||
|
||||
type xzc struct {
|
||||
xz
|
||||
canceled bool
|
||||
}
|
||||
|
||||
type xzm struct {
|
||||
P xz
|
||||
Mask uint16
|
||||
|
@ -150,21 +155,40 @@ func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||
rw.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func extractChanges(changes map[xz]bool) []xzc {
|
||||
chs := make([]xzc, len(changes))
|
||||
var i int
|
||||
for ch := range changes {
|
||||
chs[i] = xzc{ch, false}
|
||||
i++
|
||||
}
|
||||
return chs
|
||||
}
|
||||
|
||||
func activeChanges(changes []xzc) map[xz]bool {
|
||||
chs := make(map[xz]bool)
|
||||
for i := range changes {
|
||||
if !changes[i].canceled {
|
||||
chs[changes[i].xz] = true
|
||||
}
|
||||
}
|
||||
return chs
|
||||
}
|
||||
|
||||
func (tu *tileUpdater) doUpdates() {
|
||||
|
||||
for {
|
||||
var changes map[xz]bool
|
||||
tu.cond.L.Lock()
|
||||
for len(tu.changes) == 0 {
|
||||
tu.cond.Wait()
|
||||
}
|
||||
changes = tu.changes
|
||||
changes := extractChanges(tu.changes)
|
||||
tu.changes = map[xz]bool{}
|
||||
tu.cond.L.Unlock()
|
||||
|
||||
baseDir := filepath.Join(tu.mapDir, "8")
|
||||
|
||||
jobs := make(chan xz)
|
||||
jobs := make(chan *xzc)
|
||||
var done sync.WaitGroup
|
||||
|
||||
for i, n := 0, common.Min(tu.workers, len(changes)); i < n; i++ {
|
||||
|
@ -182,17 +206,25 @@ func (tu *tileUpdater) doUpdates() {
|
|||
go tu.updateBaseTiles(jobs, btc, &done)
|
||||
}
|
||||
|
||||
parentJobs := make(map[xz]uint16)
|
||||
|
||||
for c := range changes {
|
||||
for i := range changes {
|
||||
//log.Printf("job: %+v\n", c)
|
||||
jobs <- c
|
||||
pxz := c.parent()
|
||||
parentJobs[pxz.P] |= pxz.Mask
|
||||
jobs <- &changes[i]
|
||||
}
|
||||
close(jobs)
|
||||
done.Wait()
|
||||
|
||||
actChs := activeChanges(changes)
|
||||
|
||||
if len(actChs) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
parentJobs := make(map[xz]uint16)
|
||||
for c := range actChs {
|
||||
pxz := c.parent()
|
||||
parentJobs[pxz.P] |= pxz.Mask
|
||||
}
|
||||
|
||||
for level := 7; level >= 0; level-- {
|
||||
pJobs := make(chan xzm)
|
||||
for i, n := 0, common.Min(len(parentJobs), tu.workers); i < n; i++ {
|
||||
|
@ -211,7 +243,7 @@ func (tu *tileUpdater) doUpdates() {
|
|||
}
|
||||
|
||||
if tu.btu != nil {
|
||||
tu.btu.BaseTilesUpdated(changes)
|
||||
tu.btu.BaseTilesUpdated(actChs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +326,7 @@ func (tu *tileUpdater) updatePyramidTile(scratch, resized *image.RGBA, level int
|
|||
}
|
||||
|
||||
func (tu *tileUpdater) updateBaseTiles(
|
||||
jobs chan xz,
|
||||
jobs chan *xzc,
|
||||
btc *common.BaseTileCreator, done *sync.WaitGroup) {
|
||||
|
||||
defer btc.Close()
|
||||
|
|
Loading…
Reference in New Issue
Block a user