use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method testApplyWithRole.
/**
* You can have a role filter, so that the actions are only applied
* to members with the given role.
*/
@Test
public void testApplyWithRole() {
List<Action> actions = readActionsFromString("{apply role=bar {" + "add route=bike;" + "set foo=bar; }}");
Relation rel = makeRelation();
Rule rule = new ActionRule(null, actions);
rule.resolveType(rel, TypeResult.NULL_RESULT);
List<Map.Entry<String, Element>> elements = rel.getElements();
Element el1 = elements.get(0).getValue();
assertEquals("route tag added to first", "bike", el1.getTag("route"));
assertEquals("foo tag set to first", "bar", el1.getTag("foo"));
// Wrong role, so not applied.
Element el2 = elements.get(1).getValue();
assertNull("route tag not added to second element (role=foo)", el2.getTag("route"));
assertNull("foo tag not set in second element (role=foo)", el2.getTag("foo"));
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method testName.
/**
* The name action set the element-name (not the 'name' tag).
* The first value to set it counts, later matches are ignored.
*/
@Test
public void testName() {
List<Action> actions = readActionsFromString("{name '${name} (${ref})' |" + " '${ref}' | '${name}' ; }");
Element el = makeElement();
el.addTag("name", "Main St");
Rule rule = new ActionRule(null, actions);
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("just name", "Main St", el.getName());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method testRename.
@Test
public void testRename() {
List<Action> actions = readActionsFromString("{rename park landarea}");
assertEquals("one action", 1, actions.size());
Element el = stdElementRun(actions);
assertNull("park should be gone", el.getTag("park"));
assertEquals("park renamed", "no", el.getTag("landarea"));
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method testApplyWithSubst.
/**
* When an apply statement runs, then substitutions on the value use
* the tags of the relation and not of the sub element.
*/
@Test
public void testApplyWithSubst() {
List<Action> actions = readActionsFromString("{apply {" + "add route='${route_no}';" + "}}");
Relation rel = makeRelation();
rel.addTag("route_no", "66");
Element el1 = rel.getElements().get(0).getValue();
el1.addTag("route_no", "42");
Rule rule = new ActionRule(null, actions);
rule.resolveType(rel, TypeResult.NULL_RESULT);
assertEquals("route_no taken from relation tags", "66", el1.getTag("route"));
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method stdElementRun.
private Element stdElementRun(List<Action> actions) {
Rule rule = new ActionRule(null, actions);
Element el = makeElement();
rule.resolveType(el, TypeResult.NULL_RESULT);
return el;
}
Aggregations