use of de.topobyte.osm4j.pbf.protobuf.Osmformat.PrimitiveGroup in project osm4j-pbf by topobyte.
the class EntitySplitBlockwise method copy.
private void copy(BlockWriter blockWriter, List<PrimitiveGroup> gs, Osmformat.PrimitiveBlock primBlock, Compression compression) throws IOException {
Osmformat.PrimitiveBlock.Builder builder = Osmformat.PrimitiveBlock.newBuilder();
for (Osmformat.PrimitiveGroup group : gs) {
builder.addPrimitivegroup(group);
}
copyExtraData(builder, primBlock);
Osmformat.PrimitiveBlock block = builder.build();
blockWriter.write(Constants.BLOCK_TYPE_DATA, null, compression, block.toByteString());
}
use of de.topobyte.osm4j.pbf.protobuf.Osmformat.PrimitiveGroup in project osm4j-pbf by topobyte.
the class PbfWriter method writeBatch.
private void writeBatch() throws IOException {
ensureHeader();
Osmformat.PrimitiveBlock.Builder builder = Osmformat.PrimitiveBlock.newBuilder();
// First add all strings to the string table
addTagsToStringTable(bufNodes);
addTagsToStringTable(bufWays);
addTagsToStringTable(bufRelations);
addMemberRolesToStringTable(bufRelations);
if (writeMetadata) {
addUsersToStringTable(bufNodes);
addUsersToStringTable(bufWays);
addUsersToStringTable(bufRelations);
}
// And build indices
stringTable.finish();
if (bufNodes.size() > 0) {
if (useDense) {
PrimitiveGroup group = serializeDense(bufNodes);
builder.addPrimitivegroup(group);
} else {
PrimitiveGroup group = serializeNonDense(bufNodes);
builder.addPrimitivegroup(group);
}
bufNodes.clear();
}
if (bufWays.size() > 0) {
PrimitiveGroup group = serializeWays(bufWays);
builder.addPrimitivegroup(group);
bufWays.clear();
}
if (bufRelations.size() > 0) {
PrimitiveGroup group = serializeRelations(bufRelations);
builder.addPrimitivegroup(group);
bufRelations.clear();
}
builder.setDateGranularity(dateGranularity);
builder.setGranularity(granularity);
builder.setStringtable(stringTable.serialize());
PrimitiveBlock block = builder.build();
ByteString data = block.toByteString();
// Reset counter and string table
counter = 0;
stringTable.clear();
write(Constants.BLOCK_TYPE_DATA, null, compression, data);
}
use of de.topobyte.osm4j.pbf.protobuf.Osmformat.PrimitiveGroup in project osm4j-pbf by topobyte.
the class EntitySplit method copy.
private void copy(BlockWriter blockWriter, List<PrimitiveGroup> gs, Osmformat.PrimitiveBlock primBlock, Compression compression) throws IOException {
Osmformat.PrimitiveBlock.Builder builder = Osmformat.PrimitiveBlock.newBuilder();
for (Osmformat.PrimitiveGroup group : gs) {
builder.addPrimitivegroup(group);
}
copyExtraData(builder, primBlock);
Osmformat.PrimitiveBlock block = builder.build();
blockWriter.write(Constants.BLOCK_TYPE_DATA, null, compression, block.toByteString());
}
use of de.topobyte.osm4j.pbf.protobuf.Osmformat.PrimitiveGroup in project osm4j-pbf by topobyte.
the class BlockElementCountInfo method parse.
@Override
protected void parse(Osmformat.PrimitiveBlock block) {
int elements = 0;
for (int i = 0; i < block.getPrimitivegroupCount(); i++) {
PrimitiveGroup group = block.getPrimitivegroup(i);
elements += group.getNodesCount();
elements += group.getWaysCount();
elements += group.getRelationsCount();
if (group.hasDense()) {
elements += group.getDense().getIdCount();
}
}
System.out.println(String.format("Block %d: %d", nBlocks, elements));
nBlocks++;
}
Aggregations