use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNEAtTop.
@Test(expected = SyntaxException.class)
public void testNEAtTop() {
RuleSet rs = makeRuleSet("QUOTA != 'fred' [0x2]");
Element el = new Way(1);
el.addTag("QUOTA", "tom");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testMultipleActions.
@Test
public void testMultipleActions() {
String rstr = "highway=footway {add access = no; add foot = yes} [0x16 road_class=0 road_speed=0 resolution 23]";
RuleSet rs = makeRuleSet(rstr);
Element el = new Way(1);
el.addTag("highway", "footway");
getFirstType(rs, el);
assertEquals("access set", "no", el.getTag("access"));
assertEquals("access set", "yes", el.getTag("foot"));
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method getFirstType.
/**
* Resolve the rule set with the given element and get the first
* resolved type.
*/
private GType getFirstType(Rule rs, Element el) {
final List<GType> types = new ArrayList<>();
rs.resolveType(el, new TypeResult() {
public void add(Element el, GType type) {
types.add(type);
}
});
if (types.isEmpty())
return null;
else
return types.get(0);
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testIncludeFileQuoted.
@Test
public void testIncludeFileQuoted() {
StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "include \n 'inc file' \n;" }, { "inc file", "highway=secondary [0x3]" } });
RuleSet rs = makeRuleSet(loader);
Element el = new Way(1);
el.addTag("highway", "secondary");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(3, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testRegex2.
@Test
public void testRegex2() {
RuleSet rs = makeRuleSet("a=b & (smoothness ~ '.*(bad|horrible|impassable)' | sac_scale ~ '.*(mountain|alpine)_hiking') [0x1]" + "a = '>=' & b = '>' [0x2]");
assertNotNull(rs);
Element el = new Way(1);
el.addTag("a", "b");
el.addTag("smoothness", "zzzbad");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("matched .*bad", 1, type.getType());
el = new Way(1);
el.addTag("a", "b");
el.addTag("sac_scale", "zzz alpine_hiking");
type = getFirstType(rs, el);
assertNotNull(type);
el = new Way(1);
el.addTag("a", "b");
el.addTag("sac_scale", "zzz alp_hiking");
type = getFirstType(rs, el);
assertNull(type);
el = new Way(1);
el.addTag("a", ">=");
el.addTag("b", ">");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("match string that is the same as an operator", 2, type.getType());
}
Aggregations