Search in sources :

Example 86 with Way

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());
}
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 87 with Way

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"));
}
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 88 with Way

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

Example 89 with Way

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);
}
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 90 with Way

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());
}
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)

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