use of uk.me.parabola.mkgmap.osmstyle.actions.Action 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.osmstyle.actions.Action 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.osmstyle.actions.Action 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.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testSecondAlternative.
@Test
public void testSecondAlternative() {
List<Action> actions = readActionsFromString("{set fred = '${notset}' | 'default value'}");
Element el = makeElement();
el.addTag("fred", "origvalue");
Rule rule = new ActionRule(null, actions);
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("second alternative", "default value", el.getTag("fred"));
}
use of uk.me.parabola.mkgmap.osmstyle.actions.Action in project mkgmap by openstreetmap.
the class ActionReaderTest method testSimpleAdd.
@Test
public void testSimpleAdd() {
List<Action> actions = readActionsFromString("{add park=yes}");
assertEquals("one action", 1, actions.size());
// add does not overwrite existing tags.
Element el = stdElementRun(actions);
assertEquals("park not overwritten", "no", el.getTag("park"));
}
Aggregations