|
peony3000
YaBB Newbies
Offline
Posts: 5
|
//Cut and paste all into processing
//Written by Jan Humble <jch@Cs.Nott.AC.UK> for //ECT <http://www.crg.cs.nott.ac.uk/~jym/ect/ect.php> //Adapted for Processing by //Stefan Rennick Egglestone <sre@Cs.Nott.AC.UK> //Concept by Andy Boucher <a.boucher@gold.ac.uk> and //Andy Law <a.law@gold.ac.uk> //Thanks to Nicolas Villar <nvillar@gmail.com> //Original references from //<http://stevemargetts.blogspot.com/2005/07/controling-google-earth-from-jscript.html> //Google Earth //<http://earth.google.com/downloads.html>
public double longitude = -69.90; public double latitude = 18.5; public double range = 300; public double tilt = 46; public double heading = 50; public String googleEarthClient = "C:\\Program Files\\Google\\Google Earth\\GoogleEarth.exe";
void setup() { try { File localFile = new File("google_earth.kml"); FileWriter fos = new FileWriter(localFile); fos.write(getKML()); fos.flush(); fos.close();
String command = googleEarthClient + " " + localFile.getCanonicalPath();
System.out.println(command);
Process proc = Runtime.getRuntime().exec(command); } catch(IOException e) { e.printStackTrace(); } }
String getKML() { String kml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<kml xmlns=\"http://earth.google.com/kml/2.0\">" + "<Placemark>" + "<description>The Dominican Republic</description>" + "<name>Jan's House</name>" + "<LookAt>" + "<longitude>" + longitude + "</longitude>" + "<latitude>" + latitude + "</latitude>" + "<range>" + range + "</range>" + "<tilt>" + tilt + "</tilt>" + "<heading>" + heading + "</heading>" + "</LookAt>" + "<visibility>1</visibility>" + "<Style>" + "<IconStyle>" + "<Icon>" + "<href>root://icons/palette-3.png</href>" + "<x>96</x>" + "<y>160</y>" + "<w>32</w>" + "<h>32</h>" + "</Icon>" + "</IconStyle>" + "</Style>" + "<Point>" + "<extrude>1</extrude>" + "<altitudeMode>relativeToGround</altitudeMode>" + "<coordinates>" + longitude + "," + latitude + ",0</coordinates>" + "</Point>" + "</Placemark>" + "</kml>"; return kml; }
|