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;
}
Aggregations