omniscale / imposm3

Imposm imports OpenStreetMap data into PostGIS
http://imposm.org/docs/imposm3/latest/
Apache License 2.0
730 stars 157 forks source link

Invalid geometry created for way #221

Closed pnorman closed 4 years ago

pnorman commented 4 years ago

Context

When importing data, I am finding an invalid geometry is created for the way w749349005. Instead, a valid geometry should be created or no geometry at all.

The way is a figure-eight.

Input

way 749349005

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.7.5 (23447 thorn-02.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
 <node id="7007565494" visible="true" version="1" changeset="77504822" timestamp="2019-11-25T07:33:48Z" user="westlandsong" uid="10494528" lat="51.0768769" lon="-114.1329361"/>
 <node id="7007565495" visible="true" version="1" changeset="77504822" timestamp="2019-11-25T07:33:48Z" user="westlandsong" uid="10494528" lat="51.0768468" lon="-114.1329074"/>
 <node id="7007565496" visible="true" version="1" changeset="77504822" timestamp="2019-11-25T07:33:48Z" user="westlandsong" uid="10494528" lat="51.0768067" lon="-114.1328628"/>
 <node id="7007565497" visible="true" version="1" changeset="77504822" timestamp="2019-11-25T07:33:48Z" user="westlandsong" uid="10494528" lat="51.0767486" lon="-114.1328054"/>
 <way id="749349005" visible="true" version="1" changeset="77504822" timestamp="2019-11-25T07:33:48Z" user="westlandsong" uid="10494528">
  <nd ref="7007565494"/>
  <nd ref="7007565495"/>
  <nd ref="7007565496"/>
  <nd ref="7007565497"/>
  <nd ref="7007565494"/>
  <tag k="amenity" v="place_of_worship"/>
  <tag k="building" v="yes"/>
 </way>
</osm>

way in JOSM image

Output

select st_isvalid(geometry) from import.osm_poi_polygon where osm_id = 749349005;
NOTICE:  Self-intersection at or near point -12705214.511643743 6634894.5355783189
 st_isvalid 
------------
 f
select st_asewkt(geometry), osm_id from import.osm_poi_polygon where osm_id = 749349005;
-[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
st_asewkt | SRID=3857;POLYGON((-12705220.3321765 6634903.62751139,-12705205.7856278 6634880.90515021,-12705212.1771517 6634891.19703541,-12705217.1410799 6634898.29591902,-12705220.3321765 6634903.62751139))
osm_id    | 749349005
pnorman commented 4 years ago

Some other ways that have output that isn't st_isvalid: 102520500 (slim triangle), 460964455 (tiny rectangle), 246481310 (tiny triangle), 176857757 (slim triangle). The triangles have null area and webmerc_area, the rectangle has ~10^-5 area

ImreSamu commented 4 years ago

maybe this issue is related to :