Add support for data generalization #1942
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 commandosm2pgsql-gen
to access this functionality. Future versions might integrate it with theosm2pgsql
command, but because this is all experimental it is kept separate for now. Callosm2pgsql-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.