FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
geom_encoder.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef FCB_WITH_JSON
4
5# include <fcb/geometry.hpp>
6
7# include <nlohmann/json.hpp>
8
9# include <cstdint>
10# include <optional>
11# include <string>
12# include <vector>
13
14namespace fcb {
15
21 std::vector<std::uint32_t> solids; // shells per solid
22 std::vector<std::uint32_t> shells; // surfaces per shell
23 std::vector<std::uint32_t> surfaces; // rings per surface
24 std::vector<std::uint32_t> strings; // indices per ring
25 std::vector<std::uint32_t> indices; // flattened vertex indices
26};
27
31GeometryKind geometry_kind_from_name(const std::string& name);
32
38GMBoundaries encode_boundaries(GeometryKind kind, const nlohmann::ordered_json& boundaries);
39
49 nlohmann::ordered_json surfaces = nlohmann::ordered_json::array();
50 std::optional<std::vector<std::uint32_t>> values;
51};
52
70GMSemantics encode_semantics(const nlohmann::ordered_json& semantics,
71 const GMBoundaries& boundaries);
72
78 enum class Kind {
79 Value, // a single material index for the whole theme
80 Values, // one index per surface (nested per `solids`/`shells`)
81 NullValues // `"values": null` -- a theme with no arrays at all
82 };
84 std::string theme;
85 std::uint32_t value = 0; // Kind::Value
86 std::vector<std::uint32_t> solids, shells, vertices; // Kind::Values
87};
88
107std::vector<MaterialMapping> encode_material(const nlohmann::ordered_json& material);
108
114 std::string theme;
115 bool has_values = false;
116 std::vector<std::uint32_t> solids, shells, surfaces, strings, vertices;
117};
118
131std::vector<TextureMapping> encode_texture(const nlohmann::ordered_json& texture);
132
137 std::optional<GMSemantics> semantics;
138 std::optional<std::vector<MaterialMapping>> materials;
139 std::optional<std::vector<TextureMapping>> textures;
140};
141
151EncodedGeometry encode(const nlohmann::ordered_json& geometry);
152
153} // namespace fcb
154
155#endif // FCB_WITH_JSON
GeometryKind geometry_kind_from_name(const std::string &name)
Maps a CityJSON geometry type string to GeometryKind.
GMBoundaries encode_boundaries(GeometryKind kind, const nlohmann::ordered_json &boundaries)
Flattens boundaries (nested CityJSON boundary arrays, straight off the JSON as parsed – no intermedia...
GMSemantics encode_semantics(const nlohmann::ordered_json &semantics, const GMBoundaries &boundaries)
Flattens semantics (the CityJSON semantics object: surfaces plus values), using boundaries's shell/so...
std::vector< MaterialMapping > encode_material(const nlohmann::ordered_json &material)
Flattens material (the CityJSON geometry.material object: theme name -> {"value": N} / {"values": [....
EncodedGeometry encode(const nlohmann::ordered_json &geometry)
Flattens one CityJSON geometry object – its boundaries and whatever semantics, material and texture i...
GeometryKind
The FlatBuffers GeometryType enumerators, mirrored here so a caller can name a geometry type without ...
Definition geometry.hpp:22
std::vector< TextureMapping > encode_texture(const nlohmann::ordered_json &texture)
Flattens texture (the CityJSON geometry.texture object).
KeyKind kind
Definition stree.cpp:166
Everything one CityJSON geometry object flattens to.
std::optional< std::vector< TextureMapping > > textures
std::optional< GMSemantics > semantics
std::optional< std::vector< MaterialMapping > > materials
Flattened geometry boundaries: a flat vertex-index list plus one count array per level of the dimensi...
std::vector< std::uint32_t > strings
std::vector< std::uint32_t > shells
std::vector< std::uint32_t > solids
std::vector< std::uint32_t > surfaces
std::vector< std::uint32_t > indices
Flattened semantics: surfaces is the CityJSON semantics.surfaces array, passed through verbatim (Flat...
nlohmann::ordered_json surfaces
std::optional< std::vector< std::uint32_t > > values
One theme's material mapping.
std::vector< std::uint32_t > vertices
std::vector< std::uint32_t > shells
std::vector< std::uint32_t > solids
One theme's texture mapping.
std::vector< std::uint32_t > solids
std::vector< std::uint32_t > strings
std::vector< std::uint32_t > surfaces
std::vector< std::uint32_t > vertices
std::vector< std::uint32_t > shells