Skip to content

Commit

Permalink
Merge pull request #4616 from pnorman/largest_subarea
Browse files Browse the repository at this point in the history
Improve country label placement by splitting
  • Loading branch information
pnorman authored Aug 12, 2022
2 parents 332b164 + 4c06f80 commit d79419d
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit d79419d

Please sign in to comment.