use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testIsClosedFunction.
@Test
public void testIsClosedFunction() {
RuleSet rs = makeRuleSet("A=B & is_closed() = true [0x5]");
Way el = getWayForClosedCompleteCheck(true, true);
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(5, type.getType());
Way el2 = getWayForClosedCompleteCheck(false, true);
RuleSet rs2 = makeRuleSet("A=B & is_closed() = false [0x5]");
GType type2 = getFirstType(rs2, el2);
assertNotNull(type2);
assertEquals(5, type2.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleSetTest method testActionOrder.
/**
* Check that actions are run in the order given. Use the add command
* to set a variable. The first add that is run will be the value of
* the variable.
*/
@Test
public void testActionOrder() {
RuleSet rs = makeRuleSet("b=c {add fred=1}" + "a=b {add fred=2}" + "c=d {add fred=3}" + "a=b [0x1]");
// All of the conditions are set.
Way el = new Way(1);
el.addTag("a", "b");
el.addTag("b", "c");
el.addTag("c", "d");
getFirstType(rs, el);
assertEquals("b=c was first action", "1", el.getTag("fred"));
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleSetTest method testAppendInOrder.
/**
* Append to a variable in the correct order as in the rule set.
*/
@Test
public void testAppendInOrder() {
RuleSet rs = makeRuleSet("highway=primary {set R='${R} a'}" + "ref=A1 {set R='${R} b'}" + "z=1 {set R='${R} c'}" + "a=1 {set R='${R} d'}");
Way el = new Way(1);
el.addTag("R", "init");
el.addTag("highway", "primary");
el.addTag("ref", "A1");
el.addTag("z", "1");
el.addTag("a", "1");
getFirstType(rs, el);
String s = el.getTag("R");
assertEquals("appended value", "init a b c d", s);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleSetTest method testActionVarSetOnExistsRule1.
/**
* An action variable is set on a rule that starts with an exists clause.
* We then attempt to match on value that it is
* @throws Exception
*/
@Test
public void testActionVarSetOnExistsRule1() throws Exception {
RuleSet rs = makeRuleSet(MAXSPEED_EXAMPLE);
Way el = new Way(1);
el.addTag("highway", "primary");
el.addTag("maxspeed", "40mph");
el.addTag("ref", "A123");
el.addTag("name", "Long Lane");
GType type = getFirstType(rs, el);
assertEquals("should match first", 1, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleSetTest method testRuleEvaluatedOnce.
/**
* Rules should only be evaluated once for an element. Because of the
* way that we handle rules that may get run after tags are set in actions
* it is possible that a rule would get run twice if not careful.
*
* It is not that easy to trigger, as this is the second attempt at
* showing it is possible...
*/
@Test
public void testRuleEvaluatedOnce() {
RuleSet rs = makeRuleSet("highway=primary " + " {set highway=primary; set result='${result} 1';}" + "highway='primary' {set result='${result} 2'");
Way el = new Way(1);
el.addTag("highway", "primary");
el.addTag("result", "0");
getFirstType(rs, el);
assertEquals("rules run once", "0 1 2", el.getTag("result"));
}
Aggregations