Support bbox-limited vector background layers. Only checked on first load.
authorAndy Allan <andy@gravitystorm.co.uk>
Wed, 6 Jul 2011 14:18:25 +0000 (15:18 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Wed, 6 Jul 2011 14:18:25 +0000 (15:18 +0100)
net/systemeD/potlatch2/collections/VectorBackgrounds.as
resources/vectors.xml

index 6efc3f1..81f059e 100644 (file)
@@ -39,9 +39,26 @@ package net.systemeD.potlatch2.collections {
                                        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 {
+                               } else if (validBbox) {
 
                                        var name:String = (set.name == undefined) ? null : String(set.name);
                                        var loader:String = set.loader;
index d9a8174..627b50a 100644 (file)
@@ -14,7 +14,7 @@
       <url>http://80.242.147.84/osmbugs/api/</url>
       <apikey>e4d47b6b8c26e822a62d747b802f98ac</apikey>
     </set>
-    <set>
+    <set minlat="49.8" minlon="-9" maxlat="61.1" maxlon="1.9">
       <name>Bike Shop Locator - Missing Shops</name>
       <loader>BikeShopLoader</loader>
       <url>http://shaunmcdonald.dev.openstreetmap.org/bike-shop-locator/</url>