Search in sources :

Example 21 with Element

use of de.westnordost.osmapi.map.data.Element 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 22 with Element

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

the class OverpassMapDataParserTest method testTags.

public void testTags() {
    String xml = "<relation id='1' version='1' >\n" + " <tag k='a' v='b'/>" + " <tag k='c' v='d'/>" + "</relation>";
    Element element = parseOne(xml, null);
    assertNotNull(element.getTags());
    assertEquals(2, element.getTags().size());
    assertEquals("b", element.getTags().get("a"));
    assertEquals("d", element.getTags().get("c"));
}
Also used : Element(de.westnordost.osmapi.map.data.Element)

Aggregations

Element (de.westnordost.osmapi.map.data.Element)22 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)9 Point (android.graphics.Point)4 MergedElementDao (de.westnordost.streetcomplete.data.osm.persist.MergedElementDao)4 OsmQuestDao (de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao)4 ArrayList (java.util.ArrayList)4 MapDataDao (de.westnordost.osmapi.map.MapDataDao)3 Node (de.westnordost.osmapi.map.data.Node)3 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)3 Relation (de.westnordost.osmapi.map.data.Relation)3 Way (de.westnordost.osmapi.map.data.Way)3 DownloadedTilesDao (de.westnordost.streetcomplete.data.tiles.DownloadedTilesDao)3 SharedPreferences (android.content.SharedPreferences)2 LongSparseArray (android.util.LongSparseArray)2 OpenChangesetsDao (de.westnordost.streetcomplete.data.changesets.OpenChangesetsDao)2 StringMapChanges (de.westnordost.streetcomplete.data.osm.changes.StringMapChanges)2 HashMap (java.util.HashMap)2 List (java.util.List)2 View (android.view.View)1 ImageView (android.widget.ImageView)1