use of func.lib.StringStyleFileLoader in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNestedIncludeAndImmediateInclude.
/**
* Bug when the first statement of an include file is itself an include statement.
* As luck would have the test tested the supposedly more difficult case of an
* include statement in the middle of the file.
*/
@Test
public void testNestedIncludeAndImmediateInclude() {
StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "a=1 [0x1] include 'first'; a=2 [0x2]" }, { "first", "include 'second'; b=2 [0x2 ]" }, { "second", "c=1 [0x1] c=2 [0x2 ]" } });
RuleSet rs = makeRuleSet(loader);
Element el = new Way(1);
el.addTag("a", "2");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
el = new Way(2);
el.addTag("c", "1");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(1, type.getType());
el = new Way(2);
el.addTag("c", "2");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
}
use of func.lib.StringStyleFileLoader in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testLengthInPoints.
/**
* Functions can be restricted to certain files. Eg length() does not make sense on a point.
*/
@Test(expected = SyntaxException.class)
public void testLengthInPoints() {
StringStyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "points", "A=B & length() < 100" } });
RuleSet rs = new RuleSet();
RuleFileReader rr = new RuleFileReader(FeatureKind.POINT, LevelInfo.createFromString("0:24 1:20 2:18 3:16 4:14"), rs, false, null);
try {
rr.load(loader, "points");
} catch (FileNotFoundException e) {
throw new AssertionError("Failed to open file: lines");
}
}
use of func.lib.StringStyleFileLoader in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNestedIncludes.
/**
* Test an include file within an include file.
*/
@Test
public void testNestedIncludes() {
StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "a=1 [0x1] include 'first'; a=2 [0x2]" }, { "first", "b=1 [0x1] include 'second'; b=2 [0x2 ]" }, { "second", "c=1 [0x1] c=2 [0x2 ]" } });
RuleSet rs = makeRuleSet(loader);
Element el = new Way(1);
el.addTag("a", "2");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
el = new Way(2);
el.addTag("c", "1");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(1, type.getType());
el = new Way(2);
el.addTag("c", "2");
type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
}
use of func.lib.StringStyleFileLoader 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 func.lib.StringStyleFileLoader 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