Add missing offset recalc

stable-3.2
bjornharrtell 2021-11-27 23:04:24 +01:00
parent d71751919c
commit ea3c95682c
1 changed files with 7 additions and 0 deletions

View File

@ -201,6 +201,13 @@ void flatgeobuf_create_index(ctx *ctx)
ctx->offset = sizeof(signed int) + FLATGEOBUF_MAGICBYTES_SIZE;
// write new header
flatgeobuf_encode_header(ctx);
// calculate new offsets
uint64_t featureOffset = 0;
for (auto item : items) {
auto featureItem = std::static_pointer_cast<FeatureItem>(item);
featureItem->nodeItem.offset = featureOffset;
featureOffset += featureItem->size;
}
// create and write index
PackedRTree tree(items, extent, ctx->index_node_size);
const auto writeData = [&ctx] (const void *data, const size_t size) {