Search in sources :

Example 91 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.

the class RuleFileReaderTest method testGetTagValueEquality.

/**
 * Test the syntax to get a tag value on the RHS of the expression.
 */
@Test
public void testGetTagValueEquality() {
    RuleSet rs = makeRuleSet("a=b & a=$c [0x5] a=b [0x6]");
    Way w = new Way(1);
    w.addTag("a", "b");
    w.addTag("c", "b");
    GType type = getFirstType(rs, w);
    assertNotNull(type);
    assertEquals(5, type.getType());
    w.addTag("c", "x");
    type = getFirstType(rs, w);
    assertNotNull(type);
    assertEquals(6, type.getType());
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 92 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.

the class RuleFileReaderTest method test_X3NOT_Error.

@Test
public void test_X3NOT_Error() {
    // Bug caused an Error: X3:NOT syntax exception to be thrown.
    RuleSet rs = makeRuleSet("(a=1 | b=2) & !(c=1) & d!=3 [0x8]");
    Way w = new Way(1);
    w.addTag("b", "1");
    GType type = getFirstType(rs, w);
    assertNull(type);
    w.addTag("b", "2");
    type = getFirstType(rs, w);
    assertNotNull(type);
    w.addTag("d", "3");
    type = getFirstType(rs, w);
    assertNull(type);
    w.addTag("d", "2");
    type = getFirstType(rs, w);
    assertNotNull(type);
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 93 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.

the class RuleFileReaderTest method testRegexp.

/**
 * Check for the regexp handling.
 */
@Test
public void testRegexp() {
    RuleSet rs = makeRuleSet("highway=* & name ~ 'blue.*' [0x2]\n");
    assertNotNull("rule found", rs);
    // Set up element with matching name
    Element el = new Way(1);
    el.addTag("highway", "secondary");
    el.addTag("name", "blue sq");
    GType type = getFirstType(rs, el);
    assertNotNull("matched regexp", type);
    assertEquals("matched type", 2, type.getType());
    // change name to one that should not match
    el.addTag("name", "yellow");
    type = getFirstType(rs, el);
    assertNull("no match for yello", type);
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) GType(uk.me.parabola.mkgmap.reader.osm.GType) Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 94 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.

the class RuleFileReaderTest method testLessThanWithNonValue.

@Test(expected = SyntaxException.class)
public void testLessThanWithNonValue() {
    RuleSet rs = makeRuleSet("c=b & a<!* [0x5]");
    Way w = getWayWithLength();
    w.addTag("c", "b");
    getFirstType(rs, w);
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 95 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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

Way (uk.me.parabola.mkgmap.reader.osm.Way)142 Test (org.junit.Test)94 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)70 GType (uk.me.parabola.mkgmap.reader.osm.GType)60 Element (uk.me.parabola.mkgmap.reader.osm.Element)48 Coord (uk.me.parabola.imgfmt.app.Coord)31 ArrayList (java.util.ArrayList)18 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)12 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)11 List (java.util.List)8 Node (uk.me.parabola.mkgmap.reader.osm.Node)8 HashMap (java.util.HashMap)7 IdentityHashMap (java.util.IdentityHashMap)6 Map (java.util.Map)6 StringStyleFileLoader (func.lib.StringStyleFileLoader)5 CoordNode (uk.me.parabola.imgfmt.app.CoordNode)5 Relation (uk.me.parabola.mkgmap.reader.osm.Relation)5 CoordPOI (uk.me.parabola.mkgmap.reader.osm.CoordPOI)4 RestrictionRelation (uk.me.parabola.mkgmap.reader.osm.RestrictionRelation)4 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)3