Search in sources :

Example 36 with Way

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

the class RuleFileReaderTest method testComplexRegex.

/**
 * The main point of this test is to ensure that all the examples compile.
 */
@Test
public void testComplexRegex() {
    RuleSet rs = makeRuleSet(// "a~b      [0x0]" +
    "a~b & c=d  [0x1]" + "a~b & c~d & e=f   [0x2]" + "(a~b | c~d) & e=f  [0x3]" + "(a~b | c~d) & e=f & g=h  [0x4]" + "((a~b | c~d) & e=f) & g=h [0x5]" + "e=f & g=h & (a~b | c~'d.*')  [0x6]" + "(e=f & g=h) & (a~b | c~'d.*')  [0x7]" + "a=* & b=* & c=d [0x8]" + "a=* & (b=* | c=d) [0x9]" + "");
    Way el = new Way(1);
    el.addTag("c", "df");
    el.addTag("g", "h");
    el.addTag("e", "f");
    GType type = getFirstType(rs, el);
    assertNotNull("matches a rule", 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 37 with Way

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

the class RuleFileReaderTest method testSelfReference.

/**
 * This simply is to make sure that actions that affect their own
 * conditions do not hang. There are no defined semantics for this.
 */
@Test
public void testSelfReference() {
    RuleSet rs = makeRuleSet("iii=* { set iii=no }");
    // Rule rule = rs.getMap().get("foot=*");
    Way el = new Way(1);
    el.addTag("foot", "yes");
    el.addTag("iii", "xyz");
    getFirstType(rs, el);
}
Also used : TestUtils.makeRuleSet(func.lib.TestUtils.makeRuleSet) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 38 with Way

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

the class RuleFileReaderTest method testDecimalAndDecimalCompare.

@Test
public void testDecimalAndDecimalCompare() {
    RuleSet rs = makeRuleSet("z=yes & a < 3.5 [0x1]");
    Way el = new Way(1);
    el.addTag("z", "yes");
    // Is less than so
    el.addTag("a", "3.49");
    GType type = getFirstType(rs, el);
    assertNotNull("a is less than 3.5", type);
    el.addTag("a", "3.55");
    type = getFirstType(rs, el);
    assertNull("a is greater than 3.5", 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 39 with Way

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

the class RuleFileReaderTest method testDecimalValues.

/**
 * Test values such as 3.5 in comparisons.
 * Originally non-integer values were not allowed and were not even recognised.
 */
@Test
public void testDecimalValues() {
    RuleSet rs = makeRuleSet("z=yes & a < 3.5 [0x1]");
    Way el = new Way(1);
    el.addTag("z", "yes");
    // Is less than so
    el.addTag("a", "2");
    GType type = getFirstType(rs, el);
    assertNotNull("a is less than 3.5", type);
    el.addTag("a", "4");
    type = getFirstType(rs, el);
    assertNull("a is greater than 3.5", 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 40 with Way

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

the class RuleFileReaderTest method testRegexAtTop.

/**
 * Some operations could not originally be used by themselves but now they are converted
 * into expressions that can be handled automatically. The following few tests verify this.
 */
@Test
public void testRegexAtTop() {
    RuleSet rs = makeRuleSet("QUOTA ~ ' [05]00\\.0+' [0x2]");
    Element el = new Way(1);
    el.addTag("QUOTA", " 500.0");
    GType type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals(2, 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)

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