better still...
[potlatch2.git] / net / systemeD / halcyon / styleparser / Rule.as
index d9853ceccbd5ca1c97592a6cddeb447edc38aabd..cb54ed51f69c8a7a664795d7d048f5bf7bf15310 100644 (file)
@@ -1,15 +1,24 @@
 package net.systemeD.halcyon.styleparser {
 
 package net.systemeD.halcyon.styleparser {
 
+    import net.systemeD.halcyon.connection.*;
+
        public class Rule {
 
        public class Rule {
 
-               public var conditions:Array;
-               public var breaker:Boolean = true;
+               public var conditions:Array = [];
                public var isAnd:Boolean = true;
                public var isAnd:Boolean = true;
-               public var minScale:uint = 19;
-               public var maxScale:uint = 13;
-
-               public function test(tags:Object):Boolean {
-                       var v:Boolean; var i:uint=0;
+               public var minZoom:uint = 13;                   // ** FIXME: shouldn't be hardcoded
+               public var maxZoom:uint = 19;                   //  |
+               public var subject:String='';                   // "", "way", "node" or "relation"
+               
+               public function Rule(s:String=''):void {
+                       subject=s;
+               }
+               
+               public function test(obj:Entity,tags:Object,zoom:uint):Boolean {
+                       if (subject!='' && obj.getType()!=subject) { return false; }
+                       if (zoom<minZoom || zoom>maxZoom) { return false; }
+                       
+                       var v:Boolean=true; var i:uint=0;
                        for each (var condition:Condition in conditions) {
                                var r:Boolean=condition.test(tags);
                                if (i==0) { v=r; }
                        for each (var condition:Condition in conditions) {
                                var r:Boolean=condition.test(tags);
                                if (i==0) { v=r; }
@@ -19,5 +28,9 @@ package net.systemeD.halcyon.styleparser {
                        }
                        return v;
                }
                        }
                        return v;
                }
+               
+               public function toString():String {
+                       return subject+" z"+minZoom+"-"+maxZoom+": "+conditions;
+               }
        }
 }
\ No newline at end of file
        }
 }
\ No newline at end of file