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);
}
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);
}
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());
}
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);
}
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);
}
}
Aggregations