ulkoilureitit

Tue, 15 Sep 2020 17:36:45 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 15 Sep 2020 17:36:45 +0300
changeset 2
8d4148a8ded4
parent 1
959dc869b765
child 3
89b6a7562889

ulkoilureitit

flex.lua file | annotate | diff | comparison | revisions
project.mml file | annotate | diff | comparison | revisions
style/roads.mss file | annotate | diff | comparison | revisions
style/style.mss file | annotate | diff | comparison | revisions
--- a/flex.lua	Tue Sep 15 15:06:57 2020 +0300
+++ b/flex.lua	Tue Sep 15 17:36:45 2020 +0300
@@ -615,6 +615,21 @@
 	columns = gen_columns(non_point_columns, hstore or hstore_all, false, 'linestring')
 }
 
+tables.routes = osm2pgsql.define_way_table(
+	prefix .. '_routes',
+	{
+		{ column = 'tags', type = 'hstore' },
+		{ column = 'ref', type = 'text' },
+		{ column = 'name', type = 'text' },
+		{ column = 'network', type = 'text' },
+		{ column = 'route', type = 'text' },
+		{ column = 'layer', type = 'text' },
+		{ column = 'osm_way_id', type = 'text' },
+		{ column = 'way', type = 'linestring' },
+	}
+)
+
+
 local z_order_lookup = {
 	proposed = {1, false},
 	construction = {2, false},
@@ -805,6 +820,8 @@
 	tables.point:add_row(output)
 end
 
+route_ways = {}
+
 function osm2pgsql.process_way(object)
 	if clean_tags(object.tags) then
 		return
@@ -902,8 +919,52 @@
 			tables.roads:add_row(output)
 		end
 	end
+
+	if osm2pgsql.stage == 2
+	then
+		local routes = route_ways[object.id]
+		if routes ~= nil
+		then
+			for index, route in ipairs(routes) do
+				route_type = route.tags.route
+				if route_type == 'bicycle' and route.tags.network ~= nil
+				then
+					route_type = route_type .. '_' .. route.tags.network
+				end
+				row = {
+					tags = object.tags,
+					ref = route.tags.ref,
+					name = route.tags.name,
+					network = route.tags.network,
+					route = route_type,
+					osm_way_id = object.id,
+					layer = object.tags.layer or 0,
+					geom = { create = 'line' }
+				}
+				tables.routes:add_row(row)
+			end
+		end
+	end
 end
 
+
+function osm2pgsql.select_relation_members(relation)
+	if relation.tags.type == 'route' and (relation.tags.route == 'foot' or relation.tags.route == 'hiking' or relation.tags.route == 'bicycle')
+	then
+		for _, member in ipairs(relation.members) do
+			if member.type == 'w' then
+				member_id = member.ref
+				if not route_ways[member_id] then
+					route_ways[member_id] = {}
+				end
+				table.insert(route_ways[member_id], relation)
+			end
+		end
+		return { ways = osm2pgsql.way_member_ids(relation) }
+	end
+end
+
+
 function osm2pgsql.process_relation(object)
 	if clean_tags(object.tags) then
 		return
--- a/project.mml	Tue Sep 15 15:06:57 2020 +0300
+++ b/project.mml	Tue Sep 15 17:36:45 2020 +0300
@@ -63,7 +63,10 @@
 										THEN 'religious'
 										ELSE CASE WHEN ("landuse" = 'railway')
 											THEN 'industrial'
-											ELSE "landuse"
+											ELSE CASE WHEN ("natural" = 'wetland')
+												THEN 'wetland'
+												ELSE "landuse"
+											END
 										END
 									END
 								END
@@ -214,6 +217,31 @@
 		properties:
 			minzoom: 4
 			maxzoom: 9
+	- id: foot-routes-layer-n1
+		geometry: linestring
+		<<: *extents
+		Datasource:
+			<<: *osm2pgsql
+			table: &foot_routes_sql |-
+				(SELECT
+					way,
+					osm_way_id,
+					route,
+					COALESCE(layer::integer, 0) AS layer
+					FROM planet_osm_routes
+					WHERE "route" IN ('hiking', 'foot', 'bicycle_lcn', 'bicycle_rcn', 'bicycle_ncn', 'bicycle_icn')
+					ORDER BY
+					CASE
+						WHEN route = 'bicycle_icn' THEN 30
+						WHEN route = 'bicycle_ncn' THEN 31
+						WHEN route = 'bicycle_rcn' THEN 32
+						WHEN route = 'bicycle_lcn' THEN 33
+						WHEN route = 'foot' THEN 34
+						WHEN route = 'hiking' THEN 35
+					END DESC NULLS LAST
+				) AS foot_routes
+		properties:
+			minzoom: 14
 	- id: road-casing-layer-n1
 		geometry: line
 		Datasource:
@@ -300,6 +328,14 @@
 			table: *road_sql
 		properties:
 			minzoom: 12
+	- id: foot-routes
+		geometry: linestring
+		<<: *extents
+		Datasource:
+			<<: *osm2pgsql
+			table: *foot_routes_sql
+		properties:
+			minzoom: 14
 	- id: road
 		geometry: line
 		Datasource:
@@ -327,6 +363,14 @@
 				) AS bridge_area
 		properties:
 			minzoom: 12
