Search in sources :

Example 46 with Way

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

the class RuleSetTest method testCheckinExample.

/**
 * The example that was in the check in comment, make sure it actually
 * does work ;)
 */
@Test
public void testCheckinExample() {
    RuleSet rs = makeRuleSet("highway=motorway  {set blue=true;}\n" + "blue=true  [0x1 ]\n" + "highway=motorway [0x2]");
    Way el = new Way(1);
    el.addTag("highway", "motorway");
    GType type = getFirstType(rs, el);
    assertEquals("first match is on blue", 1, 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 47 with Way

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

the class RuleSetTest method testActionsMixedWithTypes.

@Test
public void testActionsMixedWithTypes() {
    RuleSet rs = makeRuleSet("highway=primary {set marker=1}" + "marker=2 [0x1]" + "highway=primary {set marker=2}" + "marker=2 [0x2]");
    Way el = new Way(1);
    el.addTag("highway", "primary");
    GType type = getFirstType(rs, el);
    assertEquals("second marker rule", 2, 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 48 with Way

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

the class RuleSetTest method testOrderChain.

/**
 * A chain of rules, some of which contain tags from the element and
 * some that contain only tags that are set in previous rules.
 */
@Test
public void testOrderChain() {
    RuleSet rs = makeRuleSet("z=1 {add fred=1;}" + "fred=1 {add abba=1}" + "z=1 & abba=1 {add destiny=1}" + "destiny=1 [0x1]" + "z=1 [0x2]");
    Way el = new Way(1);
    el.addTag("z", "1");
    GType type = getFirstType(rs, el);
    assertNotNull("chain of commands", type);
    assertEquals("'destiny' should be selected", 1, 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 49 with Way

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

the class RuleSetTest method testContinueNoPropagate.

@Test
public void testContinueNoPropagate() {
    RuleSet rs = makeRuleSet("highway=footway {set surface=good;} [0x1 continue no_propagate]" + "surface=good [0x20]" + "surface=bad [0x30]");
    Way el = new Way(1);
    el.addTag("highway", "footway");
    el.addTag("surface", "bad");
    List<GType> list = resolveList(rs, el);
    assertEquals("number of lines returned", 2, list.size());
    assertEquals("surface setting is not propagated", "bad", el.getTag("surface"));
    assertEquals("result type", 0x30, list.get(1).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 50 with Way

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

the class RuleSetTest method testContinueWithActions.

@Test
public void testContinueWithActions() {
    RuleSet rs = makeRuleSet("highway=footway {set surface=good;} [0x1 continue with_actions]" + "surface=good [0x20]" + "surface=bad [0x30]");
    Way el = new Way(1);
    el.addTag("highway", "footway");
    el.addTag("surface", "bad");
    List<GType> list = resolveList(rs, el);
    assertEquals("number of lines returned", 2, list.size());
    assertEquals("surface setting is propagated", "good", el.getTag("surface"));
    assertEquals("result type", 0x20, list.get(1).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