Skip to content

Commit

Permalink
do not expire tiles for nodes within limitto_cache_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
olt committed Feb 1, 2017
1 parent 353bc5d commit 10847c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 11 additions & 0 deletions expire/expire.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ func ExpireProjectedNodes(expireor Expireor, nodes []element.Node, srid int, clo
panic("unsupported srid")
}
}

func ExpireProjectedNode(expireor Expireor, node element.Node, srid int) {
if srid == 4326 {
expireor.Expire(node.Long, node.Lat)
} else if srid == 3857 {
long, lat := proj.MercToWgs(node.Long, node.Lat)
expireor.Expire(long, lat)
} else {
panic("unsupported srid")
}
}
10 changes: 7 additions & 3 deletions writer/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/omniscale/imposm3/cache"
"github.com/omniscale/imposm3/database"
"github.com/omniscale/imposm3/element"
"github.com/omniscale/imposm3/expire"
geomp "github.com/omniscale/imposm3/geom"
"github.com/omniscale/imposm3/geom/geos"
"github.com/omniscale/imposm3/mapping"
Expand Down Expand Up @@ -49,9 +50,6 @@ func (nw *NodeWriter) loop() {
for n := range nw.nodes {
nw.progress.AddNodes(1)
if matches := nw.pointMatcher.MatchNode(n); len(matches) > 0 {
if nw.expireor != nil {
nw.expireor.Expire(n.Long, n.Lat)
}
nw.NodeToSrid(n)
point, err := geomp.Point(geos, *n)
if err != nil {
Expand All @@ -67,6 +65,7 @@ func (nw *NodeWriter) loop() {
continue
}

inserted := false
if nw.limiter != nil {
parts, err := nw.limiter.Clip(geom.Geom)
if err != nil {
Expand All @@ -78,14 +77,19 @@ func (nw *NodeWriter) loop() {
log.Warn(err)
continue
}
inserted = true
}
} else {
if err := nw.inserter.InsertPoint(n.OSMElem, geom, matches); err != nil {
log.Warn(err)
continue
}
inserted = true
}

if inserted && nw.expireor != nil {
expire.ExpireProjectedNode(nw.expireor, *n, nw.srid)
}
}
}
nw.wg.Done()
Expand Down

0 comments on commit 10847c4

Please sign in to comment.