-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Use rtree spatial index from PlanetilerConfig bounds by default for Geopackages #635
base: main
Are you sure you want to change the base?
Conversation
Kudos, SonarCloud Quality Gate passed! |
https://github.com/onthegomap/planetiler/actions/runs/5678745487 ℹ️ Base Logs 5e7159d
ℹ️ This Branch Logs b2d4a34
|
FeatureIndexManager indexer = new FeatureIndexManager(geoPackage, | ||
features); | ||
indexer.setIndexLocation(FeatureIndexType.RTREE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while, but if I remember correctly, this will actually build the index if it doesn't already exist in the DB before running the query.
Looking at the PR where I initially added this, should be possible to check for the presence of the index before trying to use it: #413 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems awkward and unexpected behavior to modify the database in-place, can we disable that? If it's being unzipped every time it could be slow for a large geopackage.
Maybe detect the absence of the index and ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nvm, I see you mentioned exactly that behavior I suggested) so the next step is addressing possible projection mismatches; we need to find some geopackages in the wild that are neither WGS84 or webmerc
This is a first attempt at addressing #478 .
The existing issue is that all Shapefile or Geopackage features are read by every run, even if the
--bounds
argument is passed to limit the tile output or the bounds are determined implicitly based on theosm.pbf
. To reduce the runtime we can:.fbn
,.fbx
and/orqix
sidecars depending on what software created the Shapefile. Maybe GeoTools can read all of these, but I'm not familiar with its internals.rtree_
indexes (A vanilla SQLite feature, no Spatialite required)ne_50m_admin_0_boundary_lines_land
as tables we care about. IMO, this doesn't reduce the runtime by much relative to spatial indexing, so it may be an unworthy optimization.My proposal here is to not change any APIs, but change the default behavior of Geopackage to use the determined
PlanetilerConfig
bounds and apply the spatial index. Remaining todos:rtree_
indexes will always exist on gpkg or are optionalAnother relevant format would be FlatGeobuf, which has an optional spatial index as part of the single file, but I don't see key advantages of FGB over GPKG in most Planetiler use cases where data lives on disk.