use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testIncludeFile.
@Test
public void testIncludeFile() {
StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "include incfile;" }, { "incfile", "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.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testWildcardTop.
/**
* You can now have a wild card at the top level.
*/
@Test
public void testWildcardTop() {
RuleSet rs = makeRuleSet("highway=* {set a=fred} [0x1]\n");
assertNotNull("rule found", rs);
Element el = new Way(1);
el.addTag("highway", "secondary");
GType type = getFirstType(rs, el);
assertNotNull("can find match", type);
assertEquals("correct type", 1, type.getType());
assertEquals("tag set", "fred", el.getTag("a"));
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testMtbRules.
/**
* A moderately complex set of conditions and substitutions.
*/
@Test
public void testMtbRules() {
RuleSet rs = makeRuleSet("(mtb:scale=* | mtb:scale:uphill=*) & route=mtb" + "{ name 'mtbrt${mtb:scale|def:.}${mtb:scale:uphill|def:.} ${name}' " + " | 'mtbrt${mtb:scale|def:.}${mtb:scale:uphill|def:.}' }" + " (mtb:scale=* | mtb:scale:uphill=*) & route!=mtb " + "{ name 'mtb${mtb:scale|def:.}${mtb:scale:uphill|def:.} ${name}' " + " | 'mtb${mtb:scale|def:.}${mtb:scale:uphill|def:.}' }");
Way el = new Way(1);
el.addTag("route", "mtb");
el.addTag("mtb:scale", "2");
getFirstType(rs, el);
assertEquals("mtbrt2.", el.getName());
el = new Way(1);
el.addTag("route", "mtb");
el.addTag("mtb:scale:uphill", "3");
getFirstType(rs, el);
assertEquals("mtbrt.3", el.getName());
el = new Way(1);
el.addTag("name", "myname");
el.addTag("route", "mtb");
el.addTag("mtb:scale:uphill", "3");
getFirstType(rs, el);
assertEquals("mtbrt.3 myname", el.getName());
el = new Way(1);
el.addTag("mtb:scale:uphill", "3");
getFirstType(rs, el);
assertEquals("mtb.3", el.getName());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNE.
@Test
public void testNE() {
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 is 9 so a!=10 is true", type);
el.addTag("a", "10");
type = getFirstType(rs, el);
assertNull("a is 10, so a!=10 is false", type);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testLengthFunction2.
@Test
public void testLengthFunction2() {
// Its more than 91m
RuleSet rs = makeRuleSet("A=B & length() > 91 [0x5]");
Way el = getWayWithLength();
el.addTag("A", "B");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(5, type.getType());
}
Aggregations