start of turn restriction editor
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / MapFeatures.as
index 3d3d28fa44ca7faeacaa313ff48bacf97f5abe92..13428df1b01ee906f465280166f7db1f636f23f5 100644 (file)
@@ -63,15 +63,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;
         }