Regionalisedmap

From OpenStreetMap Wiki
Jump to navigation Jump to search

Localised Mapnik

To setup a localised mapnik like [cyOSM] follow the instructions on the Mapnik page making the following alterations:

In this example we want to render name:cy where it exists falling back to name where it doesn't. You will want to change name:cy for what ever variant you require.

Before Mapnik#Loading_Data

Add the relevant name:* tag (e.g. name:ca) to your default.style file. This file is part of osm2pgsql.

Before Mapnik#Rendering_with_Mapnik

Create localised views

Create localised views in the database: (these will need adjusting as the default.style changes)

create view planet_cyosm_line as
	select osm_id ,
		access ,
		admin_level ,
		aerialway ,
		aeroway ,
		amenity ,
		area ,
		bicycle ,
		bridge ,
		boundary ,
		building ,
		cutting ,
		disused ,
		embankment ,
		foot ,
		highway ,
		historic ,
		horse ,
		junction ,
		landuse ,
		layer ,
		learning ,
		leisure ,
		man_made ,
		military ,
		motorcar ,
		case when "name:cy" is not null then "name:cy" else name end as name,
		"natural" ,
		oneway ,
		power ,
		power_source ,
		place ,
		railway ,
		ref ,
		religion ,
		residence ,
		route ,
		sport ,
		tourism ,
		tracktype ,
		tunnel ,
		waterway ,
		width ,
		wood ,
		z_order ,
		way_area, 
		lcn_ref ,
		rcn_ref ,
		ncn_ref ,
		lcn ,
		rcn ,
		ncn ,
		lwn_ref ,
		rwn_ref ,
		nwn_ref ,
		lwn ,
		rwn ,
		nwn ,
		route_pref_color ,
		route_name ,
		way
	from planet_osm_line;
create view planet_cyosm_point as 
	select osm_id ,
		access ,
		admin_level ,
		aerialway ,
		aeroway ,
		amenity ,
		area ,
		bicycle ,
		bridge ,
		boundary ,
		building ,
		cutting ,
		disused ,
		embankment ,
		foot ,
		highway ,
		historic ,
		horse ,
		junction ,
		landuse ,
		layer ,
		learning ,
		leisure ,
		man_made ,
		military ,
		motorcar ,
		case when "name:cy" is not null then "name:cy" else name end as name,		
		"natural" ,
		oneway ,
		poi ,
		power ,
		power_source ,
		place ,
		railway ,
		ref ,
		religion ,
		residence ,
		route ,
		sport ,
		tourism ,
		tunnel ,
		waterway ,
		width ,
		wood ,
		z_order ,
		way 
	from planet_osm_point;
create view planet_cyosm_polygon as 
	select osm_id ,
		access ,
		admin_level ,
		aerialway ,
		aeroway ,
		amenity ,
		area ,
		bicycle ,
		bridge ,
		boundary ,
		building ,
		cutting ,
		disused ,
		embankment ,
		foot ,
		highway ,
		historic ,
		horse ,
		junction ,
		landuse ,
		layer ,
		learning ,
		leisure ,
		man_made ,
		military ,
		motorcar ,
		case when "name:cy" is not null then "name:cy" else name end as name,
		"natural" ,
		oneway ,
		power ,
		power_source ,
		place ,
		railway ,
		ref ,
		religion ,
		residence ,
		route ,
		sport ,
		tourism ,
		tracktype ,
		tunnel ,
		waterway ,
		width ,
		wood ,
		z_order ,
		way_area ,
		lcn_ref ,
		rcn_ref ,
		ncn_ref ,
		lcn ,
		rcn ,
		ncn ,
		lwn_ref ,
		rwn_ref ,
		nwn_ref ,
		lwn ,
		rwn ,
		nwn ,
		route_pref_color ,
		route_name ,
		way
	from planet_osm_polygon;
create view planet_cyosm_roads as 
	select osm_id ,
		access ,
		admin_level ,
		aerialway ,
		aeroway ,
		amenity ,
		area ,
		bicycle ,
		bridge ,
		boundary ,
		building ,
		cutting ,
		disused ,
		embankment ,
		foot ,
		highway ,
		historic ,
		horse ,
		junction ,
		landuse ,
		layer ,
		learning ,
		leisure ,
		man_made ,
		military ,
		motorcar ,
		case when "name:cy" is not null then "name:cy" else name end as name,
		"natural" ,
		oneway ,
		power ,
		power_source ,
		place ,
		railway ,
		ref ,
		religion ,
		residence ,
		route ,
		sport ,
		tourism ,
		tracktype ,
		tunnel ,
		waterway ,
		width ,
		wood ,
		z_order ,
		way_area ,
		lcn_ref ,
		rcn_ref ,
		ncn_ref ,
		lcn ,
		rcn ,
		ncn ,
		lwn_ref ,
		rwn_ref ,
		nwn_ref ,
		lwn ,
		rwn ,
		nwn ,
		route_pref_color ,
		route_name ,
		way 
	from planet_osm_roads;
INSERT INTO geometry_columns VALUES ('', 'public', 'planet_cyosm_point', 'way', 2, 900913, 'POINT');
INSERT INTO geometry_columns VALUES ('', 'public', 'planet_cyosm_line', 'way', 2, 900913, 'LINESTRING');
INSERT INTO geometry_columns VALUES ('', 'public', 'planet_cyosm_polygon', 'way', 2, 900913, 'POLYGON');
INSERT INTO geometry_columns VALUES ('', 'public', 'planet_cyosm_roads', 'way', 2, 900913, 'LINESTRING');

Get Mapnik to use the views

Edit the set-mapnik-env script to use the localised views rather than the normal tables. Change the MAPNIK_PREFIX variable to (in this example) planet_cyosm