tanaka's Programming Memo

プログラミングについてのメモ。

Google Earth作業メモ

ルートや写真を公開してよい場合は、散歩リンクを誰でも使えるようにしたい。データのホストを外部サーバにしたく、データの形式をKML方式で検討している。

ルートと写真を持っているKMLファイルの形式を確認

初期設定

  • Google Earthをインストール
  • Googleアカウントでログインする
  • 起動したら、[場所]ビューの[お気に入り]を右クリックして、[追加]→[フォルダ]を選択
  • データの名前や説明を入力してフォルダを作成。リンク、画像も含めることができる。

GPSログの登録

  • Google EarthGPSログをドラッグ&ドロップ
  • KMLトラックを作成と、標高を地面の高度に合わせるにチェックしてOK
  • 場所にログが追加されるので、ドラッグして先ほど作成したフォルダに移動させる

写真の追加

  • 作成したフォルダを右クリック→[追加]→[写真]
  • リンクで画像ファイルを追加。本番ではpicasaのURLにする。(ファイルの場合は、フォルダに写真をドラッグ&ドロップすればよい)
  • 写真の名前、場所や高度、説明を設定してOK

KMLの出力

  • フォルダを右クリック→[名前を付けて場所を保存]
  • ファイル名を名前に入力して、KML形式で保存する。

KMLファイルを開く

  • テキストエディットを開く(Mac)
  • 保存したKMLファイルをテキストエディットの一覧にドラッグ&ドロップして、登録されたkmlファイルをダブルクリックする

以上で、ルートと写真の登録が完了する。

作成したKMLファイルの編集

  • 場所パネルから編集したい写真を右クリックして、[情報を取得]
  • 変更をしたら閉じて、保存し直す。

KMLの確認

  • 先頭
<?xml version="1.0" encoding="UTF-8"?>
  • 最上位タグ。読む必要なし。
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    • Google Earthの場所に保存されていたFolderでまとめたもの。この中のものを読み取って行く。

KMLの例

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Folder>
	<name>test-tama</name>
	<open>1</open>
	<description>これはKMLテスト用の多摩動物公園の様子です。
