Skip to content

Commit

Permalink
Improvement to maritime border rendering
Browse files Browse the repository at this point in the history
* Admin rendering based on lines instead of relatinos does not work (lack of
  data in e.g. Poland, and ugly rendering of dashes in case of short sections).
  Instead, this renders maritime borders based on lines, on top of the full
  border based on the polygon.
* Fix error on high zoom levels.
* Render maritime border slightly darker.
  • Loading branch information
math1985 committed Feb 10, 2018
1 parent 106c79f commit 1ce756d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 19 deletions.
19 changes: 10 additions & 9 deletions admin.mss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@admin-boundaries: #ac46ac;
@admin-boundaries-maritime: darken(@water-color,15%);
@admin-boundaries-maritime: darken(@water-color,20%);

/* For performance reasons, the admin border layers are split into three groups
for low, middle and high zoom levels.
Expand All @@ -17,7 +17,7 @@ overlapping borders correctly.
background/line-width: 1.2;
line-join: bevel;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-width: 1.2;
Expand Down Expand Up @@ -47,7 +47,7 @@ overlapping borders correctly.
background/line-width: 0.6;
line-join: bevel;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-width: 0.6;
Expand All @@ -70,7 +70,7 @@ overlapping borders correctly.
background/line-color: white;
background/line-width: 0.4;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-join: bevel;
Expand Down Expand Up @@ -126,7 +126,7 @@ overlapping borders correctly.
background/line-width: 2;
line-join: bevel;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-width: 2;
Expand All @@ -139,7 +139,7 @@ overlapping borders correctly.
background/line-width: 2;
line-join: bevel;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-width: 2;
Expand All @@ -154,7 +154,7 @@ overlapping borders correctly.
background/line-width: 1.5;
line-join: bevel;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-width: 1.5;
Expand All @@ -166,7 +166,8 @@ overlapping borders correctly.
comp-op: darken;
}

#admin-high-zoom[zoom >= 13] {
#admin-high-zoom[zoom >= 13],
#admin-high-zoom-maritime[zoom >= 13] {
[admin_level = '9'],
[admin_level = '10'] {
[zoom >= 13] {
Expand All @@ -175,7 +176,7 @@ overlapping borders correctly.
background/line-width: 2;
line-join: bevel;
line-color: @admin-boundaries;
[maritime = 'yes'] {
[maritime = 'true'] {
line-color: @admin-boundaries-maritime;
}
line-width: 2;
Expand Down
62 changes: 52 additions & 10 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1123,58 +1123,100 @@ Layer:
properties:
minzoom: 11
- id: admin-low-zoom
class: admin
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
(
(SELECT
way,
admin_level,
tags->'maritime' as maritime
'false' as maritime
FROM planet_osm_roads
WHERE boundary = 'administrative'
AND admin_level IN ('0', '1', '2', '3', '4')
AND osm_id < 0
)
UNION
(SELECT
way,
admin_level,
'true' as maritime
FROM planet_osm_roads
WHERE boundary = 'administrative'
AND admin_level IN ('0', '1', '2', '3', '4')
AND osm_id > 0
ORDER BY admin_level DESC
AND tags->'maritime' = 'yes'
)
ORDER BY maritime, admin_level DESC
) AS admin_low_zoom
properties:
minzoom: 4
maxzoom: 10
- id: admin-mid-zoom
class: admin
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
(
(SELECT
way,
admin_level,
'false'as maritime
FROM planet_osm_roads
WHERE boundary = 'administrative'
AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8')
AND osm_id < 0
)
UNION
(SELECT
way,
admin_level,
boundary
'true' as maritime
FROM planet_osm_roads
WHERE boundary = 'administrative'
AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8')
AND osm_id > 0
ORDER BY admin_level DESC
AND tags->'maritime' = 'yes'
)
ORDER BY maritime, admin_level DESC
) AS admin_mid_zoom
properties:
minzoom: 11
maxzoom: 12
- id: admin-high-zoom
class: admin
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
(
(SELECT
way,
admin_level,
boundary
admin_level::integer, -- With 10 as a valid value, we need to do a numeric ordering, not a text ordering
'false' as maritime
FROM planet_osm_roads
WHERE boundary = 'administrative'
AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10')
AND osm_id < 0
)
UNION
(SELECT
way,
admin_level::integer, -- With 10 as a valid value, we need to do a numeric ordering, not a text ordering
'true' as maritime
FROM planet_osm_roads
WHERE boundary = 'administrative'
AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10')
AND osm_id > 0
ORDER BY admin_level::integer DESC -- With 10 as a valid value, we need to do a numeric ordering, not a text ordering
AND tags->'maritime' = 'yes'
)
ORDER BY maritime, admin_level DESC
) AS admin_high_zoom
properties:
minzoom: 13
Expand Down

0 comments on commit 1ce756d

Please sign in to comment.