-
Notifications
You must be signed in to change notification settings - Fork 819
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
Dropping subpixel accuracy for areas #2874
Conversation
If doing this then the custom indexes will need adjusting. My recollection was that I did see differences with a 1px filter, but that was a long time ago when I tested. |
I'm not aware of this problem. I don't see any specific value in
This query change means that we just don't want very small areas to have any impact on the rendering, but it's not distorting anything. In my opinion any object ~1 pixel big is still insignificant for the whole image. In some cases it might be even better to hide them, but it's rather styling problem than database filtering. |
What if somebody makes a farmland via small polygons representing each parcel. Would this be still rendered with the farmland colour before the patch and be completely missing after the patch? |
It depends on how small they are. If they are <~1 px on zoom level n, they will just not be rendered on this level, but will be visible on n+1 and z19 should be more than enough for any area, no matter how small. |
@rrzefox Could you also apply this patch on your server? It's just about being on the safe side, because we already know that:
So we know that we should end up using less resources, but we just don't know to what degree. My take is that if there won't be bad rendering changes (just less of some small objects is not bad in itself), it's worth to merge this, even just to spare some memory. |
No, because a large area mapped with blocks of 0.5 px would disappear completely. This isn't an issue with 0.01px because by the time that happens, roundoff errors will have overwhelmed anything else. |
This was a symbol to show areas "smaller but near 1 px". The rest will be just visible on n+2 - and so on. We don't even know how much such small areas change the rendering when there's more of them. The real question is however not "how Mapnik works with a lot of subpixel areas", but "do you know examples where this could be a problem"? |
That value is based on current queries.
I'm not sure what the relevance of zooming in is.
Yes we do - unless you start to get so many areas there's a roundoff error, it's the same as if they were joined. |
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'm not convinced that going this far is safe, and would like to see the difference in a region with lots of almost 1px areas before having confidence it's okay.
The way area partial indexes will need adjusting to any change.
What should it be after this PR? I will change it in the code.
It's good to remember that this style has not just one scale, as on the paper. It means that we don't "drop" any data, we just show them later. |
It should be about 0.99 of the cutoff threshold at some zoom, rounded down. This makes sure that the partial condition closely matches the queries. As for what zoom, it probably won't be z6 anymore. I looked at index size vs zoom and made a call on when the tradeoffs were best. I'd guess the area from z7-z9 is more appropriate with these changes.
Using the example of water, the problem isn't deciding not to render very small lakes. The problem is having gaps appear in rivers where the individual polygons are under the threshold but the overall size is large. |
OK, so either I need some numbers for custom indexes or you can make additional patch if this PR will be merged - I leave it to you.
Thanks, now I see. For complex objects made of smaller parts - like rivers - I would rely on relations, not individual water areas. Using any threshold is just guessing (probability of error) and safeguarding (eating resources to correct possible errors). Does it make sense or am I missing something? |
No, relations are not a solution. Water is a bit different because it has a name, but for forests, someone shouldn't make a relation unless there's an inner hole or some other reason. |
What are the area values at different zooms, calculated as above? |
For me there's a big difference between a river and small lakes/forests/buildings etc. I'm not worried about small lakes or forests - they don't need to be shown at a certain level, because they don't need to be continuous. The river is different when drawn as a water areas - they should be collected in a relation anyway. The same is true for natural reserves - they are also tagged this way when they consist of multiple areas. So I guess we are safe already. Are there any landuses or buildings that should be rendered continuously?
I'm not sure how to apply the rule you gave and get the numbers. |
So in two areas we see significant differences:
To me all these effects are rather small, and remove a lot of noise (and blurry/mixed colors) from the map. So I'm in favour of merging this as it looks now (but haven't tested it myself on Luxembourg yet). Note also that if we ever want to move to vector maps, probably we will need to do something similar. By the way, I would also be interested, just for fun, to see how the map change if we increase the pixel limit even further. |
The cemetery tagging is just being overzealous - cemetery=* key does not require amenity=cemetery. |
this has been applied two days ago and all tiles should have been rerendered by now. |
Great, thanks a lot for your help! |
This PR makes this forest disappear from z7. |
@matkoniecz Thanks, moving the cut-off from 1 to 5 pixels clearly does not work. Many forests in Poland seem to have been important in small blocks, such as this one: https://www.openstreetmap.org/#map=13/52.7647/16.5602 |
@rrzefox: I'm very glad of your help with testing medium and low zoom levels! It's important tool, since it's a risky ground that is hard to explore on our home environments (for database size and performance reasons). It's also a lot of fun for me to discover visual differences live! |
It has probably nothing to do with pixel accuracy, but do you have any idea why The Cotswolds national park (GB) disappears? |
I'm not a database guy, but maybe you know how to tune the custom indexes according to what Paul proposed:
|
No, I have no idea. |
I'm not having much luck explaining, so here are the calculations Our current index is designed for a cutoff of 0.01 of a pixel at z6 and below. The web mercator plane is 40075342.49 mercator meters in each direction, so the pixel width and height is 40075342.49/256*2^-z, giving a Next it looks at how to run the query. One way is using the Because one index is 30 times the size of the other, it expects the The reason we don't make an index for each zoom is threefold. In reverse order of importance, they are:
I'll run some queries to get index sizes. |
|
How should these indexes be applied now? I thought that maybe in the openstreetmap-carto/indexes.sql Lines 37 to 39 in eaef4bb
However 59800 * 0.99 = 59202, so (rounding down not needed) it's not the same as 59750. But maybe this was calculated in a different way and we should now replace it with 5920200? Sorry, it's not that you do something wrong with explaining, I'm just not familiar with database indexing. |
308160c
to
8474fc6
Compare
This was explained by @pnorman above: if we have an index for |
I admit I still don't get all the details, but I'm not interested too much in the inner details of a database. I just like to know what number should I put and where to make indexing aligned to a new accuracy? |
@pnorman Would this change be proper or it should be something else: WHERE way_area > 5920200 |
It might not have been clear, but the values in my table are rounded appropriately, and not the precise values that appear in the query conditions.
It depends what we're doing. I suspect an index for z6 and below and for z10 and below would be best. But I don't know, and that's the type of consideration that needs to go into selecting a different area cutoff threshold for performance reasons. |
You have a great experience at database things, especially performance related, and I ultimately trust your choices regarding this. Given that indexes for z6+ and z10+ sound good for you, I believe we can go for that. How should they be implemented in the code? |
Have two indexes, one for z6 with the 5980000 limit, one for z10 with the 23300 limit. |
Thanks! Should the code look like simply this?: CREATE INDEX planet_osm_polygon_way_area_z6
ON planet_osm_polygon USING GIST (way)
WHERE way_area > 5980000;
CREATE INDEX planet_osm_polygon_way_area_z10
ON planet_osm_polygon USING GIST (way)
WHERE way_area > 23300; |
Yes, that's correct. |
b9f31c5
to
687d19d
Compare
Z9 was quite anomaly in terms of rendering time. It was taking much longer than Z8 and Z10 during pre-computation. Dominant layer was landuse_gen0. It was using subpixel rendering for landuse, which is useful at very low zoom but seems to be safely discardable at Z9. See as well gravitystorm/openstreetmap-carto#2874 and gravitystorm/openstreetmap-carto#3458 (comment). See #644.
Z9 was quite anomaly in terms of rendering time. It was taking much longer than Z8 and Z10 during pre-computation. Dominant layer was landuse_gen0. It was using subpixel rendering for landuse, which is useful at very low zoom but seems to be safely discardable at Z9. Also add checks between way geometries and bbox to ensure correct usage of geospatial indexes in db. See as well gravitystorm/openstreetmap-carto#2874 and gravitystorm/openstreetmap-carto#3458 (comment). See #644.
Follow up to #2873.
Related to #1604.
It needs some testing, but it looks that dropping subpixel accuracy from SQL queries does not have visible effect on rendering - if any - while increasing performance (at least decreasing memory usage).
Affected objects: water, landcovers, buildings and nature reserves.