Search in sources :

Example 1 with TypeResult

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

the class RuleSetTest method getFirstType.

private GType getFirstType(Rule rs, Element el) {
    final List<GType> types = new ArrayList<GType>();
    rs.resolveType(el, new TypeResult() {

        public void add(Element el, GType type) {
            types.add(type);
        }
    });
    if (types.isEmpty())
        return null;
    else
        return types.get(0);
}
Also used : 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)

Example 2 with TypeResult

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

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

the class RuleFileReaderTest method getFirstType.

/**
 * Resolve the rule set with the given element and get the first
 * resolved type.
 */
private GType getFirstType(Rule rs, Element el) {
    final List<GType> types = new ArrayList<>();
    rs.resolveType(el, new TypeResult() {

        public void add(Element el, GType type) {
            types.add(type);
        }
    });
    if (types.isEmpty())
        return null;
    else
        return types.get(0);
}
Also used : 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)

Example 4 with TypeResult

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

the class RuleSetTest method resolveList.

private List<GType> resolveList(RuleSet rs, Way el) {
    final List<GType> list = new ArrayList<GType>();
    rs.resolveType(el, new TypeResult() {

        public void add(Element el, GType type) {
            list.add(type);
        }
    });
    return list;
}
Also used : 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)

Aggregations

ArrayList (java.util.ArrayList)4 Element (uk.me.parabola.mkgmap.reader.osm.Element)4 GType (uk.me.parabola.mkgmap.reader.osm.GType)4 TypeResult (uk.me.parabola.mkgmap.reader.osm.TypeResult)4 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)1 Test (org.junit.Test)1 Way (uk.me.parabola.mkgmap.reader.osm.Way)1