Skip to content
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

Labels for mountain ranges #130

Open
zdila opened this issue Nov 7, 2019 · 7 comments
Open

Labels for mountain ranges #130

zdila opened this issue Nov 7, 2019 · 7 comments

Comments

@zdila
Copy link

zdila commented Nov 7, 2019

Hello,

How to generate curved labels of mountain ranges like you can see for example in the following maps?

I know, OTP map is opensource and I see how they do it but it seems very complext to me. Moreover it would be best not to do it with any pre-processing.

Any ideas?

@talaj
Copy link
Member

talaj commented Nov 7, 2019

Hi, there is horizontal-alignment="adjust" for that, see mapnik/mapnik#2426.

But the version in upstream mapnik will not make the placement sometimes. I fixed it in downstream, but due to implementation difficulties did not get it to the upstream yet.

@zdila
Copy link
Author

zdila commented Nov 7, 2019

Thanks! I will actually find use of it for valleys where we currently use text symbolizer with multiple placements of different character spacing.

But AFAIK it works only on LINESTRINGs and mountain ranges are (MULTI)POLYGONs. Or am I missing something?

@talaj
Copy link
Member

talaj commented Nov 7, 2019

With polygons, it will probably do something you don't want - it will place the text on the polygon border.
I would try to use ST_ApproximateMedialAxis (+ buffer + simplify) to get linestring out of it.

@zdila
Copy link
Author

zdila commented Nov 7, 2019

Thanks, I've already tried it that way but I thought it is not the right direction. See my question at https://gis.stackexchange.com/questions/312283/st-approximatemedialaxis-returns-multilinestring-instead-of-single-linestring.

But if you were successful then I will continue to play with it this direction. (And if you have and you can provide a complete solution or a sample I won't be angry ;-)).

But the version in upstream mapnik will not make the placement sometimes.

Will it happen often? And in such a case will it prevent rendering the text completely?

I fixed it in downstream, but due to implementation difficulties did not get it to the upstream yet.

Fingers crossed to make it there!

@talaj
Copy link
Member

talaj commented Nov 7, 2019

From what I could find we have mountain ranges manually defined as linestrings by cartographers.

But I think it should be doable with enough buffer used before ST_ApproximateMedialAxis. Then maybe ST_LineMerge and pick the longest linestring.
I accidentally found this: der-stefan/OpenTopoMap#134

Will it happen often? And in such a case will it prevent rendering the text completely?

It happens rarely. I described the problem in mapnik/mapnik#3662 (comment) (but in the case of that issue, the questioner had problem with max-char-angle-delta finally).

My solution in downstream is to use mapnik/mapnik#3512 to make lines always long enough. But it needed some ugly "ifs" in the upstream code when I was trying it.

@zdila
Copy link
Author

zdila commented Nov 7, 2019

Thank you very much for all the details!
I will put here the solution once I find it :)

@zdila
Copy link
Author

zdila commented Feb 14, 2020

So far we (I) couldn't find any good solution and so we will probably define mountain ranges (and valleys etc) manually as mapy.cz did.

BTW opentopomap uses following script to do it: https://github.com/der-stefan/OpenTopoMap/blob/master/mapnik/tools/arealabel.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants