complete arbitrary sublayer support; fix roundabout tagging issue; couple of small...
authorRichard Fairhurst <richard@systemed.net>
Wed, 30 Jun 2010 08:55:09 +0000 (08:55 +0000)
committerRichard Fairhurst <richard@systemed.net>
Wed, 30 Jun 2010 08:55:09 +0000 (08:55 +0000)
TODO.txt
net/systemeD/halcyon/MapPaint.as
net/systemeD/halcyon/NodeUI.as
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/styleparser/Rule.as
net/systemeD/halcyon/styleparser/RuleSet.as
net/systemeD/halcyon/styleparser/StyleChooser.as
net/systemeD/halcyon/styleparser/StyleList.as
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/Feature.as

index 542fe5c..c7d68f3 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,7 +4,7 @@ Potlatch 2: main outstanding issues
 
 == Core geometry ==
 
-* Dragging multipolygons (or constituent nodes) doesn't force redraw of all ways - need to hook something up to WAY_NODE_MOVED
+** Dragging/creating multipolygons (or constituent nodes) doesn't force redraw of all ways - need to hook something up to WAY_NODE_MOVED
 * Make parallelise properly undoable
 * Make Quadralatalawhatsit properly undoable
 * Splitway + undo leaves way marked dirty
@@ -27,7 +27,7 @@ Potlatch 2: main outstanding issues
 
 == Tag editing ==
 
-** Roundabouts are recognised as areas, so you don't get highway types etc.
+* initialiseEditors is quite slow (typically 150ms)
 * Dynamic reloading of stylesheet/map_features, so that you don't need to reload the full page when editing them
 * If a select name is too long then, the select menu seems to give a horizontal scrollbar instead of the name of the item e.g. cuisine#Coffee Shop
 * If you have both inputSets names and buildingAddress, and name= key is filled in then the basic tab will get both, surely only name should be shown and building name should be ignored e.g. cafes. [Actually this was an issue of addr: being missing from one of them, however this may still be a problem for other overlapping inputSets]
@@ -49,7 +49,6 @@ Potlatch 2: main outstanding issues
 * Mouse wheel zooming
 * CSS editing
 * Quick-search on add-relations-to-way dialog (RelationSelectPanel)
-* Bug: when drawing way, escape ends drawing. Should revert to previous way.
 * i18n
 * Multiple selection
 * Options should be remembered via SharedObjects
@@ -60,12 +59,11 @@ Potlatch 2: main outstanding issues
 
 == Rendering (Halcyon) ==
 
-* StyleList and everything that iterates over it needs to cope with arbitrary sublayers
+** { interactive: no; } - stop items being clicked on (and their maxwidth being taken into account)
 * halcyon_viewer needs updating for new tileurl stuff
-* { interactive: no; } - stop items being clicked on (and their maxwidth being taken into account)
 * Shields
 * More line decoration (cliffs etc.), and implied values for 'dashes' if not supplied
-* Complete MapCSS support
+* MapCSS 0.2 support
 * 'Light' version without vectorlayer support etc.
 * .gz support for OSMConnection
 * Multipolygon rendering for dashedLine, lineDecoration, and WayBitmapFiller
