GS The title of this page is slightly megalomaniac ;-)
But it's just 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 vajor [$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