use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testGetTagValueEquality.
/**
* Test the syntax to get a tag value on the RHS of the expression.
*/
@Test
public void testGetTagValueEquality() {
RuleSet rs = makeRuleSet("a=b & a=$c [0x5] a=b [0x6]");
Way w = new Way(1);
w.addTag("a", "b");
w.addTag("c", "b");
GType type = getFirstType(rs, w);
assertNotNull(type);
assertEquals(5, type.getType());
w.addTag("c", "x");
type = getFirstType(rs, w);
assertNotNull(type);
assertEquals(6, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method test_X3NOT_Error.
@Test
public void test_X3NOT_Error() {
// Bug caused an Error: X3:NOT syntax exception to be thrown.
RuleSet rs = makeRuleSet("(a=1 | b=2) & !(c=1) & d!=3 [0x8]");
Way w = new Way(1);
w.addTag("b", "1");
GType type = getFirstType(rs, w);
assertNull(type);
w.addTag("b", "2");
type = getFirstType(rs, w);
assertNotNull(type);
w.addTag("d", "3");
type = getFirstType(rs, w);
assertNull(type);
w.addTag("d", "2");
type = getFirstType(rs, w);
assertNotNull(type);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testRegexp.
/**
* Check for the regexp handling.
*/
@Test
public void testRegexp() {
RuleSet rs = makeRuleSet("highway=* & name ~ 'blue.*' [0x2]\n");
assertNotNull("rule found", rs);
// Set up element with matching name
Element el = new Way(1);
el.addTag("highway", "secondary");
el.addTag("name", "blue sq");
GType type = getFirstType(rs, el);
assertNotNull("matched regexp", type);
assertEquals("matched type", 2, type.getType());
// change name to one that should not match
el.addTag("name", "yellow");
type = getFirstType(rs, el);
assertNull("no match for yello", type);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testLessThanWithNonValue.
@Test(expected = SyntaxException.class)
public void testLessThanWithNonValue() {
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 testIncludeFrom.
@Test
public void testIncludeFrom() {
// NOTE: this test uses the default style, which could change.
StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "include 'lines' from default;\n" } });
RuleSet rs = makeRuleSet(loader);
Way way = new Way(1);
way.addTag("highway", "motorway");
GType type = getFirstType(rs, way);
assertNotNull("Check type not null", type);
assertEquals(1, type.getType());
}
Aggregations