Rule the World with Tcl, Tcom and Google Earth

http://wfr.tcl.tk/fichiers/images/ge.jpg

GS The title of this page is slightly megalomaniac ;-)

But it's just a few examples that show how to use the COM API of Google Earth with Tcl. The COM API description could be found here [L1 ].

Examples tested on console:

- Instantiating a Google Earth object:

 package require tcom
 set application [::tcom::ref createobject "GoogleEarth.ApplicationGE"]

- Query if Google Earth is initialised (1) or not (0):

 $application IsInitialized

- Get the version infos:

 set apptype [$application VersionAppType]
 set vbuild [$application VersionBuild]
 set vmajor [$application versionMajor]
 set vminor [$application versionMinor]

- Fly through a predefined route:

 # SetCameraParams <latitude> <longitude> <altitude> <altMode> <range> <tilt> <azimuth> <speed>
 #
 # <latitude>  Latitude in degrees. Between -90 and 90.
 # <longitude> Longitude in degrees. Between -180 and 180.
 # <altitude>  Altitude in meters
 # <altMode>   Altitude mode that defines altitude reference origin (1=above ground, 2=absolute)
 # <range>     Distance between focus point and camera in meters
 #             If !=0 camera will move backward from range meters along the camera axis
 # <tilt>      Tilt angle in degrees. Between 0 and 90. Looking to the horizon=90, looking to the center of Earth=0
 # <azimuth>   Azimuth angle in degrees. Looking North=0, East=90, South=180, West=270
 # <speed>     Speed factor. Must be >= 0, if >=5.0 it's the teleportation mode
 
 $application SetCameraParams 45 1 1000 1 1 60 345 1
 $application SetCameraParams 46 1 1000 1 1 60 345 1
 $application SetCameraParams 47 1 1000 1 1 60 345 1
 $application SetCameraParams 48 1 1000 1 1 60 345 1
 $application SetCameraParams 48 -4 1000 1 1 60 345 1
 $application SetCameraParams 48 -4 3000 1 1 60 300 1

- Retrieve camera infos:

 set cam [$application GetCamera 1]
 set fplat [$cam FocusPointLatitude]
 set fplong [$cam FocusPointLongitude]
 set fpalt [$cam FocusPointAltitude]
 set fpaltm [$cam FocusPointAltitudeMode]
 set range [$cam Range]
 set tilt [$cam Tilt]
 set azm  [$cam Azimuth]

- Save screenshot in black and white:

 # SaveScreenShot <file> <quality>
 # <quality> Quality factor of output image. Lowest quality is 0 and highest quality is 100. 

 $application SaveScreenShot C:/tmp/ge01.jpg 40

- Search a location:

 set sc [$application SearchController]
 $sc Search "Paris"

- Open a KML file from local filesystem and from network:

 $application OpenKmlFile C:/tmp/KML_samples.kml 1
 $application OpenKmlFile http://code.google.com/apis/kml/documentation/KML_Samples.kml 1

See also Steve Landers and David Roseman' articles at the Annual Tcl Conference 2010 : Augmented Reality, Google Earth and Tcl/Tk

See also tcom

PO Added this functionality in CAWT version 1.0.0.


LVwikignoming - 2011-07-27 14:25:38

Anyone have an updated URL for proceedings? The one just mentioned doesn't work - the site doesn't even resolve at my location...


pd This no longer works, Google API is gone. But there are registry patches to restore it. Download the zip file from here . This is a rexx script that loads some binary registry files. I'm sure this could be done quite easily with the registry command. An exercise for the reader.