Search in sources :

Example 21 with OsmRelation

use of de.topobyte.osm4j.core.model.iface.OsmRelation in project osm4j-pbf by topobyte.

the class PrimParser method convert.

public OsmRelation convert(Osmformat.Relation r) {
    long id = r.getId();
    long lastMid = 0;
    List<OsmTag> tags = new ArrayList<>();
    for (int j = 0; j < r.getKeysCount(); j++) {
        tags.add(new Tag(strings[r.getKeys(j)], strings[r.getVals(j)]));
    }
    List<RelationMember> members = new ArrayList<>();
    for (int j = 0; j < r.getMemidsCount(); j++) {
        long mid = lastMid + r.getMemids(j);
        lastMid = mid;
        String role = strings[r.getRolesSid(j)];
        Osmformat.Relation.MemberType type = r.getTypes(j);
        EntityType t = getType(type);
        RelationMember member = new RelationMember(mid, t, role);
        members.add(member);
    }
    OsmMetadata metadata = null;
    if (fetchMetadata && r.hasInfo()) {
        Osmformat.Info info = r.getInfo();
        metadata = convertMetadata(info);
    }
    return new Relation(id, members, tags, metadata);
}
Also used : OsmMetadata(de.topobyte.osm4j.core.model.iface.OsmMetadata) OsmTag(de.topobyte.osm4j.core.model.iface.OsmTag) ArrayList(java.util.ArrayList) TLongArrayList(com.slimjars.dist.gnu.trove.list.array.TLongArrayList) Osmformat(de.topobyte.osm4j.pbf.protobuf.Osmformat) EntityType(de.topobyte.osm4j.core.model.iface.EntityType) Relation(de.topobyte.osm4j.core.model.impl.Relation) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) RelationMember(de.topobyte.osm4j.core.model.impl.RelationMember) Tag(de.topobyte.osm4j.core.model.impl.Tag) OsmTag(de.topobyte.osm4j.core.model.iface.OsmTag)

Aggregations

OsmRelation (de.topobyte.osm4j.core.model.iface.OsmRelation)21 ArrayList (java.util.ArrayList)9 OsmRelationMember (de.topobyte.osm4j.core.model.iface.OsmRelationMember)8 OsmNode (de.topobyte.osm4j.core.model.iface.OsmNode)7 OsmWay (de.topobyte.osm4j.core.model.iface.OsmWay)7 TLongArrayList (com.slimjars.dist.gnu.trove.list.array.TLongArrayList)6 Relation (de.topobyte.osm4j.core.model.impl.Relation)6 TLongSet (com.slimjars.dist.gnu.trove.set.TLongSet)4 OsmHandler (de.topobyte.osm4j.core.access.OsmHandler)4 OsmBounds (de.topobyte.osm4j.core.model.iface.OsmBounds)4 Node (de.topobyte.osm4j.core.model.impl.Node)4 Way (de.topobyte.osm4j.core.model.impl.Way)4 IOException (java.io.IOException)4 TLongIterator (com.slimjars.dist.gnu.trove.iterator.TLongIterator)3 TLongHashSet (com.slimjars.dist.gnu.trove.set.hash.TLongHashSet)3 InputStream (java.io.InputStream)3 OsmIterator (de.topobyte.osm4j.core.access.OsmIterator)2 InMemoryMapDataSet (de.topobyte.osm4j.core.dataset.InMemoryMapDataSet)2 EntityContainer (de.topobyte.osm4j.core.model.iface.EntityContainer)2 EntityType (de.topobyte.osm4j.core.model.iface.EntityType)2