</description>
	<Document>
		<name>GPS device</name>
		<snippet>Created Thu Aug 21 20:43:39 2014</snippet>
		<LookAt>
			<gx:TimeSpan>
				<begin>2013-04-21T03:27:59Z</begin>
				<end>2013-04-21T08:16:55Z</end>
			</gx:TimeSpan>
			<longitude>139.410705</longitude>
			<latitude>35.638616</latitude>
			<altitude>0</altitude>
			<heading>0</heading>
			<tilt>0</tilt>
			<range>5104.108517</range>
		</LookAt>
		<StyleMap id="multiTrack">
			<Pair>
				<key>normal</key>
				<styleUrl>#multiTrack_n</styleUrl>
			</Pair>
			<Pair>
				<key>highlight</key>
				<styleUrl>#multiTrack_h</styleUrl>
			</Pair>
		</StyleMap>
		<Style id="multiTrack_h">
			<IconStyle>
				<scale>1.2</scale>
				<Icon>
					<href>http://earth.google.com/images/kml-icons/track-directional/track-0.png</href>
				</Icon>
			</IconStyle>
			<LineStyle>
				<color>99ffac59</color>
				<width>8</width>
			</LineStyle>
		</Style>
		<Style id="multiTrack_n">
			<IconStyle>
				<Icon>
					<href>http://earth.google.com/images/kml-icons/track-directional/track-0.png</href>
				</Icon>
			</IconStyle>
			<LineStyle>
				<color>99ffac59</color>
				<width>6</width>
			</LineStyle>
		</Style>
		<Folder>
			<name>Tracks</name>
			<Placemark>
				<name>2013-04-21 12:27:59</name>
				<styleUrl>#multiTrack</styleUrl>
				<gx:Track>
					<when>2013-04-21T03:27:59Z</when>
					<when>2013-04-21T03:30:42Z</when>
					<when>2013-04-21T03:33:43Z</when>
					<when>2013-04-21T03:36:42Z</when>
					<when>2013-04-21T03:39:42Z</when>
					<when>2013-04-21T03:42:45Z</when>
					<when>2013-04-21T03:45:51Z</when>
					<when>2013-04-21T03:48:50Z</when>
					<when>2013-04-21T03:52:47Z</when>
					<when>2013-04-21T03:55:51Z</when>
					<when>2013-04-21T03:56:46Z</when>
					<when>2013-04-21T03:59:51Z</when>
					<when>2013-04-21T04:05:51Z</when>
					<when>2013-04-21T04:08:50Z</when>
					<when>2013-04-21T04:11:44Z</when>
					<when>2013-04-21T04:20:49Z</when>
					<when>2013-04-21T04:29:45Z</when>
					<when>2013-04-21T04:30:51Z</when>
					<when>2013-04-21T04:32:44Z</when>
					<when>2013-04-21T04:33:52Z</when>
					<when>2013-04-21T04:34:52Z</when>
					<when>2013-04-21T04:35:52Z</when>
					<when>2013-04-21T04:38:52Z</when>
					<when>2013-04-21T04:50:52Z</when>
					<when>2013-04-21T04:59:50Z</when>
					<when>2013-04-21T05:03:52Z</when>
					<when>2013-04-21T05:05:51Z</when>
					<when>2013-04-21T05:06:48Z</when>
					<when>2013-04-21T05:07:47Z</when>
					<when>2013-04-21T05:08:48Z</when>
					<when>2013-04-21T05:09:47Z</when>
					<when>2013-04-21T05:10:47Z</when>
					<when>2013-04-21T05:11:47Z</when>
					<when>2013-04-21T05:14:44Z</when>
					<when>2013-04-21T05:16:52Z</when>
					<when>2013-04-21T05:18:48Z</when>
					<when>2013-04-21T05:21:52Z</when>
					<when>2013-04-21T05:22:49Z</when>
					<when>2013-04-21T05:24:52Z</when>
					<when>2013-04-21T05:25:46Z</when>
					<when>2013-04-21T05:26:45Z</when>
					<when>2013-04-21T05:32:47Z</when>
					<when>2013-04-21T05:36:50Z</when>
					<when>2013-04-21T05:45:46Z</when>
					<when>2013-04-21T05:46:45Z</when>
					<when>2013-04-21T05:47:53Z</when>
					<when>2013-04-21T05:48:50Z</when>
					<when>2013-04-21T05:51:53Z</when>
					<when>2013-04-21T05:56:48Z</when>
					<when>2013-04-21T05:57:50Z</when>
					<when>2013-04-21T05:58:48Z</when>
					<when>2013-04-21T06:01:47Z</when>
					<when>2013-04-21T06:07:50Z</when>
					<when>2013-04-21T06:10:49Z</when>
					<when>2013-04-21T06:11:50Z</when>
					<when>2013-04-21T06:12:53Z</when>
					<when>2013-04-21T06:13:53Z</when>
					<when>2013-04-21T06:14:50Z</when>
					<when>2013-04-21T06:17:52Z</when>
					<when>2013-04-21T06:20:54Z</when>
					<when>2013-04-21T06:26:54Z</when>
					<when>2013-04-21T06:29:54Z</when>
					<when>2013-04-21T06:30:51Z</when>
					<when>2013-04-21T06:31:49Z</when>
					<when>2013-04-21T06:34:54Z</when>
					<when>2013-04-21T06:46:54Z</when>
					<when>2013-04-21T06:53:04Z</when>
					<when>2013-04-21T06:54:45Z</when>
					<when>2013-04-21T06:55:54Z</when>
					<when>2013-04-21T07:00:02Z</when>
					<when>2013-04-21T07:02:53Z</when>
					<when>2013-04-21T07:04:53Z</when>
					<when>2013-04-21T07:05:48Z</when>
					<when>2013-04-21T07:07:54Z</when>
					<when>2013-04-21T07:08:50Z</when>
					<when>2013-04-21T07:09:46Z</when>
					<when>2013-04-21T07:12:46Z</when>
					<when>2013-04-21T07:15:54Z</when>
					<when>2013-04-21T07:18:50Z</when>
					<when>2013-04-21T07:21:50Z</when>
					<when>2013-04-21T07:23:53Z</when>
					<when>2013-04-21T07:28:50Z</when>
					<when>2013-04-21T07:30:54Z</when>
					<when>2013-04-21T07:32:50Z</when>
					<when>2013-04-21T07:33:48Z</when>
					<when>2013-04-21T07:40:55Z</when>
					<when>2013-04-21T07:44:48Z</when>
					<when>2013-04-21T07:45:55Z</when>
					<when>2013-04-21T07:46:55Z</when>
					<when>2013-04-21T07:53:55Z</when>
					<when>2013-04-21T07:56:55Z</when>
					<when>2013-04-21T07:57:52Z</when>
					<when>2013-04-21T07:58:53Z</when>
					<when>2013-04-21T07:59:53Z</when>
					<when>2013-04-21T08:03:55Z</when>
					<when>2013-04-21T08:04:51Z</when>
					<when>2013-04-21T08:07:55Z</when>
					<when>2013-04-21T08:10:55Z</when>
					<when>2013-04-21T08:13:51Z</when>
					<when>2013-04-21T08:16:55Z</when>
					<gx:coord>139.42278 35.623997 126</gx:coord>
					<gx:coord>139.42284 35.630295 162</gx:coord>
					<gx:coord>139.41441 35.638466 97</gx:coord>
					<gx:coord>139.40364 35.64669 137</gx:coord>
					<gx:coord>139.4036 35.649628 142</gx:coord>
					<gx:coord>139.40384 35.649673 129</gx:coord>
					<gx:coord>139.40381 35.649883 96</gx:coord>
					<gx:coord>139.40372 35.64993 79</gx:coord>
					<gx:coord>139.40294 35.649887 131</gx:coord>
					<gx:coord>139.40083 35.650017 127</gx:coord>
					<gx:coord>139.40067 35.649784 128</gx:coord>
					<gx:coord>139.40016 35.64966 137</gx:coord>
					<gx:coord>139.40031 35.650036 130</gx:coord>
					<gx:coord>139.40106 35.650505 156</gx:coord>
					<gx:coord>139.40125 35.65077 148</gx:coord>
					<gx:coord>139.40213 35.649918 104</gx:coord>
					<gx:coord>139.40306 35.64959 97</gx:coord>
					<gx:coord>139.40308 35.64965 104</gx:coord>
					<gx:coord>139.40306 35.64965 112</gx:coord>
					<gx:coord>139.40282 35.64972 141</gx:coord>
					<gx:coord>139.40215 35.64979 110</gx:coord>
					<gx:coord>139.40202 35.6502 125</gx:coord>
					<gx:coord>139.40218 35.651806 107</gx:coord>
					<gx:coord>139.40163 35.652477 160</gx:coord>
					<gx:coord>139.40173 35.652267 110</gx:coord>
					<gx:coord>139.4017 35.652245 160</gx:coord>
					<gx:coord>139.40175 35.65223 129</gx:coord>
					<gx:coord>139.40175 35.652283 126</gx:coord>
					<gx:coord>139.40173 35.65231 124</gx:coord>
					<gx:coord>139.4017 35.65232 124</gx:coord>
					<gx:coord>139.40169 35.652344 127</gx:coord>
					<gx:coord>139.4017 35.652386 117</gx:coord>
					<gx:coord>139.40169 35.652405 113</gx:coord>
					<gx:coord>139.40164 35.652515 122</gx:coord>
					<gx:coord>139.40169 35.652534 100</gx:coord>
					<gx:coord>139.40166 35.652588 103</gx:coord>
					<gx:coord>139.40166 35.652622 115</gx:coord>
					<gx:coord>139.40172 35.652756 117</gx:coord>
					<gx:coord>139.40169 35.652687 118</gx:coord>
					<gx:coord>139.40169 35.652557 118</gx:coord>
					<gx:coord>139.40169 35.652504 117</gx:coord>
					<gx:coord>139.40152 35.652935 151</gx:coord>
					<gx:coord>139.40149 35.653236 154</gx:coord>
					<gx:coord>139.40157 35.652752 124</gx:coord>
					<gx:coord>139.40149 35.652596 117</gx:coord>
					<gx:coord>139.40103 35.65204 119</gx:coord>
					<gx:coord>139.40083 35.65171 140</gx:coord>
					<gx:coord>139.40083 35.6517 145</gx:coord>
					<gx:coord>139.40083 35.6517 153</gx:coord>
					<gx:coord>139.40083 35.651684 155</gx:coord>
					<gx:coord>139.40083 35.651672 154</gx:coord>
					<gx:coord>139.40085 35.651676 149</gx:coord>
					<gx:coord>139.40085 35.651688 150</gx:coord>
					<gx:coord>139.40085 35.651703 149</gx:coord>
					<gx:coord>139.40085 35.651707 148</gx:coord>
					<gx:coord>139.40086 35.651936 128</gx:coord>
					<gx:coord>139.40042 35.652023 138</gx:coord>
					<gx:coord>139.39984 35.651566 114</gx:coord>
					<gx:coord>139.39957 35.6513 142</gx:coord>
					<gx:coord>139.3993 35.651257 154</gx:coord>
					<gx:coord>139.39923 35.65109 147</gx:coord>
					<gx:coord>139.39928 35.651005 138</gx:coord>
					<gx:coord>139.39958 35.65048 117</gx:coord>
					<gx:coord>139.39998 35.649857 115</gx:coord>
					<gx:coord>139.40106 35.650482 111</gx:coord>
					<gx:coord>139.40079 35.650826 162</gx:coord>
					<gx:coord>139.40096 35.651005 214</gx:coord>
					<gx:coord>139.40091 35.651047 217</gx:coord>
					<gx:coord>139.40125 35.650963 180</gx:coord>
					<gx:coord>139.40128 35.650936 167</gx:coord>
					<gx:coord>139.40129 35.650936 155</gx:coord>
					<gx:coord>139.40128 35.650917 172</gx:coord>
					<gx:coord>139.40125 35.65089 158</gx:coord>
					<gx:coord>139.40112 35.650875 161</gx:coord>
					<gx:coord>139.40115 35.650364 142</gx:coord>
					<gx:coord>139.40099 35.65024 138</gx:coord>
					<gx:coord>139.39975 35.649822 140</gx:coord>
					<gx:coord>139.399 35.65022 139</gx:coord>
					<gx:coord>139.39899 35.65024 142</gx:coord>
					<gx:coord>139.39896 35.65028 150</gx:coord>
					<gx:coord>139.39873 35.650764 172</gx:coord>
					<gx:coord>139.39874 35.65066 173</gx:coord>
					<gx:coord>139.39874 35.650665 176</gx:coord>
					<gx:coord>139.39873 35.65066 180</gx:coord>
					<gx:coord>139.39873 35.650673 178</gx:coord>
					<gx:coord>139.39873 35.65068 191</gx:coord>
					<gx:coord>139.39873 35.650696 185</gx:coord>
					<gx:coord>139.39897 35.65041 155</gx:coord>
					<gx:coord>139.39903 35.649914 154</gx:coord>
					<gx:coord>139.39896 35.649315 164</gx:coord>
					<gx:coord>139.39896 35.64934 150</gx:coord>
					<gx:coord>139.39896 35.64941 151</gx:coord>
					<gx:coord>139.39894 35.64943 150</gx:coord>
					<gx:coord>139.39857 35.64951 116</gx:coord>
					<gx:coord>139.39919 35.649452 168</gx:coord>
					<gx:coord>139.40001 35.649708 158</gx:coord>
					<gx:coord>139.40216 35.64977 128</gx:coord>
					<gx:coord>139.40437 35.64904 144</gx:coord>
					<gx:coord>139.40468 35.649204 94</gx:coord>
					<gx:coord>139.40488 35.649323 78</gx:coord>
				</gx:Track>
			</Placemark>
		</Folder>
	</Document>
	<PhotoOverlay>
		<name>無題 - 写真オーバーレイ</name>
		<description>これは多摩動物公園のマップです。
