use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class WayKeyValueFilter method process.
/**
* {@inheritDoc}
*/
public void process(WayContainer container) {
Way way = container.getEntity();
boolean matchesFilter = false;
for (Tag tag : way.getTags()) {
String keyValue = tag.getKey() + "." + tag.getValue();
if (allowedKeyValues.contains(keyValue)) {
matchesFilter = true;
break;
}
}
if (matchesFilter) {
sink.process(container);
}
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class TransformHelper method processEntityContainer.
/**
* Transforms entity container according to configFile.
*
* @param entityContainer
* The entity to be processed.
* @return transformed (if needed) entityContainer
*/
protected EntityContainer processEntityContainer(EntityContainer entityContainer) {
// Entities may have been made read-only at some point in the pipeline.
// We want a writeable instance so that we can update the tags.
EntityContainer writeableEntityContainer = entityContainer.getWriteableInstance();
Entity entity = entityContainer.getEntity();
Collection<Tag> entityTags = entity.getTags();
EntityType entityType = entity.getType();
// Store the tags in a map keyed by tag key.
Map<String, String> tagMap = new HashMap<String, String>();
for (Tag tag : entity.getTags()) {
tagMap.put(tag.getKey(), tag.getValue());
}
// Apply tag transformations.
for (Translation translation : translations) {
Collection<Match> matches = translation.match(tagMap, TTEntityType.fromEntityType06(entityType), entity.getUser().getName(), entity.getUser().getId());
if (matches == null || matches.isEmpty()) {
continue;
}
if (translation.isDropOnMatch()) {
return null;
}
Map<String, String> newTags = new HashMap<String, String>();
for (Output output : translation.getOutputs()) {
output.apply(tagMap, newTags, matches, translation.getDataSources());
}
tagMap = newTags;
}
// Replace the entity tags with the transformed values.
entityTags.clear();
for (Entry<String, String> tag : tagMap.entrySet()) {
entityTags.add(new Tag(tag.getKey(), tag.getValue()));
}
return writeableEntityContainer;
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class NodeKeyFilter method process.
/**
* {@inheritDoc}
*/
public void process(NodeContainer container) {
Node node = container.getEntity();
boolean matchesFilter = false;
for (Tag tag : node.getTags()) {
if (allowedKeys.contains(tag.getKey())) {
matchesFilter = true;
break;
}
}
if (matchesFilter) {
sink.process(container);
}
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class NodeKeyValueFilter method process.
/**
* {@inheritDoc}
*/
public void process(NodeContainer container) {
Node node = container.getEntity();
boolean matchesFilter = false;
for (Tag tag : node.getTags()) {
String keyValue = tag.getKey() + "." + tag.getValue();
if (allowedKeyValues.contains(keyValue)) {
matchesFilter = true;
break;
}
}
if (matchesFilter) {
sink.process(container);
}
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class TagRemover method process.
/**
* {@inheritDoc}
*/
@Override
public void process(EntityContainer entityContainer) {
EntityContainer writeableContainer;
Entity entity;
writeableContainer = entityContainer.getWriteableInstance();
entity = writeableContainer.getEntity();
for (Iterator<Tag> i = entity.getTags().iterator(); i.hasNext(); ) {
Tag tag;
tag = i.next();
if (keysToDrop.contains(tag.getKey())) {
i.remove();
} else {
for (String prefix : keyPrefixesToDrop) {
if (tag.getKey().startsWith(prefix)) {
i.remove();
break;
}
}
}
}
sink.process(writeableContainer);
}
Aggregations