MapCSS in progress. Vast amounts still to do, but the meat of it is here. POIs are...
[potlatch2.git] / net / systemeD / halcyon / styleparser / Rule.as
1 package net.systemeD.halcyon.styleparser {
2
3     import net.systemeD.halcyon.connection.*;
4
5         public class Rule {
6
7                 public var conditions:Array = [];
8                 public var isAnd:Boolean = true;
9                 public var minZoom:uint = 13;
10                 public var maxZoom:uint = 19;
11                 public var subject:String='';                   // "", "way", "node" or "relation"
12                 
13                 public function Rule(s:String=''):void {
14                         subject=s;
15                 }
16                 
17                 public function test(obj:Entity,tags:Object):Boolean {
18                         if (subject!='' && obj.getType()!=subject) { return false; }
19                         
20                         var v:Boolean; var i:uint=0;
21                         for each (var condition:Condition in conditions) {
22                                 var r:Boolean=condition.test(tags);
23                                 if (i==0) { v=r; }
24                                 else if (isAnd) { v=v && r; }
25                                 else { v = v || r;}
26                                 i++;
27                         }
28                         return v;
29                 }
30                 
31                 public function toString():String {
32                         return subject+" z"+minZoom+"-"+maxZoom+": "+conditions;
33                 }
34         }
35 }