index 9c4f132..ff06729 100644 (file)
@@ -19,7 +19,7 @@ package net.systemeD.halcyon {
                public var wayuis:Object=new Object();                  // sprites for ways and (POI/tagged) nodes
                public var nodeuis:Object=new Object();                 //  |
                public var isBackground:Boolean = true;                 // is it a background layer or the core paint object?
-               private var sublayerIndex:Object={};                    // hash of index->position
+               public var sublayerIndex:Object={};                             // hash of index->position
 
                private const VERYBIG:Number=Math.pow(2,16);
 
index be74693..02ccbb8 100644 (file)
@@ -44,7 +44,7 @@ package net.systemeD.halcyon {
                        var tags:Object = entity.getTagsCopy();
                        tags=applyStateClasses(tags);
                        if (!entity.hasParentWays) { tags[':poi']='yes'; }
-                       if (!sl) { sl=paint.ruleset.getStyles(entity,tags); }
+                       if (!sl) { sl=paint.ruleset.getStyles(entity,tags,paint.map.scale); }
 
                        var inWay:Boolean=entity.hasParentWays;
                        var hasStyles:Boolean=sl.hasStyles();
@@ -58,7 +58,7 @@ package net.systemeD.halcyon {
                        var w:Number;
                        var icon:Sprite;
                        layer=paint.maxlayer;
-                       for (var sublayer:int=10; sublayer>=0; sublayer--) {
+                       for each (var sublayer:Number in sl.sublayers) {
 
                                if (sl.pointStyles[sublayer]) {
                                        var s:PointStyle=sl.pointStyles[sublayer];
index 291fb48..a29fe49 100755 (executable)
@@ -152,14 +152,14 @@ package net.systemeD.halcyon {
                        var maxwidth:Number=4;
 
                        // Iterate through each sublayer, drawing any styles on that layer
-                       if (!sl) { sl=paint.ruleset.getStyles(entity, tags); }
+                       if (!sl) { sl=paint.ruleset.getStyles(entity, tags, paint.map.scale); }
                        var drawn:Boolean;
                        var multis:Array=entity.findParentRelationsOfType('multipolygon','outer');
                        var inners:Array=[];
                        for each (var m:Relation in multis) {
                                inners=inners.concat(m.findMembersByRole('inner'));
                        }
-                       for (var sublayer:int=10; sublayer>=0; sublayer--) {
+                       for each (var sublayer:Number in sl.sublayers) {
                                if (sl.shapeStyles[sublayer]) {
                                        var s:ShapeStyle=sl.shapeStyles[sublayer];
                                        var stroke:Shape, fill:Shape, casing:Shape, roadname:Sprite;
@@ -237,7 +237,7 @@ package net.systemeD.halcyon {
                                if (stateClasses["showNodesHover"]) { nodetags[':hoverway']='yes'; }
                                if (node.id==nodeSelected) { nodetags[':selected']='yes'; }
                                if (node.numParentWays>1) { nodetags[':junction']='yes'; }
-                               sl=paint.ruleset.getStyles(node,nodetags);
+                               sl=paint.ruleset.getStyles(node, nodetags, paint.map.scale);
                                if (sl.hasStyles()) {
                                        if (paint.nodeuis[node.id]) {
                                                paint.nodeuis[node.id].redraw(sl);
index 9d210d7..cb54ed5 100644 (file)
@@ -14,8 +14,9 @@ package net.systemeD.halcyon.styleparser {
                        subject=s;
                }
                
-               public function test(obj:Entity,tags:Object):Boolean {
+               public function test(obj:Entity,tags:Object,zoom:uint):Boolean {
                        if (subject!='' && obj.getType()!=subject) { return false; }
+                       if (zoom<minZoom || zoom>maxZoom) { return false; }
                        
                        var v:Boolean=true; var i:uint=0;
                        for each (var condition:Condition in conditions) {
index d5aeeea..3a1fd7a 100644 (file)
@@ -226,10 +226,10 @@ package net.systemeD.halcyon.styleparser {
 
                // Get styles for an object
 
-               public function getStyles(obj:Entity,tags:Object):StyleList {
+               public function getStyles(obj:Entity, tags:Object, zoom:uint):StyleList {
                        var sl:StyleList=new StyleList();
                        for each (var sc:StyleChooser in choosers) {
-                               sc.updateStyles(obj,tags,sl,imageWidths);
+                               sc.updateStyles(obj,tags,sl,imageWidths,zoom);
                        }
                        return sl;
                }
index b73c621..8270b3f 100755 (executable)
@@ -31,13 +31,13 @@ package net.systemeD.halcyon.styleparser {
 
                // Update the current StyleList from this StyleChooser
 
-               public function updateStyles(obj:Entity, tags:Object, sl:StyleList, imageWidths:Object):void {
+               public function updateStyles(obj:Entity, tags:Object, sl:StyleList, imageWidths:Object, zoom:uint):void {
                        // Are any of the ruleChains fulfilled?
                        // ** needs to cope with min/max zoom
                        var w:Number;
                        var fulfilled:Boolean=false;
                        for each (var c:Array in ruleChains) {
-                               if (testChain(c,-1,obj,tags)) {
+                               if (testChain(c,-1,obj,tags,zoom)) {
                                        fulfilled=true; break;
                                }
                        }
@@ -73,6 +73,7 @@ package net.systemeD.halcyon.styleparser {
                                tags['_width']=sl.maxwidth;
                                
                                r.runEvals(tags);
+                               sl.addSublayer(r.sublayer);
                                if (a[r.sublayer]) {
                                        // If there's already a style on this sublayer, then merge them
                                        // (making a deep copy if necessary to avoid altering the root style)
@@ -94,16 +95,16 @@ package net.systemeD.halcyon.styleparser {
                // - if they succeed, and it's the last in the chain, return happily
                // - if they succeed, and there's more in the chain, rerun this for each parent until success
                
-               private function testChain(chain:Array,pos:int,obj:Entity,tags:Object):Boolean {
+               private function testChain(chain:Array,pos:int,obj:Entity,tags:Object,zoom:uint):Boolean {
                        if (pos==-1) { pos=chain.length-1; }
 
                        var r:Rule=chain[pos];
-                       if (!r.test(obj, tags)) { return false; }
+                       if (!r.test(obj, tags, zoom)) { return false; }
                        if (pos==0) { return true; }
                        
                        var o:Array=obj.parentObjects;
                        for each (var p:Entity in o) {
-                               if (testChain(chain, pos-1, p, p.getTagsHash() )) { return true; }
+                               if (testChain(chain, pos-1, p, p.getTagsHash(), zoom )) { return true; }
                        }
                        return false;
                }
index f00715f..0f8c4c5 100755 (executable)
@@ -11,14 +11,24 @@ package net.systemeD.halcyon.styleparser {
 
                */
 
-               public var shapeStyles:Array=[];
-               public var textStyles:Array=[];
-               public var pointStyles:Array=[];
-               public var shieldStyles:Array=[];
+               public var shapeStyles:Object={};
+               public var textStyles:Object={};
+               public var pointStyles:Object={};
+               public var shieldStyles:Object={};
                public var maxwidth:Number=0;
+               public var sublayers:Array=[];
 
                public function hasStyles():Boolean {
-                       return ( (shapeStyles.length + textStyles.length + pointStyles.length + shieldStyles.length) > 0 );
+                       return ( hasShapeStyles() || hasTextStyles() || hasPointStyles() || hasShieldStyles() );
                }
+               
+               public function addSublayer(s:Number):void {
+                       if (sublayers.indexOf(s)==-1) { sublayers.push(s); }
+               }
+
+               private function hasShapeStyles():Boolean  { for (var a:String in shapeStyles ) { return true; }; return false; }
+               private function hasTextStyles():Boolean   { for (var a:String in textStyles  ) { return true; }; return false; }
+               private function hasPointStyles():Boolean  { for (var a:String in pointStyles ) { return true; }; return false; }
+               private function hasShieldStyles():Boolean { for (var a:String in shieldStyles) { return true; }; return false; }
        }
-}
\ No newline at end of file
+}
index f4b0f40..69d7101 100644 (file)
@@ -39,7 +39,7 @@
     </mx:TileList>
   </mx:VBox>
   
-  <mx:VBox id="tagsPanel" width="100%" height="100%">
+  <mx:VBox id="tagsPanel" width="100%" height="100%" creationPolicy="auto">
     <mx:ViewStack id="stack" width="100%" height="100%">
       <mx:VBox width="100%" height="100%" label="Simple">
         <mx:HBox borderStyle="inset" verticalAlign="middle" width="100%" paddingLeft="3" id="iconContainer">
@@ -52,7 +52,7 @@
         </mx:HBox>
         <flexlib:SuperTabNavigator id="editorStack" width="100%" height="100%" paddingLeft="2" paddingRight="2"
             allowTabSqueezing="false" minTabWidth="10" closePolicy="close_never"
-                       updateComplete="tabSelected()" 
+                       updateComplete="tabSelected()" creationPolicy="auto" 
             scrollSpeed="20" change="ensureEditorsPopulated(IndexChangedEvent(event).relatedObject as VBox)"/>
       </mx:VBox>
 
       private var feature:Feature = null;
 
       public function setEntity(entity:Entity):void {
+          UIComponent.suspendBackgroundProcessing();
           if ( selectedEntity != entity ) {
               if ( selectedEntity != null )
                   selectedEntity.removeEventListener(Connection.TAG_CHANGED, tagChanged);
             initialiseEditors();
             sidebar.selectedChild = tagsPanel;
           }
+          UIComponent.resumeBackgroundProcessing();
       }
 
       private function refreshFeatureIcon():void {
           if ( selectedEntity == null )
               return;
 
+          UIComponent.suspendBackgroundProcessing();
           var newFeature:Feature = tw.selectedType;
           var undoStack:Function = MainUndoStack.getGlobalStack().addAction;
           var action:CompositeUndoableAction = new CompositeUndoableAction(
           undoStack(action);
           popupChange.close();
           initialiseEditors();
+          UIComponent.resumeBackgroundProcessing();
       }
       
       private function dragPOI(event:MouseEvent, tags:Array):void {
index f4dce50..fac24df 100644 (file)
@@ -151,7 +151,11 @@ package net.systemeD.potlatch2.mapfeatures {
         }
         
         public function isType(type:String):Boolean {
-            return _xml.elements(type).length() > 0;
+            if (type=='area') {
+                           return (_xml.elements(type).length() > 0) || (_xml.elements('line').length() > 0);
+            } else {
+                           return _xml.elements(type).length() > 0;
+                       }
         }
         
         public function hasHelpURL():Boolean {