ubuntu 8.04 ltsにて、Rails + PostGIS + MapServer + OpenLayersの環境構築のメモ
** PostGISとは [#pa2530ce]
- PostgreSQLでGISが利用可能にするPostgtreSQLの拡張
- 参考: PostGIS Manual
http://www.ne.jp/asahi/free/hiroro/postgis/manual/
- 空間データをデータベースに保存し、検索したりできる
** MapServerとは [#h4abe902]
- オープンソースなWebGISサーバー
- http://www.yaskey.cside.tv/mapserver/what.html 参照
- CGIとして動作
- 各プログラミング言語用に、MapScriptという連携用ライブラリがあり、それを通じて連携する -> http://mapserver.org/mapscript/index.html
- GISデータとして参照元として、PostgreSQL + PostGISが利用可能
** OpenLayersとは [#ff621c88]
- MapServerのようなWebGISサーバーと連携可能なJS用ライブラリらしい
- Google MapsのようなAPIが提供されるらしい
- Google Mapsとも連携可能
** Rails + PostGIS + MapServer + OpenLayersとはどんなアーキテクチャか? [#o675df5f]
ユーザー OpenLayers Apache + mod_rails Rails MapServer PostGIS
| | | | | |
+----------> | | | | |
+--------------->
+-------------->| | |
+-- mapscript ->| |
+-------------->
<--空間データ--+
|<--- 画像 -----+
|<--------------|
|<-------------+
|<------------
** MapServerのインストール [#pa2e32c2]
apt-get install cgi-mapserver
- これで、http://localhost/cgi-bin/mapserv にアクセスすると、
No query information to decode. QUERY_STRING is set, but empty.
と表示される。これ動いてるらしい。
- MapServerのチュートリアル ( http://www.yaskey.cside.tv/mapserver/tutorial/
) を動かしてみる [#w5c05453]
- http://demo.mapserver.org/tutorial/mstutorial_data.zip からデータを取ってくる
cd Webからアクセスできるディレクトリ
wget http://demo.mapserver.org/tutorial/mstutorial_data.zip
unzip mstutorial_data.zip
mv ms4w/apps/tutorial/* .
- 最初のチュートリアルを動かしてみる。
http://www.mapserver.org/tutorial/example1-1.html
- mapfiles/example1-1.map 内の
SHAPEPATH "/ms4w/apps/tutorial/data"
を、解凍して移動してできたdataのパスに変更
- mapservに直接アクセスする
http://ホスト/cgi-bin/mapserv?map=/回答したディレクトリ/mapfiles/example1-1.map&layer=states&mode=map
- これで変な地図が出てきたらOK
** PostGISのインストール [#k6082003]
- PostgreSQL と PostGISのインストール
apt-get install postgresql-8.3-postgis
- おれ最前線ねっと - [Ubuntu]Ubuntu8.10でPostGISを使えるようにする。[PostGIS]
http://ore.saizensen.net/archives/160
** MapServer + PostGISを試してみる [#laec3722]
- ここが参考になる
[ThinkIT] 第2回:MapServerで地図を表示してみよう (1/3)
http://www.thinkit.co.jp/free/article/0701/9/2/
** MapServerのWMS化を試す [#w5b537d1]
- ここが参考になる
WMS Server ― MapServer 5.4.2 documentation
http://mapserver.org/ogc/wms_server.html
- ENDの数があってなくてこういうエラーがでて嵌った orz
<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
<ServiceException code="LayerNotDefined">
msWMSLoadGetMapParams(): WMS server error. Invalid layer(s) given in the LAYERS parameter.
msWMSLoadGetMapParams(): WMS server error. Invalid layer(s) given in the LAYERS parameter.
</ServiceException>
</ServiceExceptionReport>
** MapServerのWMSとGoogle Mapsを重ねて出す [#n3f3f0e6]
- OpenLayersを使ってみる - Google Maps とMapServerを重ねる:いいタイトルが浮かびません。:So-net blog
http://shigekun.blog.so-net.ne.jp/2009-04-10-1
** Rubyからいじる [#p766af8c]
- MapScriptのRubyライブラリのインストール
apt-get install libmapscript-ruby1.8
#blikifooter(志田)