Skip to content

Commit

Permalink
Merge pull request #432 from mapzen/344-add-winter-sports-pois
Browse files Browse the repository at this point in the history
Added winter sports POIs and lines.
  • Loading branch information
zerebubuth committed Dec 9, 2015
2 parents eafe4b0 + c05d8b4 commit 9f6673a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
4 changes: 2 additions & 2 deletions data/apply-planet_osm_line.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ ALTER TABLE planet_osm_line ADD COLUMN mz_road_level SMALLINT;
ALTER TABLE planet_osm_line ADD COLUMN mz_transit_level SMALLINT;

UPDATE planet_osm_line
SET mz_road_level = mz_calculate_road_level(highway, railway, aeroway, route, service, aerialway, way)
WHERE mz_calculate_road_level(highway, railway, aeroway, route, service, aerialway, tags->'piste:type', way) IS NOT NULL;
SET mz_road_level = mz_calculate_road_level(highway, railway, aeroway, route, service, aerialway, leisure, sport, way)
WHERE mz_calculate_road_level(highway, railway, aeroway, route, service, aerialway, leisure, sport, way) IS NOT NULL;

UPDATE planet_osm_line
SET mz_transit_level = mz_calculate_transit_level(route)
Expand Down
28 changes: 27 additions & 1 deletion data/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ CREATE OR REPLACE FUNCTION mz_calculate_poi_level(
office_val text,
power_val text,
railway_val text,
rental_val text,
shop_val text,
tourism_val text,
waterway_val text,
Expand Down Expand Up @@ -167,6 +168,11 @@ BEGIN
WHEN amenity_val = 'ferry_terminal' THEN LEAST(zoom + 3.20, 15)
WHEN amenity_val = 'school' THEN LEAST(zoom + 2.30, 15)
WHEN natural_val = 'beach' THEN LEAST(zoom + 3.20, 14)
WHEN rental_val = 'ski' THEN LEAST(zoom + 1.27, 17)
WHEN shop_val = 'ski' THEN LEAST(zoom + 1.27, 17)
WHEN amenity_val = 'ski_rental' THEN LEAST(zoom + 1.27, 17)
WHEN amenity_val = 'ski_school' THEN LEAST(zoom + 2.30, 15)
WHEN man_made_val = 'snow_cannon' THEN LEAST(zoom + 4.90, 18)
WHEN (barrier_val IN ('gate')
OR craft_val IN ('sawmill')
OR highway_val IN ('gate', 'mini_roundabout')
Expand Down Expand Up @@ -303,7 +309,24 @@ BEGIN
END;
$$ LANGUAGE plpgsql IMMUTABLE;

CREATE OR REPLACE FUNCTION mz_calculate_road_level(highway_val text, railway_val text, aeroway_val text, route_val text, service_val text, aerialway_val text, way geometry)
CREATE OR REPLACE FUNCTION mz_calculate_leisure_level(leisure_val text, sport_val text)
RETURNS SMALLINT AS $$
BEGIN
RETURN CASE
WHEN leisure_val IN ('track') THEN
CASE
WHEN sport_val IN ('athletics', 'running', 'horse_racing', 'bmx',
'disc_golf', 'cycling', 'ski_jumping', 'motor', 'karting',
'obstacle_course', 'equestrian', 'alpine_slide', 'soap_box_derby',
'mud_truck_racing', 'skiing', 'drag_racing', 'archery') THEN 14
ELSE NULL
END
ELSE NULL
END;
END;
$$ LANGUAGE plpgsql IMMUTABLE;

CREATE OR REPLACE FUNCTION mz_calculate_road_level(highway_val text, railway_val text, aeroway_val text, route_val text, service_val text, aerialway_val text, leisure_val text, sport_val text, way geometry)
RETURNS SMALLINT AS $$
BEGIN
RETURN LEAST(
Expand All @@ -321,6 +344,9 @@ BEGIN
ELSE NULL END,
CASE WHEN aerialway_val IS NOT NULL
THEN mz_calculate_aerialway_level(aerialway_val)
ELSE NULL END,
CASE WHEN leisure_val IS NOT NULL
THEN mz_calculate_leisure_level(leisure_val, sport_val)
ELSE NULL END);
END;
$$ LANGUAGE plpgsql IMMUTABLE;
Expand Down
2 changes: 1 addition & 1 deletion data/triggers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CREATE TRIGGER mz_trigger_point BEFORE INSERT OR UPDATE ON planet_osm_point FOR
CREATE OR REPLACE FUNCTION mz_trigger_function_line()
RETURNS TRIGGER AS $$
BEGIN
NEW.mz_road_level := mz_calculate_road_level(NEW."highway", NEW."railway", NEW."aeroway", NEW."route", NEW."service", NEW."aerialway", NEW."way");
NEW.mz_road_level := mz_calculate_road_level(NEW."highway", NEW."railway", NEW."aeroway", NEW."route", NEW."service", NEW."aerialway", NEW."leisure", NEW."sport", NEW."way");
NEW.mz_transit_level := mz_calculate_transit_level(NEW."route");
RETURN NEW;
END;
Expand Down
2 changes: 2 additions & 0 deletions queries/boundaries.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ SELECT
NULL AS admin_level,
NULL AS boundary_type,
CASE WHEN barrier='retaining_wall' THEN 'retaining_wall'
WHEN man_made='snow_fence' THEN 'snow_fence'
ELSE 'city_wall'
END AS kind,
{% filter geometry %}way{% endfilter %} AS __geometry__,
Expand All @@ -120,6 +121,7 @@ WHERE
barrier='city_wall' OR historic='citywalls'
{% if zoom >= 15 %}
OR barrier='retaining_wall'
OR man_made='snow_fence'
{% endif %}
)

Expand Down
4 changes: 2 additions & 2 deletions queries/pois.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SELECT
transit_routes,
%#tags AS tags,
COALESCE("aerialway", "aeroway", "amenity", "barrier", "craft", "highway", "historic",
"leisure", "lock", "man_made", "natural", "office", "power", "railway", "shop",
"tourism", "waterway") AS kind
"leisure", "lock", "man_made", "natural", "office", "power", "railway",
"tags"->'rental', "shop", "tourism", "waterway") AS kind

FROM (

Expand Down
6 changes: 6 additions & 0 deletions queries/roads.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ SELECT
NULL AS snowshoe,
NULL AS symbol,
NULL AS exit_to,
leisure,
sport,
%#tags AS tags

FROM planet_osm_line
Expand Down Expand Up @@ -121,6 +123,8 @@ SELECT
tags->'snowshoe' AS snowshoe,
tags->'symbol' AS symbol,
NULL AS exit_to,
leisure,
sport,
%#tags AS tags

FROM planet_osm_line
Expand Down Expand Up @@ -173,6 +177,8 @@ SELECT
NULL AS snowshoe,
NULL AS symbol,
tags->'exit_to' AS exit_to,
NULL AS leisure,
NULL AS sport,
%#tags AS tags

FROM planet_osm_point
Expand Down

0 comments on commit 9f6673a

Please sign in to comment.