Search in sources :

Example 1 with Node

use of de.westnordost.osmapi.map.data.Node in project StreetComplete by westnordost.

the class MergedElementDaoTest method testPutNode.

public void testPutNode() {
    Node node = mock(Node.class);
    when(node.getType()).thenReturn(Element.Type.NODE);
    dao.put(node);
    verify(nodeDao).put(node);
}
Also used : Node(de.westnordost.osmapi.map.data.Node) OsmNode(de.westnordost.osmapi.map.data.OsmNode)

Example 2 with Node

use of de.westnordost.osmapi.map.data.Node in project StreetComplete by westnordost.

the class MergedElementDao method putAll.

public void putAll(Collection<Element> elements) {
    Collection<Node> nodes = new ArrayList<>();
    Collection<Way> ways = new ArrayList<>();
    Collection<Relation> relations = new ArrayList<>();
    for (Element element : elements) {
        switch(element.getType()) {
            case NODE:
                nodes.add((Node) element);
                break;
            case WAY:
                ways.add((Way) element);
                break;
            case RELATION:
                relations.add((Relation) element);
                break;
        }
    }
    if (!nodes.isEmpty())
        nodeDao.putAll(nodes);
    if (!ways.isEmpty())
        wayDao.putAll(ways);
    if (!relations.isEmpty())
        relationDao.putAll(relations);
}
Also used : Relation(de.westnordost.osmapi.map.data.Relation) Node(de.westnordost.osmapi.map.data.Node) Element(de.westnordost.osmapi.map.data.Element) ArrayList(java.util.ArrayList) Way(de.westnordost.osmapi.map.data.Way)

Example 3 with Node

use of de.westnordost.osmapi.map.data.Node in project StreetComplete by westnordost.

the class OverpassMapDataParserTest method testNode.

public void testNode() {
    LatLon pos = new OsmLatLon(51.7463194, 0.2428181);
    String xml = " <node id='5' version='1' lat='" + pos.getLatitude() + "' lon='" + pos.getLongitude() + "'/>";
    Element e = parseOne(xml, null);
    assertTrue(e instanceof Node);
    Node node = (Node) e;
    assertEquals(pos, node.getPosition());
    assertEquals(5, node.getId());
    assertEquals(1, node.getVersion());
    assertNull(node.getTags());
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Element(de.westnordost.osmapi.map.data.Element) Node(de.westnordost.osmapi.map.data.Node) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 4 with Node

use of de.westnordost.osmapi.map.data.Node in project StreetComplete by westnordost.

the class MergedElementDaoTest method testGetNode.

public void testGetNode() {
    Node node = mock(Node.class);
    when(node.getId()).thenReturn(1L);
    dao.get(Element.Type.NODE, 1L);
    verify(nodeDao).get(1L);
}
Also used : Node(de.westnordost.osmapi.map.data.Node) OsmNode(de.westnordost.osmapi.map.data.OsmNode)

Example 5 with Node

use of de.westnordost.osmapi.map.data.Node in project StreetComplete by westnordost.

the class OverpassMapDataParser method onEndElement.

@Override
protected void onEndElement() {
    String name = getName();
    Element element = null;
    ElementGeometry geometry = null;
    switch(name) {
        case MEMBER:
            wayNodes = null;
            break;
        case NODE:
            Node node = factory.createNode(id, version, lat, lon, tags, null, null);
            geometry = elementGeometryCreator.create(node);
            element = node;
            break;
        case WAY:
            Way way = factory.createWay(id, version, nodes, tags, null, null);
            geometry = elementGeometryCreator.create(way);
            element = way;
            nodes = null;
            nodePositionsByWay = null;
            wayNodes = null;
            break;
        case RELATION:
            Relation relation = factory.createRelation(id, version, members, tags, null, null);
            geometry = elementGeometryCreator.create(relation);
            element = relation;
            members = null;
            nodePositionsByWay = null;
            break;
    }
    if (element != null) {
        tags = null;
        handler.handle(element, geometry);
    }
}
Also used : Relation(de.westnordost.osmapi.map.data.Relation) Element(de.westnordost.osmapi.map.data.Element) Node(de.westnordost.osmapi.map.data.Node) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) Way(de.westnordost.osmapi.map.data.Way)

Aggregations

Node (de.westnordost.osmapi.map.data.Node)7 OsmNode (de.westnordost.osmapi.map.data.OsmNode)4 Element (de.westnordost.osmapi.map.data.Element)3 LatLon (de.westnordost.osmapi.map.data.LatLon)3 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)3 Relation (de.westnordost.osmapi.map.data.Relation)2 Way (de.westnordost.osmapi.map.data.Way)2 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1