</description>
		<Camera>
			<gx:TimeStamp><when>2013-04-21T03:27:59Z</when>
</gx:TimeStamp>
			<longitude>139.4034872488945</longitude>
			<latitude>35.64708437260732</latitude>
			<altitude>129.5933041272907</altitude>
			<heading>-0.003643344821066278</heading>
			<tilt>18.32214665323198</tilt>
			<roll>-0.0003792642188950362</roll>
			<altitudeMode>absolute</altitudeMode>
		</Camera>
		<Style>
			<IconStyle>
				<Icon>
					<href>:/camera_mode.png</href>
				</Icon>
			</IconStyle>
			<ListStyle>
				<listItemType>check</listItemType>
				<ItemIcon>
					<state>open closed error fetching0 fetching1 fetching2</state>
					<href>http://maps.google.com/mapfiles/kml/shapes/camera-lv.png</href>
				</ItemIcon>
				<bgColor>00ffffff</bgColor>
				<maxSnippetLines>2</maxSnippetLines>
			</ListStyle>
		</Style>
		<Icon>
			<href>sampo/tanaka/P1090079.jpg</href>
		</Icon>
		<ViewVolume>
			<leftFov>-25</leftFov>
			<rightFov>25</rightFov>
			<bottomFov>-19.275</bottomFov>
			<topFov>19.275</topFov>
			<near>1.97471</near>
		</ViewVolume>
		<Point>
			<altitudeMode>absolute</altitudeMode>
			<coordinates>139.4034872488945,35.64708437260732,129.5933041272907</coordinates>
		</Point>
	</PhotoOverlay>
	<PhotoOverlay>
		<name>ばく</name>
		<description>マレーばくです</description>
		<Camera>
			<gx:TimeStamp><when>2013-04-21T03:27:59Z</when>
