Use the inputSets to add more autocomplete keys
authorAndy Allan <andy@gravitystorm.co.uk>
Sun, 22 May 2011 17:00:10 +0000 (18:00 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Sun, 22 May 2011 17:00:10 +0000 (18:00 +0100)
net/systemeD/potlatch2/mapfeatures/Feature.as
net/systemeD/potlatch2/mapfeatures/MapFeatures.as

index 007c87e..beb69ff 100644 (file)
@@ -81,7 +81,6 @@ package net.systemeD.potlatch2.mapfeatures {
             var inputType:String = inputXML.@type;
             var presenceStr:String = inputXML.@presence;
             var sortOrderStr:String = inputXML.@priority;
-//          _tags.push( { k:String(inputXML.@key) } ); /* add the key to tags so that e.g. addr:housenumber shows up on autocomplete */
             var editor:EditorFactory = EditorFactory.createFactory(inputType, inputXML);
             if ( editor != null ) {
                 editor.presence = Presence.getPresence(presenceStr);
index e7ce895..789241a 100644 (file)
@@ -59,6 +59,10 @@ package net.systemeD.potlatch2.mapfeatures {
                     if (f.isType('relation'))                 { addToTagList('relation',tag); }
                     if (f.isType('point'))                    { addToTagList('node',tag); }
                 }
+
+                for each (var inputSet:XML in feature..inputSet) {
+                    tagsFromInputSet(definition.inputSet.(@id == String(inputSet.@ref)), f);
+                }
             }
 
             _categories = new Array();
@@ -69,6 +73,23 @@ package net.systemeD.potlatch2.mapfeatures {
             dispatchEvent(new Event("featuresLoaded"));
         }
 
+        private function tagsFromInputSet(inputSet:XMLList, f:Feature):void {
+            for each (var input:XML in inputSet.input) {
+                // Take all the k/v pairs from inputs that have choice
+                // Todo - add the freetext keys (source, addr:housenumber etc)
+                for each (var choice:XML in input..choice ) {
+                    if (f.isType('line') || f.isType('area')) { addToTagList('way', {k:String(input.@key), v:String(choice.@value)}); }
+                    if (f.isType('relation'))                 { addToTagList('relation',{k:String(input.@key), v:String(choice.@value)}); }
+                    if (f.isType('point'))                    { addToTagList('node',{k:String(input.@key), v:String(choice.@value)}); }
+                }
+            }
+
+            // inputSets can have their own inputSets, so recurse
+            for each (var i:XML in inputSet.inputSet) {
+                tagsFromInputSet(definition.inputSet.(@id == String(i.@ref)), f);
+            }
+        }
+
         /** Add one item to tagList index, which will end up being a list like: ["way"]["highway"]["residential"] */
                private function addToTagList(type:String,tag:Object):void {
                        if (tag.v=='*') { return; }