mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-25 01:30:17 +01:00
Added 'websocket' branch. Added mechanism to forward the coords of the updated base tiles.
This commit is contained in:
parent
003d8cc785
commit
3e0e909a69
@ -78,6 +78,9 @@ func main() {
|
|||||||
subBaseLine := newSubBaseLine(mapDir)
|
subBaseLine := newSubBaseLine(mapDir)
|
||||||
router.Path("/map/{z:[0-9]+}/{x:[0-9]+}/{y:[0-9]+}.png").Handler(subBaseLine)
|
router.Path("/map/{z:[0-9]+}/{x:[0-9]+}/{y:[0-9]+}.png").Handler(subBaseLine)
|
||||||
|
|
||||||
|
// TODO: Implement me!
|
||||||
|
var btu baseTilesUpdates
|
||||||
|
|
||||||
if redisHost != "" {
|
if redisHost != "" {
|
||||||
var colors *common.Colors
|
var colors *common.Colors
|
||||||
var err error
|
var err error
|
||||||
@ -92,7 +95,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tu := newTileUpdater(
|
tu := newTileUpdater(
|
||||||
mapDir, redisAddress, allowedUpdateIps, colors, transparent, workers)
|
mapDir,
|
||||||
|
redisAddress,
|
||||||
|
allowedUpdateIps,
|
||||||
|
colors,
|
||||||
|
transparent,
|
||||||
|
workers,
|
||||||
|
btu)
|
||||||
go tu.doUpdates()
|
go tu.doUpdates()
|
||||||
router.Path("/update").Methods("POST").Handler(tu)
|
router.Path("/update").Methods("POST").Handler(tu)
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,13 @@ import (
|
|||||||
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type baseTilesUpdates interface {
|
||||||
|
BaseTilesUpdated(map[xz]bool)
|
||||||
|
}
|
||||||
|
|
||||||
type tileUpdater struct {
|
type tileUpdater struct {
|
||||||
changes map[xz]bool
|
changes map[xz]bool
|
||||||
|
btu baseTilesUpdates
|
||||||
mapDir string
|
mapDir string
|
||||||
redisAddress string
|
redisAddress string
|
||||||
ips []net.IP
|
ips []net.IP
|
||||||
@ -67,9 +72,11 @@ func newTileUpdater(
|
|||||||
ips []net.IP,
|
ips []net.IP,
|
||||||
colors *common.Colors,
|
colors *common.Colors,
|
||||||
transparent bool,
|
transparent bool,
|
||||||
workers int) *tileUpdater {
|
workers int,
|
||||||
|
btu baseTilesUpdates) *tileUpdater {
|
||||||
|
|
||||||
tu := tileUpdater{
|
tu := tileUpdater{
|
||||||
|
btu: btu,
|
||||||
mapDir: mapDir,
|
mapDir: mapDir,
|
||||||
redisAddress: redisAddress,
|
redisAddress: redisAddress,
|
||||||
ips: ips,
|
ips: ips,
|
||||||
@ -166,7 +173,7 @@ func (tu *tileUpdater) doUpdates() {
|
|||||||
|
|
||||||
parentJobs := make(map[xz]uint16)
|
parentJobs := make(map[xz]uint16)
|
||||||
|
|
||||||
for c, _ := range changes {
|
for c := range changes {
|
||||||
//log.Printf("job: %+v", c)
|
//log.Printf("job: %+v", c)
|
||||||
jobs <- c
|
jobs <- c
|
||||||
pxz := c.parent()
|
pxz := c.parent()
|
||||||
@ -191,6 +198,10 @@ func (tu *tileUpdater) doUpdates() {
|
|||||||
done.Wait()
|
done.Wait()
|
||||||
parentJobs = ppJobs
|
parentJobs = ppJobs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tu.btu != nil {
|
||||||
|
tu.btu.BaseTilesUpdated(changes)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user