use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.
the class MergedElementDaoTest method testGetWay.
public void testGetWay() {
Way way = mock(Way.class);
when(way.getId()).thenReturn(1L);
dao.get(Element.Type.WAY, 1L);
verify(wayDao).get(1L);
}
use of de.westnordost.osmapi.map.data.Way 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);
}
}
use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.
the class OverpassMapDataParserTest method testWay.
public void testWay() {
OsmLatLon[] p = new OsmLatLon[2];
p[0] = new OsmLatLon(1, 2);
p[1] = new OsmLatLon(3, 4);
String xml = "<way id='8' version='1' >\n" + " <nd ref='2' lat='" + p[0].getLatitude() + "' lon='" + p[0].getLongitude() + "' />\n" + " <nd ref='3' lat='" + p[1].getLatitude() + "' lon='" + p[1].getLongitude() + "' />\n" + "</way>";
LongSparseArray<List<LatLon>> expectedGeometry = new LongSparseArray<>();
expectedGeometry.put(8, new ArrayList<>(Arrays.asList(p)));
Element e = parseOne(xml, expectedGeometry);
assertTrue(e instanceof Way);
Way way = (Way) e;
assertEquals(8, way.getId());
assertEquals(1, way.getVersion());
assertEquals(2, way.getNodeIds().size());
assertEquals(2, (long) way.getNodeIds().get(0));
assertEquals(3, (long) way.getNodeIds().get(1));
}
use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.
the class WayDaoTest method testPutGetWithTags.
public void testPutGetWithTags() {
Map<String, String> tags = new HashMap<>();
tags.put("a key", "a value");
Way way = new OsmWay(5, 1, Arrays.asList(1L, 2L, 3L, 4L), tags);
dao.put(way);
Way dbWay = dao.get(5);
checkEqual(way, dbWay);
}
Aggregations