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

Add rendering for waterway=waterfall #3164

Merged
merged 12 commits into from
Apr 17, 2018
32 changes: 31 additions & 1 deletion amenity-points.mss
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,19 @@
marker-placement: interior;
marker-clip: false;
}


[feature = 'waterway_waterfall'] {
[zoom >= 13][height > 20],
[zoom >= 14][height > 10],
[zoom >= 15][name != null],
[zoom >= 16] {
marker-file: url('symbols/waterfall.svg');
marker-placement: interior;
marker-clip: false;
marker-fill: @water-text;
}
}

[feature = 'military_bunker'][zoom >= 17] {
marker-file: url('symbols/bunker.svg');
marker-fill: @man-made-icon;
Expand Down Expand Up @@ -1515,6 +1527,24 @@
text-placement: interior;
}

[feature = 'waterway_waterfall'] {
[zoom >= 13][height > 20],
[zoom >= 14][height > 10],
[zoom >= 15][name != null],
[zoom >= 16] {
text-name: "[name]";
text-size: @standard-font-size;
text-wrap-width: @standard-wrap-width;
text-line-spacing: @standard-line-spacing-size;
text-fill: @water-text;
text-dy: 10;
text-face-name: @standard-font;
text-halo-radius: @standard-halo-radius;
text-halo-fill: @standard-halo-fill;
text-placement: interior;
}
}

