Removed executable flag from files which don't need it.
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / MapFeatures.as
index 9319190082735ac60c8e68b936d9b3349c0826d4..072d78a9a7660a4255042d0e684f7983e22e3893 100644 (file)
@@ -27,7 +27,7 @@ package net.systemeD.potlatch2.mapfeatures {
         private var xml:XML = null;
         private var _features:Array = null;
         private var _categories:Array = null;
-               private var _keys:Array = null;
+//             private var _keys:Array = null;
                private var _tags:Object = null;
 
         protected function loadFeatures():void {
@@ -46,18 +46,17 @@ package net.systemeD.potlatch2.mapfeatures {
 
             xml = new XML(URLLoader(event.target).data);
             _features = [];
-                       _keys = [];
-                       _tags = {};
+                       _tags = { relation:{}, way:{}, node:{} };
 
             for each(var feature:XML in xml.feature) {
                 f=new Feature(this,feature);
                                _features.push(f);
                                for each (var tag:Object in f.tags) {
-                                       if (!_tags[tag.k]) { _tags[tag.k]=new Object; _keys.push(tag.k); }
-                                       _tags[tag.k][tag.v]=true;
+                                       if (f.isType('line') || f.isType('area')) { addToTagList('way',tag); }
+                                       if (f.isType('relation'))                                 { addToTagList('relation',tag); }
+                                       if (f.isType('point'))                                    { addToTagList('node',tag); }
                                }
             }            
-                       _keys.sort();
 
             _categories = new Array();
             for each(var catXML:XML in xml.category) {
@@ -67,6 +66,12 @@ package net.systemeD.potlatch2.mapfeatures {
             dispatchEvent(new Event("featuresLoaded"));
         }
 
+               private function addToTagList(type:String,tag:Object):void {
+                       if (tag.v=='*') { return; }
+                       if (!_tags[type][tag.k]) { _tags[type][tag.k]=new Array(); }
+                       if (_tags[type][tag.k].indexOf(tag.v)==-1) { _tags[type][tag.k].push(tag.v); }
+               }
+
         public function hasLoaded():Boolean {
             return xml != null;
         }
@@ -144,15 +149,25 @@ package net.systemeD.potlatch2.mapfeatures {
         }
 
                [Bindable(event="featuresLoaded")]
-               public function getAutoCompleteKeys():Array {
-                       return _keys;
-               }
-               
-               public function getAutoCompleteValues(key:String):Array {
+               public function getAutoCompleteKeys(type:String):Array {
                        var list:Array=[];
-                       for (var v:String in _tags[key]) { list.push(v); }
+                       var a:Array=[];
+
+                       for (var k:String in _tags[type]) { list.push(k); }
                        list.sort();
-                       return list;
+
+                       for each (k in list) { a.push( { name: k } ); }
+                       return a;
+               }
+               
+               [Bindable(event="featuresLoaded")]
+               public function getAutoCompleteValues(type:String,key:String):Array {
+                       var a:Array=[];
+                       if (_tags[type][key]) {
+                               _tags[type][key].sort();
+                               for each (var v:String in _tags[type][key]) { a.push( { name: v } ); }
+                       }
+                       return a;
                }
                
     }