Search in sources :

Example 26 with Way

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

the class RuleFileReaderTest method testGetTagValueAlone.

@Test
public void testGetTagValueAlone() {
    RuleSet rs = makeRuleSet("a<$b [0x5] a=b [0x6]");
    Way w = new Way(1);
    w.addTag("a", "1");
    w.addTag("b", "2");
    GType type = getFirstType(rs, w);
    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)

Example 27 with Way

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

the class RuleFileReaderTest method testBugOrWithAndOnLeft.

@Test
public void testBugOrWithAndOnLeft() {
    RuleSet rs = makeRuleSet("((a=1&b=2) | a=2) & c!=4 [0x2]");
    Way w = new Way(1);
    w.addTag("a", "2");
    GType 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 28 with Way

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

the class RuleFileReaderTest method testFunctionWithSpaces.

@Test
public void testFunctionWithSpaces() {
    RuleSet rs = makeRuleSet("A=B & length ( \n) > 91 & length\n()\n < 92 [0x5]");
    Way el = getWayWithLength();
    el.addTag("A", "B");
    GType type = getFirstType(rs, el);
    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 29 with Way

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

the class RuleFileReaderTest method testBugOrWithAndOnLeft2.

@Test
public void testBugOrWithAndOnLeft2() {
    RuleSet rs = makeRuleSet("(((a=1 | a=5)&b=2) | a=2) & c!=4 [0x2]");
    Way w = new Way(1);
    w.addTag("a", "2");
    GType type = getFirstType(rs, w);
    assertNotNull(type);
    assertEquals(type.getType(), 2);
}
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 30 with Way

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

the class RuleFileReaderTest method testOptimizeWithOr2.

/**
 * Test is a simplified version of a rule in the floodblocker style.
 */
@Test
public void testOptimizeWithOr2() {
    String s = "highway=*" + "& tunnel!=*" + "& (layer!=* | layer=0)" + " [0x02]\n";
    RuleSet rs = makeRuleSet(s);
    Element el = new Way(1);
    el.addTag("highway", "primary");
    GType type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals(2, type.getType());
    el.addTag("layer", "0");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals(2, type.getType());
    el.addTag("layer", "1");
    type = getFirstType(rs, el);
    assertNull(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)

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