categories of additional tags for roads
authorDave Stubbs <osm@randomjunk.co.uk>
Fri, 11 Sep 2009 19:34:34 +0000 (19:34 +0000)
committerDave Stubbs <osm@randomjunk.co.uk>
Fri, 11 Sep 2009 19:34:34 +0000 (19:34 +0000)
12 files changed:
lib/flexlib.swc [new file with mode: 0644]
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/EditorFactory.as
net/systemeD/potlatch2/mapfeatures/Feature.as
net/systemeD/potlatch2/mapfeatures/MapFeatures.as
net/systemeD/potlatch2/mapfeatures/editors/ChoiceComboBox.as
net/systemeD/potlatch2/mapfeatures/editors/ChoiceEditor.mxml
net/systemeD/potlatch2/mapfeatures/editors/FreeTextEditor.mxml
net/systemeD/potlatch2/mapfeatures/editors/FreeTextEditorFactory.as
net/systemeD/potlatch2/mapfeatures/editors/RestrictionRenderer.mxml
net/systemeD/potlatch2/mapfeatures/editors/SpeedEditor.mxml
resources/map_features.xml

diff --git a/lib/flexlib.swc b/lib/flexlib.swc
new file mode 100644 (file)
index 0000000..597c87b
Binary files /dev/null and b/lib/flexlib.swc differ
index 064cd25..bdcf17e 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <mx:VBox
-       xmlns:mx="http://www.adobe.com/2006/mxml" 
+       xmlns:mx="http://www.adobe.com/2006/mxml"
+       xmlns:flexlib="flexlib.containers.*"
     backgroundColor="white"
     creationComplete="loadFeatures()">
 
@@ -14,7 +15,9 @@
         </mx:VBox>
         <mx:LinkButton label="?" click="openDescription()" id="helpLabel"/>
     </mx:HBox>
-    <mx:VBox width="100%" id="editorBox" paddingLeft="2" paddingRight="2"/>
+    <flexlib:SuperTabNavigator id="editorStack" width="100%" height="100%" paddingLeft="2" paddingRight="2"
+        allowTabSqueezing="false" minTabWidth="10" closePolicy="close_never"
+        scrollSpeed="20"/>
   </mx:VBox>
 
   <mx:VBox width="100%" height="100%" label="Advanced" initialize="checkAdvanced()" verticalGap="1">
       }
 
       private function initialiseEditors():void {
-          editorBox.removeAllChildren();
+          editorStack.removeAllChildren();
           if ( selectedEntity == null || feature == null )
               return;
-              
+          
+          var editorBox:VBox = createEditorBox();
+          editorBox.label = "Basic";
+          editorStack.addChild(editorBox);
+          
+          var tabs:Object = {};
+          
           for each (var factory:EditorFactory in feature.editors) {
-              var editor:DisplayObject = factory.createEditorInstance(selectedEntity);
-              if ( editor != null )
-                 editorBox.addChild(editor);
+              if ( factory.presence.isEditorPresent(factory, selectedEntity, null) ) {
+                  var editor:DisplayObject = factory.createEditorInstance(selectedEntity);
+                  if ( editor != null )
+                      editorBox.addChild(editor);
+              }
+              var category:String = factory.category;
+              var tab:VBox = tabs[category];
+              if ( tab == null ) {
+                  tab = createEditorBox();
+                  tab.label = category;
+                  editorStack.addChild(tab);
+                  tabs[category] = tab;
+              }
+              var catEditor:DisplayObject = factory.createEditorInstance(selectedEntity);
+              if ( catEditor != null )
+                  tab.addChild(catEditor);
           }
       }
       
+      private function createEditorBox():VBox {
+          var box:VBox = new VBox();
+          box.percentWidth = 100;
+          box.percentHeight = 100;
+          return box;
+      }
+
       private function checkAdvanced():void {
           if ( selectedEntity != null )
              setupAdvanced(selectedEntity);
index 4cd9b1d..3b8a002 100644 (file)
@@ -43,8 +43,9 @@ package net.systemeD.potlatch2.mapfeatures {
         private var _description:String;
         
         public function EditorFactory(inputXML:XML) {
-            _name = inputXML.@name;
-            _description = inputXML.@description;
+            _name = String(inputXML.@name);
+            _description = String(inputXML.@description);
+            category = String(inputXML.@category);
         }
         
         public function areTagsMatching(entity:Entity):Boolean {
index 2a25052..e24c827 100644 (file)
@@ -32,21 +32,37 @@ package net.systemeD.potlatch2.mapfeatures {
         private function parseEditors():void {
             _editors = new Array();
             
-            for each(var inputXML:XML in definition.input) {
-                var inputType:String = inputXML.@type;
-                var presenceStr:String = inputXML.@presence;
-                var sortOrderStr:String = inputXML.@priority;
-                var editor:EditorFactory = EditorFactory.createFactory(inputType, inputXML);
-                if ( editor != null ) {
-                    editor.presence = Presence.getPresence(presenceStr);
-                    editor.sortOrder = EditorFactory.getPriority(sortOrderStr);
-                    _editors.push(editor);
+            addEditors(definition);
+            
+            _editors.sortOn(["sortOrder", "name"], [Array.DESCENDING | Array.NUMERIC, Array.CASEINSENSITIVE]);
+        }
+        
+        private function addEditors(xml:XML):void {
+            var inputXML:XML;
+            
+            for each(var inputSetRef:XML in xml.inputSet) {
+                var setName:String = String(inputSetRef.@ref);
+                for each (inputXML in mapFeatures.definition.inputSet.(@id==setName)) {
+                    addEditors(inputXML);
                 }
             }
             
-            _editors.sortOn(["sortOrder", "name"], [Array.DESCENDING | Array.NUMERIC, Array.CASEINSENSITIVE]);
+            for each(inputXML in xml.input) {
+                addEditor(inputXML);
+            }
         }
         
+        private function addEditor(inputXML:XML):void {
+            var inputType:String = inputXML.@type;
+            var presenceStr:String = inputXML.@presence;
+            var sortOrderStr:String = inputXML.@priority;
+            var editor:EditorFactory = EditorFactory.createFactory(inputType, inputXML);
+            if ( editor != null ) {
+                editor.presence = Presence.getPresence(presenceStr);
+                editor.sortOrder = EditorFactory.getPriority(sortOrderStr);
+                _editors.push(editor);
+            }
+        }
         public function get editors():Array {
             return _editors;
         }
index 40dfc06..9a699ac 100644 (file)
@@ -35,6 +35,10 @@ package net.systemeD.potlatch2.mapfeatures {
             loader.load(request);
         }
 
+        internal function get definition():XML {
+            return xml;
+        }
+        
         private function onFeatureLoad(event:Event):void {
             xml = new XML(URLLoader(event.target).data);
             
index e9d4e27..ed1a372 100644 (file)
@@ -55,6 +55,7 @@ package net.systemeD.potlatch2.mapfeatures.editors {
 
             if ( textInputReplacement ) {
                 IDataRenderer(textInputReplacement).data = selectedItem;
+                var prefSize:Object = calculatePreferredSizeFromData(collection.length);
 
                 var arrowWidth:Number = getStyle("arrowButtonWidth");\r
                 var itemHeight:Number = textInputReplacement.getExplicitOrMeasuredHeight();\r
@@ -65,13 +66,33 @@ package net.systemeD.potlatch2.mapfeatures.editors {
 
                 var bm:EdgeMetrics = borderMetrics;
                 itemHeight += bm.top + bm.bottom;\r
-                itemWidth += bm.left + bm.right + arrowWidth;\r
+                itemWidth += bm.left + bm.right + arrowWidth + 8;
+                prefSize.height += bm.top + bm.bottom;
+                prefSize.width += bm.left + bm.right + arrowWidth + 8;\r
 
-                measuredMinHeight = measuredHeight = Math.max(measuredHeight, itemHeight);\r
-                measuredMinWidth = measuredWidth = Math.max(measuredWidth, itemWidth);\r
+                measuredMinHeight = measuredHeight = Math.max(prefSize.height, itemHeight);\r
+                measuredMinWidth = measuredWidth = Math.max(prefSize.width, itemWidth);\r
             }
         }
 
+        override protected function calculatePreferredSizeFromData(numItems:int):Object {
+            if ( collection == null ) return { width: 0, height: 0 };
+            
+            var maxWidth:Number = 0;
+            var maxHeight:Number = 0;
+            
+            var test:UIComponent = itemRenderer.newInstance();
+            addChild(test)
+            for ( var i:int = 0; i < numItems; i++ ) {
+                IDataRenderer(test).data = collection[i];
+                test.validateDisplayList();
+                test.validateSize(true);
+                maxWidth = Math.max(maxWidth, test.getExplicitOrMeasuredWidth());\r
+                maxHeight = Math.max(maxHeight, test.getExplicitOrMeasuredHeight());\r
+            }
+            removeChild(test);
+            return {width: maxWidth, height: maxHeight};
+        }
     }
 }
 
index fa03e3a..0126334 100644 (file)
@@ -3,12 +3,11 @@
        xmlns:mx="http://www.adobe.com/2006/mxml" 
        xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
        verticalGap="0"
-       width="100%"
        toolTip="{fieldDescription}">
 
   <mx:Label text="{fieldName}:"/>
   <edit:ChoiceComboBox id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
-      width="100%" change="value = inputBox.selectedItem.value"
+      change="value = inputBox.selectedItem.value"
       open="inputBox.dropdown.variableRowHeight = true">
       <edit:itemRenderer>
         <mx:Component>
index 310ba08..0c9819c 100644 (file)
@@ -2,12 +2,21 @@
 <edit:SingleTagEditor
        xmlns:mx="http://www.adobe.com/2006/mxml" 
        xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
+       xmlns:flexlib="flexlib.controls.*"
        verticalGap="0"
        width="100%"
        toolTip="{fieldDescription}">
 
   <mx:Label text="{fieldName}:"/>
-  <mx:TextInput id="inputBox" text="{value}" width="100%" change="value = inputBox.text"/>
+  <flexlib:PromptingTextInput id="inputBox" prompt="{prompt}" text="{value}" width="100%" change="value = inputBox.text"/>
 
+  <mx:Script><![CDATA[
+  
+      [Bindable(event="factory_set")]
+      protected function get prompt():String {
+          return _factory == null ? null : FreeTextEditorFactory(_factory).notPresentText;
+      }
+      
+  ]]></mx:Script>
 </edit:SingleTagEditor>
 
index 2fd25ce..2b209e2 100644 (file)
@@ -5,16 +5,20 @@ package net.systemeD.potlatch2.mapfeatures.editors {
     import flash.display.*;
 
        public class FreeTextEditorFactory extends SingleTagEditorFactory {
-           private var notPresentText:String;
+           private var _notPresentText:String;
         
         public function FreeTextEditorFactory(inputXML:XML) {
             super(inputXML);
-            notPresentText = inputXML.@absenceHTMLText;
+            _notPresentText = inputXML.hasOwnProperty("@absenceText") ? String(inputXML.@absenceText) : "Unset";
         }
         
         override protected function createSingleTagEditor():SingleTagEditor {
             return new FreeTextEditor();
         }
+        
+        public function get notPresentText():String {
+            return _notPresentText;
+        }
     }
 
 }
index 6a941b5..b075186 100644 (file)
@@ -2,7 +2,7 @@
 <mx:Canvas
        xmlns:mx="http://www.adobe.com/2006/mxml" 
        xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
-       width="50" height="50"
+       width="50" height="50" maxWidth="50" maxHeight="50" minWidth="50" minHeight="50"
        toolTip="{data.description}" enabled="{data.value != null}"
        mouseEnabled="false" mouseChildren="false">
 
index 37a81f0..9a74d39 100644 (file)
@@ -2,16 +2,16 @@
 <edit:SingleTagEditor
        xmlns:mx="http://www.adobe.com/2006/mxml" 
        xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
-       verticalGap="0"
-       width="100%"
-       toolTip="{fieldDescription}">
+       toolTip="{fieldDescription}"
+       verticalGap="0">
 
   <mx:Label text="{fieldName}:"/>
   <edit:ChoiceComboBox id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
       dropdownFactory="mx.controls.TileList"
-      width="100%" change="value = inputBox.selectedItem.value"
-      open="inputBox.dropdown.variableRowHeight = true"
-      itemRenderer="net.systemeD.potlatch2.mapfeatures.editors.RestrictionRenderer">
+      change="value = inputBox.selectedItem.value"
+      itemRenderer="net.systemeD.potlatch2.mapfeatures.editors.RestrictionRenderer"
+      dropdownWidth="250" rowCount="4"
+      fontWeight="normal">
   </edit:ChoiceComboBox>
 
   <mx:Script><![CDATA[
index 5e34c7c..e262df6 100644 (file)
   </category>
 
   <!-- Roads -->
+  
+  <inputSet id="majorRoad">
+    <inputSet ref="roadNames"/>
+    <inputSet ref="roadRefs"/>
+    <inputSet ref="roadRestrictions"/>
+    <inputSet ref="roadPhysical"/>
+  </inputSet>
+  
+  <inputSet id="minorRoad">
+    <inputSet ref="roadNames"/>
+    <inputSet ref="roadRestrictions"/>
+    <inputSet ref="roadPhysical"/>
+  </inputSet>
+  
+  <inputSet id="roadNames">
+    <input type="freetext" presence="always"
+        name="Name" category="Naming" priority="highest"
+        key="name" description="The most common name"/>
+    <input type="freetext" presence="onTagMatch"
+        name="International Name" category="Naming"
+        key="int_name" description="The internationally recognised name"/>
+    <input type="freetext" presence="onTagMatch"
+        name="Historical Name" category="Naming" priority="low"
+        key="old_name" description="The historic or previous name"/>
+  </inputSet>
+
+  <inputSet id="roadRefs">
+    <input type="freetext" presence="always"
+        name="Reference" category="Naming" priority="high"
+        key="ref" description="The official reference number"/>
+    <input type="freetext" presence="onTagMatch"
+        name="International Reference" category="Naming"
+        key="int_ref" description="The official international reference number"/>
+    <input type="freetext" presence="onTagMatch"
+        name="Old Reference" category="Naming" priority="low"
+        key="old_ref" description="The historic or previous reference number"/>  
+  </inputSet>
+  
+  <inputSet id="roadPhysical">
+    <input type="slider" presence="onTagMatch"
+        name="Layer" category="Physical" description="Relative vertical positions (-5 lowest, +5 highest)"
+        key="layer" min="-5" max="5" default="0"/>
+    <input type="freetext" presence="onTagMatch"
+        name="Width" category="Physical"
+        key="width" description="Width of the road"/>
+    <input type="choice" presence="onTagMatch"
+        name="Surface" category="Physical" description="Type of road surface"
+        key="surface">
+      <choice value="unpaved" text="Unpaved" description="Road surface is unsealed"/>
+      <choice value="paved" text="Paved" description="Road surface is sealed"/>
+      <choice value="asphalt" text="Asphalt"/>
+      <choice value="concrete" text="Concrete"/>
+      <choice value="paving_stones" text="Paving stones"/>
+      <choice value="cobblestone" text="Cobblestone"/>
+      <choice value="sand" text="Sand"/>
+      <choice value="gravel" text="Gravel"/>
+    </input>
+    <input type="choice" presence="onTagMatch"
+        name="Bridge" category="Physical" description="Road goes over a bridge"
+        key="bridge">
+      <choice value="yes" text="Generic Bridge" description="Generic bridge -- type unknown"/>
+      <choice value="viaduct" text="Viaduct" description="Viaduct"/>
+      <choice value="suspension" text="Suspension bridge"/>
+    </input>
+    <input type="choice" presence="onTagMatch"
+        name="Tunnel" category="Physical" description="Road goes into a tunnel"
+        key="tunnel">
+      <choice value="yes" text="Tunnel" description="Generic tunnel"/>
+    </input>
+  </inputSet>
 
+  <inputSet id="roadRestrictions">
+    <input type="choice" presence="onTagMatch"
+        name="Oneway" category="Restrictions" description="Oneway roads"
+        key="oneway">
+      <choice value="yes" match="yes|true|1" text="One way"
+        description="Road can only be travelled in direction of way" icon="features/oneway__yes.png"/>
+      <choice value="no" match="no|false|0" text="Two way"
+        description="Road can be travelled in both directions" icon="features/oneway__no.png"/>
+      <choice value="-1" match="-1|reverse" text="One way reverse"
+        description="Road can be travelled in opposite direction to way" icon="features/oneway__-1.png"/>
+    </input>
+    <input type="speed" presence="onTagMatch"
+        name="Speed Limit" category="Restrictions" description="Maximum permitted speed on this road"
+        key="maxspeed"/>
+  </inputSet>
+    
   <feature name="Motorway">
     <category>roads</category>
     <icon image="features/highway__motorway.png">
 
     <line/>
     <tag k="highway" v="motorway"/>
+
+    <inputSet ref="majorRoad"/>
   </feature>
 
   <feature name="Motorway link" icon="features/motorway_link.png">
     <category>roads</category>
     <line/>
     <tag k="highway" v="motorway_link"/>
+
+    <inputSet ref="majorRoad"/>
   </feature>
 
   <feature name="Trunk Road">
     <line/>
     <tag k="highway" v="trunk"/>
     
-    <input type="freetext" presence="always"
-        name="Name" category="Naming" priority="highest"
-        key="name" description="The most common name for this road"/>
-    <input type="freetext" presence="always"
-        name="Reference" category="Naming" priority="high"
-        key="ref" description="The official reference number for this road"/>
-    <input type="choice" presence="always"
-        name="Surface" category="Physical" description="Type of road surface"
-        key="surface">
-      <choice value="unpaved" text="Unpaved" description="Road surface is unsealed"/>
-      <choice value="paved" text="Paved" description="Road surface is sealed"/>
-    </input>
-    <input type="choice" presence="onTagMatch"
-        name="Oneway" category="Restrictions" description="Oneway roads"
-        key="oneway">
-      <choice value="yes" match="yes|true|1" text="One way"
-        description="Road can only be travelled in direction of way" icon="features/oneway__yes.png"/>
-      <choice value="no" match="no|false|0" text="Two way"
-        description="Road can be travelled in both directions" icon="features/oneway__no.png"/>
-      <choice value="-1" match="-1|reverse" text="One way reverse"
-        description="Road can be travelled in opposite direction to way" icon="features/oneway__-1.png"/>
-    </input>
-    <input type="speed" presence="onTagMatch"
-        name="Speed Limit" category="Restrictions" description="Maximum permitted speed on this road"
-        key="maxspeed"/>
+    <inputSet ref="majorRoad"/>
   </feature>
 
   <feature name="Primary Road">
 
     <line/>
     <tag k="highway" v="primary"/>
+
+    <inputSet ref="majorRoad"/>
   </feature>
 
   <feature name="Secondary Road">
 
     <line/>
     <tag k="highway" v="secondary"/>
+
+    <inputSet ref="majorRoad"/>
   </feature>
 
   <feature name="Tertiary Road">
 
     <line/>
     <tag k="highway" v="tertiary"/>
+
+    <inputSet ref="majorRoad"/>
   </feature>
 
   <feature name="Residential Road">
 
     <line/>
     <tag k="highway" v="residential"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>
 
   <feature name="Road">
 
     <line/>
     <tag k="highway" v="unclassified"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>
 
   <feature name="Service Road">
 
     <line/>
     <tag k="highway" v="service"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>
 
   <feature name="Unknown Road">
 
     <line/>
     <tag k="highway" v="road"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>
 
   <feature name="Living Street">
 
     <line/>
     <tag k="highway" v="tertiary"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>
 
   <feature name="Track">
 
     <line/>
     <tag k="highway" v="track"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>
 
   <feature name="Pedestrian Road">
 
     <line/>
     <tag k="highway" v="pedestrian"/>
+
+    <inputSet ref="minorRoad"/>
   </feature>