use of de.topobyte.osm4j.pbf.util.BlockData in project osm4j-pbf by topobyte.
the class PbfIterator method advanceBlock.
private void advanceBlock() throws IOException {
BlobHeader header = PbfUtil.parseHeader(input);
Fileformat.Blob blob = PbfUtil.parseBlock(input, header.getDataLength());
BlockData blockData = PbfUtil.getBlockData(blob);
String type = header.getType();
if (type.equals(Constants.BLOCK_TYPE_DATA)) {
beyondBounds = true;
Osmformat.PrimitiveBlock block = Osmformat.PrimitiveBlock.parseFrom(blockData.getBlobData());
PrimParser primParser = new PrimParser(block, fetchMetadata);
for (Osmformat.PrimitiveGroup group : block.getPrimitivegroupList()) {
if (group.getNodesCount() > 0) {
pushNodes(primParser, group.getNodesList());
}
if (group.hasDense()) {
pushNodes(primParser, group.getDense());
}
if (group.getWaysCount() > 0) {
pushWays(primParser, group.getWaysList());
}
if (group.getRelationsCount() > 0) {
pushRelations(primParser, group.getRelationsList());
}
}
} else if (type.equals(Constants.BLOCK_TYPE_HEADER)) {
Osmformat.HeaderBlock block = Osmformat.HeaderBlock.parseFrom(blockData.getBlobData());
HeaderBBox bbox = block.getBbox();
if (bbox != null && !beyondBounds) {
this.bounds = PbfUtil.bounds(bbox);
}
beyondBounds = true;
} else {
throw new IOException("invalid PBF block");
}
}
Aggregations