-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add support for polygon label position #80
Comments
I think neither Mapsforge supports area caption in render theme schema. |
Yes. But as I see map writer has support for them. Is it unfinished? |
In both libraries there is support for |
I was trying to add similar for lakes and landuse areas with poor result. |
I am currently investigating the subject. Foremost I want to mention that I have successfully implemented basic functionality with my forks of mapsforge and vtm libraries. But there are some issues and questions to discuss. In general my task is to properly add captions and symbols to various polygons. For instance - water area names, airport and other notable area symbols, proper building numbers (see below). This task can not be solved in general. The major problem is that the majority of polygons is split among several tiles but map renderer operates on a single tile. There is no way for the renderer to get full polygon information and to decide where to put it's label. Current implementation puts a label in the center of a clipped polygon in each tile. This affects even building numbers: if the building is split by tile its number is drawn several times. This can be seen even with raster mapsforge renderer. Mapsforge map writer contains This is working but is very excessive in terms of map data size and processing speed. There is no need to have this option map-wide and generate position for each and every polygon. I propose to make it settable for individual tags in mappings file. Speaking about vtm this approach works good for building numbers and polygon symbols. But polygon labeling needs significant improvement. Currently labeling can be filtered only by zoom level. But if you need to label land areas (water, protected areas and similar objects of very varying sizes) labeling should be limited to polygon area. (You can see such behavior on OpenStreetMap) Technically this can be done but needs extending of style rules. So I want to discuss it also. |
@andreynovikov nice analysis! 👍 Extensions to map-writer or Mapsforge / VTM renderers are always welcome (provided somehow backwards compatibility). 😄 BTW |
Yes, you have enabled it via mapsforge/mapsforge@f02aa93 but is looks like it was a wrong decision. :) Are label positions currently used in MapsForge rendering code or it was made for future? |
I have played with filtering polygon labels based on its calculated area. It works well despite one irritating fact: when using mapsforge maps on zooms lower then base zoom polygons are split into many peaces, that prevents correct polygon area calculation. As a matter of fact this behavior produces many rendering problems, the major one is contouring a polygon. May be we should join polygons in this case? There are ready to use solutions, such as: P.S. Even with split polygons area filtering works well but sometimes requires complex style rules (for zooms below and above 14). |
To conclusion: I will prettify the code and create a PR both for mapsforge and vtm. It will take some time though. |
You mean the artifacts in zooms 12-13 coming from base zoom 14 grid, discussed many times in the forum, right? BTW I remember @hjanetzek had mentioned 3 years ago an idea for that.
👍 And I suppose we should revert the |
Yes, mapwriter and vtm. Can't talk about mapsforge renderer because I do not use it. Anyway all updates to mapwriter are back compatible.
Not at this point. It was only the suggestion.
Yes, this will be the part of PR as I implemented per-tag configuration. |
I have created both PRs. Have tested them on my custom map. This is what I used for testing:
And default building styles, of course. |
Thanks @andreynovikov very clean work! 👍
|
|
In my tests the client has serious performance issues with the calculations. |
At what particular cases? I am working on it a week already and use VTM sample app heavily for testing but did not notice any issues. |
Areas with buildings with many house numbers. I even got an OOM on Android. |
Strange. I have added PolyLabel to VTM first and didn't notice any performance problems during tests. But if this is the issue we can simplify the logic - take centroid and only if it is outside the polygon, calculate alternative position for label. |
@andreynovikov you can try Mapsforge luxembourg.map (2016-03-03) inside the capital. |
Yes, of course. But what should I look out for? |
@Longri try issue_204 branch with e.g. older luxembourg.map and zoom inside the capital. In my tests on Android and Desktop, older maps after a little zoom / pan become unresponsive, too much GC and CPU utilization. |
Furthermore the label calculation needs more checks. |
|
Also please check with the
|
I tested this branch under iOS with luxembourg.map. With zoom the app freezes and then crashes after a short time. |
I've got the issue (using memory allocation tracking). Sometimes for unknown reason this limitation: |
@Longri thanks for the feedback. @andreynovikov since this is an important feature and would need good testing, I'll proceed with |
Agree. |
In PolyLabel class I didn't check for geometry type, I've thought that
|
Nice city - Luxembourg! Have found another issue - building polygon consisting of three points in a line (with equal Y coordinate). So, disregard my previous diff, here is the correct one:
|
Thanks @andreynovikov works nice! BTW do we need the same fix on map-writer? Trying now the heavy netherlands.map at small zoom levels 8-9, I notice that |
I will update my PR. Map-writer checks for geometries thoroughly. I can not think how bad polygons can pass. Yes, as I said you should not add captions for water polygons to default styles until maps will contain calculated label positions. Or add zoom filter to show them only on higher zooms. |
That could happen if we use |
Yes. My intent was to leave everything as it was, and add more styles carefully in future. As currently only building polygons have labeling I have added corresponding |
I have added three extra commits to my branch, have a look. |
- Fix infinite recursion on invalid polygons - Allow setting area-size for text styles - Skip unnecessary calculations if label is outside of visible area
Map writer has an option to compute label position for polygons that cover multiple tiles. Currently VTM lacks proper area name display. It would be nice to add support for it.
The text was updated successfully, but these errors were encountered: