X-Git-Url: https://git.openstreetmap.org/potlatch2.git/blobdiff_plain/ebce9b54244d9742be3e05e07f311c642240d27b..8e5a523fdeb7f1d2e385f8f3100985ed1e0846b3:/net/systemeD/potlatch2/mapfeatures/MapFeatures.as diff --git a/net/systemeD/potlatch2/mapfeatures/MapFeatures.as b/net/systemeD/potlatch2/mapfeatures/MapFeatures.as index 9a699acc..d9f64e5c 100644 --- a/net/systemeD/potlatch2/mapfeatures/MapFeatures.as +++ b/net/systemeD/potlatch2/mapfeatures/MapFeatures.as @@ -3,13 +3,12 @@ package net.systemeD.potlatch2.mapfeatures { import flash.events.EventDispatcher; import flash.events.Event; import flash.net.URLLoader; - import flash.net.URLRequest; import flash.system.Security; import flash.net.*; import net.systemeD.halcyon.connection.*; - + import net.systemeD.halcyon.DebugURLRequest; public class MapFeatures extends EventDispatcher { private static var instance:MapFeatures; @@ -29,10 +28,10 @@ package net.systemeD.potlatch2.mapfeatures { private var _categories:Array = null; protected function loadFeatures():void { - var request:URLRequest = new URLRequest("map_features.xml"); + var request:DebugURLRequest = new DebugURLRequest("map_features.xml"); var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, onFeatureLoad); - loader.load(request); + loader.load(request.request); } internal function get definition():XML { @@ -63,15 +62,26 @@ package net.systemeD.potlatch2.mapfeatures { return null; for each(var feature:Feature in features) { - // check for matching tags var match:Boolean = true; + + // check for matching tags for each(var tag:Object in feature.tags) { var entityTag:String = entity.getTag(tag.k); match = entityTag == tag.v || (entityTag != null && tag.v == "*"); if ( !match ) break; } - if ( match ) + + // check for matching withins + if (match) { + for each (var within:Object in feature.withins) { + match = entity.countParentObjects(within) >= (within.minimum ? within.minimum : 1); + if (!match) { break; } + } + } + + if (match) { return feature; + } } return null; } @@ -79,10 +89,25 @@ package net.systemeD.potlatch2.mapfeatures { [Bindable(event="featuresLoaded")] public function get categories():Array { if ( xml == null ) - return null; + return null; return _categories; } + [Bindable(event="featuresLoaded")] + public function getCategoriesForType(type:String):Array { + if ( xml == null ) + return null; + if ( type == null || type == "" ) + return []; //_categories; + + var filteredCategories:Array = new Array(); + for each( var cat:Category in _categories ) { + if ( cat.getFeaturesForType(type).length > 0 ) + filteredCategories.push(cat); + } + return filteredCategories; + } + [Bindable(event="featuresLoaded")] public function get features():Array { if ( xml == null ) @@ -90,6 +115,19 @@ package net.systemeD.potlatch2.mapfeatures { return _features; } + [Bindable(event="featuresLoaded")] + public function get pois():Array { + if (xml == null ) + return null; + var pois:Array = []; + var counter:int = 0; + for each ( var feature:Feature in _features ) { + if (feature.isType("point")) { + pois.push(feature); + } + } + return pois; + } } }