disable caching when using Flash Debug Player
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / MapFeatures.as
index 92d72ea0312d3be8ecc0d06852584ae77cf7113d..d9f64e5c99778655d059fd5d252e64fd7a7f7cdb 100644 (file)
@@ -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?"+Math.random());
+            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;
         }
@@ -88,7 +98,7 @@ package net.systemeD.potlatch2.mapfeatures {
             if ( xml == null )
                 return null;
             if ( type == null || type == "" )  
-                return _categories;
+                return []; //_categories;
                 
             var filteredCategories:Array = new Array();
             for each( var cat:Category in _categories ) {
@@ -105,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;
+        }
     }
 
 }