Zh-hant:mapnik starter

From OpenStreetMap Wiki
Jump to: navigation, search

返回 開發 (正體中文)

大直橋周邊

輸出結果

Dazhi-bridge.png

輸出方式

cd ~/pv2
bin/nik2img.py mapstyle-dazhi.xml dazhi-bridge.png \
   -f png256 \
   -b 121.54432 25.07480 121.54632 25.07780

輸出設定 (mapstyle-dazhi.xml)

<Map background-color="#ffffe7" srs="+proj=longlat +datum=WGS84 +no_defs" >

  <!--
  ==================================================
                        圖資
  ==================================================
  -->

  <!-- 地貌 -->
  <Layer name="area" status="on">
    <StyleName>area</StyleName>
    <Datasource>
      <Parameter name="type">postgis</Parameter>
      <Parameter name="host">127.0.0.1</Parameter>
      <Parameter name="user">osm</Parameter>
      <Parameter name="password">osm4326</Parameter>
      <Parameter name="dbname">osm</Parameter>
      <Parameter name="table">planet_osm_polygon</Parameter>
    </Datasource>
  </Layer>

  <!-- 道路 -->
  <Layer name="roads" status="on">
    <StyleName>roads</StyleName>
    <Datasource>
      <Parameter name="type">postgis</Parameter>
      <Parameter name="host">127.0.0.1</Parameter>
      <Parameter name="user">osm</Parameter>
      <Parameter name="password">osm4326</Parameter>
      <Parameter name="dbname">osm</Parameter>
      <Parameter name="table">planet_osm_line</Parameter>
    </Datasource>
  </Layer>

  <!--
  ==================================================
                      彩繪方式
  ==================================================
  -->

  <!-- 道路樣式 -->
  <Style name="roads">
    <!-- 主要道路與次要道路 -->
    <Rule>
      <Filter>([highway]='primary' || [highway]='secondary') &amp;&amp; [bridge]=NULL</Filter>
      <LineSymbolizer stroke="#707030" stroke-width="16.0" />
      <LineSymbolizer stroke="#ffffb0" stroke-width="15.0" />
      <TextSymbolizer face-name="unifont Medium" size="10" fill="black"
        spacing="100" placement="line">[name]</TextSymbolizer>
    </Rule>
    <!-- 主要道路與次要道路(橋樑) -->
    <Rule>
      <Filter>([highway]='primary' || [highway]='secondary') &amp;&amp; [bridge]='yes'</Filter>
      <LineSymbolizer stroke="#806000" stroke-width="16.0" />
      <LineSymbolizer stroke="#ffb000" stroke-width="15.0" />
      <TextSymbolizer face-name="unifont Medium" size="10" fill="black"
        spacing="100" placement="line">[name]</TextSymbolizer>
    </Rule>
    <!-- 巷子 -->
    <Rule>
      <Filter>[highway]='residential'</Filter>
      <LineSymbolizer stroke="#707070" stroke-width="10.0" smooth="1" />
      <LineSymbolizer stroke="#ffffff" stroke-width="8.0" smooth="1" />
      <TextSymbolizer face-name="unifont Medium" size="10" fill="black"
        spacing="100" placement="line">[name]</TextSymbolizer>
    </Rule>
    <!-- 單車道 -->
    <Rule>
      <Filter>[highway]='cycleway'</Filter>
      <LineSymbolizer stroke="#802040" stroke-width="14.0" />
      <LineSymbolizer stroke="#ffb0e0" stroke-width="13.0" />
      <TextSymbolizer face-name="unifont Medium" size="12" fill="black"
        spacing="100" placement="line" halo-fill="white" halo-radius="2"
        allow-overlap="false">[name]</TextSymbolizer>
    </Rule>
    <!-- 人行道 -->
    <Rule>
      <Filter>[highway]='footway'</Filter>
      <LineSymbolizer stroke="#707070" stroke-width="6.0" stroke-opacity="0.4" />
      <LineSymbolizer stroke="#d0d0d0" stroke-width="5.0" stroke-opacity="0.4" />
      <TextSymbolizer face-name="unifont Medium" size="12" fill="black"
        spacing="100" placement="line" halo-fill="white" halo-radius="2"
        allow-overlap="false">[name]</TextSymbolizer>
    </Rule>
    <!-- 河川,只標名不畫線 -->
    <Rule>
      <Filter>[waterway]='river'</Filter>
      <TextSymbolizer face-name="unifont Medium" size="12"
        halo-fill="white" halo-radius="2" 
        spacing="200" placement="line" allow-overlap="false">[name]</TextSymbolizer>
    </Rule>
    <!-- 捷運文湖線 -->
    <Rule>
      <Filter>[railway]='subway'</Filter>
      <LineSymbolizer stroke="#707070" stroke-width="5.0" />
      <LineSymbolizer stroke="#ffffff" stroke-width="5.0" stroke-dasharray="20,20" />
    </Rule>
    <!-- 其他 -->
    <Rule><ElseFilter/></Rule>
  </Style>

  <!-- 地貌與建築物 -->
  <Style name="area">
    <!-- 河川 -->
    <Rule>
      <Filter>[waterway]='riverbank'</Filter>
      <LineSymbolizer stroke="#707070" stroke-width="2.0" />
      <PolygonSymbolizer fill="#a0c0ff" />
    </Rule>
    <!-- 其他 -->
    <Rule><ElseFilter/></Rule>
  </Style>

</Map>


延伸閱讀