最近、業務ではなく余暇に複数人で地図系開発をしているため、開発者の構築可能環境が揃えられずバックエンドが選べない状況でした。 なのでバックエンドを抽象化しないといけなかったのですが、その結果Web開発系の主要3空間DBでの空間検索記述差がわかったので簡単にまとめておきます。 座標値からのGeometryオブジェクトの作成 GeomFromTextで当然…と思ってましたが、PostGISだと通らなくなってます。 PostGISでは空間系関数は頭にSTをつけることで統一したよう。 頭にSTをつけた関数については、spatialiteも対応してますし、mysqlは最新の5.6でも未対応なものの、後述の通り関係性記述の関数では(既存関数との互換性のためとはいえ)ST_系を出してきているので、将来的にはST_系で統一されるものと思います。 蓄積済みデータに対する、検索クエリの差 蓄積済みデータに対し
GDALのogr2ogrコマンドでテーブル全体をkmlにすることはできますが、 PostGISの関数にもST_AsKml()というのがあります。 この関数の引数にgeometryを渡すとkml形式で出力してくれます。 kmlは経緯度しか扱わないので、SRIDが設定されていなければなりません。 SRIDが設定されていれば、平面直角座標系の値でも経緯度に変換して出力されます。 ただし、図形要素部分しか出力しないので、 その他の必要なタグはこちらで用意する必要があります。 なので、完成形のkmlにするには結構手間はかかります。 psqlで-tオプションをつけて -cオプションでSQLを指定して、リダイレクトでテキストに書き出して 編集するか、スクリプトを作るかになるかと思われます。 以下の例はPythonで、psycopg2でSQLを発行してkmlファイルに書き出す例です。 せっかくなのでついで
Posted by nene2001 at 01:25 / Tag(Edit): mysql spatial / 2 Comments: Post / View / 1 TrackBack / Google Maps Web2.0ワークショップで講演するのに、ただでさえ一人だけ素人でまともな講演できるか不安なのに、勉強せずに今の知識だけではいかんだろうということで、今までほったらかしてきたMySQL4.1以降の空間情報利用法を勉強。 といっても、こちらに4.1の日本語マニュアルあるので全然苦労なしだが。 ただ動作確認は5.1でやっているので、英語版5.1マニュアルとの照らし合わせはやってますけど。一応。 PostGISとの比較で書くと、PostGISの場合、PostgreSQL本体とは別のプラグインであるせいか、位置情報カラムのついたテーブルはいっぺんにはできない。 例え
2008年11月13日 GoogleMapsと連動したいならPostGISの他にmysqlという選択肢も出てきた あとジオメディアサミット関西も 随分以前に、GoogleMapsと連動したいなら幾何データ型よりPostGISという記事を書いたけど、徐々にmysqlという選択肢も出てきつつある、という話。 特にGoogleMaps連動に限った話ではなく、位置情報を扱う場合、ということだけど、その辺は前記事を踏襲してみた。 ネタは最近行ったFOSS4G 2008 OSAKAで仕入れたもの。 FOSS4Gに関しては、OSAKAだけでなくTOKYOも行ったので、遅れたレポートに意味があるのかはともかくまたレポートまとめたいと思っているのだけれど、忙しいわ、今指の調子がぶっ壊れてるわで余裕がない。 とりあえずこのネタだけ先に書く。 話としては、沖電気さんが発表した、mysqlに、PostGIS
なんか向こうのコメントに書き込んだのだが、よく判らんが削除されてしまったのでこっちのエントリで取り上げる。 データベース上の位置情報を効率的に検索する方法(PostgreSQL編) -Web屋のネタ帳- たとえばおいしいケーキ屋さんの位置情報がデータベース上にあるとしよう。...GoogleMapsなどである範囲の地図を表示したとして、お店の位置を地図上にマーキングさせたい場合には、その地図の範囲の情報をキーにしてデータベース上の緯度経度を検索する必要がある。 ......... だが、ひとたび ある1点から半径rの円内に該当するデータを検索したい さらにその検索結果を、中心点からの距離でソートしたい といったことになると、とたんに難しくなる。しかし、PostgreSQLにもう5年以上前から実装されている幾何データ型、幾何関数、幾何演算子を使えば、SELECT一発でできることだ。 幾何
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く