Search in sources :

Example 31 with Way

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

the class RuleFileReaderTest method testGTR.

@Test
public void testGTR() {
    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);
    assertNull("a less that 10, no result", type);
    el.addTag("a", "10");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("Valid type returned", 1, type.getType());
    el.addTag("a", "11");
    type = getFirstType(rs, el);
    assertNotNull(type);
    assertEquals("Valid type returned", 1, 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 32 with Way

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

the class RuleFileReaderTest method getWayForClosedCompleteCheck.

/**
 * Get a way with a few points for testing the closed and complete flag.
 * @param closed way should be closed
 * @param complete way should not be complete
 */
private Way getWayForClosedCompleteCheck(boolean closed, boolean complete) {
    Way el = new Way(1);
    el.addTag("A", "B");
    el.addPoint(new Coord(1000, 1000));
    el.addPoint(new Coord(1000, 2000));
    el.addPoint(new Coord(2000, 2000));
    el.addPoint(new Coord(2000, 1000));
    if (closed)
        el.addPoint(el.getPoints().get(0));
    el.setComplete(complete);
    el.setClosedInOSM(true);
    return el;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 33 with Way

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

the class RuleFileReaderTest method testOptimizeWithOr3.

@Test
public void testOptimizeWithOr3() throws Exception {
    String s = "highway=* &  bridge!=* & " + "   (mtb:scale>0 | mtb:scale='0+' | tracktype ~ 'grade[2-6]' |" + "   sac_scale ~ '.*(mountain|alpine)_hiking' |" + "   sport=via_ferrata) [0x3]";
    RuleSet rs = makeRuleSet(s);
    Element el = new Way(1);
    el.addTag("highway", "primary");
    el.addTag("mtb:scale", "0+");
    GType type = getFirstType(rs, el);
    assertNotNull(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)

Example 34 with Way

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

the class RuleFileReaderTest method testNestedIncludeAndImmediateInclude.

/**
 * Bug when the first statement of an include file is itself an include statement.
 * As luck would have the test tested the supposedly more difficult case of an
 * include statement in the middle of the file.
 */
@Test
public void testNestedIncludeAndImmediateInclude() {
    StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "a=1 [0x1] include 'first'; a=2 [0x2]" }, { "first", "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 35 with Way

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

the class RuleFileReaderTest method testBugOr.

@Test
public void testBugOr() {
    String s = "maxspeed=*\n" + "  & ( maxspeedkmh()>120 | maxspeed = none )\n" + "  & ( highway = motorway | highway = trunk )\n" + "[0x4]\n";
    RuleSet rs = makeRuleSet(s);
    Way w = new Way(1);
    w.addTag("highway", "trunk");
    w.addTag("maxspeed", "122");
    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)

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