Search in sources :

Example 1 with OsmIdHandler

use of de.topobyte.osm4j.core.access.OsmIdHandler 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)1 OsmIdHandler (de.topobyte.osm4j.core.access.OsmIdHandler)1 OsmBounds (de.topobyte.osm4j.core.model.iface.OsmBounds)1 IOException (java.io.IOException)1