-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat: added maxzoomForRendering
and minzoomForRendering
#272
Conversation
This will allow rendering with `—maxzoom=6` while having zoom 6 rendered the same way as if `—maxzoom=14` `maxzoomForRendering` will be used for simplifly algorithms
# Conflicts: # planetiler-core/src/main/java/com/onthegomap/planetiler/FeatureCollector.java
https://github.com/onthegomap/planetiler/actions/runs/2528221604 ℹ️ Base Logs c9682d5
ℹ️ This Branch Logs f20b99b
|
Interesting that no tests break. Maybe you want to add some for the new behavior? Also, maybe this change could be somewhere reflected in the documentation? |
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.
Looks good! A couple of small comments
arguments.getInteger("minzoomForRendering", "minimum zoom level", MIN_MINZOOM), | ||
arguments.getInteger("maxzoomForRendering", "maximum rendering zoom level (limit 14)", MAX_MAXZOOM), |
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.
For naming, I think maxzoom_for_render
or render_maxzoom
(let's stick with lower_camel_case) makes sense, but maybe add to the description that minzoom/maxzoom are "minimum/maximum tile zoom level to generate" and something in the render max zoom that it's the zoom level that contains fine details for overzooming?
On a side note I almost wonder if it is more a property of the profile? Maybe we can revisit as we get deeper into config-driven schemas.
@@ -99,6 +101,8 @@ public static PlanetilerConfig from(Arguments arguments) { | |||
arguments.getDuration("loginterval", "time between logs", "10s"), | |||
arguments.getInteger("minzoom", "minimum zoom level", MIN_MINZOOM), | |||
arguments.getInteger("maxzoom", "maximum zoom level (limit 14)", MAX_MAXZOOM), | |||
arguments.getInteger("minzoomForRendering", "minimum zoom level", MIN_MINZOOM), |
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.
I don't think min zoom for rendering is really necessary - I see it's only used in CacheByZoom which just uses the thresholds to set a size for the value array ahead of time - so just using min zoom would be fine.
@@ -29,7 +29,7 @@ private CacheByZoom(int minzoom, int maxzoom, IntFunction<T> supplier) { | |||
* @return a cache for {@code supplier} by zom | |||
*/ | |||
public static <T> CacheByZoom<T> create(PlanetilerConfig config, IntFunction<T> supplier) { | |||
return new CacheByZoom<>(config.minzoom(), config.maxzoom(), supplier); | |||
return new CacheByZoom<>(config.minzoomForRendering(), config.maxzoomForRendering(), supplier); |
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.
these zoom levels don't matter too much - they just define the size of the object array that stores cached values, you can just leave with minzoom/maxzoom so that minzoomForRendering isn't necessary.
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.
@msbarry actually it fails without this. I end up with an inifinite amount of error about out of bounds (sorry dont have the error here).
Good point, 1 new test in PlanetilerTest might make sense similar to the compact DB tests - basically run planetiler with That kind of smoke test also ensures we don't throw an exception when someone uses this option. |
@msbarry i am looking at writing the test. I get the idea of what you want to do but to be honest i am a bit lost on the features to add. what we need for the test is 2 have one feature only visible at zoom 8 and one visible at zoom 14.
The tricky part is that i cant do it with |
No problem, I'll take a look at adding a test for this. |
Kudos, SonarCloud Quality Gate passed! |
Looks good, thanks for adding! |
I think this logic is correct: planetiler/planetiler-core/src/test/java/com/onthegomap/planetiler/PlanetilerTests.java Lines 1789 to 1792 in 76c7880
We don't want --maxzoom=8 to cause small features to show up in the z8 unless you explicitly set --render-maxzoom=8 |
@msbarry I think you got this wrong (or this PR is not doing what i think it is). The point of |
I was interpreting The test verifies that the contents of z8 tiles is the same with maxzoom=8 or maxzoom=14, but only changes if you set render_maxzoom=8 (which clients would very rarely do). |
@msbarry damin Mike i am sorry you are 100% right, it is me who got the test mixed up in my head :( i am so so so sorry. Indeed in my case i use render_maxzoom=14 to get what i described before. But your test uses 8. |
Great feature. I have a few questions, because I'm not really sure if understand this correctly.
|
Hello! Overzooming only happens in the client. Planetiler assists the client by including more detail at the max zoom level for rendering that it generates. This PR made it so that setting max zoom lower just omits zoom levels above that, without including more detail at the max zoom level. If you actually do want more detail at that max zoom level, then use the max zoom level for rendering flag instead. Setting max zoom level for rendering less than max zoom results in undefined, I'll try adding an error message at startup that explains a little better. |
Aha, now I get it, thanks. Client (at least mine) will overzoom if you say that generated map is to zoom 8 (source in style.json) and you want max zoom 14 (for example in mapbox map). But when you have merged map with some parts (planet) to level 8 and some region (country) to 14 will:
I thought it's solving that problem. My mistake, sorry. |
This will allow rendering with
—maxzoom=6
while having zoom 6 rendered the same way as if—maxzoom=14
.maxzoomForRendering
will be used for simplifly algorithms. The default isMAX_ZOOM
(14) so by default whatevermaxzoom
is used you will get the same render as ifmaxzoom=14