make imagery menu adapt to where you are. I guess it might need to be bindable so...
authorRichard Fairhurst <richard@systemed.net>
Fri, 26 Nov 2010 12:30:53 +0000 (12:30 +0000)
committerRichard Fairhurst <richard@systemed.net>
Fri, 26 Nov 2010 12:30:53 +0000 (12:30 +0000)
net/systemeD/potlatch2/BackgroundSelector.mxml
potlatch2.mxml
resources/imagery.xml

index 3bb05b7..d7363db 100644 (file)
@@ -7,7 +7,7 @@
        <mx:List width="100%" height="100%" id="background" verticalScrollPolicy="on" 
                        labelField="name"
                        change="Application.application.bgButton.close(); Application.application.setBackground(background.selectedItem);"                      
-               dataProvider="{Application.application.theController.imagery}" />
+               dataProvider="{Application.application.getAvailableImagery()}" />
        <mx:CheckBox width="100%" label="Dim background" selected="true" id="dim"
            change="Application.application.theMap.setDimming(dim.selected); Application.application.yahoo.alpha = dim.selected ? 0.5 : 1" />
 
index 3025108..61560f9 100644 (file)
                                { name: "Yahoo", url: "yahoo", sourcetag: "Yahoo" } );
                        for each(var set:XML in xml.set) {
                                var obj:Object={};
-                               for (var a:String in set.children()) {
-                                       obj[set.child(a).name()]=set.child(a);
-                               }
+                               var a:XML;
+                               for each (a in set.@*) { obj[a.name().localName]=a.toString(); }
+                               for each (a in set.* ) { obj[a.name()          ]=a.toString(); }
                 theController.imagery.push(obj);
                                if ((obj.url ==saved.url) ||
                                    (obj.name==saved.name && obj.name!='Custom')) { isSet=true; }
                        obj.flush();
                }
 
+               public function getAvailableImagery():Array {
+                       var available:Array=[];
+                       for each (var bg:Object in theController.imagery) {
+                               if (bg.minlon) {
+                                       // if there's a bbox, check the current viewport intersects it
+                                       if (((theMap.edge_l>bg.minlon && theMap.edge_l<bg.maxlon) ||
+                                            (theMap.edge_r>bg.minlon && theMap.edge_r<bg.maxlon) ||
+                                            (theMap.edge_l<bg.minlon && theMap.edge_r>bg.maxlon)) &&
+                                           ((theMap.edge_b>bg.minlat && theMap.edge_b<bg.maxlat) ||
+                                            (theMap.edge_t>bg.minlat && theMap.edge_t<bg.maxlat) ||
+                                            (theMap.edge_b<bg.minlat && theMap.edge_t>bg.maxlat))) {
+                                               available.push(bg);
+                                       }
+                               } else {
+                                       // if there's no bbox (i.e. global set), include it anyway
+                                       available.push(bg);
+                               }
+                       }
+                       return available;
+               }
+
                private function onStylesheetsLoad(event:Event):void {
                        var xml:XML = new XML(URLLoader(event.target).data);
                        var saved_url:String = SharedObject.getLocal("user_state").data['stylesheet_url'];
index 24c3f47..154592b 100644 (file)
@@ -9,62 +9,57 @@
                <name>OSM - Osmarender</name>
                <url>http://tah.openstreetmap.org/Tiles/tile/$z/$x/$y.png</url>
        </set>
-       <set>
+       <set minlat="49.8" minlon="-9" maxlat="61.1" maxlon="1.9">
                <name>OS OpenData Streetview</name>
                <url>http://os.openstreetmap.org/sv/$z/$x/$y.png</url>
                <sourcetag>OS OpenData StreetView</sourcetag>
        </set>
-       <set>
+       <set minlat="49.8" minlon="-9" maxlat="61.1" maxlon="1.9">
                <name>OS OpenData Locator</name>
                <url>http://tiles.itoworld.com/os_locator/$z/$x/$y.png</url>
                <sourcetag>OS OpenData Locator</sourcetag>
        </set>
-       <set>
+       <set minlat="49.8" minlon="-9" maxlat="61.1" maxlon="1.9">
                <name>OS 1:25k historic</name>
                <url>http://ooc.openstreetmap.org/os1/$z/$x/$y.png</url>
                <sourcetag>OS 1:25k</sourcetag>
        </set>
-       <set>
+       <set minlat="49.8" minlon="-9" maxlat="61.1" maxlon="1.9">
                <name>OS 7th Series historic</name>
                <url>http://ooc.openstreetmap.org/os7/$z/$x/$y.png</url>
                <sourcetag>OS7</sourcetag>
        </set>
-       <set>
+       <set minlat="49.8" minlon="-5.8" maxlat="55.8" maxlon="1.9">
                <name>OS New Popular Edition historic</name>
                <url>http://ooc.openstreetmap.org/npe/$z/$x/$y.png</url>
                <sourcetag>NPE</sourcetag>
        </set>
-       <set>
+       <set minlat="54.5" minlon="-7.8" maxlat="61.1" maxlon="-1.1">
                <name>OS Scottish Popular historic</name>
                <url>http://gibin.geog.ucl.ac.uk/~ollie/scotland/tiles/$z/$x/$y.jpg</url>
                <sourcetag>NPE</sourcetag>
        </set>
-       <set>
+       <set minlat="51.071" minlon="-0.856" maxlat="51.473" maxlon="0.062">
                <name>Surrey aerial</name>
                <url>http://gravitystorm.dev.openstreetmap.org/surrey/$z/$x/$y.png</url>
                <sourcetag>Surrey aerial</sourcetag>
        </set>
-       <set>
-               <name>NearMap aerial</name>
-               <url>http://www.nearmap.com/maps/nml=Vert&amp;zxy=$z,$x,$y</url>
-               <sourcetag>NearMap</sourcetag>
-       </set>
-       <set>
+       <set minlat="17.95" minlon="-74.5" maxlat="20.12" maxlon="-71.58">
                <name>Haiti - GeoEye Jan 13</name>
                <url>http://gravitystorm.dev.openstreetmap.org/imagery/haiti/$z/$x/$y.jpg</url>
                <sourcetag>Haiti GeoEye</sourcetag>
        </set>
-       <set>
+       <set minlat="17.95" minlon="-74.5" maxlat="20.12" maxlon="-71.58">
                <name>Haiti - GeoEye Jan 13+</name>
                <url>http://maps.nypl.org/tilecache/1/geoeye/$z/$x/$y.jpg</url>
                <sourcetag>Haiti GeoEye</sourcetag>
        </set>
-       <set>
+       <set minlat="17.95" minlon="-74.5" maxlat="20.12" maxlon="-71.58">
                <name>Haiti - DigitalGlobe</name>
                <url>http://maps.nypl.org/tilecache/1/dg_crisis/$z/$x/$y.jpg</url>
                <sourcetag>Haiti DigitalGlobe</sourcetag>
        </set>
-       <set>
+       <set minlat="17.95" minlon="-74.5" maxlat="20.12" maxlon="-71.58">
                <name>Haiti - Street names</name>
                <url>http://hypercube.telascience.org/tiles/1.0.0/haiti-city/$z/$x/$y.jpg</url>
                <sourcetag>Haiti streetnames</sourcetag>