Created
February 19, 2018 23:59
-
-
Save tacigar/a923b6e3c759b339cc4caaa68b5b10dc to your computer and use it in GitHub Desktop.
駅データ.jp から駅の緯度経度情報を取得し KML を出力する Lua スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# JR山手線 | |
- 西日暮里 | |
- 田端 | |
- 駒込 | |
- 巣鴨 | |
- 大塚 | |
- 池袋 | |
- 目白 | |
- 高田馬場 | |
- 新大久保 | |
- 代々木 | |
- 原宿 | |
- 渋谷 | |
- 恵比寿 | |
- 目黒 | |
- 五反田 | |
- 大崎 | |
- 品川 | |
# JR中央 | |
- 東京 | |
- 神田 | |
- 御茶ノ水 | |
- 水道橋 | |
- 飯田橋 | |
- 市ケ谷 | |
- 四ツ谷 | |
- 信濃町 | |
- 千駄ケ谷 | |
- 代々木 | |
- 大久保 | |
- 東中野 | |
- 中野 | |
- 高円寺 | |
- 阿佐ケ谷 | |
- 荻窪 | |
- 西荻窪 | |
- 吉祥寺 | |
- 三鷹 | |
- 武蔵境 | |
# JR埼京線 | |
- 浮間舟渡 | |
- 北赤羽 | |
- 赤羽 | |
- 十条 | |
- 板橋 | |
- 池袋 | |
- 渋谷 | |
- 恵比寿 | |
- 大崎 | |
# 小田急線 | |
- 登戸 | |
- 成城学園前 | |
- 千歳船橋 | |
- 経堂 | |
- 豪徳寺 | |
- 梅ケ丘 | |
- 世田谷代田 | |
- 下北沢 | |
- 代々木上原 | |
- 代々木八幡 | |
- 参宮橋 | |
- 南新宿 | |
# 東京メトロ丸ノ内線 | |
- 銀座 | |
- 霞ケ関 | |
- 国会議事堂前 | |
- 赤坂見附 | |
- 四ツ谷 | |
- 四谷三丁目 | |
- 新宿御苑前 | |
- 新宿三丁目 | |
- 西新宿 | |
- 中野坂上 | |
- 新中野 | |
- 東高円寺 | |
- 新高円寺 | |
- 南阿佐ケ谷 | |
- 荻窪 | |
# 京王線 | |
- 調布 | |
- つつじケ丘 | |
- 千歳烏山 | |
- 芦花公園 | |
- 八幡山 | |
- 上北沢 | |
- 桜上水 | |
- 下高井戸 | |
- 明大前 | |
- 代田橋 | |
- 笹塚 | |
- 新宿 | |
# 京王新線 | |
- 幡ヶ谷 | |
- 初台 | |
# 都営大江戸線 | |
- 青山一丁目 | |
- 国立競技場 | |
- 代々木 | |
- 都庁前 | |
- 西新宿五丁目 | |
- 中野坂上 | |
- 東中野 | |
- 中井 | |
- 落合南長崎 | |
- 新江古田 | |
- 練馬 | |
# 都営新宿線 | |
- 新宿三丁目 | |
- 曙橋 | |
- 市ヶ谷 | |
- 九段下 | |
- 神保町 | |
- 小川町 | |
- 岩本町 | |
- 馬喰横山 | |
- 浜町 | |
- 森下 | |
- 菊川 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://earth.google.com/kml/2.0"> <Document> | |
<Placemark> | |
<name>西日暮里</name> | |
<Point> | |
<coordinates> | |
139.766857, 35.731954, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>田端</name> | |
<Point> | |
<coordinates> | |
139.761229, 35.737781, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>駒込</name> | |
<Point> | |
<coordinates> | |
139.748053, 35.736825, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>巣鴨</name> | |
<Point> | |
<coordinates> | |
139.739303, 35.733445, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>大塚</name> | |
<Point> | |
<coordinates> | |
139.728584, 35.731412, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>池袋</name> | |
<Point> | |
<coordinates> | |
139.711086, 35.730256, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>目白</name> | |
<Point> | |
<coordinates> | |
139.706228, 35.720476, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>高田馬場</name> | |
<Point> | |
<coordinates> | |
139.703715, 35.712677, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新大久保</name> | |
<Point> | |
<coordinates> | |
139.700261, 35.700875, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>代々木</name> | |
<Point> | |
<coordinates> | |
139.702042, 35.683061, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>原宿</name> | |
<Point> | |
<coordinates> | |
139.702592, 35.670646, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>渋谷</name> | |
<Point> | |
<coordinates> | |
139.701238, 35.658871, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>恵比寿</name> | |
<Point> | |
<coordinates> | |
139.71007, 35.646685, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>目黒</name> | |
<Point> | |
<coordinates> | |
139.715775, 35.633923, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>五反田</name> | |
<Point> | |
<coordinates> | |
139.723822, 35.625974, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>大崎</name> | |
<Point> | |
<coordinates> | |
139.728439, 35.619772, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>品川</name> | |
<Point> | |
<coordinates> | |
139.738999, 35.62876, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>東京</name> | |
<Point> | |
<coordinates> | |
139.766103, 35.681391, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>神田</name> | |
<Point> | |
<coordinates> | |
139.770641, 35.691173, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>御茶ノ水</name> | |
<Point> | |
<coordinates> | |
139.764955, 35.699605, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>水道橋</name> | |
<Point> | |
<coordinates> | |
139.754312, 35.702039, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>飯田橋</name> | |
<Point> | |
<coordinates> | |
139.745143, 35.701835, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>市ケ谷</name> | |
<Point> | |
<coordinates> | |
139.735241, 35.691105, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>四ツ谷</name> | |
<Point> | |
<coordinates> | |
139.730644, 35.686041, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>信濃町</name> | |
<Point> | |
<coordinates> | |
139.720729, 35.680031, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>千駄ケ谷</name> | |
<Point> | |
<coordinates> | |
139.711644, 35.681231, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>代々木</name> | |
<Point> | |
<coordinates> | |
139.702042, 35.683061, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>大久保</name> | |
<Point> | |
<coordinates> | |
139.69732, 35.700784, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>東中野</name> | |
<Point> | |
<coordinates> | |
139.684436, 35.706529, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>中野</name> | |
<Point> | |
<coordinates> | |
139.665835, 35.705765, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>高円寺</name> | |
<Point> | |
<coordinates> | |
139.649664, 35.705326, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>阿佐ケ谷</name> | |
<Point> | |
<coordinates> | |
139.635868, 35.704818, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>荻窪</name> | |
<Point> | |
<coordinates> | |
139.620109, 35.704523, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>西荻窪</name> | |
<Point> | |
<coordinates> | |
139.599361, 35.703842, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>吉祥寺</name> | |
<Point> | |
<coordinates> | |
139.579765, 35.703119, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>三鷹</name> | |
<Point> | |
<coordinates> | |
139.560325, 35.702683, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>武蔵境</name> | |
<Point> | |
<coordinates> | |
139.543402, 35.702083, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>浮間舟渡</name> | |
<Point> | |
<coordinates> | |
139.691341, 35.791209, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>北赤羽</name> | |
<Point> | |
<coordinates> | |
139.70569, 35.787007, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>赤羽</name> | |
<Point> | |
<coordinates> | |
139.720928, 35.778026, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>十条</name> | |
<Point> | |
<coordinates> | |
139.722233, 35.760321, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>板橋</name> | |
<Point> | |
<coordinates> | |
139.719507, 35.745435, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>池袋</name> | |
<Point> | |
<coordinates> | |
139.711086, 35.730256, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>渋谷</name> | |
<Point> | |
<coordinates> | |
139.701238, 35.658871, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>恵比寿</name> | |
<Point> | |
<coordinates> | |
139.71007, 35.646685, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>大崎</name> | |
<Point> | |
<coordinates> | |
139.728439, 35.619772, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>登戸</name> | |
<Point> | |
<coordinates> | |
139.569449, 35.62115, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>成城学園前</name> | |
<Point> | |
<coordinates> | |
139.598958, 35.640114, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>千歳船橋</name> | |
<Point> | |
<coordinates> | |
139.624544, 35.647616, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>経堂</name> | |
<Point> | |
<coordinates> | |
139.635993, 35.650991, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>豪徳寺</name> | |
<Point> | |
<coordinates> | |
139.647381, 35.653807, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>世田谷代田</name> | |
<Point> | |
<coordinates> | |
139.661557, 35.65834, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>下北沢</name> | |
<Point> | |
<coordinates> | |
139.667516, 35.661655, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>代々木上原</name> | |
<Point> | |
<coordinates> | |
139.680153, 35.669159, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>代々木八幡</name> | |
<Point> | |
<coordinates> | |
139.688913, 35.669715, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>参宮橋</name> | |
<Point> | |
<coordinates> | |
139.693568, 35.678586, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>南新宿</name> | |
<Point> | |
<coordinates> | |
139.69867, 35.683483, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>銀座</name> | |
<Point> | |
<coordinates> | |
139.763965, 35.671989, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>霞ケ関</name> | |
<Point> | |
<coordinates> | |
139.750899, 35.673838, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>国会議事堂前</name> | |
<Point> | |
<coordinates> | |
139.745219, 35.67393, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>赤坂見附</name> | |
<Point> | |
<coordinates> | |
139.737047, 35.677021, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>四ツ谷</name> | |
<Point> | |
<coordinates> | |
139.729947, 35.684586, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>四谷三丁目</name> | |
<Point> | |
<coordinates> | |
139.720103, 35.687958, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新宿御苑前</name> | |
<Point> | |
<coordinates> | |
139.71069, 35.688588, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新宿三丁目</name> | |
<Point> | |
<coordinates> | |
139.704895, 35.690847, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>西新宿</name> | |
<Point> | |
<coordinates> | |
139.692778, 35.694298, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>中野坂上</name> | |
<Point> | |
<coordinates> | |
139.68291, 35.69792, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新中野</name> | |
<Point> | |
<coordinates> | |
139.66903, 35.697491, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>東高円寺</name> | |
<Point> | |
<coordinates> | |
139.657822, 35.697802, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新高円寺</name> | |
<Point> | |
<coordinates> | |
139.648068, 35.697985, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>南阿佐ケ谷</name> | |
<Point> | |
<coordinates> | |
139.63576, 35.699624, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>荻窪</name> | |
<Point> | |
<coordinates> | |
139.620116, 35.704304, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>調布</name> | |
<Point> | |
<coordinates> | |
139.543988, 35.652181, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>千歳烏山</name> | |
<Point> | |
<coordinates> | |
139.60067, 35.667921, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>芦花公園</name> | |
<Point> | |
<coordinates> | |
139.608247, 35.670479, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>八幡山</name> | |
<Point> | |
<coordinates> | |
139.614927, 35.669982, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>上北沢</name> | |
<Point> | |
<coordinates> | |
139.62329, 35.668857, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>桜上水</name> | |
<Point> | |
<coordinates> | |
139.63129, 35.66768, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>下高井戸</name> | |
<Point> | |
<coordinates> | |
139.641372, 35.66615, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>明大前</name> | |
<Point> | |
<coordinates> | |
139.650352, 35.668758, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>代田橋</name> | |
<Point> | |
<coordinates> | |
139.659413, 35.671092, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>笹塚</name> | |
<Point> | |
<coordinates> | |
139.667251, 35.673758, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新宿</name> | |
<Point> | |
<coordinates> | |
139.699187, 35.690163, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>幡ヶ谷</name> | |
<Point> | |
<coordinates> | |
139.676183, 35.677061, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>初台</name> | |
<Point> | |
<coordinates> | |
139.686354, 35.68123, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>青山一丁目</name> | |
<Point> | |
<coordinates> | |
139.72396, 35.672929, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>国立競技場</name> | |
<Point> | |
<coordinates> | |
139.714932, 35.679831, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>代々木</name> | |
<Point> | |
<coordinates> | |
139.701666, 35.683218, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>都庁前</name> | |
<Point> | |
<coordinates> | |
139.69257, 35.690551, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>西新宿五丁目</name> | |
<Point> | |
<coordinates> | |
139.684304, 35.689798, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>中野坂上</name> | |
<Point> | |
<coordinates> | |
139.682279, 35.69709, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>東中野</name> | |
<Point> | |
<coordinates> | |
139.682987, 35.706891, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>中井</name> | |
<Point> | |
<coordinates> | |
139.686356, 35.714035, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>落合南長崎</name> | |
<Point> | |
<coordinates> | |
139.683303, 35.723608, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新江古田</name> | |
<Point> | |
<coordinates> | |
139.670653, 35.732538, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>練馬</name> | |
<Point> | |
<coordinates> | |
139.65477, 35.737404, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>新宿三丁目</name> | |
<Point> | |
<coordinates> | |
139.706271, 35.690616, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>曙橋</name> | |
<Point> | |
<coordinates> | |
139.722881, 35.692402, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>市ヶ谷</name> | |
<Point> | |
<coordinates> | |
139.735794, 35.692594, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>九段下</name> | |
<Point> | |
<coordinates> | |
139.751948, 35.695589, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>神保町</name> | |
<Point> | |
<coordinates> | |
139.757606, 35.695966, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>小川町</name> | |
<Point> | |
<coordinates> | |
139.767551, 35.695487, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>岩本町</name> | |
<Point> | |
<coordinates> | |
139.775866, 35.695534, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>馬喰横山</name> | |
<Point> | |
<coordinates> | |
139.782768, 35.69212, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>浜町</name> | |
<Point> | |
<coordinates> | |
139.788154, 35.688516, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>森下</name> | |
<Point> | |
<coordinates> | |
139.797042, 35.68796, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
<Placemark> | |
<name>菊川</name> | |
<Point> | |
<coordinates> | |
139.806016, 35.688379, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
</Document> </kml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local socket = require "socket" | |
local http = require "socket.http" | |
local json = require "dkjson" | |
local USAGE = [[USAGE: lua kml-generator.lua <prefname> <filename>]] | |
local PREFECTURE_CODE = { | |
["北海道"] = 1, ["青森県"] = 2, ["岩手県"] = 3, ["宮城県"] = 4, | |
["秋田県"] = 5, ["山形県"] = 6, ["福島県"] = 7, ["茨城県"] = 8, | |
["栃木県"] = 9, ["群馬県"] = 10, ["埼玉県"] = 11, ["千葉県"] = 12, | |
["東京都"] = 13, ["神奈川県"] = 14, ["新潟県"] = 15, ["富山県"] = 16, | |
["石川県"] = 17, ["福井県"] = 18, ["山梨県"] = 19, ["長野県"] = 20, | |
["岐阜県"] = 21, ["静岡県"] = 22, ["愛知県"] = 23, ["三重県"] = 24, | |
["滋賀県"] = 25, ["京都府"] = 26, ["大阪府"] = 27, ["兵庫県"] = 28, | |
["奈良県"] = 29, ["和歌山県"] = 30, ["鳥取県"] = 31, ["島根県"] = 32, | |
["岡山県"] = 33, ["広島県"] = 34, ["山口県"] = 35, ["徳島県"] = 36, | |
["香川県"] = 37, ["愛媛県"] = 38, ["高知県"] = 39, ["福岡県"] = 40, | |
["佐賀県"] = 41, ["長崎県"] = 42, ["熊本県"] = 43, ["大分県"] = 44, | |
["宮崎県"] = 45, ["鹿児島県"] = 46, ["沖縄県"] = 47, | |
} | |
local prefcode = PREFECTURE_CODE[arg[1]] | |
if prefcode == nil then | |
error(USAGE) | |
end | |
local prefMsg = http.request( | |
string.format( | |
"http://www.ekidata.jp/api/p/%s.json", | |
prefcode | |
) | |
) | |
if prefMsg == nil then | |
error(USAGE) | |
end | |
local function fixJSONBug(msg) | |
local newMsg = msg | |
newMsg = newMsg:gsub("if[^\n]*\n", "") | |
newMsg = newMsg:gsub("xml.data = ", "") | |
return newMsg | |
end | |
prefMsg = fixJSONBug(prefMsg) | |
local prefData, _, err = json.decode(prefMsg) | |
if err then | |
error(USAGE) | |
end | |
io.write [[ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://earth.google.com/kml/2.0"> <Document> | |
]] | |
local function writePlacemark(name, lon, lat) | |
io.write(string.format([[ | |
<Placemark> | |
<name>%s</name> | |
<Point> | |
<coordinates> | |
%s, %s, 0. | |
</coordinates> | |
</Point> | |
</Placemark> | |
]], name, lon, lat)) | |
end | |
local lineData = nil | |
local filename = arg[2] | |
local f = io.open(filename, "r") | |
for str in f:lines() do | |
local linename = str:match("#%s*(.*)%s*") | |
if linename then -- START NEW LINE. | |
local linecodes = {} | |
for _, line in ipairs(prefData["line"]) do | |
if line["line_name"]:find(linename) then | |
table.insert(linecodes, line["line_cd"]) | |
end | |
end | |
if #linecodes == 0 then | |
goto CONTINUE | |
end | |
lineData = {} | |
for _, linecode in ipairs(linecodes) do | |
socket.sleep(5) | |
local lineMsg = http.request( | |
string.format( | |
"http://ekidata.jp/api/l/%s.json", | |
linecode | |
) | |
) | |
lineMsg = fixJSONBug(lineMsg) | |
local tmpData, _, err = json.decode(lineMsg) | |
if err then | |
error(USAGE) | |
end | |
if lineData["station_l"] == nil then | |
lineData = tmpData | |
else | |
for _, val in ipairs(tmpData["station_l"]) do | |
table.insert(lineData["station_l"], val) | |
end | |
end | |
end | |
else -- CONTINUE IN THE LINE. | |
local stationName = str:match("-%s*(.*)%s*") | |
if stationName then | |
for _, station in ipairs(lineData["station_l"]) do | |
if station["station_name"]:find(stationName) then | |
writePlacemark( | |
station["station_name"], | |
station["lon"], | |
station["lat"] | |
) | |
goto CONTINUE | |
end | |
end | |
end | |
end | |
::CONTINUE:: | |
end | |
io.write("</Document> </kml>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment