FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
layout.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <fcb/error.hpp>
4#include <fcb/span.hpp>
5
6#include <cstdint>
7
8namespace fcb {
9
10constexpr std::size_t kMagicBytesSize = 8;
11constexpr std::size_t kHeaderSizeSize = 4;
12constexpr std::size_t kHeaderMinBufferSize = 8;
13constexpr std::size_t kHeaderMaxBufferSize = 1024ULL * 1024ULL * 512ULL; // 512 MB
14constexpr std::uint8_t kVersion = 1;
15constexpr std::size_t kNodeItemSize = 40;
16constexpr std::uint16_t kDefaultNodeSize = 16;
17
20constexpr std::uint64_t kMaxFeatureSize = 256ULL * 1024ULL * 1024ULL;
21
25
28std::uint64_t rtree_index_size(std::uint64_t num_items, std::uint16_t node_size);
29
32struct FileLayout {
33 std::uint64_t header_len;
34 std::uint64_t rtree_begin;
35 std::uint64_t rtree_size;
36 std::uint64_t attr_index_begin;
37 std::uint64_t attr_index_size;
38 std::uint64_t feature_begin;
39};
40
43FileLayout compute_layout(std::uint32_t header_size, std::uint64_t features_count,
44 std::uint16_t index_node_size, std::uint64_t attr_index_size);
45
48void validate_layout_against_size(const FileLayout& l, std::uint64_t total_size);
49
50} // namespace fcb
Minimal C++17 stand-in for std::span: a non-owning view over contiguous memory.
Definition span.hpp:13
constexpr std::uint64_t kMaxFeatureSize
Hard ceiling on a single feature's byte length, enforced before allocating.
Definition layout.hpp:20
std::uint64_t rtree_index_size(std::uint64_t num_items, std::uint16_t node_size)
Mirrors PackedRTree::index_size (packed_rtree/mod.rs:879-898).
Definition layout.cpp:26
constexpr std::uint16_t kDefaultNodeSize
Definition layout.hpp:16
constexpr std::size_t kHeaderMinBufferSize
Definition layout.hpp:12
constexpr std::size_t kNodeItemSize
Definition layout.hpp:15
constexpr std::size_t kHeaderMaxBufferSize
Definition layout.hpp:13
constexpr std::size_t kHeaderSizeSize
Definition layout.hpp:11
FileLayout compute_layout(std::uint32_t header_size, std::uint64_t features_count, std::uint16_t index_node_size, std::uint64_t attr_index_size)
Throws fcb::Error{IllegalHeaderSize} when header_size is out of range or any size arithmetic overflow...
Definition layout.cpp:49
constexpr std::uint8_t kVersion
Definition layout.hpp:14
void validate_layout_against_size(const FileLayout &l, std::uint64_t total_size)
Throws unless the computed sections fit inside the resource.
Definition layout.cpp:70
bool check_magic_bytes(bytes_view b)
Mirrors fcb_core::check_magic_bytes (src/rust/fcb_core/src/lib.rs:56-58).
Definition layout.cpp:14
constexpr std::size_t kMagicBytesSize
Definition layout.hpp:10
std::uint64_t node_size
Definition stree.cpp:167
Byte offsets of each section.
Definition layout.hpp:32
std::uint64_t rtree_begin
Definition layout.hpp:34
std::uint64_t attr_index_size
Definition layout.hpp:37
std::uint64_t rtree_size
Definition layout.hpp:35
std::uint64_t attr_index_begin
Definition layout.hpp:36
std::uint64_t header_len
Definition layout.hpp:33
std::uint64_t feature_begin
Definition layout.hpp:38