User:Tatata/Mapnik-Win32

From OpenStreetMap Wiki
Jump to: navigation, search

このページはTatataが自分のPC (Windows XP) にMapnikのwin32 binariesをインストールした時に気が付いたことなどをメモしたものです。

外部向けのサーバーによるサービスのために必要と思われるセキュリティ上の配慮は行っていませんので、外部向けのサーバーにインストールする場合にはアカウント名、パスワード、DB接続設定(password-less connections)、DB名などに注意して下さい。


Contents

Perl

Perlの導入を行う。


Python

Pythonの導入を行う。


PostgreSQL

PostgreSQLの導入を行う。


PostGIS

PostGISの導入を行う。


osm2pgsql

osm2pgsql.exe(osmのデータをPostgreSQLのデータベースにロードするプログラム)の導入を行う。


your mapnik directoryはプログラム(osm2pgsql.exe)とデータ(map.osm)を置いたディレクトリ。

C:\your mapnik directory>osm2pgsql -m -d postgis map.osm
osm2pgsql win32

Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
Setting up table: planet_osm_line
Setting up table: planet_osm_polygon
Setting up table: planet_osm_roads

Reading in file: map.osm
Processing: Node(16k) Way(1k) Relation(0k)
Writing rel(0k)

Writing way(0k)

Node stats: total(16952), max(262487770)
Way stats: total(1459), max(24243409)
Relation stats: total(0), max(0)


C:\your mapnik directory>


OSM data

OSMのデータの取得方法は数種類ある。


name:ja

道路や駅などの名称を日本語のみの表示にしたい場合は、これらの値を取得するキーを name から name:ja に変更する必要があるため、データベースへロードする前にデータファイル内のタグ(キー)を書き換えておく。

エディタを使用して変更する場合の手順

  1. エディタでデータファイルを開く。
  2. k="name" を適当な名前(k="name:x"など)で置換する。
  3. k="name:ja" を k="name" で置換する。
  4. データファイルを保存する。


Mapnik

Mapnikの導入を行う。


World Boundaries, Coastlines

国境データと海岸線データをダウンロードする。

2つのデータを解凍したらcoastlinesフォルダの中身をworld_boundariesフォルダの中に移動する。


Subversion

OSMのmapnik用ファイルをダウンロードするため、Subversion(サブバージョン)のクライアントの導入を行う。


OSM files

Subversionのクライアントを使って、http://svn.openstreetmap.org/applications/rendering/mapnik からOSMのmapnik用ファイルをダウンロード(チェックアウト)する。


TortoiseSVNの場合の手順

  1. ダウンロード用のフォルダを作成する。(エクスプローラで作成先のフォルダを開き、メニューの「ファイル」→「新規作成」→「フォルダ」をクリックして名前を付ける。)
  2. 作成したダウンロード用のフォルダを右クリックして、「SVN Checkout」をクリックする。
  3. Checkoutウィンドウ開くので、「URL of repository」に http://svn.openstreetmap.org/applications/rendering/mapnik を入力して「OK」をクリックする。


コマンドラインツールのクライアントの場合は次のようなコマンドを実行する。(クライアントによって若干異なると思われます。)


svn checkout http://svn.openstreetmap.org/applications/rendering/mapnik


ダウンロードしたOSMのmapnik用ファイルについての作業


Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)] on

win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mapnik import *
>>> for fname in FontEngine.face_names():
... print fname
...
DejaVu Sans Bold
DejaVu Sans Bold Oblique
DejaVu Sans Book
DejaVu Sans Condensed
DejaVu Sans Condensed Bold
DejaVu Sans Condensed Bold Oblique
DejaVu Sans Condensed Oblique
DejaVu Sans ExtraLight
DejaVu Sans Mono Bold
DejaVu Sans Mono Bold Oblique
DejaVu Sans Mono Book
DejaVu Sans Mono Oblique
DejaVu Sans Oblique
DejaVu Serif Bold
DejaVu Serif Bold Oblique
DejaVu Serif Book
DejaVu Serif Condensed
DejaVu Serif Condensed Bold
DejaVu Serif Condensed Bold Oblique
DejaVu Serif Condensed Oblique
DejaVu Serif Oblique
IPAUIGothic Regular
>>>


rendering


generate_image.pyでの設定 生成された画像ファイル
例1

#---------------------------------------------------
# Change this to the bounding box you want
#
ll = (139.7177, 35.6271, 139.8051, 35.7273)
#---------------------------------------------------

z = 10
imgx = 128 * z
imgy = 128 * z

Tokyo Central.png
例2

#---------------------------------------------------
# Change this to the bounding box you want
#
ll = (139.752, 35.66921, 139.77728, 35.69155)
#---------------------------------------------------

z = 10
imgx = 128 * z
imgy = 128 * z

Tokyo Marunouchi.png


Disk space

名称 説明 ファイル/フォルダ 容量(MB)
Perl インストーラー ActivePerl-5.10.0.1002-MSWin32-x86-283697.msi 14.90
Perl 導入先フォルダ C:\Perl 73.80
Python インストーラー ActivePython-2.5.2.2-win32-x86.msi 21.70
Python 導入先フォルダ C:\Python25 47.80
PostgreSQL/PostGIS インストーラー(zipファイル 20.0MB + 解凍済みフォルダ 21.6MB) postgresql-8.3.0-1.zip, postgresql-8.3.0-1 41.60
PostgreSQL/PostGIS 導入先フォルダ(データベース用フォルダを含む) C:\Program Files\PostgreSQL 130.00
osm2pgsql zipファイル osm2pgsql_latest.exe.zip 0.50
osm2pgsql exeファイル osm2pgsql.exe 1.04
Mapnik win32 binaries zipファイル mapnik_win32_py25-0.5.1.zip 7.21
Mapnik win32 binaries 解凍済みフォルダ C:\mapnik-0_5_1 16.10
World Boundaries tgzファイル world_boundaries-spherical.tgz 50.40
World Boundaries 解凍済みフォルダ world_boundaries 74.40
Coastlines zipファイル processed_p.zip 214.00
Coastlines 解凍済みフォルダ coastlines 344.00
TortoiseSVN インストーラー TortoiseSVN-1.4.8.12137-win32-svn-1.4.6.msi 8.91
TortoiseSVN 導入先フォルダ C:\Program Files\TortoiseSVN 15.70
OSM files ダウンロードフォルダ site 2.12
IPAフォント zipファイル IPAfont00203.zip 15.30
IPAフォント 解凍済みフォルダ IPAfont00203 25.30
合計 1,104.78
Personal tools
Namespaces
Variants
Actions
site
Toolbox