FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
attribute.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef FCB_WITH_JSON
4
5# include <fcb/generated/header_generated.h>
6# include <fcb/key.hpp>
7
8# include <nlohmann/json.hpp>
9
10# include <cstdint>
11# include <map>
12# include <string>
13# include <utility>
14# include <vector>
15
16# include <flatbuffers/flatbuffers.h>
17
18namespace fcb {
19
42using AttributeSchema = std::map<std::string, std::pair<std::uint16_t, ::ColumnType>>;
43
50void add_attributes(AttributeSchema& schema, const nlohmann::ordered_json& attrs);
51
54std::size_t attr_size(::ColumnType coltype, const nlohmann::ordered_json& colval);
55
62std::vector<std::uint8_t> encode_attributes_with_schema(const nlohmann::ordered_json& attr,
63 const AttributeSchema& schema);
64
67::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::Column>>>
68to_columns(::flatbuffers::FlatBufferBuilder& fbb, const AttributeSchema& schema);
69
74 std::uint16_t index;
76};
77
86std::vector<AttributeIndexEntry>
87attribute_to_index_entries(const nlohmann::ordered_json& attr, const AttributeSchema& schema,
88 const std::vector<std::string>& indexing_attr);
89
95std::vector<AttributeIndexEntry>
96cityfeature_to_index_entries(const nlohmann::ordered_json& city_feature,
97 const AttributeSchema& schema,
98 const std::vector<std::string>& indexing_attr);
99
100} // namespace fcb
101
102#endif // FCB_WITH_JSON
A decoded index key.
Definition key.hpp:40
std::vector< std::uint8_t > encode_attributes_with_schema(const nlohmann::ordered_json &attr, const AttributeSchema &schema)
Encodes attr (a CityJSON attributes object) against schema: repeated [u16 LE column index][value] rec...
std::size_t attr_size(::ColumnType coltype, const nlohmann::ordered_json &colval)
Byte width one value of coltype occupies in the attribute blob, EXCLUDING the 2-byte column-index pre...
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::Column > > > to_columns(::flatbuffers::FlatBufferBuilder &fbb, const AttributeSchema &schema)
Builds the Column vector for Header.columns or CityObject.columns, in ascending column-index order.
void add_attributes(AttributeSchema &schema, const nlohmann::ordered_json &attrs)
Adds every member of a JSON object to schema, assigning each new, non-null name the next free column ...
std::vector< AttributeIndexEntry > cityfeature_to_index_entries(const nlohmann::ordered_json &city_feature, const AttributeSchema &schema, const std::vector< std::string > &indexing_attr)
Same, over every object in one CityJSONFeature's CityObjects, visited in ascending object-id order (n...
std::map< std::string, std::pair< std::uint16_t, ::ColumnType > > AttributeSchema
Attribute schema: name -> (column index, column type).
Definition attribute.hpp:42
std::vector< AttributeIndexEntry > attribute_to_index_entries(const nlohmann::ordered_json &attr, const AttributeSchema &schema, const std::vector< std::string > &indexing_attr)
Extracts index entries for indexing_attr from one CityJSON attributes object.
One indexable (column, value) pair pulled out of a feature for the static B+tree builder (M6).
Definition attribute.hpp:73