use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class AddAccessAction method perform.
public boolean perform(Element el) {
// 1st build the value
Element tags = valueTags != null ? valueTags : el;
String accessValue = null;
for (ValueBuilder value : getValueBuilder()) {
accessValue = value.build(tags, el);
if (accessValue != null) {
break;
}
}
if (accessValue == null) {
return false;
}
for (Short accessTag : ACCESS_TAGS_COMPILED.keySet()) {
setTag(el, accessTag, accessValue);
}
return true;
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ValueItem method getValue.
public String getValue(Element el, Element local_el) {
if (tagname == null && value != null)
// already known
return value;
if (tagname != null) {
Element e = tagname_is_local ? local_el : el;
String tagval = e.getTag(tagKey);
if (filter != null)
value = filter.filter(tagval, local_el);
else
value = tagval;
}
return value;
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class O5mBinHandler method readRel.
/**
* read a relation data set
* @throws IOException
*/
private void readRel() throws IOException {
lastRelId += readSignedNum64();
if (bytesToRead == 0)
// only relId: this is a delete action, we ignore it
return;
readVersionTsAuthor();
if (bytesToRead == 0)
// only relId + version: this is a delete action, we ignore it
return;
GeneralRelation rel = new GeneralRelation(lastRelId);
long refSize = readUnsignedNum32();
long stop = bytesToRead - refSize;
while (bytesToRead > stop) {
Element el = null;
long deltaRef = readSignedNum64();
int refType = readRelRef();
String role = stringPair[1];
lastRef[refType] += deltaRef;
long memId = lastRef[refType];
if (refType == 0) {
el = saver.getNode(memId);
if (el == null) {
// we didn't make a node for this point earlier,
// do it now (if it exists)
Coord co = saver.getCoord(memId);
if (co != null) {
el = new Node(memId, co);
saver.addNode((Node) el);
}
}
} else if (refType == 1) {
el = saver.getWay(memId);
} else if (refType == 2) {
el = saver.getRelation(memId);
if (el == null) {
saver.deferRelation(memId, rel, role);
}
} else {
assert false;
}
if (// ignore non existing ways caused by splitting files
el != null)
rel.addElement(role, el);
}
boolean tagsIncomplete = readTags(rel);
rel.setTagsIncomplete(tagsIncomplete);
saver.addRelation(rel);
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method testApplyAction.
/**
* The apply action works on the members of relations.
*/
@Test
public void testApplyAction() {
List<Action> actions = readActionsFromString("{apply {" + "add route=bike;" + "set foo=bar; }" + "}\n");
Relation rel = makeRelation();
Rule rule = new ActionRule(null, actions);
rule.resolveType(rel, TypeResult.NULL_RESULT);
assertNull("Tag not set on relation", rel.getTag("route"));
// Will be set on all members as there is no role filter.
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"));
Element el2 = elements.get(1).getValue();
assertEquals("route tag added to second", "bike", el2.getTag("route"));
assertEquals("foo tag set to second", "bar", el2.getTag("foo"));
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class ActionReaderTest method testSimpleSet.
@Test
public void testSimpleSet() {
List<Action> actions = readActionsFromString("{set park=yes}");
assertEquals("one action", 1, actions.size());
Element el = stdElementRun(actions);
assertEquals("park overwritten", "yes", el.getTag("park"));
}
Aggregations