[Tile-serving] [osm2pgsql-dev/osm2pgsql] New feature: Check location of OSM objects against list of regions (PR #2333)
Jochen Topf
notifications at github.com
Thu May 29 20:38:30 UTC 2025
This PR introduces a new feature: Locators. A locator is initialized with one or more regions, each region has a name and a polygon or bounding box. A geometry of an OSM object can then be checked against this region list to figure out in which region(s) it is located. This check is much faster than it would be to do this inside the database after import.
Locators can be used for all sorts of interesting features:
* Read larger OSM file but import only data inside some area.
* Annotate each OSM object with the country (or other region) it is in. This can then, for instance, be used to show special highway shields for each country.
* Use the information which region the data is in for further processing, for instance setting of default values for the speed limit or using special language transliterations rules based on country.
Locators are created in Lua with `define_locator()`. Bounding boxes can be added with `add_bbox()`. Polygons can be added from the database by calling `add_from_db()` and specifiying an SQL query which can return any number of rows each defining a region with the name and the (multi)polygon as columns.
A locator can then be queried using `all_intersecting()` returning a list of names of all regions that intersect the specified OSM object geometry. Or the `first_intersecting()` function can be used which only returns a single region for those cases where there can be no overlapping data or where the details of objects straddling region boundaries don't matter.
Several example config files are provided in the flex-config/locator directory.
You can view, comment on, or merge this pull request online at:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2333
-- Commit Summary --
* Make box_t type available to boost as box type
* New feature: Check location of OSM objects against list of regions
-- File Changes --
M .github/workflows/luacheck.yml (2)
A flex-config/locator/README.md (9)
A flex-config/locator/buildings.lua (74)
A flex-config/locator/iceland.lua (32)
A flex-config/locator/import-countries.lua (35)
A flex-config/locator/motorway-colours.lua (40)
M src/CMakeLists.txt (2)
A src/flex-lua-locator.cpp (188)
A src/flex-lua-locator.hpp (53)
M src/flex-lua-wrapper.hpp (3)
M src/geom-boost-adaptor.hpp (44)
M src/geom-box.hpp (5)
A src/locator.cpp (128)
A src/locator.hpp (147)
M src/output-flex.cpp (31)
M src/output-flex.hpp (8)
M src/pgsql-capabilities-int.hpp (1)
M src/pgsql-capabilities.cpp (19)
M src/pgsql-capabilities.hpp (2)
M src/pgsql.hpp (6)
M tests/CMakeLists.txt (1)
A tests/bdd/flex/locator.feature (233)
M tests/bdd/steps/steps_execute.py (6)
M tests/test-geom-box.cpp (42)
A tests/test-locator.cpp (136)
-- Patch Links --
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2333.patch
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2333.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2333
You are receiving this because you are subscribed to this thread.
Message ID: <osm2pgsql-dev/osm2pgsql/pull/2333 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20250529/387862b1/attachment.htm>
More information about the Tile-serving
mailing list