+	- id: foot-routes-layer-1
+		geometry: linestring
+		<<: *extents
+		Datasource:
+			<<: *osm2pgsql
+			table: *foot_routes_sql
+		properties:
+			minzoom: 14
 	- id: road-casing-layer-1
 		geometry: line
 		Datasource:
@@ -669,6 +713,31 @@
 			table: *road_sql
 		properties:
 			minzoom: 14
+	- id: foot-routes-text
+		geometry: linestring
+		<<: *extents
+		Datasource:
+			<<: *osm2pgsql
+			table: |-
+				(SELECT
+					way,
+					name,
+					ref,
+					route
+					FROM planet_osm_routes
+					WHERE "route" IN ('hiking', 'foot', 'bicycle_lcn', 'bicycle_rcn', 'bicycle_ncn', 'bicycle_icn')
+					ORDER BY
+					CASE
+						WHEN route = 'bicycle_icn' THEN 30
+						WHEN route = 'bicycle_ncn' THEN 31
+						WHEN route = 'bicycle_rcn' THEN 32
+						WHEN route = 'bicycle_lcn' THEN 33
+						WHEN route = 'foot' THEN 34
+						WHEN route = 'hiking' THEN 35
+					END DESC NULLS LAST
+				) AS foot_routes
+		properties:
+			minzoom: 15
 	- id: roads-text-ref
 		geometry: linestring
 		<<: *extents
--- a/style/roads.mss	Tue Sep 15 15:06:57 2020 +0300
+++ b/style/roads.mss	Tue Sep 15 17:36:45 2020 +0300
@@ -601,3 +601,80 @@
 	text-avoid-edges: true;
 	text-size: 12;
 }
+
+@foot-route-fill: #ffc3c3;
+@hiking-route-fill: #f7cfb1;
+@bicycle-lcn-route-fill: #c3e1ff;
+@bicycle-rcn-route-fill: #d6cdff;
+@bicycle-ncn-route-fill: #ffc3ff;
+
+#foot-routes-layer-n1[layer < 0],
+#foot-routes[layer = 0],
+#foot-routes-layer-1[layer > 0]
+{
+	line-color: @foot-route-fill;
+	[route = 'hiking']
+	{
+		line-color: @hiking-route-fill;
+	}
+	[route = 'bicycle_lcn']
+	{
+		line-color: @bicycle-lcn-route-fill;
+	}
+	[route = 'bicycle_rcn']
+	{
+		line-color: @bicycle-rcn-route-fill;
+	}
+	[route = 'bicycle_ncn'],
+	[route = 'bicycle_icn']
+	{
+		line-color: @bicycle-ncn-route-fill;
+	}
+	line-width: 4;
+	[zoom >= 15] { line-width: 6; }
+	[zoom >= 16] { line-width: 8; }
+	[zoom >= 17] { line-width: 10; }
+	[zoom >= 18] { line-width: 13; }
+	[zoom >= 19] { line-width: 16; }
+	[zoom >= 20] { line-width: 20; }
+	line-join: round;
+	line-cap: round;
+}
+
+#foot-routes-text
+{
+	text-name: "[name]";
+	[ref != null]
+	{
+		text-name: "[ref]";
+	}
+	text-fill: saturate(darken(@foot-route-fill, 50%), 35%);
+	[route = 'hiking']
+	{
+		text-fill: saturate(darken(@hiking-route-fill, 50%), 35%);
+	}
+	[route = 'bicycle_lcn']
+	{
+		text-fill: saturate(darken(@bicycle-lcn-route-fill, 50%), 35%);
+	}
+	[route = 'bicycle_rcn']
+	{
+		text-fill: saturate(darken(@bicycle-rcn-route-fill, 50%), 35%);
+	}
+	[route = 'bicycle_ncn'],
+	[route = 'bicycle_icn']
+	{
+		text-fill: saturate(darken(@bicycle-ncn-route-fill, 50%), 35%);
+	}
+	text-dy: 5;
+	text-face-name: "Liberation Sans Regular";
+	text-repeat-distance: 300;
+	text-placement: line;
+	text-halo-radius: 1;
+	text-halo-fill: white;
+	text-clip: false;
+	text-avoid-edges: true;
+	text-size: 10;
+	[zoom >= 16] { text-size: 11; }
+	[zoom >= 17] { text-size: 12; }
+}
--- a/style/style.mss	Tue Sep 15 15:06:57 2020 +0300
+++ b/style/style.mss	Tue Sep 15 17:36:45 2020 +0300
@@ -25,6 +25,7 @@
 @religious-color: #c2cdb6;
 @construction-color: #ada9a0;
 @civic-services-color: #f0edcd;
+@wetland-color: #e8ebc6;
 
 #railway-landuse
 {
@@ -92,6 +93,13 @@
 			line-color: darken(@construction-color, 20%);
 		}
 	}
+	[feature = 'wetland'] {
+		polygon-fill: @wetland-color;
+		[zoom >= 17] {
+			line-width: 0.5;
+			line-color: darken(@wetland-color, 20%);
+		}
+	}
 }
 
 #civic-services {

mercurial