use of uk.me.parabola.mkgmap.reader.osm.Rule 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.Rule 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;
}
use of uk.me.parabola.mkgmap.reader.osm.Rule 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.reader.osm.Rule in project mkgmap by openstreetmap.
the class ActionReaderTest method testDoubleName.
/**
* Test with two name actions. This works just the same as having several
* name options on the same name command, in that it is still the
* first one to match that counts.
*/
@Test
public void testDoubleName() {
List<Action> actions = readActionsFromString("{name '${name} (${ref})' |" + " '${ref}' | '${name}' ; " + " name 'fred';}");
// Something that matches nothing in the first name command.
Element el = makeElement();
Rule rule = new ActionRule(null, actions);
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("no tags, second action matches", "fred", el.getName());
el = makeElement();
el.addTag("ref", "A1");
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("just a ref tag", "A1", el.getName());
el = makeElement();
el.addTag("ref", "A1");
el.addTag("name", "Main St");
rule.resolveType(el, TypeResult.NULL_RESULT);
assertEquals("ref and name", "Main St (A1)", el.getName());
}
use of uk.me.parabola.mkgmap.reader.osm.Rule 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"));
}
Aggregations