diff --git a/.gitignore b/.gitignore index f3b6c169..b07f6064 100644 --- a/.gitignore +++ b/.gitignore @@ -2,13 +2,18 @@ build.properties l10n/locale/bundles version.as halcyon.tmproj +Potlatch2.as3proj resources/locales resources/*.swf resources/*.cache resources/docs +resources/mapquest /tests/bin/ /tests/report/ /generated + +bin/ +obj/ diff --git a/embedded/search.svg b/embedded/search.svg new file mode 100644 index 00000000..f06e194a --- /dev/null +++ b/embedded/search.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + +]> + + + + + + + + + + + + + diff --git a/net/systemeD/halcyon/connection/Connection.as b/net/systemeD/halcyon/connection/Connection.as index f355b9b9..74514eb2 100644 --- a/net/systemeD/halcyon/connection/Connection.as +++ b/net/systemeD/halcyon/connection/Connection.as @@ -544,7 +544,7 @@ package net.systemeD.halcyon.connection { public function loadBbox(left:Number, right:Number, top:Number, bottom:Number):void { } - public function loadEntity(entity:Entity):void {} + public function loadEntityByID(type:String, id:Number):void {} public function setAuthToken(id:Object):void {} public function setAccessToken(key:String, secret:String):void {} public function createChangeset(tags:Object):void {} @@ -553,6 +553,11 @@ package net.systemeD.halcyon.connection { public function fetchUserTraces(refresh:Boolean=false):void {} public function fetchTrace(id:Number, callback:Function):void {} public function hasAccessToken():Boolean { return false; } + + public function loadEntity(entity:Entity):void { + loadEntityByID(entity.getType(),entity.id); + } + } } diff --git a/net/systemeD/halcyon/connection/XMLConnection.as b/net/systemeD/halcyon/connection/XMLConnection.as index 6a22bf4c..7fe45ec7 100644 --- a/net/systemeD/halcyon/connection/XMLConnection.as +++ b/net/systemeD/halcyon/connection/XMLConnection.as @@ -46,9 +46,9 @@ package net.systemeD.halcyon.connection { sendLoadRequest(mapRequest); } - override public function loadEntity(entity:Entity):void { - var url:String=Connection.apiBaseURL + entity.getType() + "/" + entity.id; - if (entity is Relation || entity is Way) url+="/full"; + override public function loadEntityByID(type:String, id:Number):void { + var url:String=Connection.apiBaseURL + type + "/" + id; + if (type=='way') url+="/full"; sendLoadRequest(new URLRequest(url)); } diff --git a/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as b/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as index 4ca186f5..56e6cdb5 100644 --- a/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as +++ b/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as @@ -25,7 +25,7 @@ package net.systemeD.halcyon.connection.actions { for each (var member:RelationMember in memberList) { member.entity.removeParent(relation); } - memberList.splice(0, memberList.length); + memberList=[]; effects.doAction(); setDeleted(true); @@ -52,6 +52,7 @@ package net.systemeD.halcyon.connection.actions { effects.undoAction(); for each(var member:RelationMember in oldMemberList) { memberList.push(member); + member.entity.addParent(relation); relation.dispatchEvent(new RelationMemberEvent( Connection.RELATION_MEMBER_ADDED, member.entity, relation, 0)); } diff --git a/net/systemeD/halcyon/styleparser/RuleSet.as b/net/systemeD/halcyon/styleparser/RuleSet.as index fed1ea72..33c20b9c 100644 --- a/net/systemeD/halcyon/styleparser/RuleSet.as +++ b/net/systemeD/halcyon/styleparser/RuleSet.as @@ -304,7 +304,7 @@ package net.systemeD.halcyon.styleparser { private function loadedImage(event:Event):void { var fn:String=event.target.info['filename']; - images[fn]=event.target.data; + images[fn]=event.target.data; if (images[fn].length==0) return; var loader:ExtendedLoader = new ExtendedLoader(); loader.info['filename']=fn; diff --git a/net/systemeD/potlatch2/RelationLoaderPanel.mxml b/net/systemeD/potlatch2/RelationLoaderPanel.mxml new file mode 100644 index 00000000..53c9624e --- /dev/null +++ b/net/systemeD/potlatch2/RelationLoaderPanel.mxml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + diff --git a/net/systemeD/potlatch2/RelationSelectPanel.mxml b/net/systemeD/potlatch2/RelationSelectPanel.mxml index 37a184f7..6cd409ed 100644 --- a/net/systemeD/potlatch2/RelationSelectPanel.mxml +++ b/net/systemeD/potlatch2/RelationSelectPanel.mxml @@ -80,6 +80,14 @@ panel.setRelation(relation); PopUpManager.centerPopUp(panel); } + + public function closeAndLoadRelation():void { + PopUpManager.removePopUp(this); + var panel:RelationLoaderPanel = RelationLoaderPanel( + PopUpManager.createPopUp(Application(Application.application), RelationLoaderPanel, true)); + panel.setEntity(entity); + PopUpManager.centerPopUp(panel); + } ]]> @@ -87,6 +95,7 @@ + diff --git a/net/systemeD/potlatch2/TagViewer.mxml b/net/systemeD/potlatch2/TagViewer.mxml index b107fe0d..a6f961b2 100644 --- a/net/systemeD/potlatch2/TagViewer.mxml +++ b/net/systemeD/potlatch2/TagViewer.mxml @@ -217,6 +217,7 @@ import mx.core.*; import mx.managers.PopUpManager; import mx.controls.Menu; + import mx.controls.Alert; import flash.geom.Point; import flash.net.*; import mx.events.DragEvent; @@ -659,7 +660,8 @@ var menu:Menu = new Menu(); var dp:Object = [ {label: "Select all members"}, {label: "Deselect all members"}, - {label: "Add selection to this relation", enabled: false} ]; + {label: "Add selection to this relation", enabled: false}, + {label: "Delete relation"} ]; menu.dataProvider = dp; menu.addEventListener("itemClick", selectRelationMenu); button.popUp = menu; @@ -710,6 +712,14 @@ } MainUndoStack.getGlobalStack().addAction(undo); break; + + case 3: // Delete relation + Alert.show("Do you really want to delete the relation?","Are you sure?",Alert.YES | Alert.CANCEL,null, + function(event:CloseEvent):void { + if (event.detail==Alert.CANCEL) return; + rel.remove(MainUndoStack.getGlobalStack().addAction); + } ); + break; } } diff --git a/net/systemeD/potlatch2/Yahoo.as b/net/systemeD/potlatch2/Yahoo.as index 6e0cefb3..75303243 100644 --- a/net/systemeD/potlatch2/Yahoo.as +++ b/net/systemeD/potlatch2/Yahoo.as @@ -13,54 +13,68 @@ package net.systemeD.potlatch2 { private static const token:String="f0a.sejV34HnhgIbNSmVHmndXFpijgGeun0fSIMG9428hW_ifF3pYKwbV6r9iaXojl1lU_dakekR"; private static const MAXZOOM:int=17; + private static const UNINITIALISED:uint=0; + private static const INITIALISING:uint=1; + private static const HIDDEN:uint=2; + private static const SHOWING:uint=3; + private var currentState:uint=UNINITIALISED; + private var _lat:Number; private var _lon:Number; private var _scale:Number; private var offset_lat:Number=0; private var offset_lon:Number=0; - private var inited:Boolean; - private var enabled:Boolean; - public function Yahoo(w:Number, h:Number, map:Map) { + public function Yahoo(map:Map) { super(); - this.init(token, w, h); - this.mapType="satellite"; - this.alpha=0.5; + currentState=UNINITIALISED; this.map=map; - inited=false; - visible=enabled=false; - this.addEventListener(YahooMapEvent.MAP_INITIALIZE, initHandler); + visible=false; } public function show():void { - visible=enabled=true; - if (inited) { + visible=true; + if (currentState==UNINITIALISED) { + currentState=INITIALISING; + this.addEventListener(YahooMapEvent.MAP_INITIALIZE, initHandler); + this.init(token, map.mapwidth, map.mapheight); + this.mapType="satellite"; + this.alpha=0.5; // ** FIXME - should take the value the user has chosen + activateListeners(); + } else if (currentState==HIDDEN) { + currentState=SHOWING; moveto(map.centre_lat, map.centre_lon, map.scale); this.setSize(map.mapwidth,map.mapheight); + activateListeners(); } + } + + public function hide():void { + deactivateListeners(); + visible=false; + if (currentState==SHOWING) currentState=HIDDEN; + } + private function activateListeners():void { map.addEventListener(MapEvent.MOVE, moveHandler); map.addEventListener(MapEvent.RESIZE, resizeHandler); map.addEventListener(MapEvent.NUDGE_BACKGROUND, nudgeHandler); } - - public function hide():void { - visible=enabled=false; - + + private function deactivateListeners():void { map.removeEventListener(MapEvent.MOVE, moveHandler); map.removeEventListener(MapEvent.RESIZE, resizeHandler); map.removeEventListener(MapEvent.NUDGE_BACKGROUND, nudgeHandler); } private function initHandler(event:YahooMapEvent):void { - inited=true; + currentState=visible ? SHOWING : HIDDEN; if (map.centre_lat) { moveto(map.centre_lat, map.centre_lon, map.scale); } this.removeEventListener(YahooMapEvent.MAP_INITIALIZE, initHandler); - visible=enabled; } private function moveHandler(event:MapEvent):void { - if (!inited) { return; } + if (currentState!=SHOWING) { return; } moveto(event.params.lat, event.params.lon, event.params.scale); } diff --git a/net/systemeD/potlatch2/collections/Imagery.as b/net/systemeD/potlatch2/collections/Imagery.as index e837e105..d0443c55 100644 --- a/net/systemeD/potlatch2/collections/Imagery.as +++ b/net/systemeD/potlatch2/collections/Imagery.as @@ -61,9 +61,7 @@ package net.systemeD.potlatch2.collections { var backgroundSet:Boolean = false; // Read all values from XML file - collection=new Array( - { name: "None", url: "" }, - { name: "Yahoo", url: "yahoo", sourcetag: "Yahoo" } ); + collection=new Array({ name: "None", url: "" }); for each(var set:XML in xml.set) { var obj:Object={}; var a:XML; @@ -75,7 +73,7 @@ package net.systemeD.potlatch2.collections { } // Add user's previous preference (from SharedObject) if we didn't find it in the XML file - if (!isSet && saved.name && saved.url && saved.url!='' && saved.url!='yahoo') { + if (!isSet && saved.name && saved.url && saved.url!='') { collection.push(saved); isSet=true; } diff --git a/net/systemeD/potlatch2/controller/DrawQuadrilateral.as b/net/systemeD/potlatch2/controller/DrawQuadrilateral.as new file mode 100644 index 00000000..4fc55890 --- /dev/null +++ b/net/systemeD/potlatch2/controller/DrawQuadrilateral.as @@ -0,0 +1,87 @@ +package net.systemeD.potlatch2.controller { + import flash.events.*; + import flash.display.Stage; + import net.systemeD.halcyon.connection.*; + import net.systemeD.halcyon.Map; + import net.systemeD.potlatch2.tools.Parallelise; + + public class DrawQuadrilateral extends ControllerState { + private var sourceNode:Node; + private var way:Way; + private var centrelon:Number; + private var centrelatp:Number; + private var radius:Number; + private var startX:Number; + private var startY:Number; + + public function DrawQuadrilateral(node:Node) { + sourceNode = node; + } + + override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState { + if (event.type==MouseEvent.MOUSE_MOVE) { + // redraw the rectangle sprite + var undo:CompositeUndoableAction = new CompositeUndoableAction("Draw quadrilateral"); + + var dx:Number=controller.map.mouseX-startX; + var dy:Number=controller.map.mouseY-startY; + var angle:Number=(dy % 360) * Math.PI/180; + + way.getNode(1).setLonLatp(centrelon +radius*Math.sin(angle), + centrelatp+radius*Math.cos(angle), + undo.push); + way.getNode(3).setLonLatp(centrelon -radius*Math.sin(angle), + centrelatp-radius*Math.cos(angle), + undo.push); + undo.doAction(); + } else if (event.type==MouseEvent.CLICK || event.type==MouseEvent.MOUSE_UP) { + // select the new rectangle + return new SelectedWay(way); + } else { + trace(event.type); + } + return this; + } + + override public function processKeyboardEvent(event:KeyboardEvent):ControllerState { + if (event.keyCode==27) { // Escape + // make sure the rectangle sprite is cleared + return new NoSelection(); + } + var cs:ControllerState = sharedKeyboardEvents(event); + return cs ? cs : this; + } + + override public function enterState():void { + controller.map.draggable=false; + var conn:Connection=controller.connection; + var undo:CompositeUndoableAction = new CompositeUndoableAction("Draw quadrilateral"); + var cornerlon:Number =controller.map.coord2lon(controller.map.mouseX); + var cornerlat:Number =controller.map.coord2lat(controller.map.mouseY); + var cornerlatp:Number=controller.map.coord2latp(controller.map.mouseY); + + var xradius:Number=(cornerlon-sourceNode.lon)/2; + var yradius:Number=(cornerlatp-sourceNode.latp)/2; + centrelon =sourceNode.lon +xradius; + centrelatp=sourceNode.latp+yradius; + radius=Math.sqrt(xradius*xradius+yradius*yradius); + + startX=controller.map.mouseX; + startY=controller.map.mouseY; + var node1:Node=conn.createNode({}, cornerlat , sourceNode.lon, undo.push); + var node2:Node=conn.createNode({}, cornerlat , cornerlon , undo.push); + var node3:Node=conn.createNode({}, sourceNode.lat, cornerlon , undo.push); + way = conn.createWay(sourceNode.getTagsCopy(), [sourceNode,node1,node2,node3,sourceNode], undo.push); + for (var k:String in sourceNode.getTagsCopy()) sourceNode.setTag(k, null, undo.push); + + MainUndoStack.getGlobalStack().addAction(undo); + } + override public function exitState(newState:ControllerState):void { + controller.map.draggable=true; + } + + override public function toString():String { + return "DrawQuadrilateral"; + } + } +} diff --git a/net/systemeD/potlatch2/controller/SelectedPOINode.as b/net/systemeD/potlatch2/controller/SelectedPOINode.as index 415004d5..178f2b00 100644 --- a/net/systemeD/potlatch2/controller/SelectedPOINode.as +++ b/net/systemeD/potlatch2/controller/SelectedPOINode.as @@ -35,6 +35,9 @@ package net.systemeD.potlatch2.controller { if (event.type==MouseEvent.MOUSE_DOWN && event.ctrlKey && entity && entity!=firstSelected) { return new SelectedMultiple([firstSelected,entity]); } + if (event.type==MouseEvent.MOUSE_DOWN && event.shiftKey && !entity) { + return new DrawQuadrilateral(firstSelected as Node); + } var cs:ControllerState = sharedMouseEvents(event, entity); return cs ? cs : this; } diff --git a/net/systemeD/potlatch2/find/FindDialog.mxml b/net/systemeD/potlatch2/find/FindDialog.mxml new file mode 100644 index 00000000..a64c90e7 --- /dev/null +++ b/net/systemeD/potlatch2/find/FindDialog.mxml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/net/systemeD/potlatch2/save/OAuthPanel.mxml b/net/systemeD/potlatch2/save/OAuthPanel.mxml index 096222e2..bada911a 100644 --- a/net/systemeD/potlatch2/save/OAuthPanel.mxml +++ b/net/systemeD/potlatch2/save/OAuthPanel.mxml @@ -67,11 +67,14 @@ diff --git a/potlatch2.mxml b/potlatch2.mxml index fbf700e5..368b7d38 100644 --- a/potlatch2.mxml +++ b/potlatch2.mxml @@ -72,6 +72,8 @@ rollOverEffect="glowImage" rollOutEffect="unglowImage" toolTip="{'Zoom in - currently z'+getScale()}" /> + @@ -87,6 +89,7 @@ import net.systemeD.halcyon.connection.*; import net.systemeD.potlatch2.*; import net.systemeD.potlatch2.save.SaveManager; + import net.systemeD.potlatch2.find.*; import net.systemeD.potlatch2.collections.*; import net.systemeD.potlatch2.controller.*; import net.systemeD.potlatch2.help.*; @@ -178,7 +181,7 @@ theMap.addEventListener(MapEvent.INITIALISED, function(e:Event):void { VectorBackgrounds.instance().init(theMap); }); theMap.backdrop=b; - yahoo=new Yahoo(w,h,theMap); + yahoo=new Yahoo(theMap); yahoo.hide(); _root.addChild(yahoo); _root.addChild(theMap); diff --git a/resources/imagery.xml b/resources/imagery.xml index f09c1bda..5caaf3b0 100644 --- a/resources/imagery.xml +++ b/resources/imagery.xml @@ -12,6 +12,15 @@ http://opengeodata.org/microsoft-imagery-details yes + + MapQuest Open Aerial + http://oatile1.mqcdn.com/naip/$z/$x/$y.png + + + Yahoo + yahoo + yahoo + OSM - Mapnik http://c.tile.openstreetmap.org/$z/$x/$y.png @@ -27,6 +36,11 @@ OSM - MapQuest http://otile1.mqcdn.com/tiles/1.0.0/osm/$z/$x/$y.png + + + OSM - Tiger Edited Map + 900913 + http://tiger-osm.mapquest.com/tiles/1.0.0/tiger/$z/$x/$y.png OS OpenData Streetview @@ -84,7 +98,16 @@ http://hypercube.telascience.org/tiles/1.0.0/haiti-city/$z/$x/$y.jpg Haiti streetnames - + + National Agriculture Imagery Program + http://cube.telascience.org/tilecache/tilecache.py/1.0.0/NAIP_ALL/$z/$x/$y.png + NAIP + + + National Agriculture Imagery Program + http://cube.telascience.org/tilecache/tilecache.py/1.0.0/NAIP_ALL/$z/$x/$y.png + NAIP + Denmark - Fugro Aerial Imagery http://fugro.findvej.dk/fugro2005/$z/$x/$y.jpg diff --git a/resources/ok_go.html b/resources/ok_go.html new file mode 100644 index 00000000..d6b1baf3 --- /dev/null +++ b/resources/ok_go.html @@ -0,0 +1,20 @@ + + + + + +SUCCESS! + + +go here to clear cache and see this window again + + + \ No newline at end of file diff --git a/resources/potlatch2.html b/resources/potlatch2.html index f4533ca6..cb1f0a94 100644 --- a/resources/potlatch2.html +++ b/resources/potlatch2.html @@ -5,12 +5,6 @@ Potlatch TWO - - - - - - + + + + + + + + If you see this message you need to install Flash Play 9.0 or above, from Adobe, available here in order to use Potlatch 2 + -