Search in sources :

Example 86 with Tag

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);
    }
}
Also used : Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way)

Example 87 with Tag

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;
}
Also used : Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) Translation(org.openstreetmap.osmosis.tagtransform.Translation) HashMap(java.util.HashMap) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) Match(org.openstreetmap.osmosis.tagtransform.Match) TTEntityType(org.openstreetmap.osmosis.tagtransform.TTEntityType) EntityType(org.openstreetmap.osmosis.core.domain.v0_6.EntityType) Output(org.openstreetmap.osmosis.tagtransform.Output) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 88 with Tag

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);
    }
}
Also used : Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 89 with Tag

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);
    }
}
Also used : Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 90 with Tag

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);
}
Also used : Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)23 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Date (java.util.Date)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Tag (org.mozilla.jss.asn1.Tag)7 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)6 Osmformat (crosby.binary.Osmformat)5 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)5 Point (com.vividsolutions.jts.geom.Point)4