Search in sources :

Example 16 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class TagSorter method process.

/**
 * {@inheritDoc}
 */
public void process(EntityContainer entityContainer) {
    EntityContainer writeableContainer;
    Entity entity;
    Collection<Tag> sortedTags;
    writeableContainer = entityContainer.getWriteableInstance();
    entity = writeableContainer.getEntity();
    sortedTags = sortTags(entity.getTags());
    entity.getTags().clear();
    entity.getTags().addAll(sortedTags);
    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)

Example 17 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class OsmWriterTest method testProcess8.

/**
 * Test processing a Relation.
 */
@Test
public final void testProcess8() {
    Relation testRelation;
    testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
    testRelation.getTags().add(new Tag("test_key1", "test_value1"));
    testOsmWriter.process(new RelationContainer(testRelation));
// Nothing to assert; just expect no exception
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) RelationContainer(org.openstreetmap.osmosis.core.container.v0_6.RelationContainer) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Date(java.util.Date) Test(org.junit.Test)

Example 18 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class OsmWriterTest method testProcess9.

/**
 * Test processing a Bound after a Relation.
 */
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess9() {
    Relation testRelation;
    testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
    testRelation.getTags().add(new Tag("test_key1", "test_value1"));
    testOsmWriter.process(new RelationContainer(testRelation));
    testOsmWriter.process(new BoundContainer(new Bound("source")));
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) RelationContainer(org.openstreetmap.osmosis.core.container.v0_6.RelationContainer) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Date(java.util.Date) Test(org.junit.Test)

Example 19 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class RelationWriterTest method testProcessRelationWithNoUser.

/**
 * Test writing of a Relation element with no user.
 */
@Test
public final void testProcessRelationWithNoUser() {
    Relation relation = new Relation(new CommonEntityData(1234, 2, timestamp, OsmUser.NONE, 0));
    relation.getMembers().add(new RelationMember(2345, EntityType.Node, "noderole"));
    relation.getMembers().add(new RelationMember(3456, EntityType.Way, "wayrole"));
    relation.getMembers().add(new RelationMember(4567, EntityType.Relation, "relationrole"));
    relation.getTags().add(new Tag("relationkey", "relationvalue"));
    testRelationWriter.process(relation);
    try {
        testBufferedWriter.flush();
    } catch (IOException e) {
        e.printStackTrace();
        fail("IOException");
    }
    String relationOpeningNoUserMatch = "^\\s*<relation\\s*" + "id=['\"]1234['\"]\\s*" + "version=['\"]2['\"]\\s*" + "timestamp=['\"]2013-10-07T10:24:31Z?['\"]\\s*" + ">\\s*";
    String[] strArray = testWriter.toString().split("\\n", 6);
    assertTrue(strArray[0].matches(relationOpeningNoUserMatch));
    assertTrue(strArray[1].matches(nodeMemberMatch));
    assertTrue(strArray[2].matches(wayMemberMatch));
    assertTrue(strArray[3].matches(relationMemberMatch));
    assertTrue(strArray[4].matches(relationTagMatch));
    assertTrue(strArray[5].matches(relationClosingMatch));
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) IOException(java.io.IOException) Test(org.junit.Test)

Example 20 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class FastXmlParser method readTag.

private Tag readTag() throws Exception {
    Tag tag = new Tag(reader.getAttributeValue(null, ATTRIBUTE_NAME_KEY), reader.getAttributeValue(null, ATTRIBUTE_NAME_VALUE));
    reader.nextTag();
    reader.nextTag();
    return tag;
}
Also used : 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