I try to create multipolygon describing border of Poland to test if some building are in this administration area. I took data from db (I imported OSM data to local db first preserving order of ways and nodes during the import). What I see is some ways in relation definition (members) are not on proper position. The question is: should I reorder ways on relation data or it's an issue with Geofabrik data export and look for other source of OSM data? |
Do not write your own multipolygon building code. You are re-inventing the wheel. Re-use the code that already exists in osm2pgsql (PostGIS importer), libosmium (C++ processing library with Python bindings), or GDAL (has an OSM input driver and can write various output formats) instead! OSM does not require that relation members be stored in the right order; this is something the software must do. 1
In addition, even if you were to make sure that all objects in a relation (such as a route relation) were "in order", as soon as someone edits that relation (e.g. to split a way) the objects will be "out of order" again.
(21 Jul '16, 12:40)
SomeoneElse ♦
I don't plan to draw any shapes. I have to test if some coordinates belong to some administration hierarchy (country, region, county and so on). To do it I have to create the shape of boundary to test if any point/location is withing such shape. I will take a look if PostGIS importer creates such shapes during the import (as mentioned by you). It's not a rocket science to reorder ways when I know they are in random order. btw: I use SqlServer and its spatial support to speed up things during the processing and I don't load any data to any external applications to not slow it down (it's not necessary in reality, because every complex operation on such data is easy to implement using T-SQL). It's like using many "db engine cursors" in case of external apps versus raw performance of group of queries optimized by DB engine :) Thanks for the info :)
(21 Jul '16, 13:41)
stalek
1
After reordering of a few ways/lines I received proper shape already, so the info from Frederik helped :) Thanks.
(21 Jul '16, 14:20)
stalek
|