Don't try and load policy files from localhost:3000...
authorRichard Fairhurst <richard@systemeD.net>
Tue, 6 Mar 2012 16:56:10 +0000 (16:56 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Tue, 6 Mar 2012 16:56:10 +0000 (16:56 +0000)
net/systemeD/potlatch2/collections/VectorBackgrounds.as

index 8ec7e5f..34a4fcc 100644 (file)
@@ -35,98 +35,100 @@ package net.systemeD.potlatch2.collections {
                        // use .forEach to avoid closure problem (http://stackoverflow.com/questions/422784/how-to-fix-closure-problem-in-actionscript-3-as3#3971784)
                        sets.forEach(function(set:XML, index:int, array:Array):void {
 
                        // use .forEach to avoid closure problem (http://stackoverflow.com/questions/422784/how-to-fix-closure-problem-in-actionscript-3-as3#3971784)
                        sets.forEach(function(set:XML, index:int, array:Array):void {
 
-                               if (!(set.policyfile == undefined)) {
-                                       Security.loadPolicyFile(String(set.policyfile));
-                               }
+                               // Skip if just an example
+                               if (!(set.@disabled=="true")) {
+
+                                       if (!(set.policyfile == undefined)) {
+                                               Security.loadPolicyFile(String(set.policyfile));
+                                       }
 
 
-                // Check for any bounds for the vector layer. Obviously won't kick in during subsequent panning
-                var validBbox:Boolean = false;
-                if (set.@minlon && String(set.@minlon) != '') {
-                    if (((_map.edge_l>set.@minlon && _map.edge_l<set.@maxlon) ||
-                         (_map.edge_r>set.@minlon && _map.edge_r<set.@maxlon) ||
-                         (_map.edge_l<set.@minlon && _map.edge_r>set.@maxlon)) &&
-                        ((_map.edge_b>set.@minlat && _map.edge_b<set.@maxlat) ||
-                         (_map.edge_t>set.@minlat && _map.edge_t<set.@maxlat) ||
-                         (_map.edge_b<set.@minlat && _map.edge_t>set.@maxlat))) {
-                        validBbox = true;
-                    } else {
-                        validBbox = false; // out of bounds
-                    }
-                } else {
-                    validBbox = true; // global set
-                }
-
-                               if (set.@disabled == "true") {
-                    // Don't do anything with it. The "disabled" attribute allows examples to appear in the config file
-                               } else if (validBbox) {
-
-                                       var name:String = (set.name == undefined) ? null : String(set.name);
-                                       var loader:String = set.loader;
-                                       switch (loader) {
-                                               case "TrackLoader":
-                                                       break;
-                                               case "KMLImporter":
-                                                       break;
-                                               case "GPXImporter":
-                                                       if (set.url) {
-                                                               if (set.@loaded == "true") {
-                                                                       name ||= 'GPX file';
-                                                                       var gpx_url:String = String(set.url);
-
-                                                                       var connection:Connection = new Connection(name, gpx_url, null, null);
-                                                                       var gpx:GpxImporter=new GpxImporter(connection, _map, [gpx_url],
-                                                                       function(success:Boolean,message:String=null):void {
-                                                                               if (!success) return;
-                                                                               var paint:MapPaint = _map.addLayer(connection, "stylesheets/gpx.css");
-                                                                               paint.updateEntityUIs(false, false);
-                                                                               dispatchEvent(new Event("layers_changed"));
-                                                                       }, false);
+                       // Check for any bounds for the vector layer. Obviously won't kick in during subsequent panning
+                       var validBbox:Boolean = false;
+                       if (set.@minlon && String(set.@minlon) != '') {
+                           if (((_map.edge_l>set.@minlon && _map.edge_l<set.@maxlon) ||
+                                (_map.edge_r>set.@minlon && _map.edge_r<set.@maxlon) ||
+                                (_map.edge_l<set.@minlon && _map.edge_r>set.@maxlon)) &&
+                               ((_map.edge_b>set.@minlat && _map.edge_b<set.@maxlat) ||
+                                (_map.edge_t>set.@minlat && _map.edge_t<set.@maxlat) ||
+                                (_map.edge_b<set.@minlat && _map.edge_t>set.@maxlat))) {
+                               validBbox = true;
+                           } else {
+                               validBbox = false; // out of bounds
+                           }
+                       } else {
+                           validBbox = true; // global set
+                       }
+
+                                       if (validBbox) {
+
+                                               var name:String = (set.name == undefined) ? null : String(set.name);
+                                               var loader:String = set.loader;
+                                               switch (loader) {
+                                                       case "TrackLoader":
+                                                               break;
+                                                       case "KMLImporter":
+                                                               break;
+                                                       case "GPXImporter":
+                                                               if (set.url) {
+                                                                       if (set.@loaded == "true") {
+                                                                               name ||= 'GPX file';
+                                                                               var gpx_url:String = String(set.url);
+
+                                                                               var connection:Connection = new Connection(name, gpx_url, null, null);
+                                                                               var gpx:GpxImporter=new GpxImporter(connection, _map, [gpx_url],
+                                                                               function(success:Boolean,message:String=null):void {
+                                                                                       if (!success) return;
+                                                                                       var paint:MapPaint = _map.addLayer(connection, "stylesheets/gpx.css");
+                                                                                       paint.updateEntityUIs(false, false);
+                                                                                       dispatchEvent(new Event("layers_changed"));
+                                                                               }, false);
+                                                                       } else {
+                                                                       trace("VectorBackgrounds: configured but not loaded isn't supported yet");
+                                                                       }
                                                                } else {
                                                                } else {
-                                                               trace("VectorBackgrounds: configured but not loaded isn't supported yet");
+                                                                       trace("VectorBackgrounds: no url for GPXImporter");
                                                                }
                                                                }
-                                                       } else {
-                                                               trace("VectorBackgrounds: no url for GPXImporter");
-                                                       }
-                                                       break;
-
-                                               case "BugLoader":
-                                                       if (set.url && set.apiKey) {
-                                                               name ||= 'Bugs';
-                                                               var bugLoader:BugLoader = new BugLoader(_map, String(set.url), String(set.apikey), name, String(set.details));
-                                                               if (set.@loaded == "true") {
-                                                                       bugLoader.load();
+                                                               break;
+
+                                                       case "BugLoader":
+                                                               if (set.url && set.apiKey) {
+                                                                       name ||= 'Bugs';
+                                                                       var bugLoader:BugLoader = new BugLoader(_map, String(set.url), String(set.apikey), name, String(set.details));
+                                                                       if (set.@loaded == "true") {
+                                                                               bugLoader.load();
+                                                                       }
+                                                               } else {
+                                                                       trace("VectorBackgrounds: error with BugLoader");
                                                                }
                                                                }
-                                                       } else {
-                                                               trace("VectorBackgrounds: error with BugLoader");
-                                                       }
-                                                       break;
-
-                                               case "BikeShopLoader":
-                                                       if (set.url) {
-                                                               name ||= 'Missing Bike Shops'
-                                                               var bikeShopLoader:BikeShopLoader = new BikeShopLoader(_map, String(set.url), name);
-                                                               if (set.@loaded == "true") {
-                                                                       bikeShopLoader.load();
+                                                               break;
+
+                                                       case "BikeShopLoader":
+                                                               if (set.url) {
+                                                                       name ||= 'Missing Bike Shops'
+                                                                       var bikeShopLoader:BikeShopLoader = new BikeShopLoader(_map, String(set.url), name);
+                                                                       if (set.@loaded == "true") {
+                                                                               bikeShopLoader.load();
+                                                                       }
+                                                               } else {
+                                                                       trace("VectorBackgrounds: no url for BikeShopLoader");
                                                                }
                                                                }
-                                                       } else {
-                                                               trace("VectorBackgrounds: no url for BikeShopLoader");
-                                                       }
-                                                       break;
-
-                                               case "SnapshotLoader":
-                                                       if (set.url) {
-                                                               name ||= 'Snapshot Server'
-                                                               var snapshotLoader:SnapshotLoader = new SnapshotLoader(_map, String(set.url), name, String(set.style));
-                                                               if (set.@loaded == "true") {
-                                                                       snapshotLoader.load();
+                                                               break;
+
+                                                       case "SnapshotLoader":
+                                                               if (set.url) {
+                                                                       name ||= 'Snapshot Server'
+                                                                       var snapshotLoader:SnapshotLoader = new SnapshotLoader(_map, String(set.url), name, String(set.style));
+                                                                       if (set.@loaded == "true") {
+                                                                               snapshotLoader.load();
+                                                                       }
+                                                               } else {
+                                                                       trace("VectorBackgrounds: no url for SnapshotLoader");
                                                                }
                                                                }
-                                                       } else {
-                                                               trace("VectorBackgrounds: no url for SnapshotLoader");
-                                                       }
-                                                       break;
+                                                               break;
 
 
-                                               default:
-                                                       trace("VectorBackgrounds: unknown loader: " + loader);
+                                                       default:
+                                                               trace("VectorBackgrounds: unknown loader: " + loader);
+                                               }
                                        }
                                }
                        });
                                        }
                                }
                        });