Support loading 1+ GPX files via imagery.xml
authorAndy Allan <gravitystorm@gmail.com>
Tue, 30 Nov 2010 15:23:51 +0000 (15:23 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Tue, 30 Nov 2010 15:23:51 +0000 (15:23 +0000)
net/systemeD/potlatch2/AutoVectorBackground.as
resources/vectors.xml

index 6a7a92c..39b3e7b 100644 (file)
@@ -4,8 +4,10 @@ package net.systemeD.potlatch2 {
 
         import flash.events.*
         import flash.net.*
+        import flash.system.Security;
         import net.systemeD.halcyon.Map;
         import net.systemeD.halcyon.DebugURLRequest;
+        import net.systemeD.halcyon.VectorLayer;
         import net.systemeD.potlatch2.utils.*;
 
         private var map:Map;
@@ -24,6 +26,15 @@ package net.systemeD.potlatch2 {
         public function onConfigLoad(e:Event):void {
             var xml:XML = XML(e.target.data);
             for each(var set:XML in xml.set) {
+
+              // allow layers to be defined but disabled. This lets me put examples in the
+              // config file.
+              if (set.@disabled == "true") continue;
+
+              if (!(set.policyfile == undefined)) {
+                Security.loadPolicyFile(String(set.policyfile));
+              }
+
               var name:String = (set.name == undefined) ? null : String(set.name);
               var loader:String = set.loader;
               switch (loader) {
@@ -31,6 +42,20 @@ package net.systemeD.potlatch2 {
                   break;
                 case "KMLImporter":
                   break;
+                case "GPXImporter":
+                  if (set.url) {
+                    if (set.@loaded == "true") {
+                      name ||= 'GPX file';
+                      var layer:VectorLayer = new VectorLayer(name, map, 'gpx.css');
+                      map.addVectorLayer(layer);
+                      var gpxImporter:GpxImporter = new GpxImporter(layer, layer.paint, [String(set.url)]);
+                    } else {
+                      trace("configured but not loaded isn't supported yet");
+                    }
+                  } else {
+                    trace("AutoVectorBackground: no url for GPXImporter");
+                  }
+                  break;
 
                 case "BugLoader":
                   if (set.url && set.apiKey) {
index 0149032..0a7b960 100644 (file)
@@ -20,6 +20,7 @@
     <set disabled="true">
       <name>A particular GPX file</name>
       <loader>GPXImporter</loader>
-      <url></url>
+      <policyfile>http://gravitystorm.dev.openstreetmap.org/gpx/crossdomain.xml</policyfile>
+      <url>http://gravitystorm.dev.openstreetmap.org/gpx/112.gpx</url>
     </set>
 </vectors>
\ No newline at end of file