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

Render place names from both points and polygons #2816

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions placenames.mss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
shield-margin: 7.7; // 0.7 em
shield-halo-fill: @standard-halo-fill;
shield-halo-radius: @standard-halo-radius * 1.5;
shield-placement: interior;
shield-placement-type: simple;
shield-placements: 'S,N,E,W';
[dir = 1] {
Expand Down Expand Up @@ -111,6 +112,7 @@
text-margin: 9.1; // 0.7 em
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;

[zoom >= 10] {
text-size: 14;
Expand Down Expand Up @@ -143,6 +145,7 @@
shield-margin: 7.7; // 0.7 em
shield-halo-fill: @standard-halo-fill;
shield-halo-radius: @standard-halo-radius * 1.5;
shield-placement: interior;
shield-placement-type: simple;
shield-placements: 'S,N,E,W';
[dir = 1] {
Expand Down Expand Up @@ -178,6 +181,7 @@
text-margin: 9.1; // 0.7 em
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;

[zoom >= 10] {
text-size: 14;
Expand Down Expand Up @@ -211,6 +215,7 @@
shield-wrap-width: 30; // 3.0 em
shield-line-spacing: -1.5; // -0.15 em
shield-margin: 7.0; // 0.7 em
shield-placement: interior;
shield-placement-type: simple;
shield-placements: 'S,N,E,W';
[dir = 1] {
Expand All @@ -228,6 +233,7 @@
text-face-name: @book-fonts;
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;
text-wrap-width: 40; // 4.0 em
text-line-spacing: -1.0; // -0.10 em
text-margin: 7.0; // 0.7 em
Expand Down Expand Up @@ -268,6 +274,7 @@
text-face-name: @book-fonts;
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;
text-wrap-width: 45; // 4.5 em
text-line-spacing: -0.8; // -0.08 em
text-margin: 7; // 0.7 em
Expand Down Expand Up @@ -301,6 +308,7 @@
text-face-name: @book-fonts;
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;
text-wrap-width: 55; // 5.0 em
text-line-spacing: -0.55; // -0.05 em
text-margin: 7.7; // 0.7 em
Expand Down Expand Up @@ -336,6 +344,7 @@
text-face-name: @book-fonts;
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;
text-wrap-width: 50; // 5.0 em
text-line-spacing: -0.50; // -0.05 em
text-margin: 7.0; // 0.7 em
Expand Down Expand Up @@ -382,6 +391,7 @@
text-face-name: @book-fonts;
text-halo-fill: @standard-halo-fill;
text-halo-radius: @standard-halo-radius * 1.5;
text-placement: interior;
text-wrap-width: 45; // 4.5 em
text-line-spacing: -0.8; // -0.08 em
text-margin: 7.0; // 0.7 em
Expand Down
72 changes: 64 additions & 8 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1232,11 +1232,30 @@ Layer:
WHEN (tags->'population' ~ '^[0-9]{1,8}$') THEN (tags->'population')::INTEGER ELSE 0
END as population,
round(ascii(md5(osm_id::text)) / 55) AS dir -- base direction factor on geometry to be consistent across metatiles
FROM planet_osm_point
WHERE place IN ('city', 'town', 'village', 'hamlet')
AND name IS NOT NULL
AND tags @> 'capital=>yes'
ORDER BY population DESC
FROM
(SELECT
way,
osm_id,
name,
place,
tags,
NULL AS way_area
FROM planet_osm_point
UNION ALL
SELECT
way,
osm_id,
name,
place,
tags,
way_area
FROM planet_osm_polygon
Copy link

@Komzpa Komzpa Sep 20, 2017

Choose a reason for hiding this comment

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

from planet_osm_polygon a
where not exists (
    select 
    from planet_osm_point p
    where a.place=p.place 
        and a.name=p.name 
        and ST_Intesects(a.geom, p.geom)
)

) places
WHERE place IN ('city', 'town', 'village', 'hamlet')
AND name IS NOT NULL
AND tags @> 'capital=>yes'
ORDER BY population DESC,
way_area DESC NULLS LAST
) AS capital_names
properties:
minzoom: 3
Expand Down Expand Up @@ -1296,7 +1315,25 @@ Layer:
ELSE 1
END)
) AS score
FROM planet_osm_point
FROM
(SELECT
osm_id,
way,
place,
name,
tags,
NULL AS way_area
FROM planet_osm_point
UNION ALL
SELECT
osm_id,
way,
place,
name,
tags,
way_area
FROM planet_osm_polygon
Copy link

@Komzpa Komzpa Sep 20, 2017

Choose a reason for hiding this comment

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

from planet_osm_polygon a
where not exists (
    select 
    from planet_osm_point p
    where a.place=p.place 
        and a.name=p.name 
        and ST_Intesects(a.geom, p.geom)
)

) places
WHERE place IN ('city', 'town')
AND name IS NOT NULL
AND NOT (tags @> 'capital=>yes')
Expand All @@ -1316,7 +1353,23 @@ Layer:
way,
place,
name
FROM planet_osm_point
FROM
(SELECT
way,
place,
name,
tags,
NULL AS way_area
FROM planet_osm_point
UNION ALL
SELECT
way,
place,
name,
tags,
NULL AS way_area
FROM planet_osm_polygon
Copy link

@Komzpa Komzpa Sep 20, 2017

Choose a reason for hiding this comment

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

from planet_osm_polygon a
where not exists (
    select 
    from planet_osm_point p
    where a.place=p.place 
        and a.name=p.name 
        and ST_Intesects(a.geom, p.geom)
)

Choose a reason for hiding this comment

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

Nice idea.

One thing I noted. Should:

from planet_osm_point p

not be:

from planet_osm_point b

?

Copy link

Choose a reason for hiding this comment

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

sure, fixed :) [a for area, p for point]

) AS places
WHERE place IN ('village', 'hamlet')
AND name IS NOT NULL
AND NOT tags @> 'capital=>yes'
Expand All @@ -1330,7 +1383,10 @@ Layer:
WHEN place = 'locality' THEN 7
WHEN place = 'isolated_dwelling' THEN 8
WHEN place = 'farm' THEN 9
END ASC, length(name) DESC, name
END ASC,
way_area DESC NULLS LAST,
length(name) DESC,
name
) AS placenames_small
properties:
minzoom: 12
Expand Down