Search in sources :

Example 6 with Relation

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

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

the class RelationDaoTest method testPutGetWithTags.

public void testPutGetWithTags() {
    List<RelationMember> members = new ArrayList<>();
    members.add(new OsmRelationMember(0, "outer", Element.Type.WAY));
    members.add(new OsmRelationMember(1, "inner", Element.Type.WAY));
    Map<String, String> tags = new HashMap<>();
    tags.put("a key", "a value");
    Relation relation = new OsmRelation(5, 1, members, tags);
    dao.put(relation);
    Relation dbRelation = dao.get(5);
    checkEqual(relation, dbRelation);
}
Also used : Relation(de.westnordost.osmapi.map.data.Relation) OsmRelation(de.westnordost.osmapi.map.data.OsmRelation) OsmRelationMember(de.westnordost.osmapi.map.data.OsmRelationMember) RelationMember(de.westnordost.osmapi.map.data.RelationMember) HashMap(java.util.HashMap) OsmRelation(de.westnordost.osmapi.map.data.OsmRelation) ArrayList(java.util.ArrayList) OsmRelationMember(de.westnordost.osmapi.map.data.OsmRelationMember)

Aggregations

Relation (de.westnordost.osmapi.map.data.Relation)7 OsmRelation (de.westnordost.osmapi.map.data.OsmRelation)4 ArrayList (java.util.ArrayList)4 Element (de.westnordost.osmapi.map.data.Element)3 RelationMember (de.westnordost.osmapi.map.data.RelationMember)3 Node (de.westnordost.osmapi.map.data.Node)2 OsmRelationMember (de.westnordost.osmapi.map.data.OsmRelationMember)2 Way (de.westnordost.osmapi.map.data.Way)2 LongSparseArray (android.util.LongSparseArray)1 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)1 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)1 HashMap (java.util.HashMap)1 List (java.util.List)1