From c65cde3afbd5719acafc3b04aaf652bc55d194c6 Mon Sep 17 00:00:00 2001 From: Richard Fairhurst Date: Fri, 11 Jun 2010 15:24:38 +0000 Subject: [PATCH] load imagery from XML file --- TODO.txt | 6 +- .../potlatch2/BackgroundSelector.mxml | 31 +++---- potlatch2.mxml | 52 ++++++----- resources/imagery.xml | 91 +++++++++++++++++++ 4 files changed, 138 insertions(+), 42 deletions(-) create mode 100644 resources/imagery.xml diff --git a/TODO.txt b/TODO.txt index 43632c98..deb3275a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -41,15 +41,14 @@ Potlatch 2: main outstanding issues * Ability to specify that a node should be a point in a way, for example for crossings * Ability to say that it's unlikely/impossible to have a way that is a bridge and a tunnel at the same time. - == UI == ** Potlatch 1-style "floaty warnings" ** Toolbox fixes (see comments in file) ** Should remember which background imagery layer you had previously selected -** Background imagery layers should match those of p1 ** Dialog for adding custom imagery url -** onDataComplete fires the first time a map call has returned - but multiple calls might have been made, so really we should count them and only reset dataWorking when it's back to 0 again +* B keypress for background source tag +* Bbox-sensitive menu for background imagery * Mouse wheel zooming * CSS editing * Quick-search on add-relations-to-way dialog (RelationSelectPanel) @@ -60,7 +59,6 @@ Potlatch 2: main outstanding issues * Remove created_by=* tags from any data touched - == Rendering (Halcyon) == ** Changing style, and then back again, doesn't redraw everything diff --git a/net/systemeD/potlatch2/BackgroundSelector.mxml b/net/systemeD/potlatch2/BackgroundSelector.mxml index 0a28e3b6..1e899a71 100644 --- a/net/systemeD/potlatch2/BackgroundSelector.mxml +++ b/net/systemeD/potlatch2/BackgroundSelector.mxml @@ -4,22 +4,8 @@ paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" horizontalAlign="left" backgroundColor="white" borderStyle="inset"> - - - - - - - - - - - - - - - - + @@ -30,7 +16,19 @@ import net.systemeD.halcyon.connection.*; import net.systemeD.potlatch2.*; import mx.core.*; + import mx.collections.ArrayCollection; import mx.managers.PopUpManager; + import net.systemeD.halcyon.Globals; + + [Bindable] private var _layers:Array=new Array( + { label: "None", data: "" }, + { label: "Yahoo", data: "yahoo" } ); + + public function populate(xml:XML):void { + for each(var set:XML in xml.set) { + _layers.push({ label:set.child("name"), data:set.child("url") }); + } + } private function updateBackground():void { var theMap:Map = Globals.vars.root; @@ -43,7 +41,6 @@ Globals.vars.yahoo.hide(); } } - ]]> diff --git a/potlatch2.mxml b/potlatch2.mxml index b2ff679f..8395adb2 100755 --- a/potlatch2.mxml +++ b/potlatch2.mxml @@ -129,6 +129,9 @@ public var theMap:Map; public var theController:EditController; + private var savecount:uint=0; + private var loadcount:uint=0; + private function initApp():void { Globals.vars.map_area = map_area; @@ -163,15 +166,6 @@ _root.addChild(s); theMap.mask=s; - // add crosshair - /*s=new Sprite(); - s.graphics.lineStyle(2,0); - s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2); - s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2); - s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20); - s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20); - _root.addChild(s);*/ - // mouse-up handler attached to stage, so the user can release outside the map stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler); Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler); @@ -180,12 +174,11 @@ // keyboard event attached to stage stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler); - // example listener event - var myListenerObj:Object = new Object(); - myListenerObj.mapHandler=function(event:MapEvent):void { - Globals.vars.debug.appendText("Download event fired - "+event.params.minlat+","+event.params.minlon+"\n"); - }; - theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler); + // load imagery XML + var request:URLRequest = new URLRequest("imagery.xml?"+Math.random()); + var loader:URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, onImageryLoad); + loader.load(request); // add debug field var t:TextField=new TextField(); @@ -202,9 +195,8 @@ var conn:Connection = Connection.getConnectionInstance(); conn.addEventListener(Connection.LOAD_STARTED, onDataStart); conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete); - - // and to import a shapefile... -// var importer:ShpImporter = new ShpImporter(theMap, ["http://127.0.0.1/~richard/shp/wildrnp020.shp","http://127.0.0.1/~richard/shp/wildrnp020.shx","http://127.0.0.1/~richard/shp/wildrnp020.dbf"]); + conn.addEventListener(Connection.SAVE_STARTED, onDataStart); + conn.addEventListener(Connection.SAVE_COMPLETED, onDataComplete); } public function onResizeMap():void { @@ -213,13 +205,31 @@ } private function onDataStart(event:Event):void { - dataWorking.text = event.type == Connection.LOAD_STARTED ? "Loading data..." : "Saving Data..."; - dataWorking.visible = true; + switch (event.type) { + case Connection.LOAD_STARTED: loadcount++; break; + case Connection.SAVE_STARTED: savecount++; break; + } + updateDataWorking(); } private function onDataComplete(event:Event):void { - dataWorking.visible = false; + switch (event.type) { + case Connection.LOAD_COMPLETED: loadcount--; break; + case Connection.SAVE_COMPLETED: savecount--; break; + } + updateDataWorking(); } + private function updateDataWorking():void { + if (loadcount>0 && savecount>0) { dataWorking.text="Loading/saving..."; } + else if (loadcount>0) { dataWorking.text="Loading data..."; } + else if (savecount>0) { dataWorking.text="Saving data..."; } + else { dataWorking.text=""; } + dataWorking.visible=(dataWorking.text!=""); + } + private function onImageryLoad(event:Event):void { + var imagery:XML = new XML(URLLoader(event.target).data); + BackgroundSelector(bgButton.popUp).populate(imagery); + } private function dragEnterHandler(event:DragEvent):void { diff --git a/resources/imagery.xml b/resources/imagery.xml new file mode 100644 index 00000000..79652df6 --- /dev/null +++ b/resources/imagery.xml @@ -0,0 +1,91 @@ + + + + + OSM - Mapnik + 900913 + http://tile.openstreetmap.org/$z/$x/$y.png + + + OSM - Osmarender + 900913 + http://tah.openstreetmap.org/Tiles/tile/$z/$x/$y.png + + + OSM - Maplint (errors) + 900913 + http://tah.openstreetmap.org/Tiles/maplint/$z/$x/$y.png + + + OS OpenData Streetview + 900913 + http://os.openstreetmap.org/sv/$z/$x/$y.png + OS OpenData StreetView + + + OS OpenData Locator + 900913 + http://tiles.itoworld.com/os_locator/$z/$x/$y.png + OS OpenData Locator + + + OS 1:25k historic + 900913 + http://ooc.openstreetmap.org/os1/$z/$x/$y.png + OS 1:25k + + + OS 7th Series historic + 900913 + http://ooc.openstreetmap.org/os7/$z/$x/$y.png + OS7 + + + OS New Popular Edition historic + 900913 + http://ooc.openstreetmap.org/npe/$z/$x/$y.png + NPE + + + OS Scottish Popular historic + 900913 + http://gibin.geog.ucl.ac.uk/~ollie/scotland/tiles/$z/$x/$y.jpg + NPE + + + Surrey aerial + 900913 + http://gravitystorm.dev.openstreetmap.org/surrey/$z/$x/$y.png + Surrey aerial + + + NearMap aerial + 900913 + http://www.nearmap.com/maps/nml=Vert&zxy=$z,$x,$y + NearMap + + + Haiti - GeoEye Jan 13 + 900913 + http://gravitystorm.dev.openstreetmap.org/imagery/haiti/$z/$x/$y.jpg + Haiti GeoEye + + + Haiti - GeoEye Jan 13+ + 900913 + http://maps.nypl.org/tilecache/1/geoeye/$z/$x/$y.jpg + Haiti GeoEye + + + Haiti - DigitalGlobe + 900913 + http://maps.nypl.org/tilecache/1/dg_crisis/$z/$x/$y.jpg + Haiti DigitalGlobe + + + Haiti - Street names + 900913 + http://hypercube.telascience.org/tiles/1.0.0/haiti-city/$z/$x/$y.jpg + Haiti streetnames + + -- 2.30.1