From: Thierry Parmentelat Date: Wed, 17 Sep 2008 11:56:44 +0000 (+0000) Subject: fancier kml output using 2.2 X-Git-Tag: MyPLC-4.3-2~38 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=3dba899f01111b2b9c58ca006a4530301175458e;p=myplc.git fancier kml output using 2.2 --- diff --git a/plc-kml.py b/plc-kml.py index 69ef5ae..ec2cbb2 100755 --- a/plc-kml.py +++ b/plc-kml.py @@ -4,6 +4,10 @@ # you should crontab this job from your myplc image # you can then use the googlemap.js javascript for creating your applet # more on this at http://svn.planet-lab.org/wiki/GooglemapSetup +# +# kml reference can be found at +# http://code.google.com/apis/kml/documentation/kmlreference.html +# import sys @@ -28,21 +32,43 @@ class KmlMap: def write(self,string): self.output.write(string.encode("UTF-8")) + @staticmethod + def site_compare (s1,s2): + n1=s1['name'] + n2=s2['name'] + if n1n2: + return 1 + else: + return 0 + def refresh (self): self.open() self.write_header() # cache peers peers = GetPeers({},['peer_id','peername']) - for site in GetSites({'enabled':True,'is_public':True}): + all_sites = GetSites({'enabled':True,'is_public':True}) + all_sites.sort(KmlMap.site_compare) + for site in all_sites: self.write_site(site,peers) self.write_footer() self.close() +# initial placement is for europe - dunno how to tune that yet def write_header (self): self.write(""" PlanetLab Sites + +9.180821112577378 +44.43275321178062 +0 +5782133.196489797 +0 +-7.767386340832667 + All the sites known to the PlanetLab testbed. """) @@ -127,9 +153,17 @@ class KmlMap: iconspec="%(iconurl)s%(xyspec)s"%locals() + # set the camera 50km high template=""" + + %(latitude)f + %(longitude)f + 0 + relativeToGround + 50000. + %(longitude)f,%(latitude)f,0