Search in sources :

Example 11 with OsmRelation

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

the class EntityFinderIgnoreMissing method findMemberRelationsRecursively.

private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) {
    TLongSet ids = new TLongHashSet();
    while (!queue.isEmpty()) {
        OsmRelation relation = queue.remove();
        for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
            if (member.getType() != EntityType.Relation) {
                continue;
            }
            long id = member.getId();
            if (ids.contains(id)) {
                continue;
            }
            ids.add(id);
            try {
                OsmRelation child = entityProvider.getRelation(id);
                outRelations.add(child);
                queue.add(child);
            } catch (EntityNotFoundException e) {
            // ignore silently
            }
        }
    }
}
Also used : TLongSet(com.slimjars.dist.gnu.trove.set.TLongSet) TLongHashSet(com.slimjars.dist.gnu.trove.set.hash.TLongHashSet) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) OsmRelationMember(de.topobyte.osm4j.core.model.iface.OsmRelationMember)

Example 12 with OsmRelation

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

the class EntityFinderLogMissing method findMemberRelationsRecursively.

private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) {
    TLongSet ids = new TLongHashSet();
    while (!queue.isEmpty()) {
        OsmRelation relation = queue.remove();
        for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
            if (member.getType() != EntityType.Relation) {
                continue;
            }
            long id = member.getId();
            if (ids.contains(id)) {
                continue;
            }
            ids.add(id);
            try {
                OsmRelation child = entityProvider.getRelation(id);
                outRelations.add(child);
                queue.add(child);
            } catch (EntityNotFoundException e) {
                logRelationNotFound(id);
            }
        }
    }
}
Also used : TLongSet(com.slimjars.dist.gnu.trove.set.TLongSet) TLongHashSet(com.slimjars.dist.gnu.trove.set.hash.TLongHashSet) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) OsmRelationMember(de.topobyte.osm4j.core.model.iface.OsmRelationMember)

Example 13 with OsmRelation

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

the class EntityFinderLogMissing method findRelations.

@Override
public List<OsmRelation> findRelations(TLongCollection ids) {
    List<OsmRelation> relations = new ArrayList<>();
    TLongIterator idIterator = ids.iterator();
    while (idIterator.hasNext()) {
        long id = idIterator.next();
        try {
            relations.add(entityProvider.getRelation(id));
        } catch (EntityNotFoundException e) {
            logRelationNotFound(id);
        }
    }
    return relations;
}
Also used : OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) ArrayList(java.util.ArrayList) TLongIterator(com.slimjars.dist.gnu.trove.iterator.TLongIterator)

Example 14 with OsmRelation

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

the class EntityFinderThrowMissing method findRelations.

@Override
public List<OsmRelation> findRelations(TLongCollection ids) throws EntityNotFoundException {
    List<OsmRelation> relations = new ArrayList<>();
    TLongIterator idIterator = ids.iterator();
    while (idIterator.hasNext()) {
        relations.add(entityProvider.getRelation(idIterator.next()));
    }
    return relations;
}
Also used : OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) ArrayList(java.util.ArrayList) TLongIterator(com.slimjars.dist.gnu.trove.iterator.TLongIterator)

Example 15 with OsmRelation

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

the class EntityFinderThrowMissing method findMemberRelationsRecursively.

private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) throws EntityNotFoundException {
    TLongSet ids = new TLongHashSet();
    while (!queue.isEmpty()) {
        OsmRelation relation = queue.remove();
        for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
            if (member.getType() != EntityType.Relation) {
                continue;
            }
            long id = member.getId();
            if (ids.contains(id)) {
                continue;
            }
            ids.add(id);
            OsmRelation child = entityProvider.getRelation(id);
            outRelations.add(child);
            queue.add(child);
        }
    }
}
Also used : TLongSet(com.slimjars.dist.gnu.trove.set.TLongSet) TLongHashSet(com.slimjars.dist.gnu.trove.set.hash.TLongHashSet) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) OsmRelationMember(de.topobyte.osm4j.core.model.iface.OsmRelationMember)

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