Search in sources :

Example 56 with Element

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

the class RuleFileReaderTest method testLevel.

/**
 * Test for non-standard level specification.  You can give a range
 * of levels, rather than defaulting the max end to 0.
 */
@Test
public void testLevel() {
    RuleSet rs = makeRuleSet("highway=primary [0x1 level 1-3]");
    Element el = new Way(1);
    el.addTag("highway", "primary");
    GType type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("min level", 1, type.getMinLevel());
    assertEquals("max level", 3, type.getMaxLevel());
}
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 57 with Element

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

the class RuleFileReaderTest method testLeftSideOr.

/**
 * Deal with cases such as
 * (a = b | a = c) & d!=*
 * where there is no key at the top level.  This gets converted
 * to: (a=b & d!=*) | (a=c & d!= *) which can then be used.
 *
 * This is applied recursively, so you can have chains of any length.
 */
@Test
public void testLeftSideOr() {
    RuleSet rs = makeRuleSet("(a = b | a = c | a=d) & e!=* [0x2]" + "a=c & e!=* [0x1]");
    assertNotNull("a=b chain", rs);
    assertNotNull("a=c chain", rs);
    assertNotNull("a=d chain", rs);
    // get the a=c chain and look at it more closely
    Element el = new Way(1);
    el.addTag("a", "c");
    GType type = getFirstType(rs, el);
    assertNotNull("match e not existing", type);
    assertEquals("correct type", 2, type.getType());
    el = new Way(2);
    el.addTag("a", "d");
    assertNotNull("match e not existing", type);
    assertEquals("correct type", 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)

Example 58 with Element

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

the class RuleFileReaderTest method testNumberOpAtTop.

@Test
public void testNumberOpAtTop() {
    RuleSet rs = makeRuleSet("QUOTA > 10 [0x1] QUOTA < 6 [0x2]");
    Element el = new Way(1);
    el.addTag("QUOTA", "2");
    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)

Example 59 with Element

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

the class RuleFileReaderTest method testContinue.

/**
 * Test the continue keyword.  If a type is marked with this word, then
 * further matches are performed and this might result in more types
 * being added.
 */
@Test
public void testContinue() {
    RuleSet rs = makeRuleSet("highway=primary [0x1 continue]" + "highway=primary [0x2 continue]" + "highway=primary [0x3]" + "highway=primary [0x4]");
    Way el = new Way(1);
    el.addTag("highway", "primary");
    final List<GType> list = new ArrayList<>();
    rs.resolveType(el, new TypeResult() {

        public void add(Element el, GType type) {
            list.add(type);
        }
    });
    GType type = list.get(0);
    assertEquals("first type", 1, type.getType());
    assertEquals("continue search", true, type.isContinueSearch());
    assertEquals("number of result types", 3, list.size());
    assertEquals("type of first", 1, list.get(0).getType());
    assertEquals("type of second", 2, list.get(1).getType());
    assertEquals("type of third", 3, list.get(2).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) ArrayList(java.util.ArrayList) TypeResult(uk.me.parabola.mkgmap.reader.osm.TypeResult) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 60 with Element

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

the class RuleFileReaderTest method testNEAtTopWithRE.

@Test
public void testNEAtTopWithRE() {
    RuleSet rs = makeRuleSet("a != 'fred' &  a ~ '.*' [0x2]");
    Element el = new Way(1);
    el.addTag("a", "tom");
    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

Element (uk.me.parabola.mkgmap.reader.osm.Element)94 Test (org.junit.Test)75 Way (uk.me.parabola.mkgmap.reader.osm.Way)48 GType (uk.me.parabola.mkgmap.reader.osm.GType)25 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)23 Action (uk.me.parabola.mkgmap.osmstyle.actions.Action)15 Rule (uk.me.parabola.mkgmap.reader.osm.Rule)8 ArrayList (java.util.ArrayList)7 Node (uk.me.parabola.mkgmap.reader.osm.Node)7 Relation (uk.me.parabola.mkgmap.reader.osm.Relation)7 Coord (uk.me.parabola.imgfmt.app.Coord)5 StringStyleFileLoader (func.lib.StringStyleFileLoader)4 Map (java.util.Map)4 GeneralRelation (uk.me.parabola.mkgmap.reader.osm.GeneralRelation)4 TypeResult (uk.me.parabola.mkgmap.reader.osm.TypeResult)4 HashMap (java.util.HashMap)3 IdentityHashMap (java.util.IdentityHashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Area (uk.me.parabola.imgfmt.app.Area)2