Search in sources :

Example 51 with Way

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

the class RuleSetTest method testContinueDefault.

@Test
public void testContinueDefault() {
    RuleSet rs = makeRuleSet("highway=footway {set surface=good;} [0x1 continue]" + "surface=good [0x20]" + "surface=bad [0x30]");
    Way el = new Way(1);
    el.addTag("highway", "footway");
    el.addTag("surface", "bad");
    List<GType> list = resolveList(rs, el);
    assertEquals("number of lines returned", 2, list.size());
    assertEquals("surface setting not propagated", "bad", el.getTag("surface"));
    assertEquals("result type", 0x30, list.get(1).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 52 with Way

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

the class StyledConverterTest method testOverlay.

/**
 * Test the overlay feature, when one line is duplicated with different
 * types.
 */
@Test
public void testOverlay() throws FileNotFoundException {
    Way way = makeWay();
    way.addTag("highway", "overlay");
    converter = makeConverter("simple");
    converter.convertWay(way);
    converter.end();
    assertEquals("lines produced", 3, lines.size());
    assertEquals("first line is 1", 1, lines.get(0).getType());
    assertEquals("second line is 2", 2, lines.get(1).getType());
    assertEquals("third line is 3", 3, lines.get(2).getType());
}
Also used : Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 53 with Way

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

the class StyledConverterTest method convertTag.

private Way convertTag(String key, String value) throws FileNotFoundException {
    lines.clear();
    Way way = makeWay();
    way.addTag(key, value);
    converter = makeConverter("d");
    converter.convertWay(way);
    converter.end();
    return way;
}
Also used : Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 54 with Way

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

the class StyledConverterTest method testConvertWay.

@Test
public void testConvertWay() throws FileNotFoundException {
    converter = makeConverter("simple");
    Way way = makeWay();
    way.addTag("highway", "primary");
    way.addTag("x", "y");
    converter.convertWay(way);
    converter.end();
    assertEquals("line converted", 1, lines.size());
    assertEquals("line from highway", 0x2, lines.get(0).getType());
}
Also used : Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 55 with Way

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

the class StyledConverterTest method testFinalizer.

@Test
public void testFinalizer() throws FileNotFoundException {
    // test three ways
    // the first two ways should get the name "OK" by the finalize part
    // the third way should not be handled by the finalize part
    String[][] tests = new String[][] { { "residential", "OK" }, { "track", "OK" }, { "secondary", null } };
    for (String[] test : tests) {
        // clear the lines list for each test
        lines.clear();
        converter = makeConverter("finalize");
        Way w = makeWay();
        w.addTag("highway", test[0]);
        converter.convertWay(w);
        converter.end();
        assertEquals("lines converted", 1, lines.size());
        assertEquals("wrong name set by the finalize block", test[1], lines.get(0).getName());
    }
    // check if continue works
    lines.clear();
    converter = makeConverter("finalize");
    Way w = makeWay();
    w.addTag("highway", "trunk");
    converter.convertWay(w);
    converter.end();
    assertEquals("lines converted", 2, lines.size());
    assertEquals("wrong name set by the finalize block", "OK", lines.get(0).getName());
    assertEquals("wrong name set by the finalize block", null, lines.get(1).getName());
}
Also used : 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