[Tile-serving] [openstreetmap/osm2pgsql] Fix: Handle special single-geom case for multipoint/linestring (PR #1791)
Jochen Topf
notifications at github.com
Mon Oct 3 19:49:02 UTC 2022
@mboeringa The immediate technical reason is that single geometries are simpler and more efficient to handle than multi-geometries. But this isn't a big deal in this case, because it shouldn't happen that often. But thinking about all the different ways of handling the corner cases the behaviour does make sense:
1. You can call `as_multipoint()` on nodes or relations. And `as_multilinestring()/as_multipolygon()` on ways or relations. That can make user code simpler, because you can handle different cases with the same code.
2. You want the node/way case to be efficient, i.e. always generate a single geometry even when using those `as_multi*()` functions.
3. It is easy to detect that we have a single geometry when writing into a multi-geometry column and just turn the single geom into a multi-geometry (which we do). This doesn't work the other way around, though. So that's another reason to go with the single geom.
4. If you want to split multi geoms into several rows in the database each only with a single geom, the code for iterating over a multi geom will still do the right thing with a single geom.
And yes, the documentation isn't all that good around these issues. This is mostly, because our thinking on and experience with it is still evolving, so I keep patching the documentation here and there, but at some point I have to do a more systematic writeup of all this.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/1791#issuecomment-1265951465
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/osm2pgsql/pull/1791/c1265951465 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20221003/c7c983b2/attachment.htm>
More information about the Tile-serving
mailing list