Google Mapsのマイマップで作成したマーカーとラインを、Waypoint、Route or
Trackデータとして[[カシミール3D:http://www.kashmir3d.com/]]に読み込む試み。
最初に[[GPS Babel 1.3.3:http://www.gpsbabel.org/]]という変換ツールを試みたが、
期待したようにはうごかなかったので、簡易な変換ツールを自作した。
マイマップから出力したラインとマーカーだけ変換するつもりで書いたので、
KMLを完全に読み込むことができるわけではありません。このスクリプトは
カシミール3Dの[[CSV読み込みプラグイン:http://www.kashmir3d.com/kash/kashget.html#plugin_gfil]]
で読むことができるCSV形式でstdoutにデータを変換して出力する。
なので、事前にこのカシミール3Dのプラグインをインストールしておく必要がある。
~
~
スクリプトはこれ。~
http://reddog.s35.xrea.com/software/kml2csv.tcl
~
tclの実行環境と、tclのxml拡張の[[tDOM:http://www.tdom.org/]]が必用です。またインターネットに接続している必要があります。
~
tclsh kml2csv.tcl data.kml > data.csv
みたいにして使う。マーカーはwaypointに、ラインは-tオプションでrouteかtrackのどちらかに変換する。デフォルトではtrackに変換する。routeに変換するときは
tclsh kml2csv.tcl -t route output.kml > data.csv
みたいに-tでrouteを指定する。-tでの指定を省略したときはtrackに変換する。routeは各点ごとに名前を付けないといけないが、KMLのラインから変換する場合は意味のある名前をつけることができないので、ただの連番の名前になる。~
~
使ってみる。~
~
まずはマイマップで適当にライン一つとマーカー二つを作ってみる。~
~
http://reddog.s35.xrea.com/img/kml2csv1.jpg~
~
KMLを押してKMLファイルをダウンロードする。で、これをkml2csv.tclで
tclsh kml2csv.tcl 京都御所.kml > 京都御所.csv
と変換する。ファイルの中身は、
H1,御所散歩,0,0,255,5,1
T1,T1-001,35.01030,135.45471,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-002,35.01057,135.45472,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-003,35.01070,135.45436,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-004,35.01155,135.45435,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-005,35.01156,135.45388,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-006,35.01206,135.45387,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-007,35.01234,135.45388,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-008,35.01233,135.45434,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-009,35.01206,135.45435,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-010,35.01208,135.45502,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-011,35.01243,135.45502,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-012,35.01323,135.45497,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-013,35.01392,135.45491,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-014,35.01390,135.45389,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-015,35.01393,135.45388,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-016,35.01401,135.45388,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-017,35.01404,135.45376,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-018,35.01409,135.45367,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-019,35.01400,135.45357,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-020,35.01393,135.45352,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-021,35.01389,135.45352,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-022,35.01389,135.45385,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-023,35.01333,135.45387,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-024,35.01333,135.45380,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-025,35.01337,135.45363,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-026,35.01339,135.45358,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-027,35.01325,135.45357,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-028,35.01301,135.45358,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
T1,T1-029,35.01300,135.45330,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0
W2,目印 1,35.01118,135.45505,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0,0,1,,
W3,目印 2,35.01300,135.45386,0.000000,2007-07-06,03:16:32,WGS84,0.0,0.0,0,1,,
こんな感じにtrack一つ、waypoint二つが出力されている。
これをカシミール3Dへ「ツール->GPSファイルツール->CSV形式から読み込み」で読み込む。
http://reddog.s35.xrea.com/img/kml2csv2.jpg~
終り。このカシミール3Dの地図はプロアトラスから切り出したビットマップ地図です。
***コメントをどーぞ [#y28a6e18]
- CGIWrap Errorが表示されてダウンロード出来ません。 -- &new{2007-09-09 (日) 15:19:26};
-- 直しました。すいません。 -- [[reddog]] &new{2007-09-09 (日) 15:51:10};
- ダウンロード出来ました!素早い対応有難うございます。 -- &new{2007-09-09 (日) 18:15:06};
- とてもすばらしいツールです。早速つかってみようとしたのですが、エラーが出ます。Tcl環境が初めてなので何か間違っているのでしょうか? Parse Error: getUrlFromKml C:/Documents/test.kml while executing "error "Parse Error: [info level [info level]]\n"" (procedure "getUrlFromKml" line 10) invoked from within "getUrlFromKml $file" (procedure "main" line 29) invoked from within "main $argv" (file "kml2csv.tcl" line 228) -- [[Error Message]] &new{2008-08-31 (日) 16:49:14};
-- KMLのバージョンがあがってたのでプログラムが対応できなくなってたみたいです。ちょっと直してみたので試してみてください。 -- [[reddog]] &new{2008-08-31 (日) 21:43:13};
- お陰様でバッチリ動作しました。すばやい対応に感謝感激しております。ありがとうございました。 -- [[Error Message その後]] &new{2008-08-31 (日) 23:43:05};
#comment
----
[[CategoryGoogle]]
HTML convert time: 0.002 sec.