[feature = 'man_made_cross'][zoom >= 17],
[feature = 'historic_wayside_cross'][zoom >= 17],
[feature = 'historic_wayside_shrine'][zoom >= 17],
Expand Down
37 changes: 34 additions & 3 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@ Layer:
table: |-
(SELECT
way,
name,
COALESCE(
'aeroway_' || CASE WHEN aeroway IN ('helipad', 'aerodrome') THEN aeroway ELSE NULL END,
'tourism_' || CASE WHEN tourism IN ('artwork', 'alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'wilderness_hut', 'guest_house', 'apartment',
Expand Down Expand Up @@ -1533,6 +1534,7 @@ Layer:
table: |-
(SELECT
way,
name,
COALESCE(
'aeroway_' || CASE WHEN aeroway IN ('helipad', 'aerodrome') THEN aeroway ELSE NULL END,
'tourism_' || CASE WHEN tourism IN ('artwork', 'alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'wilderness_hut', 'guest_house', 'apartment', 'hostel',
Expand All @@ -1552,6 +1554,7 @@ Layer:
'dog_park', 'fitness_centre', 'fitness_station', 'firepit', 'sauna') THEN leisure ELSE NULL END,
'man_made_' || CASE WHEN man_made IN ('mast', 'tower', 'water_tower', 'lighthouse', 'windmill', 'obelisk') THEN man_made ELSE NULL END,
'natural_' || CASE WHEN "natural" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance') THEN "natural" ELSE NULL END,
'waterway_' || CASE WHEN "waterway" IN ('waterfall') THEN waterway ELSE NULL END,
'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site', 'fort')
THEN concat_ws('_', historic, CASE WHEN tags->'memorial' IN ('plaque') THEN tags->'memorial' ELSE NULL END)
ELSE NULL END,
Expand All @@ -1571,13 +1574,18 @@ Layer:
WHEN tags->'ele' ~ '^-?\d{1,4}(\.\d+)?$' THEN (tags->'ele')::NUMERIC
ELSE NULL
END
WHEN "waterway" IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,4}(\.\d+)?$' THEN (tags->'height')::NUMERIC
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check this solution please for height values with "m" unit: #3158 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now a trailing "m" would not match the regular expression and would be dropped as if there were no height tag.

Not hard to parse around the "m", but looking at the wiki (https://wiki.openstreetmap.org/wiki/Key:height), height may be in any of the following formats:

  • 123
  • 123.4
  • 123 m
  • 123.4 m
  • 12'
  • 12'3"

Supporting feet and inches will take a little parsing and unit conversion, and would also affect the tower code. (The tower code could also use a fix for this.)

Copy link

@gpsvisualizer gpsvisualizer Apr 7, 2018

Choose a reason for hiding this comment

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

Wow... I would have thought feet or feet/inches was simply not allowed! I know that meters are required in the "ele" tag.

How many waterfalls are tagged with the "'" unit? If it's not too many, maybe we should just convert them all to meters and be done with it.

EDIT: In the U.S., there were 28. Plus a handful with "ft" or "feet." I've fixed them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My suggestion would be to make this PR about waterfalls and add support for feet/inches in another PR (if we decide to do it at all).

Wether or not to support an "m" unit in the string doesn't matter much to me. This handles all of the above cases except feet/inches:

WHEN tags->'height' ~ '^\d{1,4}(\.\d+)?\s?m?$' THEN (SUBSTRING(tags->'height', '^(\d{1,4}(\.\d+)?)\s?m?$'))::NUMERIC

ELSE NULL
END
ELSE NULL
END AS score,
religion,
tags->'denomination' as denomination,
tags->'generator:source' as "generator:source",
CASE
WHEN man_made IN ('mast', 'tower') THEN
WHEN man_made IN ('mast', 'tower') OR waterway IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^-?\d{1,4}(\.\d+)?$' THEN (tags->'height')::NUMERIC
ELSE NULL
Expand Down Expand Up @@ -1613,6 +1621,7 @@ Layer:
OR barrier IN ('toll_booth')
OR man_made IN ('mast', 'tower', 'water_tower', 'lighthouse', 'windmill', 'cross', 'obelisk')
OR "natural" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance')
OR waterway IN ('waterfall')
OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross', 'fort', 'wayside_shrine')
OR tags->'memorial' IN ('plaque')
OR military IN ('bunker')
Expand Down Expand Up @@ -2025,6 +2034,14 @@ Layer:
NULL
END
) AS name,
CASE
WHEN "waterway" IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,4}(\.\d+)?$' THEN (tags->'height')::NUMERIC
ELSE NULL
END
ELSE NULL
END AS height,
tags->'operator' as operator,
tags->'icao' as icao,
tags->'iata' as iata,
Expand Down Expand Up @@ -2099,13 +2116,16 @@ Layer:
access,
CONCAT(
name,
CASE WHEN name IS NOT NULL AND elevation IS NOT NULL THEN E'\n' ELSE NULL END,
CASE WHEN elevation IS NOT NULL THEN CONCAT(REPLACE(ROUND(elevation)::TEXT, '-', U&'\2212'), U&'\00A0', 'm') ELSE NULL END
CASE WHEN name IS NOT NULL AND elevation IS NOT NULL OR height IS NOT NULL THEN E'\n' ELSE NULL END,
CASE WHEN elevation IS NOT NULL THEN CONCAT(REPLACE(ROUND(elevation)::TEXT, '-', U&'\2212'), U&'\00A0', 'm') ELSE NULL END,
CASE WHEN height IS NOT NULL THEN CONCAT(ROUND(height)::TEXT, U&'\00A0', 'm') ELSE NULL END
) AS name,
CASE
WHEN "natural" IN ('peak', 'volcano', 'saddle') THEN elevation
WHEN "waterway" IN ('waterfall') THEN height
ELSE NULL
END AS score,
height,
operator,
icao,
iata,
Expand Down Expand Up @@ -2151,6 +2171,7 @@ Layer:
'natural_' || CASE WHEN "natural" IN ('wood', 'peak', 'volcano', 'saddle', 'cave_entrance', 'water', 'mud', 'wetland', 'marsh', 'bay', 'spring',
'scree', 'shingle', 'bare_rock', 'sand', 'heath', 'grassland', 'scrub', 'beach', 'glacier', 'tree')
THEN "natural" ELSE NULL END,
'waterway_' || CASE WHEN waterway IN ('waterfall') THEN waterway ELSE NULL END,
'place_' || CASE WHEN place IN ('island', 'islet') THEN place ELSE NULL END,
'barrier_' || CASE WHEN barrier IN ('toll_booth') THEN barrier ELSE NULL END,
'military_' || CASE WHEN military IN ('danger_area', 'bunker') THEN military ELSE NULL END,
Expand All @@ -2174,7 +2195,16 @@ Layer:
END
ELSE NULL
END AS elevation,
CASE
WHEN "waterway" IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,4}(\.\d+)?$' THEN (tags->'height')::NUMERIC
ELSE NULL
END
ELSE NULL
END AS height,
"natural",
waterway,
tags->'operator' as operator,
tags->'icao' as icao,
tags->'iata' as iata,
Expand All @@ -2196,6 +2226,7 @@ Layer:
'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'construction', 'military', 'plant_nursery')
OR man_made IN ('lighthouse', 'windmill', 'mast', 'tower', 'water_tower', 'cross', 'obelisk', 'works')
OR "natural" IS NOT NULL
OR waterway IN ('waterfall')
OR place IN ('island', 'islet')
OR barrier IN ('toll_booth')
OR military IN ('danger_area', 'bunker')
Expand Down
4 changes: 4 additions & 0 deletions symbols/waterfall.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.