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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1178,13 +1178,20 @@ Layer:
<<: *extents
Datasource:
<<: *osm2pgsql
# By splitting MPs into polygons, finding the largest in real area, and
# finding a label point in 4326 we get better labeling points. 4326 does
# distort the placement, but it does so in a way that results in better
# results for most countries.
table: |-
(SELECT
ST_PointOnSurface(way) AS way,
(SELECT ST_Transform(ST_PointOnSurface(geom),3857)
FROM ST_Dump(ST_Transform(way,4326))
ORDER BY ST_Area(geom::geography) DESC
LIMIT 1) AS way,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
name
FROM planet_osm_polygon
WHERE ST_PointOnSurface(way) && !bbox!
WHERE way && !bbox!
AND name IS NOT NULL
AND boundary = 'administrative'
AND admin_level = '2'
Expand Down