-
-
Notifications
You must be signed in to change notification settings - Fork 185
Make tile extent runtime configurable with default 4096 #1565
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
Open
tasiotas
wants to merge
3
commits into
onthegomap:main
Choose a base branch
from
tasiotas:tile-extent-runtime-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,8 @@ public class FeatureRenderer implements Consumer<FeatureCollector.Feature>, Clos | |
| /** Constructs a new feature render that will send rendered features to {@code consumer}. */ | ||
| public FeatureRenderer(PlanetilerConfig config, Consumer<RenderedFeature> consumer, Stats stats, | ||
| Closeable closeable) { | ||
| VectorTile.setExtent(config.tileExtent()); | ||
| GeoUtils.setTileExtent(config.tileExtent()); | ||
| this.config = config; | ||
| this.consumer = consumer; | ||
| this.stats = stats; | ||
|
|
@@ -141,7 +143,7 @@ private void renderPoint(int zoom, Map<String, Object> attrs, FeatureCollector.F | |
| RenderedFeature.Group groupInfo = null; | ||
| if (hasLabelGrid && coords.length == 1) { | ||
| double labelGridTileSize = feature.getPointLabelGridPixelSizeAtZoom(zoom) / 256d; | ||
| groupInfo = labelGridTileSize < 1d / 4096d ? null : new RenderedFeature.Group( | ||
| groupInfo = labelGridTileSize < 1d / config.tileExtent() ? null : new RenderedFeature.Group( | ||
| GeoUtils.labelGridId(tilesAtZoom, labelGridTileSize, coords[0]), | ||
| feature.getPointLabelGridLimitAtZoom(zoom) | ||
| ); | ||
|
|
@@ -264,9 +266,11 @@ private void writeTileFeatures(int zoom, long id, FeatureCollector.Feature featu | |
| // post-processing. Features need to be "unscaled" in FeatureGroup after line merging, | ||
| // and before emitting to the output archive. | ||
| scale = Math.max(config.maxzoom(), 14) - zoom; | ||
| // need 14 bits to represent tile coordinates (4096 * 2 for buffer * 2 for zigzag encoding) | ||
| // need enough bits to represent tile coordinates (extent * 2 for buffer * 2 for zigzag encoding) | ||
| // so cap the scale factor to avoid overflowing 32-bit integer space | ||
| scale = Math.min(31 - 14, scale); | ||
| long maxCoordinate = config.tileExtent() * 4L; | ||
| int bits = 64 - Long.numberOfLeadingZeros(maxCoordinate - 1); | ||
| scale = Math.clamp(scale, 0, Math.max(0, 31 - bits)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few more subtle places that the 4096 assumption has snuck in that might not explicitly reference 4096 - this is one of them, thanks for fixing! I'm trying to think if there might be any others... |
||
| } | ||
|
|
||
| if (!geom.isEmpty()) { | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Ideally we move all references to 4096 out of static variables and either pass them as args to functions that need them or extract them from geoutils to a class that you instantiate with a tile extent. That might make this PR very big though, let me know what you think - if it's too much I could do in a followup PR.
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.
This issue also asks for the extent to be configurable per-zoom #1286 so we might even want to make it a global setting 🤔
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.
how would you implement per zoom tile extent configuration? per zoom args?
--tileExtentZ12, --tileExtentZ13, etc... ?