diff --git a/test/imposm_system_test.py b/test/imposm_system_test.py index 2c74476..80a09ce 100644 --- a/test/imposm_system_test.py +++ b/test/imposm_system_test.py @@ -322,6 +322,32 @@ def test_relation_way_not_inserted(): scrub = query_row(db_conf, 'osm_landusages', 9110) assert scrub['type'] == 'scrub' +def test_relation_ways_inserted(): + """Outer ways of multipolygon are inserted. """ + park = query_row(db_conf, 'osm_landusages', -9201) + assert park['type'] == 'park' + assert park['name'] == '9209' + + # outer ways of multipolygon stand for their own + road = query_row(db_conf, 'osm_roads', 9209) + assert road['type'] == 'secondary' + assert road['name'] == '9209' + road = query_row(db_conf, 'osm_roads', 9210) + assert road['type'] == 'residential' + assert road['name'] == '9210' + + park = query_row(db_conf, 'osm_landusages', -9301) + assert park['type'] == 'park' + assert park['name'] == '' # no name on relation + + # outer ways of multipolygon stand for their own + road = query_row(db_conf, 'osm_roads', 9309) + assert road['type'] == 'secondary' + assert road['name'] == '9309' + road = query_row(db_conf, 'osm_roads', 9310) + assert road['type'] == 'residential' + assert road['name'] == '9310' + def test_relation_way_inserted(): """Part of relation was inserted twice.""" park = query_row(db_conf, 'osm_landusages', -8001) diff --git a/test/test.osm b/test/test.osm index 5ae1a03..63f4e2f 100644 --- a/test/test.osm +++ b/test/test.osm @@ -406,6 +406,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/writer/ways.go b/writer/ways.go index a62979d..c75a446 100644 --- a/writer/ways.go +++ b/writer/ways.go @@ -44,14 +44,11 @@ func (ww *WayWriter) loop() { if len(w.Tags) == 0 { continue } - inserted, err := ww.osmCache.InsertedWays.IsInserted(w.Id) + insertedAsRelation, err := ww.osmCache.InsertedWays.IsInserted(w.Id) if err != nil { log.Warn(err) continue } - if inserted { - continue - } err = ww.osmCache.Coords.FillWay(w) if err != nil { @@ -59,12 +56,13 @@ func (ww *WayWriter) loop() { } proj.NodesToMerc(w.Nodes) - inserted = false + inserted := false if ok, matches := ww.inserter.ProbeLineString(w.OSMElem); ok { ww.buildAndInsert(geos, w, matches, false) inserted = true } - if w.IsClosed() { + if w.IsClosed() && !insertedAsRelation { + // only add polygons that were not inserted as a MultiPolygon relation if ok, matches := ww.inserter.ProbePolygon(w.OSMElem); ok { ww.buildAndInsert(geos, w, matches, true) inserted = true