Search in sources :

Example 6 with Way

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);
}
Also used : OsmWay(de.westnordost.osmapi.map.data.OsmWay) Way(de.westnordost.osmapi.map.data.Way)

Example 7 with Way

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

Example 8 with Way

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));
}
Also used : LongSparseArray(android.util.LongSparseArray) Element(de.westnordost.osmapi.map.data.Element) ArrayList(java.util.ArrayList) List(java.util.List) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Way(de.westnordost.osmapi.map.data.Way)

Example 9 with Way

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);
}
Also used : OsmWay(de.westnordost.osmapi.map.data.OsmWay) HashMap(java.util.HashMap) Way(de.westnordost.osmapi.map.data.Way) OsmWay(de.westnordost.osmapi.map.data.OsmWay)

Aggregations

Way (de.westnordost.osmapi.map.data.Way)9 OsmWay (de.westnordost.osmapi.map.data.OsmWay)4 Element (de.westnordost.osmapi.map.data.Element)3 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)3 LatLon (de.westnordost.osmapi.map.data.LatLon)2 Node (de.westnordost.osmapi.map.data.Node)2 Relation (de.westnordost.osmapi.map.data.Relation)2 Note (de.westnordost.osmapi.notes.Note)2 ArrayList (java.util.ArrayList)2 LongSparseArray (android.util.LongSparseArray)1 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)1 HashMap (java.util.HashMap)1 List (java.util.List)1