</gx:TimeStamp>
			<longitude>139.404006112</longitude>
			<latitude>35.64617043400001</latitude>
			<altitude>319.0299999979915</altitude>
			<heading>-0.00332325045907889</heading>
			<tilt>19.36068524941071</tilt>
			<roll>-9.202101893537872e-05</roll>
			<altitudeMode>absolute</altitudeMode>
		</Camera>
		<Style>
			<IconStyle>
				<Icon>
					<href>:/camera_mode.png</href>
				</Icon>
			</IconStyle>
			<ListStyle>
				<listItemType>check</listItemType>
				<ItemIcon>
					<state>open closed error fetching0 fetching1 fetching2</state>
					<href>http://maps.google.com/mapfiles/kml/shapes/camera-lv.png</href>
				</ItemIcon>
				<bgColor>00ffffff</bgColor>
				<maxSnippetLines>2</maxSnippetLines>
			</ListStyle>
		</Style>
		<Icon>
			<href>sampo/tanaka/P1090080.jpg</href>
		</Icon>
		<ViewVolume>
			<leftFov>-25</leftFov>
			<rightFov>25</rightFov>
			<bottomFov>-19.275</bottomFov>
			<topFov>19.275</topFov>
			<near>65.0988</near>
		</ViewVolume>
		<Point>
			<altitudeMode>absolute</altitudeMode>
			<coordinates>139.404006112,35.64617043400001,319.0299999979915</coordinates>
		</Point>
	</PhotoOverlay>
</Folder>
</kml>

散歩リンクに実装する方針

  • 写真はPicasaと連携
  • 散歩リンクでルートと写真の配置を作成する
    • 写真の名前にユーザーインデックス、ユーザー名、日時(1:ユーザー名[日時])を記載
    • 標高はGPSログから算出。10mほど上空に
  • KMLにエクスポート
  • Google Earthでコメントなどを追加(配置などがずれるかも。操作方法を要調査)