Search in sources :

Example 1 with StringStyleFileLoader

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());
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) StringStyleFileLoader(func.lib.StringStyleFileLoader) Element(uk.me.parabola.mkgmap.reader.osm.Element) StringStyleFileLoader(func.lib.StringStyleFileLoader) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 2 with StringStyleFileLoader

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");
    }
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) FileNotFoundException(java.io.FileNotFoundException) StringStyleFileLoader(func.lib.StringStyleFileLoader) Test(org.junit.Test)

Example 3 with StringStyleFileLoader

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());
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) StringStyleFileLoader(func.lib.StringStyleFileLoader) Element(uk.me.parabola.mkgmap.reader.osm.Element) StringStyleFileLoader(func.lib.StringStyleFileLoader) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 4 with StringStyleFileLoader

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());
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) StringStyleFileLoader(func.lib.StringStyleFileLoader) Element(uk.me.parabola.mkgmap.reader.osm.Element) StringStyleFileLoader(func.lib.StringStyleFileLoader) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 5 with StringStyleFileLoader

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());
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) StringStyleFileLoader(func.lib.StringStyleFileLoader) StringStyleFileLoader(func.lib.StringStyleFileLoader) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Aggregations

StringStyleFileLoader (func.lib.StringStyleFileLoader)6 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)6 Test (org.junit.Test)6 GType (uk.me.parabola.mkgmap.reader.osm.GType)5 Way (uk.me.parabola.mkgmap.reader.osm.Way)5 Element (uk.me.parabola.mkgmap.reader.osm.Element)4 FileNotFoundException (java.io.FileNotFoundException)1