TileStache
2014年11月21日
TileStacheとは
TileStacheとは、ベクトルタイルに対応したタイルキャッシュサーバです。
インストール
・pip
curl -O -L https://raw.github.com/pypa/pip/master/contrib/get-pip.py -k sudo python get-pip.py
・ModestMaps、PIL
sudo pip install -U --allow-external PIL modestmaps simplejson werkzeug
・mapnik
!!入っていた!!たしか、苦労した記憶がある
・TileStache
git clone https://github.com/TileStache/TileStache.git cd TileStache sudo python setup.py install
※次のエラーが出たが動いたのでそのまま
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib64/python2.6/multiprocessing/util.py", line 258, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib64/python2.6/multiprocessing/util.py", line 258, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
実行
./scripts/tilestache-server.py --config ./tilestache.cfg --ip 192.168.0.25 --port 8081
オプションは
--config : 設定ファイル。デフォルトはtilestache.cfg
--ip : 待ち受けするサーバ自身のIPアドレス。0.0.0.0だと全てを許可。デフォルトは127.0.0.1
--port : ポート。デフォルトは8080
テスト
デフォルトのtilestache.cfgでは次の2つが見えます。
http://192.168.0.25:8081/osm/preview.html
http://192.168.0.25:8081/example/preview.html
ベクトルタイルの設定例
"road":
{
"provider": {"name": "vector", "driver": "PostgreSQL",
"parameters": {"dbname": "dbname",
"host": "hostname", "port":"5432", "user": "user", "password": "passwd",
"table": "tablename"},
"properties": {"mesh":"二次メッシュ", "node1":"ノード1", "node2":"ノード2"}
}
,"bounds": {"north": 50, "west": 120, "south": 22, "east": 150, "low": 15, "high": 31}
,"tile height": 256
,"allowed origin": "*"
,"cache lifespan": 86400
,"maximum cache age": 86400
}
http://192.168.0.25:8081/road/15/28786/12890.geojson
{
type: "FeatureCollection",
features: [
{
geometry: {
type: "LineString",
coordinates: [
[
136.263428,
35.793489
],
・・・
[
136.252865,
35.796169
],
[
136.252441,
35.796172
]
]
},
type: "Feature",
properties: {
二次メッシュ: "533652",
ノード1: "****",
ノード2: "****",
}
}
]
}

