use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testComparasons.
/**
* Test based on email on the mailing list at:
* http://www.mkgmap.org.uk/pipermail/mkgmap-dev/2009q3/003009.html
* See that email for an explanation.
*/
@Test
public void testComparasons() {
String str = "highway=null_null & layer<0 [0x01 resolution 10]\n" + "highway=null_null & layer=0 [0x02 resolution 10]\n" + "highway=null_null & layer>0 [0x03 resolution 10]\n" + "highway=null_null & layer='-1' [0x04 resolution 10]\n" + "highway=null_null & layer='0' [0x05 resolution 10]\n" + "highway=null_null & layer='1' [0x06 resolution 10]\n" + "highway=null_null & layer='+1' [0x07 resolution 10]\n" + "highway=null_null [0x08 resolution 10]";
RuleSet rs = makeRuleSet(str);
// 9902
Element el = new Way(1);
el.addTag("highway", "null_null");
el.addTag("layer", "-1");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("9902 layer = -1", 0x1, type.getType());
// 9912
el.addTag("layer", "0");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("9912 layer = 0", 0x2, type.getType());
// 9922
el.deleteTag("layer");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("9922 no layer tag", 0x8, type.getType());
// 9932
el.addTag("layer", "1");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("9932 layer is 1", 0x3, type.getType());
// 9952
el.addTag("layer", "+1");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("9952 layer is +1", 0x3, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testLTE.
@Test
public void testLTE() {
RuleSet rs = makeRuleSet("z=0 & a <= 10 [0x1]");
Way el = new Way(1);
el.addTag("z", "0");
el.addTag("a", "9");
GType type = getFirstType(rs, el);
assertNotNull("a less that 10", type);
assertEquals("found type for a <= 10", 1, type.getType());
el.addTag("a", "10");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("Found type for a == 10", 1, type.getType());
el.addTag("a", "11");
type = getFirstType(rs, el);
assertNull("a is 11, a <= 10 is false", type);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testExists.
@Test
public void testExists() {
RuleSet rs = makeRuleSet("highway=* & maxspeed=40 {set mcssl=40}" + "highway=primary & mcssl=40 [0x2 ]" + "highway=* & mcssl=40 [0x3]");
Way el = new Way(1);
el.addTag("ref", "A123");
el.addTag("name", "Long Lane");
el.addTag("highway", "primary");
el.addTag("maxspeed", "40");
GType type = getFirstType(rs, el);
assertNotNull("finds the type", type);
assertEquals("resulting type", 2, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testWithNonValue.
/**
* A test between something that is not not a value should be caught as a syntax
* error.
*/
@Test(expected = SyntaxException.class)
public void testWithNonValue() {
RuleSet rs = makeRuleSet("c=b & a=!* [0x5]");
Way w = getWayWithLength();
w.addTag("c", "b");
getFirstType(rs, w);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testIsCompleteFunction.
@Test
public void testIsCompleteFunction() {
RuleSet rs = makeRuleSet("A=B & is_complete() = true [0x5]");
Way el = getWayForClosedCompleteCheck(false, true);
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(5, type.getType());
Way el2 = getWayForClosedCompleteCheck(false, false);
RuleSet rs2 = makeRuleSet("A=B & is_complete() = false [0x5]");
GType type2 = getFirstType(rs2, el2);
assertNotNull(type2);
assertEquals(5, type2.getType());
}
Aggregations