Add support for data generalization#1942
Merged
lonvia merged 2 commits intoosm2pgsql-dev:masterfrom Mar 8, 2023
Merged
Conversation
pnorman
reviewed
Mar 6, 2023
| std::string canvas_t::to_wkb(tile_t const &tile, double margin) const | ||
| { | ||
| std::string wkb; | ||
| wkb.reserve(61 + 2 + m_rast.size()); |
Collaborator
There was a problem hiding this comment.
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.
ee3c9bf to
899c56a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/gendirectory. It includes a new commandosm2pgsql-gento access this functionality. Future versions might integrate it with theosm2pgsqlcommand, but because this is all experimental it is kept separate for now. Callosm2pgsql-genwith-hto 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.