use of de.topobyte.osm4j.pbf.protobuf.Fileformat.Blob in project osm4j-pbf by topobyte.
the class EntitySplitBlockwise method copyWays.
private void copyWays(Interval ways, boolean firstWayBlockMixed, boolean lastWayBlockMixed) throws IOException {
int firstWayOnlyBlock = ways.getStart();
if (firstWayBlockMixed) {
firstWayOnlyBlock += 1;
}
int lastWayOnlyBlock = ways.getEnd();
if (lastWayBlockMixed) {
lastWayOnlyBlock -= 1;
}
if (firstWayBlockMixed) {
// First copy all ways from the first partial block
copyPartial(ways.getStart(), EntityType.Way, blockWriterWays);
}
// Then copy all blocks that contain only ways block-wise
for (int i = firstWayOnlyBlock; i <= lastWayOnlyBlock; i++) {
Fileformat.Blob blob = pbfFile.getDataBlob(i);
blockWriterWays.write(Constants.BLOCK_TYPE_DATA, null, blob);
}
// If the last block contains data other than ways, continue
if (!lastWayBlockMixed) {
return;
}
// But not if we copied the partial block in the beginning already
if (ways.getStart() == ways.getEnd()) {
return;
}
// Copy the remaining ways group-wise
copyPartial(ways.getEnd(), EntityType.Way, blockWriterWays);
}
use of de.topobyte.osm4j.pbf.protobuf.Fileformat.Blob in project osm4j-pbf by topobyte.
the class EntitySplitBlockwise method copyRelations.
private void copyRelations(Interval relations, boolean firstRelationBlockMixed) throws IOException {
int firstRelationOnlyBlock = relations.getStart();
if (firstRelationBlockMixed) {
firstRelationOnlyBlock += 1;
}
if (firstRelationBlockMixed) {
// First copy all relations from the first partial block
copyPartial(relations.getStart(), EntityType.Relation, blockWriterRelations);
}
// Then copy all blocks that contain only relations block-wise
for (int i = firstRelationOnlyBlock; i <= relations.getEnd(); i++) {
Fileformat.Blob blob = pbfFile.getDataBlob(i);
blockWriterRelations.write(Constants.BLOCK_TYPE_DATA, null, blob);
}
}
use of de.topobyte.osm4j.pbf.protobuf.Fileformat.Blob in project osm4j-pbf by topobyte.
the class EntitySplitBlockwise method copyNodes.
private void copyNodes(Interval nodes, boolean lastNodeBlockDirty) throws IOException {
int lastNodeOnlyBlock = nodes.getEnd();
if (lastNodeBlockDirty) {
lastNodeOnlyBlock -= 1;
}
// First copy all blocks that contain only nodes block-wise
for (int i = nodes.getStart(); i <= lastNodeOnlyBlock; i++) {
Fileformat.Blob blob = pbfFile.getDataBlob(i);
blockWriterNodes.write(Constants.BLOCK_TYPE_DATA, null, blob);
}
// If the last block contains data other than nodes, continue
if (!lastNodeBlockDirty) {
return;
}
// Copy the remaining nodes group-wise
copyPartial(nodes.getEnd(), EntityType.Node, blockWriterNodes);
}
use of de.topobyte.osm4j.pbf.protobuf.Fileformat.Blob in project osm4j-pbf by topobyte.
the class EntitySplitBlockwise method copyPartial.
private void copyPartial(int blockIndex, EntityType type, BlockWriter blockWriter) throws IOException {
Blob blob = pbfFile.getDataBlob(blockIndex);
BlockData blockData = PbfUtil.getBlockData(blob);
PrimitiveBlock block = PrimitiveBlock.parseFrom(blockData.getBlobData());
EntityGroups groups = EntityGroups.splitEntities(block);
copy(blockWriter, groups.getGroups(type), block, blockData.getCompression());
}
Aggregations