Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for data generalization #1942

Merged
merged 2 commits into from
Mar 8, 2023

Conversation

joto
Copy link
Collaborator

@joto joto commented Mar 2, 2023

This large commit adds a framework to generalize OSM data using different strategies and implements several strategies. The source is all in the new src/gen directory. It includes a new command osm2pgsql-gen to access this functionality. Future versions might integrate it with the osm2pgsql command, but because this is all experimental it is kept separate for now. Call osm2pgsql-gen with -h to get usage help.

See also https://osm2pgsql.org/generalization/ and the chapter on Generalization in the manual:
https://osm2pgsql.org/doc/manual.html#generalization

For the raster support this adds two new library dependency: CImg and potrace. Both have been around for a long time and are readily available on all systems.

The following strategies work on a tile-by-tile basis and operate on polygons:

The "vector-union" strategy buffers and unionizes polygons using vector operations.

The "raster-union" strategy does a similar thing but does it in raster space which is much faster. First the polygons are rendered into a raster, an open/close operation is called (which basically does the same thing as the buffering in vector space) and finally the resulting raster is vectorized again.

The "builtup" strategy is intended to derive a layer of builtup areas from landuse=residential/industrial etc. as well as building cover and dense road networks.

The following strategies always work on all data (not tile-based):

The "discrete-isolation" strategy rates places based on some importance metric to get a more even distribution of places on the map.

The new "rivers" strategy finds important rivers, this is still very much work in progress.

std::string canvas_t::to_wkb(tile_t const &tile, double margin) const
{
std::string wkb;
wkb.reserve(61 + 2 + m_rast.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use variables for magic numbers

This large commit adds a framework to generalize OSM data using
different strategies and implements several strategies. The source is
all in the new `src/gen` directory. It includes a new command
`osm2pgsql-gen` to access this functionality. Future versions might
integrate it with the `osm2pgsql` command, but because this is all
experimental it is kept separate for now. Call `osm2pgsql-gen` with
`-h` to get usage help.

See also https://osm2pgsql.org/generalization/ and the chapter on
Generalization in the manual:
https://osm2pgsql.org/doc/manual.html#generalization

For the raster support this adds two new library dependency: CImg and
potrace. Both have been around for a long time and are readily available
on all systems.

The following strategies work on a tile-by-tile basis and operate on
polygons:

The "vector-union" strategy buffers and unionizes polygons using vector
operations.

The "raster-union" strategy does a similar thing but does it in raster
space which is much faster. First the polygons are rendered into a
raster, an open/close operation is called (which basically does the same
thing as the buffering in vector space) and finally the resulting raster
is vectorized again.

The "builtup" strategy is intended to derive a layer of builtup areas
from landuse=residential/industrial etc. as well as building cover and
dense road networks.

The following strategies always work on all data (not tile-based):

The "discrete-isolation" strategy rates places based on some importance
metric to get a more even distribution of places on the map.

The new "rivers" strategy finds important rivers, this is still very
much work in progress.
@lonvia lonvia merged commit 4be22ba into osm2pgsql-dev:master Mar 8, 2023
@joto joto deleted the generalization-support branch March 9, 2023 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants