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

Improve country label placement by splitting #4616

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

pnorman
Copy link
Collaborator

@pnorman pnorman commented Jul 22, 2022

By splitting MPs into polygons, taking the largest, and finding a point in 4326 we get better points for placing labels. 4326 does distort the placement, but it does so in a way that results in better results for most countries.

When monitoring for slow queries, this query does not take significant time compared to other layers. I have some upcoming work that will improve the other queries, as some of them are quite slow on low zoom.

I am making this change for countries only because

  • splitting and calculating true area is only different from what st_pointonsurface does if there is a significant north/south difference in the different polygons that make up a MP. In practice, this means only countries are impacted.
  • The difference for ST_PointOnSurface between 4326 and 3857 is only significant for large objects. This could in theory impact large bays, but people tend to not have strong opinions on bays, label placement isn't as crucial when the entire area is water, and we're considering removing them from the very low zooms.

Fixes #4241

For the images, left is the tile.osm.org deployment, right is this PR
image
image
image
image
image

From my tests, I have a geojson with all the country labels computed this way, because this PR is easiest to test with a full planet import.

point_4326.zip

By splitting MPs into polygons, taking the largest,
and finding a point in 4326 we get better points for
placing labels. 4326 does distort the placement, but
it does so in a way that results in better results
for most countries.
@pnorman
Copy link
Collaborator Author

pnorman commented Jul 22, 2022

cc @swedneck, if you want to review this

@swedneck
Copy link

Looks great!

@pnorman pnorman mentioned this pull request Jul 27, 2022
@pnorman
Copy link
Collaborator Author

pnorman commented Jul 28, 2022

Note that adding the index in #4617 makes this substantially faster to view with large databases.

Copy link
Collaborator

@sommerluk sommerluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, some changes in the Pacific Ocean (small island states like Kiribati), looks good.

@pnorman pnorman merged commit d79419d into gravitystorm:master Aug 12, 2022
@pnorman pnorman deleted the largest_subarea branch August 12, 2022 08:24
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

Successfully merging this pull request may close these issues.

Bad label placement at high latitudes due to coordinate calculations in mercator projection
3 participants