use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testLevel.
/**
* Test for non-standard level specification. You can give a range
* of levels, rather than defaulting the max end to 0.
*/
@Test
public void testLevel() {
RuleSet rs = makeRuleSet("highway=primary [0x1 level 1-3]");
Element el = new Way(1);
el.addTag("highway", "primary");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals("min level", 1, type.getMinLevel());
assertEquals("max level", 3, type.getMaxLevel());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testLeftSideOr.
/**
* Deal with cases such as
* (a = b | a = c) & d!=*
* where there is no key at the top level. This gets converted
* to: (a=b & d!=*) | (a=c & d!= *) which can then be used.
*
* This is applied recursively, so you can have chains of any length.
*/
@Test
public void testLeftSideOr() {
RuleSet rs = makeRuleSet("(a = b | a = c | a=d) & e!=* [0x2]" + "a=c & e!=* [0x1]");
assertNotNull("a=b chain", rs);
assertNotNull("a=c chain", rs);
assertNotNull("a=d chain", rs);
// get the a=c chain and look at it more closely
Element el = new Way(1);
el.addTag("a", "c");
GType type = getFirstType(rs, el);
assertNotNull("match e not existing", type);
assertEquals("correct type", 2, type.getType());
el = new Way(2);
el.addTag("a", "d");
assertNotNull("match e not existing", type);
assertEquals("correct type", 2, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNumberOpAtTop.
@Test
public void testNumberOpAtTop() {
RuleSet rs = makeRuleSet("QUOTA > 10 [0x1] QUOTA < 6 [0x2]");
Element el = new Way(1);
el.addTag("QUOTA", "2");
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 testContinue.
/**
* Test the continue keyword. If a type is marked with this word, then
* further matches are performed and this might result in more types
* being added.
*/
@Test
public void testContinue() {
RuleSet rs = makeRuleSet("highway=primary [0x1 continue]" + "highway=primary [0x2 continue]" + "highway=primary [0x3]" + "highway=primary [0x4]");
Way el = new Way(1);
el.addTag("highway", "primary");
final List<GType> list = new ArrayList<>();
rs.resolveType(el, new TypeResult() {
public void add(Element el, GType type) {
list.add(type);
}
});
GType type = list.get(0);
assertEquals("first type", 1, type.getType());
assertEquals("continue search", true, type.isContinueSearch());
assertEquals("number of result types", 3, list.size());
assertEquals("type of first", 1, list.get(0).getType());
assertEquals("type of second", 2, list.get(1).getType());
assertEquals("type of third", 3, list.get(2).getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNEAtTopWithRE.
@Test
public void testNEAtTopWithRE() {
RuleSet rs = makeRuleSet("a != 'fred' & a ~ '.*' [0x2]");
Element el = new Way(1);
el.addTag("a", "tom");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
}
Aggregations