From 3e0e909a6913b2fc8a4c3c4a8a82406b3b221155 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Mon, 2 Mar 2015 13:10:30 +0100 Subject: [PATCH] Added 'websocket' branch. Added mechanism to forward the coords of the updated base tiles. --- cmd/mtwebmapper/main.go | 11 ++++++++++- cmd/mtwebmapper/tilesupdater.go | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cmd/mtwebmapper/main.go b/cmd/mtwebmapper/main.go index 4edd209..22f14c6 100644 --- a/cmd/mtwebmapper/main.go +++ b/cmd/mtwebmapper/main.go @@ -78,6 +78,9 @@ func main() { subBaseLine := newSubBaseLine(mapDir) router.Path("/map/{z:[0-9]+}/{x:[0-9]+}/{y:[0-9]+}.png").Handler(subBaseLine) + // TODO: Implement me! + var btu baseTilesUpdates + if redisHost != "" { var colors *common.Colors var err error @@ -92,7 +95,13 @@ func main() { } tu := newTileUpdater( - mapDir, redisAddress, allowedUpdateIps, colors, transparent, workers) + mapDir, + redisAddress, + allowedUpdateIps, + colors, + transparent, + workers, + btu) go tu.doUpdates() router.Path("/update").Methods("POST").Handler(tu) } diff --git a/cmd/mtwebmapper/tilesupdater.go b/cmd/mtwebmapper/tilesupdater.go index a0b07d4..6277d52 100644 --- a/cmd/mtwebmapper/tilesupdater.go +++ b/cmd/mtwebmapper/tilesupdater.go @@ -24,8 +24,13 @@ import ( "bitbucket.org/s_l_teichmann/mtsatellite/common" ) +type baseTilesUpdates interface { + BaseTilesUpdated(map[xz]bool) +} + type tileUpdater struct { changes map[xz]bool + btu baseTilesUpdates mapDir string redisAddress string ips []net.IP @@ -67,9 +72,11 @@ func newTileUpdater( ips []net.IP, colors *common.Colors, transparent bool, - workers int) *tileUpdater { + workers int, + btu baseTilesUpdates) *tileUpdater { tu := tileUpdater{ + btu: btu, mapDir: mapDir, redisAddress: redisAddress, ips: ips, @@ -166,7 +173,7 @@ func (tu *tileUpdater) doUpdates() { parentJobs := make(map[xz]uint16) - for c, _ := range changes { + for c := range changes { //log.Printf("job: %+v", c) jobs <- c pxz := c.parent() @@ -191,6 +198,10 @@ func (tu *tileUpdater) doUpdates() { done.Wait() parentJobs = ppJobs } + + if tu.btu != nil { + tu.btu.BaseTilesUpdated(changes) + } } }