mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +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
|
Z int16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type xzc struct {
|
||||||
|
xz
|
||||||
|
canceled bool
|
||||||
|
}
|
||||||
|
|
||||||
type xzm struct {
|
type xzm struct {
|
||||||
P xz
|
P xz
|
||||||
Mask uint16
|
Mask uint16
|
||||||
@ -150,21 +155,40 @@ func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||||||
rw.WriteHeader(http.StatusOK)
|
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() {
|
func (tu *tileUpdater) doUpdates() {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
var changes map[xz]bool
|
|
||||||
tu.cond.L.Lock()
|
tu.cond.L.Lock()
|
||||||
for len(tu.changes) == 0 {
|
for len(tu.changes) == 0 {
|
||||||
tu.cond.Wait()
|
tu.cond.Wait()
|
||||||
}
|
}
|
||||||
changes = tu.changes
|
changes := extractChanges(tu.changes)
|
||||||
tu.changes = map[xz]bool{}
|
tu.changes = map[xz]bool{}
|
||||||
tu.cond.L.Unlock()
|
tu.cond.L.Unlock()
|
||||||
|
|
||||||
baseDir := filepath.Join(tu.mapDir, "8")
|
baseDir := filepath.Join(tu.mapDir, "8")
|
||||||
|
|
||||||
jobs := make(chan xz)
|
jobs := make(chan *xzc)
|
||||||
var done sync.WaitGroup
|
var done sync.WaitGroup
|
||||||
|
|
||||||
for i, n := 0, common.Min(tu.workers, len(changes)); i < n; i++ {
|
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)
|
go tu.updateBaseTiles(jobs, btc, &done)
|
||||||
}
|
}
|
||||||
|
|
||||||
parentJobs := make(map[xz]uint16)
|
for i := range changes {
|
||||||
|
|
||||||
for c := range changes {
|
|
||||||
//log.Printf("job: %+v\n", c)
|
//log.Printf("job: %+v\n", c)
|
||||||
jobs <- c
|
jobs <- &changes[i]
|
||||||
pxz := c.parent()
|
|
||||||
parentJobs[pxz.P] |= pxz.Mask
|
|
||||||
}
|
}
|
||||||
close(jobs)
|
close(jobs)
|
||||||
done.Wait()
|
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-- {
|
for level := 7; level >= 0; level-- {
|
||||||
pJobs := make(chan xzm)
|
pJobs := make(chan xzm)
|
||||||
for i, n := 0, common.Min(len(parentJobs), tu.workers); i < n; i++ {
|
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 {
|
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(
|
func (tu *tileUpdater) updateBaseTiles(
|
||||||
jobs chan xz,
|
jobs chan *xzc,
|
||||||
btc *common.BaseTileCreator, done *sync.WaitGroup) {
|
btc *common.BaseTileCreator, done *sync.WaitGroup) {
|
||||||
|
|
||||||
defer btc.Close()
|
defer btc.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user