Search in sources :

Example 1 with Tag

use of org.openstreetmap.osmosis.core.domain.v0_6.Tag in project requery by requery.

the class UpsertTest method testUpsertManyToMany.

@Test
public void testUpsertManyToMany() {
    Event event1 = new Event();
    event1.setId(UUID.randomUUID());
    Tag tag = new Tag();
    tag.setId(UUID.randomUUID());
    tag.getEvents().add(event1);
    data.upsert(tag);
    Event event2 = new Event();
    event2.setId(UUID.randomUUID());
    tag.getEvents().add(event2);
    data.upsert(event2);
    data.upsert(tag);
}
Also used : Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) Test(org.junit.Test)

Example 2 with Tag

use of org.openstreetmap.osmosis.core.domain.v0_6.Tag in project requery by requery.

the class JacksonTest method testManyToManySerialize.

@Test
public void testManyToManySerialize() {
    Tag t1 = new Tag();
    t1.setId(UUID.randomUUID());
    for (int i = 0; i < 3; i++) {
        Event event = new Event();
        UUID id = UUID.randomUUID();
        event.setId(id);
        event.setName("event" + i);
        t1.getEvents().add(event);
    }
    data.insert(t1);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, t1);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        Tag tag = mapper.readValue(value, Tag.class);
        assertSame(t1, tag);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) IOException(java.io.IOException) UUID(java.util.UUID) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Example 3 with Tag

use of org.openstreetmap.osmosis.core.domain.v0_6.Tag in project requery by requery.

the class JacksonTest method testOneToManySerialize.

@Test
public void testOneToManySerialize() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    event.setId(id);
    event.setName("test");
    Tag t1 = new Tag();
    t1.setId(UUID.randomUUID());
    Tag t2 = new Tag();
    t2.setId(UUID.randomUUID());
    event.getTags().add(t1);
    event.getTags().add(t2);
    Place p = new Place();
    p.setId("SF");
    p.setName("San Francisco, CA");
    event.setPlace(p);
    data.insert(event);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, event);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        Event read = mapper.readValue(value, Event.class);
        assertSame(event, read);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) IOException(java.io.IOException) UUID(java.util.UUID) Place(io.requery.test.model3.Place) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Example 4 with Tag

use of org.openstreetmap.osmosis.core.domain.v0_6.Tag in project voltdb by VoltDB.

the class VoltDBOsmSink method process.

/**
     * {@inheritDoc}
     */
public void process(RelationContainer relationContainer) {
    Relation relation;
    int memberSequenceId;
    relation = relationContainer.getEntity();
    try {
        client.callProcedure(new InsertCallback(), INS_RELATIONS_PROC, relation.getId(), relation.getVersion(), relation.getUser().getId(), relation.getTimestamp(), relation.getChangesetId());
    } catch (NoConnectionsException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    memberSequenceId = 0;
    for (RelationMember member : relation.getMembers()) {
        try {
            client.callProcedure(new InsertCallback(), INS_RELATIONS_MEMBER_PROC, relation.getId(), member.getMemberId(), member.getMemberType().ordinal(), member.getMemberRole(), memberSequenceId);
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        memberSequenceId++;
    }
    for (Tag tag : relation.getTags()) {
        try {
            client.callProcedure(new InsertCallback(), INS_RELATION_TAGS_PROC, relation.getId(), tag.getKey(), tag.getValue());
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) NoConnectionsException(org.voltdb.client.NoConnectionsException) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) IOException(java.io.IOException) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 5 with Tag

use of org.openstreetmap.osmosis.core.domain.v0_6.Tag in project voltdb by VoltDB.

the class VoltDBOsmSink method process.

public void process(NodeContainer nodeContainer) {
    Node node;
    node = nodeContainer.getEntity();
    double lat = node.getLatitude();
    double lng = node.getLongitude();
    String pointText = "POINT(" + lng + " " + lat + ")";
    // keep track of the nodes so we can build polygons later
    if (enableBboxBuilder || enableLinestringBuilder) {
        wayGeometryBuilder.addNodeLocation(node);
    }
    try {
        client.callProcedure(new InsertCallback(), INS_NODE_PROC, node.getId(), node.getVersion(), node.getUser().getId(), new TimestampType(node.getTimestamp().getTime()), node.getChangesetId(), pointText);
    } catch (NoConnectionsException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Collection<Tag> tags = node.getTags();
    for (Tag tag : tags) {
        // System.out.println(INS_NODE_TAG_PROC+","+node.getId()+","+tag.getKey()+","+tag.getValue());
        try {
            client.callProcedure(new InsertCallback(), INS_NODE_TAG_PROC, node.getId(), tag.getKey(), tag.getValue());
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : NoConnectionsException(org.voltdb.client.NoConnectionsException) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) TimestampType(org.voltdb.types.TimestampType) LineString(org.postgis.LineString) IOException(java.io.IOException) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)10 IOException (java.io.IOException)5 Point (com.vividsolutions.jts.geom.Point)4 Event (io.requery.test.model3.Event)4 Tag (io.requery.test.model3.Tag)4 Test (org.junit.Test)4 Geometry (com.vividsolutions.jts.geom.Geometry)3 UUID (java.util.UUID)3 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)3 NoConnectionsException (org.voltdb.client.NoConnectionsException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Optional (com.google.common.base.Optional)2 LineString (com.vividsolutions.jts.geom.LineString)2 EntityMapper (io.requery.jackson.EntityMapper)2 StringWriter (java.io.StringWriter)2 Entry (java.util.Map.Entry)2 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)2 RevFeature (org.locationtech.geogig.api.RevFeature)2 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)2 OSMMappingLogEntry (org.locationtech.geogig.osm.internal.log.OSMMappingLogEntry)2