User:Julienfastre/Première carte de ville

From OpenStreetMap Wiki
Jump to: navigation, search

J'ai utilisé cette feuille de style pour ma première carte.


Carte de Liège avec parkings vélos

Notes

Base de donnée avec hstore

J'ai utilisé l'extension Hstore dans la base de donnée. Pour installer l'extension, il est nécessaire d'exécuter la requête suivante dans postgresql version 9.1+:

CREATE EXTENSION hstore;

import avec osm2pgsql

J'ai utilisé la commande suivante pour importer le fichier .osm :

osm2pgsql -d mapnikliege -U osm -W -j -l -S <nom de la feuille de style>.style liege.osm

et la feuille de style suivante (<nom de la feuille de style>.style ci-dessus) :

(Notons que beaucoup d'éléments pourraient être supprimés ! )

# This is the style file that matches the old version of osm2pgsql, which
# did not make distinctions between tags for nodes and for ways. There are a
# number of optimisations that can be applied here. Firstly, certain tags
# only apply to only nodes or only ways. By fixing this we reduce the amount
# of useless data loaded into the DB, which is a good thing. Possible
# optimisations for the future:

# 1. Generate this file directly from the mapnik XML config, so it's always
# optimal

# 2. Extend it so it can understand that highway=tertiary is for ways and
# highway=bus_stop is for nodes

# Flags field isn't used much yet, expect if it contains the text "polygon"
# it indicates the shape is candidate for the polygon table. In the future I
# would like to be able to add directives like "nocache" which tells
# osm2pgsql that it is unlikely this node will be used by a way and so it
# doesn't need to be stored (eg coastline nodes). While in essence an
# optimisation hack, for --slim mode it doesn't matter if you're wrong, but
# in non-slim you might break something!

# Also possibly an ignore flag, for things like "note" and "source" which
# can simply be deleted. (In slim mode this is, does not apply to non-slim
# obviously)

# OsmType  Tag          DataType     Flags
node,way   note         text         delete   # These tags can be long but are useless for rendering
node,way   source       text         delete   # This indicates that we shouldn't store them
node,way   created_by   text         delete

node,way   access       text         linear
node,way   addr:housename      text  linear
node,way   addr:housenumber    text  linear
node,way   addr:interpolation  text  linear 
node,way   admin_level  text         linear
node,way   aerialway    text         linear
node,way   aeroway      text         polygon
node,way   amenity      text         nocache,polygon
node,way   area         text         # hard coded support for area=1/yes => polygon is in osm2pgsql
node,way   barrier      text         linear
node,way   bicycle      text         nocache
node,way   brand        text         linear
node,way   bridge       text         linear
node,way   boundary     text         linear
node,way   building     text         polygon
node       capital      text         linear
node,way   construction text         linear
node,way   covered      text         linear
node,way   culvert      text         linear
node,way   cutting      text         linear
node,way   denomination text         linear
node,way   disused      text         linear
node       ele          text         linear
node,way   embankment   text         linear
node,way   foot         text         linear
node,way   generator:source    text  linear
node,way   harbour      text         polygon
way   highway      text         linear
node,way   historic     text         polygon
node,way   horse        text         linear
node,way   intermittent text         linear
node,way   junction     text         linear
node,way   landuse      text         polygon
node,way   layer        text         linear
node,way   leisure      text         polygon
node,way   lock         text         linear
node,way   man_made     text         polygon
node,way   military     text         polygon
node,way   motorcar     text         linear
node,way   name         text         linear
node,way   natural      text         polygon  # natural=coastline tags are discarded by a hard coded rule in osm2pgsql
node,way   oneway       text         linear
node,way   operator     text         linear
node       poi          text
node,way   population   text         linear
node,way   power        text         polygon
node,way   power_source text         linear
node,way   place        text         polygon
node,way   railway      text         linear
node,way   ref          text         linear
node,way   religion     text         nocache
node,way   route        text         linear
node,way   service      text         linear
node,way   shop         text         polygon
node,way   sport        text         polygon
node,way   surface      text         linear
node,way   toll         text         linear
node,way   tourism      text         polygon
node,way   tower:type   text         linear
way        tracktype    text         linear
node,way   tunnel       text         linear
node,way   water        text         polygon
node,way   waterway     text         polygon
node,way   wetland      text         polygon
node,way   width        text         linear
node,way   wood         text         linear
node,way   z_order      int4         linear # This is calculated during import
way        way_area     real                # This is calculated during import

# If you're interested in bicycle routes, you may want the following fields
# To make these work you need slim mode or the necessary data won't be remembered.
way       lcn_ref      text     linear
way       rcn_ref      text     linear
way       ncn_ref      text     linear
way       lcn          text     linear
way       rcn          text     linear
way       ncn          text     linear
way       lwn_ref      text     linear
way       rwn_ref      text     linear
way       nwn_ref          text     linear
way       lwn              text     linear
way       rwn              text     linear
way       nwn              text     linear
way       route_pref_color text     linear
way       route_name       text     linear


#ajouts perso
node	bicycle_parking	text	linear
way	oneway:bicycle	text	linear
way	bicycle:oneway	text	linear
node	capacity	text	liner


# The following entries can be used with the --extra-attributes option
# to include the username, userid, version & timstamp in the DB
#node,way  osm_user       text
#node,way  osm_uid        text
#node,way  osm_version    text
#node,way  osm_timestamp  text


Feuilles de style

Publié sous licence CC-BY-SA-2.0-be.

Toutes les icônes sont disponibles sur http://commons.wikimedia.org.

<?xml version="1.0" encoding="utf-8"?>
  <!DOCTYPE Map SYSTEM "mapnik2.dtd">
  <Map background-color="white" srs="+proj=latlong +datum=WGS84">
  

  <Style name="highway">
  
  	<!--Autoroutes et voies d'accès-->
  	<Rule>
  		<Filter>[highway] = 'motorway' </Filter>
	   		<LineSymbolizer stroke="#B9121B" stroke-width="3" stroke-linejoin="round" stroke-linecap="round" />
   </Rule>
   <Rule>
  		<Filter>[highway] = 'motorway_link' or [highway] = 'trunk' </Filter>
	   		<LineSymbolizer stroke="#B9121B" stroke-width="2" stroke-linejoin="round" stroke-linecap="round" />
   </Rule>


	<!--Routes moyennes et voies d'accès-->
   <Rule>
   		<Filter>[highway] = 'primary'
   			or [highway] = 'secondary'
   			or [highway] = 'secondary_link'
   			or [highway] = 'primary_link'
   		 </Filter>
   		<LineSymbolizer stroke="#ffc809" stroke-width="2" stroke-linejoin="round" stroke-linecap="round" />   
	</Rule>
	
	<Rule>
		<Filter>[highway] = 'residential'
			or [highway] = 'unclassified' 
			or [highway] = 'tertiary'
			or [highway] = 'road'
			or [highway] = 'tertiary_link'
			or [highway] = 'service'
		</Filter>
		<LineSymbolizer stroke="#BD8D46" stroke-width="1" stroke-linejoin="round" stroke-linecap="round" /> 
	</Rule>
	
	<Rule>
		<Filter>[highway] = 'footway'
			or [highway] = 'track' 
			or [highway] = 'steps'
			or [highway] = 'pedestrian'
			or [highway] = 'bridleway' 
			or [highway] = 'cycleway'
			or [highway] = 'living_street'
			or [highway] = 'path'
			
			</Filter>
		<LineSymbolizer stroke="#BD8D46" stroke-width="1" stroke-dasharray="5,5" stroke-linejoin="round" stroke-linecap="round" /> 
	</Rule>

  </Style>
  
  <Style name="text">
  	<Rule>
  		<Filter>[highway] &lt;&gt; ''or [highway] = 'notnull'</Filter>
	   <TextSymbolizer face-name="DejaVu Sans Book" size="10" fill="black" halo-fill= "white" halo-radius="1" placement="line" allow-overlap="false">[name]</TextSymbolizer>
   </Rule>
   <Rule>
  		<ElseFilter />
	   <TextSymbolizer face-name="DejaVu Sans Book" size="7" fill="black" halo-fill= "white" halo-radius="1" placement="line" allow-overlap="false">[name]</TextSymbolizer>
   </Rule>
  </Style>
  
  <Style name="park">
  	<Rule>
  		<PolygonSymbolizer fill="#B5E655" fill-opacity="1"/>
  		<TextSymbolizer face-name="DejaVu Sans Book" size="7" fill="black" halo-fill="white" halo-radius="1" allow-overlap="false">[name]</TextSymbolizer>
  	</Rule>
  
  </Style>
  
  <Style name="water_area">
  	<Rule>
  		<PolygonSymbolizer fill="#4BB5C1" fill-opacity="1" />
   	</Rule>
  
  </Style>
  
  <Style name="water_area_text">
  	<Rule>
  		<TextSymbolizer face-name="DejaVu Sans Book" size="10" fill="black" halo-fill="white" halo-radius="1" allow-overlap="false">[name]</TextSymbolizer>
  	</Rule>
  </Style>
  
  <Style name="place">
  	<Rule>
  		<Filter>[place] = 'city' </Filter>
  		<TextSymbolizer face-name="DejaVu Sans Book" size="35"  text-transform="uppercase" fill="grey" halo-fill="white" halo-radius="1" opacity="0.8">[name]</TextSymbolizer>
  	</Rule>
  	<Rule>
  		<Filter>[place] = 'town'</Filter>
  		<TextSymbolizer face-name="DejaVu Sans Book" size="30"  text-transform="capitalize" fill="grey" halo-fill="white" halo-radius="1" opacity="0.8">[name]</TextSymbolizer>
  	</Rule>
  	<Rule>
  		<Filter>[place] = 'village' or [place] = 'hamlet'</Filter>
  		<TextSymbolizer face-name="DejaVu Sans Book" size="26"  text-transform="capitalize" fill="grey" halo-fill="white" halo-radius="1" opacity="0.8">[name]</TextSymbolizer>
  	</Rule>
  	
  </Style>
  
  <Style name="building">
  	<Rule>
  		<PolygonSymbolizer fill="#CBCDCC" />
  		</Rule>
  </Style>
  
  <Style name="hills">
  	<Rule>
  		<RasterSymbolizer opacity="0.2" mode="grain_merge2" />
  	</Rule>
  </Style>
  
  <Style name="bicycle_parking">
  	<Rule>
  		<PointSymbolizer  file="./../icons/Parking_icon.svg" />
  		
  	</Rule>
  	<Rule>
  		<!-- <Filter>[capacity] &lt; 10</Filter> -->
  		<TextSymbolizer dx="6" face-name="DejaVu Sans Book" size="8"  fill="grey" halo-fill="white" halo-radius="1" opacity="1">[capacity]</TextSymbolizer>
  	</Rule>
  	<!--  
  	<Rule>
  		<Filter>[capacity] &gt; 9</Filter>
  		<TextSymbolizer dx="6" face-name="DejaVu Sans Book" size="12"  fill="black" halo-fill="white" halo-radius="1" opacity="1">[capacity]</TextSymbolizer>
  	</Rule>-->
  </Style>
  
  <Style name="railways">
  	 <Rule>
  		<LineSymbolizer stroke-width="2" stroke="#CBCDCC"/>
  		
  	</Rule>
  	<Rule>
  		<LineSymbolizer stroke-width="2" stroke-dasharray="7" stroke="black" />
  	</Rule>
  
  </Style>
  
  <Style name="railstation">
  	<Rule>
  	 <!--  transform="scale(0.03,0.03)" --> 
  		<PointSymbolizer file="./../icons/train_station2.png"/>
  		
  	</Rule>
  	
  </Style>
  
  <Style name="railstation_text">
  	<Rule>
  		<TextSymbolizer dy="10" face-name="DejaVu Sans Book" allow-overlap="true" size="10"  fill="black" halo-fill="white" halo-radius="2" opacity="1">[name]</TextSymbolizer>
  	</Rule>
  </Style>
  
  
   <Layer name="water_area" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>water_area</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(
        select way, name from planet_osm_polygon where tags ? 'waterway' 
        union
        select way, name from planet_osm_polygon where landuse = 'water'
        ) as water_area</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  <Layer name="water_area_text" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>water_area_text</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(
        select way, name from planet_osm_polygon where tags ? 'waterway' 
        union
        select way, name from planet_osm_polygon where landuse = 'water'
        ) as water_area</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  
  
  <Layer name="building" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>building</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select way, name, amenity, shop from planet_osm_polygon where building='yes' and 
        	
        	(
			(tags ? 'amenity' and (
				amenity='hospital'
				or amenity='cinema'
				or amenity='university'
				or amenity='place_of_worship'
				or amenity='school'
				or amenity='public_building'
				or amenity='courthous'
				or amenity='townhall'
				or amenity='post_office'
				or amenity='police'
				or amenity='fire_station'
				or amenity='cultural_center'
				
				))
		or
		     	(tags ? 'shop' and (
				shop = 'supermarket' or shop='car' or shop='sports' or shop='mall' 
				)) 
		)
        	
		
		) as buildings</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  <Layer name="pitch" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>park</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select name, way from planet_osm_polygon where 
        	leisure = 'pitch'
        	
        	) as pitch</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  
  
  <Layer name="park" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>park</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select name, way from planet_osm_polygon where 
        leisure = 'park' 
        or leisure = 'garden' 
        
			union 
		select name, way from planet_osm_polygon where 
		landuse = 'forest' 
		
			union
		select name, way from planet_osm_polygon where 
        	  
        	landuse = 'cemetery'
        	
        	and osm_id > 0) as parks</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  <Layer name="bicycle_parking" status="on" srs="+proj=latlong +datum=WGS84">
  	<StyleName>bicycle_parking</StyleName>
  	<Datasource>
  		<Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select way, name, capacity from planet_osm_point where amenity='bicycle_parking' ) as bicycle_parking</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
  	</Datasource>
  </Layer>
  
 
  
  <Layer name="highway" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>highway</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select way, name, highway, oneway, "oneway:bicycle" as sul from planet_osm_line where tags ? 'highway' and osm_id > 0) as highway</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  <Layer name="railway" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>railways</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select way from planet_osm_line where railway = 'rail'	) as railway</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  <Layer name="railstation" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>railstation</StyleName>
      <StyleName>railstation_text</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(select name, way from planet_osm_point where 
        	railway='station'
        	
        	) as station</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  

 
 <Layer name="highway-text" status="on" srs="+proj=latlong +datum=WGS84">
      <StyleName>text</StyleName>
      <Datasource>
        <Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="table">(
        	select way, name, highway, amenity, shop from planet_osm_line where tags ? 'highway' and osm_id > 0
        	union
        	select way, name, highway, amenity, shop from planet_osm_polygon where building='yes' and 
        	
        	(
			(tags ? 'amenity' and (
				amenity='hospital'
				or amenity='cinema'
				or amenity='university'
				or amenity='place_of_worship'
				or amenity='school'
				or amenity='public_building'
				or amenity='courthous'
				or amenity='townhall'
				or amenity='post_office'
				or amenity='police'
				or amenity='fire_station'
				or amenity='cultural_center'
				
				))
		or
		     	(tags ? 'shop' and (
				shop = 'supermarket' or shop='car' or shop='sports' or shop='mall' 
				)) 
				
		)
			union 
			select way, name, 'notnull', null, null from planet_osm_point where 
        	railway='station'
        	
        	) as highway</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter> 
      </Datasource>
  </Layer>
  
  
  
  <Layer name="place_name" status="on" >
  	<StyleName>place</StyleName>
  	<Datasource>
  		<Parameter name="table">(select name, way, place from planet_osm_point where tags ? 'place') as place</Parameter>
  		<Parameter name="type">postgis</Parameter>
        <Parameter name="host">localhost</Parameter>
        <Parameter name="dbname">mapnikliege</Parameter>
        <Parameter name="user">osm</Parameter>      
        <Parameter name="password">osm</Parameter>
        <Parameter name="estimate_extent">true</Parameter>
        <Parameter name="extent">5.51,50.58,5.66,50.70</Parameter>
  	</Datasource>
  </Layer>
  
 
  
  </Map>