FlatCityBuf C++ reader 0.10.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
header_serializer.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef FCB_WITH_JSON
4
5# include <fcb/generated/extension_generated.h>
6# include <fcb/generated/header_generated.h>
7# include <fcb/layout.hpp>
11
12# include <nlohmann/json.hpp>
13
14# include <array>
15# include <optional>
16# include <string>
17# include <vector>
18
19namespace fcb {
20
26 std::uint16_t index;
27 std::uint32_t length;
28 std::uint16_t branching_factor;
29 std::uint32_t num_unique_items;
30};
31
38 bool write_index = true;
39 std::uint64_t feature_count = 0;
43 std::vector<std::pair<std::string, std::optional<std::uint16_t>>> attribute_indices;
44 std::optional<std::array<double, 6>> geographical_extent;
49 std::optional<std::uint16_t> id_index = kDefaultBranchingFactor;
50};
51
55::Transform to_transform(const nlohmann::ordered_json& transform);
56
59 std::string authority;
60 std::int32_t version = 0;
61 std::int32_t code = 0;
62};
63
75std::optional<ParsedReferenceSystem> parse_reference_system(const std::string& url);
76
80::flatbuffers::Offset<::ReferenceSystem> to_reference_system(::flatbuffers::FlatBufferBuilder& fbb,
81 const ParsedReferenceSystem& ref_sys);
82
87::flatbuffers::Offset<::Extension> to_extension(::flatbuffers::FlatBufferBuilder& fbb,
88 const std::string& name, const std::string& url,
89 const std::string& version,
90 const nlohmann::ordered_json& members);
91
97::flatbuffers::Offset<::flatbuffers::Vector<const ::DoubleVertex*>>
98to_templates_vertices(::flatbuffers::FlatBufferBuilder& fbb,
99 const nlohmann::ordered_json& vertices_templates);
100
111 std::optional<::flatbuffers::Offset<::flatbuffers::String>> contact_name;
112 std::optional<::flatbuffers::Offset<::flatbuffers::String>> contact_type;
113 std::optional<::flatbuffers::Offset<::flatbuffers::String>> role;
114 std::optional<::flatbuffers::Offset<::flatbuffers::String>> phone;
115 std::optional<::flatbuffers::Offset<::flatbuffers::String>> email;
116 std::optional<::flatbuffers::Offset<::flatbuffers::String>> website;
117 std::optional<::flatbuffers::Offset<::flatbuffers::String>> address_thoroughfare_number;
118 std::optional<::flatbuffers::Offset<::flatbuffers::String>> address_thoroughfare_name;
119 std::optional<::flatbuffers::Offset<::flatbuffers::String>> address_locality;
120 std::optional<::flatbuffers::Offset<::flatbuffers::String>> address_postcode;
121 std::optional<::flatbuffers::Offset<::flatbuffers::String>> address_country;
122};
123PocOffsets to_point_of_contact(::flatbuffers::FlatBufferBuilder& fbb,
124 const nlohmann::ordered_json& poc);
125
150::flatbuffers::Offset<::Header>
151to_fcb_header(::flatbuffers::FlatBufferBuilder& fbb, const nlohmann::ordered_json& cj,
152 const HeaderWriterOptions& options, const AttributeSchema& attr_schema,
153 const AttributeSchema* semantic_attr_schema,
154 const std::vector<AttributeIndexInfo>* attribute_indices_info);
155
156} // namespace fcb
157
158#endif // FCB_WITH_JSON
constexpr std::uint16_t kDefaultNodeSize
Definition layout.hpp:16
constexpr std::uint16_t kDefaultBranchingFactor
Mirrors static_btree::DEFAULT_BRANCHING_FACTOR (static_btree/mod.rs:19), used whenever a caller reque...
::flatbuffers::Offset<::Extension > to_extension(::flatbuffers::FlatBufferBuilder &fbb, const std::string &name, const std::string &url, const std::string &version, const nlohmann::ordered_json &members)
Builds one extensions entry: name, url, version, and members – every other member of the entry,...
::Transform to_transform(const nlohmann::ordered_json &transform)
Builds the Transform struct (scale + translate) from CityJSON's top-level transform member.
std::map< std::string, std::pair< std::uint16_t, ::ColumnType > > AttributeSchema
Attribute schema: name -> (column index, column type).
Definition attribute.hpp:43
::flatbuffers::Offset<::flatbuffers::Vector< const ::DoubleVertex * > > to_templates_vertices(::flatbuffers::FlatBufferBuilder &fbb, const nlohmann::ordered_json &vertices_templates)
Builds Header.templates_vertices from CityJSON's geometry-templates.vertices-templates (f64 precision...
PocOffsets to_point_of_contact(::flatbuffers::FlatBufferBuilder &fbb, const nlohmann::ordered_json &poc)
::flatbuffers::Offset<::ReferenceSystem > to_reference_system(::flatbuffers::FlatBufferBuilder &fbb, const ParsedReferenceSystem &ref_sys)
Builds the ReferenceSystem table from a parsed metadata.referenceSystem URL.
std::optional< ParsedReferenceSystem > parse_reference_system(const std::string &url)
Parses a referenceSystem URL (https://www.opengis.net/def/crs/{authority}/{version}...
::flatbuffers::Offset<::Header > to_fcb_header(::flatbuffers::FlatBufferBuilder &fbb, const nlohmann::ordered_json &cj, const HeaderWriterOptions &options, const AttributeSchema &attr_schema, const AttributeSchema *semantic_attr_schema, const std::vector< AttributeIndexInfo > *attribute_indices_info)
Builds the whole Header table from the CityJSON metadata line (the first line of a CityJSONSeq: type/...
One attribute column's B+tree index metadata, as recorded in the header (AttributeIndex,...
Configuration for header writing.
std::vector< std::pair< std::string, std::optional< std::uint16_t > > > attribute_indices
(attribute name, branching factor); std::nullopt branching factor means the default.
std::optional< std::uint16_t > id_index
The branching factor of the index over City Object ids, or std::nullopt for none.
std::optional< std::array< double, 6 > > geographical_extent
A metadata.referenceSystem URL, parsed into its OGC three-element form.
Builds the pointOfContact fields of a header from CityJSON metadata.pointOfContact.
std::optional<::flatbuffers::Offset<::flatbuffers::String > > contact_name
std::optional<::flatbuffers::Offset<::flatbuffers::String > > role
std::optional<::flatbuffers::Offset<::flatbuffers::String > > phone
std::optional<::flatbuffers::Offset<::flatbuffers::String > > website
std::optional<::flatbuffers::Offset<::flatbuffers::String > > address_postcode
std::optional<::flatbuffers::Offset<::flatbuffers::String > > email
std::optional<::flatbuffers::Offset<::flatbuffers::String > > address_thoroughfare_number
std::optional<::flatbuffers::Offset<::flatbuffers::String > > address_country
std::optional<::flatbuffers::Offset<::flatbuffers::String > > address_thoroughfare_name
std::optional<::flatbuffers::Offset<::flatbuffers::String > > contact_type
std::optional<::flatbuffers::Offset<::flatbuffers::String > > address_locality