Search in sources :

Example 51 with Element

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

the class ActionReaderTest method makeElement.

/**
 * Make a standard element for the tests.
 */
private Element makeElement() {
    Element el = new Way(0);
    el.addTag("park", "no");
    el.addTag("test", "1");
    return el;
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 52 with Element

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

the class ActionReaderTest method testAlternatives.

@Test
public void testAlternatives() {
    List<Action> actions = readActionsFromString("{set fred = '${park}' | 'default value'}");
    Element el = makeElement();
    Rule rule = new ActionRule(null, actions);
    rule.resolveType(el, TypeResult.NULL_RESULT);
    assertEquals("first alternative", "no", el.getTag("fred"));
}
Also used : Action(uk.me.parabola.mkgmap.osmstyle.actions.Action) Element(uk.me.parabola.mkgmap.reader.osm.Element) Rule(uk.me.parabola.mkgmap.reader.osm.Rule) Test(org.junit.Test)

Example 53 with Element

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

the class ActionReaderTest method testMultipleNoSeparators.

@Test
public void testMultipleNoSeparators() {
    List<Action> actions = readActionsFromString("{" + "set park='${notset}' | yes " + "add fred=other " + "set pooh=bear}");
    assertEquals("number of actions", 3, actions.size());
    Element el = stdElementRun(actions);
    assertEquals("park set to yes", "yes", el.getTag("park"));
    assertEquals("fred set", "other", el.getTag("fred"));
    assertEquals("pooh set", "bear", el.getTag("pooh"));
}
Also used : Action(uk.me.parabola.mkgmap.osmstyle.actions.Action) Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 54 with Element

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

the class ActionReaderTest method testMultipleCommands.

/**
 * Test several commands in the block.  They should all be executed.
 */
@Test
public void testMultipleCommands() {
    List<Action> actions = readActionsFromString("{set park=yes; add fred=other;" + "set pooh=bear}");
    assertEquals("number of actions", 3, actions.size());
    Element el = stdElementRun(actions);
    assertEquals("park set to yes", "yes", el.getTag("park"));
    assertEquals("fred set", "other", el.getTag("fred"));
    assertEquals("pooh set", "bear", el.getTag("pooh"));
}
Also used : Action(uk.me.parabola.mkgmap.osmstyle.actions.Action) Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 55 with Element

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

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