only skip import of polygons if way was inserted as multipolygon
parent
07c11bf4da
commit
e449183225
|
@ -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)
|
||||
|
|
|
@ -406,6 +406,62 @@
|
|||
<tag k="type" v="multipolygon"/>
|
||||
</relation>
|
||||
|
||||
<!-- test multipolygon ways were inserted -->
|
||||
<node id="9201" version="1" timestamp="2011-11-11T00:11:11Z" lat="47" lon="80"/>
|
||||
<node id="9202" version="1" timestamp="2011-11-11T00:11:11Z" lat="47" lon="82"/>
|
||||
<node id="9203" version="1" timestamp="2011-11-11T00:11:11Z" lat="49" lon="82"/>
|
||||
<node id="9204" version="1" timestamp="2011-11-11T00:11:11Z" lat="49" lon="80"/>
|
||||
<way id="9209" version="1" timestamp="2011-11-11T00:11:11Z">
|
||||
<nd ref="9201"/>
|
||||
<nd ref="9202"/>
|
||||
<nd ref="9203"/>
|
||||
<tag k="landuse" v="park"/>
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="9209"/>
|
||||
</way>
|
||||
<way id="9210" version="1" timestamp="2011-11-11T00:11:11Z">
|
||||
<nd ref="9203"/>
|
||||
<nd ref="9204"/>
|
||||
<nd ref="9201"/>
|
||||
<tag k="landuse" v="park"/>
|
||||
<tag k="highway" v="residential"/>
|
||||
<tag k="name" v="9210"/>
|
||||
</way>
|
||||
<relation id="9201" version="1" timestamp="2011-11-11T00:11:11Z">
|
||||
<member type="way" ref="9209" role="outer"/>
|
||||
<member type="way" ref="9210" role="outer"/>
|
||||
<tag k="type" v="multipolygon"/>
|
||||
</relation>
|
||||
|
||||
<!-- test multipolygon ways were inserted (same as 92xx, but different tagging) -->
|
||||
<node id="9301" version="1" timestamp="2011-11-11T00:11:11Z" lat="47" lon="80"/>
|
||||
<node id="9302" version="1" timestamp="2011-11-11T00:11:11Z" lat="47" lon="82"/>
|
||||
<node id="9303" version="1" timestamp="2011-11-11T00:11:11Z" lat="49" lon="82"/>
|
||||
<node id="9304" version="1" timestamp="2011-11-11T00:11:11Z" lat="49" lon="80"/>
|
||||
<way id="9309" version="1" timestamp="2011-11-11T00:11:11Z">
|
||||
<nd ref="9301"/>
|
||||
<nd ref="9302"/>
|
||||
<nd ref="9303"/>
|
||||
<tag k="landuse" v="park"/>
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="9309"/>
|
||||
</way>
|
||||
<way id="9310" version="1" timestamp="2011-11-11T00:11:11Z">
|
||||
<nd ref="9303"/>
|
||||
<nd ref="9304"/>
|
||||
<nd ref="9301"/>
|
||||
<tag k="highway" v="residential"/>
|
||||
<tag k="name" v="9310"/>
|
||||
</way>
|
||||
<relation id="9301" version="1" timestamp="2011-11-11T00:11:11Z">
|
||||
<member type="way" ref="9309" role="outer"/>
|
||||
<member type="way" ref="9310" role="outer"/>
|
||||
<tag k="type" v="multipolygon"/>
|
||||
<tag k="landuse" v="park"/>
|
||||
</relation>
|
||||
|
||||
|
||||
|
||||
<!-- test multipolygon way was inserted -->
|
||||
<node id="8001" version="1" timestamp="2011-11-11T00:11:11Z" lat="47" lon="80"/>
|
||||
<node id="8002" version="1" timestamp="2011-11-11T00:11:11Z" lat="47" lon="82"/>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue