Search in sources :

Example 6 with TLongSet

use of com.slimjars.dist.gnu.trove.set.TLongSet 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 7 with TLongSet

use of com.slimjars.dist.gnu.trove.set.TLongSet 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)

Example 8 with TLongSet

use of com.slimjars.dist.gnu.trove.set.TLongSet in project osm4j-core by topobyte.

the class IdDataSetReader method read.

public static InMemorySetIdDataSet read(OsmIdReader reader) throws OsmInputException {
    final InMemorySetIdDataSet dataSet = new InMemorySetIdDataSet();
    final TLongSet nodeIds = dataSet.getNodeIds();
    final TLongSet wayIds = dataSet.getWayIds();
    final TLongSet relationIds = dataSet.getRelationIds();
    reader.setIdHandler(new OsmIdHandler() {

        @Override
        public void handle(OsmBounds bounds) throws IOException {
            dataSet.setBounds(bounds);
        }

        @Override
        public void handleNode(long id) throws IOException {
            nodeIds.add(id);
        }

        @Override
        public void handleWay(long id) throws IOException {
            wayIds.add(id);
        }

        @Override
        public void handleRelation(long id) throws IOException {
            relationIds.add(id);
        }

        @Override
        public void complete() throws IOException {
        // nothing to do here
        }
    });
    reader.read();
    return dataSet;
}
Also used : OsmBounds(de.topobyte.osm4j.core.model.iface.OsmBounds) TLongSet(com.slimjars.dist.gnu.trove.set.TLongSet) OsmIdHandler(de.topobyte.osm4j.core.access.OsmIdHandler) IOException(java.io.IOException)

Aggregations

TLongSet (com.slimjars.dist.gnu.trove.set.TLongSet)8 TLongHashSet (com.slimjars.dist.gnu.trove.set.hash.TLongHashSet)4 OsmRelation (de.topobyte.osm4j.core.model.iface.OsmRelation)4 OsmRelationMember (de.topobyte.osm4j.core.model.iface.OsmRelationMember)3 OsmBounds (de.topobyte.osm4j.core.model.iface.OsmBounds)2 IOException (java.io.IOException)2 OsmHandler (de.topobyte.osm4j.core.access.OsmHandler)1 OsmIdHandler (de.topobyte.osm4j.core.access.OsmIdHandler)1 EntityContainer (de.topobyte.osm4j.core.model.iface.EntityContainer)1 IdContainer (de.topobyte.osm4j.core.model.iface.IdContainer)1 OsmNode (de.topobyte.osm4j.core.model.iface.OsmNode)1 OsmWay (de.topobyte.osm4j.core.model.iface.OsmWay)1