Search in sources :

Example 21 with Way

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

the class RuleFileReaderTest method testComparasons.

/**
 * Test based on email on the mailing list at:
 * http://www.mkgmap.org.uk/pipermail/mkgmap-dev/2009q3/003009.html
 * See that email for an explanation.
 */
@Test
public void testComparasons() {
    String str = "highway=null_null & layer<0  [0x01 resolution 10]\n" + "highway=null_null & layer=0  [0x02 resolution 10]\n" + "highway=null_null & layer>0  [0x03 resolution 10]\n" + "highway=null_null & layer='-1'  [0x04 resolution 10]\n" + "highway=null_null & layer='0'  [0x05 resolution 10]\n" + "highway=null_null & layer='1'  [0x06 resolution 10]\n" + "highway=null_null & layer='+1'  [0x07 resolution 10]\n" + "highway=null_null   [0x08 resolution 10]";
    RuleSet rs = makeRuleSet(str);
    // 9902
    Element el = new Way(1);
    el.addTag("highway", "null_null");
    el.addTag("layer", "-1");
    GType type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("9902 layer = -1", 0x1, type.getType());
    // 9912
    el.addTag("layer", "0");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("9912 layer = 0", 0x2, type.getType());
    // 9922
    el.deleteTag("layer");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("9922 no layer tag", 0x8, type.getType());
    // 9932
    el.addTag("layer", "1");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("9932 layer is 1", 0x3, type.getType());
    // 9952
    el.addTag("layer", "+1");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("9952 layer is +1", 0x3, type.getType());
}
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 22 with Way

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

the class RuleFileReaderTest method testLTE.

@Test
public void testLTE() {
    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 less that 10", type);
    assertEquals("found type for a <= 10", 1, type.getType());
    el.addTag("a", "10");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("Found type for a == 10", 1, type.getType());
    el.addTag("a", "11");
    type = getFirstType(rs, el);
    assertNull("a is 11, 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 23 with Way

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

the class RuleFileReaderTest method testExists.

@Test
public void testExists() {
    RuleSet rs = makeRuleSet("highway=* & maxspeed=40 {set mcssl=40}" + "highway=primary & mcssl=40 [0x2 ]" + "highway=* & mcssl=40 [0x3]");
    Way el = new Way(1);
    el.addTag("ref", "A123");
    el.addTag("name", "Long Lane");
    el.addTag("highway", "primary");
    el.addTag("maxspeed", "40");
    GType type = getFirstType(rs, el);
    assertNotNull("finds the type", type);
    assertEquals("resulting type", 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 24 with Way

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

the class RuleFileReaderTest method testWithNonValue.

/**
 * A test between something that is not not a value should be caught as a syntax
 * error.
 */
@Test(expected = SyntaxException.class)
public void testWithNonValue() {
    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 25 with Way

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

the class RuleFileReaderTest method testIsCompleteFunction.

@Test
public void testIsCompleteFunction() {
    RuleSet rs = makeRuleSet("A=B & is_complete() = true [0x5]");
    Way el = getWayForClosedCompleteCheck(false, true);
    GType type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals(5, type.getType());
    Way el2 = getWayForClosedCompleteCheck(false, false);
    RuleSet rs2 = makeRuleSet("A=B & is_complete() = false [0x5]");
    GType type2 = getFirstType(rs2, el2);
    assertNotNull(type2);
    assertEquals(5, type2.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