do not expire clipped ways/relations
parent
10847c43c4
commit
4de5d987d7
|
@ -172,6 +172,9 @@ func handleMultiPolygon(rw *RelationWriter, r *element.Relation, geos *geosp.Geo
|
||||||
if duration := time.Now().Sub(start); duration > time.Minute {
|
if duration := time.Now().Sub(start); duration > time.Minute {
|
||||||
log.Warnf("clipping relation %d to -limitto took %s", r.Id, duration)
|
log.Warnf("clipping relation %d to -limitto took %s", r.Id, duration)
|
||||||
}
|
}
|
||||||
|
if len(parts) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
for _, g := range parts {
|
for _, g := range parts {
|
||||||
rel := element.Relation(*r)
|
rel := element.Relation(*r)
|
||||||
rel.Id = rw.relId(r.Id)
|
rel.Id = rw.relId(r.Id)
|
||||||
|
|
|
@ -89,31 +89,28 @@ func (ww *WayWriter) loop() {
|
||||||
inserted := false
|
inserted := false
|
||||||
insertedPolygon := false
|
insertedPolygon := false
|
||||||
if matches := ww.lineMatcher.MatchWay(w); len(matches) > 0 {
|
if matches := ww.lineMatcher.MatchWay(w); len(matches) > 0 {
|
||||||
err := ww.buildAndInsert(geos, w, matches, false)
|
err, inserted = ww.buildAndInsert(geos, w, matches, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
|
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
|
||||||
log.Warn(err)
|
log.Warn(err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
inserted = true
|
|
||||||
}
|
}
|
||||||
if !insertedAsRelation && (w.IsClosed() || w.TryClose(ww.maxGap)) {
|
if !insertedAsRelation && (w.IsClosed() || w.TryClose(ww.maxGap)) {
|
||||||
// only add polygons that were not inserted as a MultiPolygon relation
|
// only add polygons that were not inserted as a MultiPolygon relation
|
||||||
if matches := ww.polygonMatcher.MatchWay(w); len(matches) > 0 {
|
if matches := ww.polygonMatcher.MatchWay(w); len(matches) > 0 {
|
||||||
err := ww.buildAndInsert(geos, w, matches, true)
|
err, insertedPolygon = ww.buildAndInsert(geos, w, matches, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
|
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
|
||||||
log.Warn(err)
|
log.Warn(err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
inserted = true
|
|
||||||
insertedPolygon = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if inserted && ww.expireor != nil {
|
if (inserted || insertedPolygon) && ww.expireor != nil {
|
||||||
expire.ExpireProjectedNodes(ww.expireor, w.Nodes, ww.srid, insertedPolygon)
|
expire.ExpireProjectedNodes(ww.expireor, w.Nodes, ww.srid, insertedPolygon)
|
||||||
}
|
}
|
||||||
if ww.diffCache != nil {
|
if ww.diffCache != nil {
|
||||||
|
@ -123,7 +120,7 @@ func (ww *WayWriter) loop() {
|
||||||
ww.wg.Done()
|
ww.wg.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ww *WayWriter) buildAndInsert(g *geos.Geos, w *element.Way, matches []mapping.Match, isPolygon bool) error {
|
func (ww *WayWriter) buildAndInsert(g *geos.Geos, w *element.Way, matches []mapping.Match, isPolygon bool) (error, bool) {
|
||||||
var err error
|
var err error
|
||||||
var geosgeom *geos.Geom
|
var geosgeom *geos.Geom
|
||||||
// make copy to avoid interference with polygon/linestring matches
|
// make copy to avoid interference with polygon/linestring matches
|
||||||
|
@ -138,42 +135,47 @@ func (ww *WayWriter) buildAndInsert(g *geos.Geos, w *element.Way, matches []mapp
|
||||||
geosgeom, err = geomp.LineString(g, way.Nodes)
|
geosgeom, err = geomp.LineString(g, way.Nodes)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err, false
|
||||||
}
|
}
|
||||||
|
|
||||||
geom, err := geomp.AsGeomElement(g, geosgeom)
|
geom, err := geomp.AsGeomElement(g, geosgeom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inserted := true
|
||||||
if ww.limiter != nil {
|
if ww.limiter != nil {
|
||||||
parts, err := ww.limiter.Clip(geom.Geom)
|
parts, err := ww.limiter.Clip(geom.Geom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err, false
|
||||||
|
}
|
||||||
|
if len(parts) == 0 {
|
||||||
|
// outside of limitto
|
||||||
|
inserted = false
|
||||||
}
|
}
|
||||||
for _, p := range parts {
|
for _, p := range parts {
|
||||||
way := element.Way(*w)
|
way := element.Way(*w)
|
||||||
geom = geomp.Geometry{Geom: p, Wkb: g.AsEwkbHex(p)}
|
geom = geomp.Geometry{Geom: p, Wkb: g.AsEwkbHex(p)}
|
||||||
if isPolygon {
|
if isPolygon {
|
||||||
if err := ww.inserter.InsertPolygon(way.OSMElem, geom, matches); err != nil {
|
if err := ww.inserter.InsertPolygon(way.OSMElem, geom, matches); err != nil {
|
||||||
return err
|
return err, false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := ww.inserter.InsertLineString(way.OSMElem, geom, matches); err != nil {
|
if err := ww.inserter.InsertLineString(way.OSMElem, geom, matches); err != nil {
|
||||||
return err
|
return err, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if isPolygon {
|
if isPolygon {
|
||||||
if err := ww.inserter.InsertPolygon(way.OSMElem, geom, matches); err != nil {
|
if err := ww.inserter.InsertPolygon(way.OSMElem, geom, matches); err != nil {
|
||||||
return err
|
return err, false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := ww.inserter.InsertLineString(way.OSMElem, geom, matches); err != nil {
|
if err := ww.inserter.InsertLineString(way.OSMElem, geom, matches); err != nil {
|
||||||
return err
|
return err, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil, inserted
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue