Search in sources :

Example 76 with Way

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

the class RuleFileReaderTest method getWayWithLength.

/**
 * Get a way with a few points for testing length.
 *
 * The length of this segment was independently confirmed to be around 91m.
 */
private Way getWayWithLength() {
    Way el = new Way(1);
    el.addPoint(new Coord(51.6124376, -0.1777185));
    el.addPoint(new Coord(51.6127816, -0.1775029));
    el.addPoint(new Coord(51.6132048, -0.1772467));
    return el;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 77 with Way

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

the class RuleFileReaderTest method testNestedIncludes.

/**
 * Test an include file within an include file.
 */
@Test
public void testNestedIncludes() {
    StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "a=1 [0x1] include 'first'; a=2 [0x2]" }, { "first", "b=1 [0x1] include 'second'; b=2 [0x2 ]" }, { "second", "c=1 [0x1] c=2 [0x2 ]" } });
    RuleSet rs = makeRuleSet(loader);
    Element el = new Way(1);
    el.addTag("a", "2");
    GType type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals(2, type.getType());
    el = new Way(2);
    el.addTag("c", "1");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals(1, type.getType());
    el = new Way(2);
    el.addTag("c", "2");
    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) StringStyleFileLoader(func.lib.StringStyleFileLoader) Element(uk.me.parabola.mkgmap.reader.osm.Element) StringStyleFileLoader(func.lib.StringStyleFileLoader) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 78 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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 79 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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 80 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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)

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