Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
Created January 1, 2011 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laclefyoshi/761625 to your computer and use it in GitHub Desktop.
Save laclefyoshi/761625 to your computer and use it in GitHub Desktop.
Controlling Google Earth for Mac
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright : (c) SAEKI Yoshiyasu
# License : MIT-style license
# <http://www.opensource.org/licenses/mit-license.php>
# last updated: 2011/01/01
import subprocess
import time
GE_COMMAND = 'tell application "Google Earth"'
def changeView(lat, lon):
c = subprocess.Popen("osascript -e '" + GE_COMMAND + " to SetViewInfo" +
" {latitude:%f, longitude:%f," % (lat, lon) +
" distance:200000, tilt:0, azimuth:0} speed 0.5'",
shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p_check = subprocess.Popen("osascript -e '" + GE_COMMAND +
" to get (GetStreamingProgress)'",
shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p = p_check.communicate()[0].strip()
while p != "100":
time.sleep(0.1)
p_check = subprocess.Popen("osascript -e '" + GE_COMMAND +
" to get (GetStreamingProgress)'",
shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p = p_check.communicate()[0].strip()
if __name__ == "__main__":
changeView(34.0, 135.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment