FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
geometry.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#include <string>
8#include <vector>
9
10#ifdef FCB_WITH_JSON
11# include <nlohmann/json.hpp>
12#endif
13
14namespace fcb {
15
17
22enum class GeometryKind : std::uint8_t {
23 MultiPoint = 0,
25 MultiSurface = 2,
27 Solid = 4,
28 MultiSolid = 5,
31};
32
33#ifdef FCB_WITH_JSON
34
35// ---------------------------------------------------------------------------
36// NESTING DEPTH COMES FROM THE GEOMETRY TYPE, NEVER FROM THE ARRAYS.
37//
38// The format stores a dimensional hierarchy as parallel count arrays:
39// `solids[i]` = shells in solid i, `shells[i]` = surfaces in shell i,
40// `surfaces[i]` = rings in surface i, `strings[i]` = vertex indices in ring i,
41// and `indices` is the flat vertex-index list. Those arrays are AMBIGUOUS: a
42// `Solid` with one shell and a `MultiSolid` with one solid flatten to
43// byte-identical arrays, so no test over them can tell the two apart. Only
44// `Geometry.type()` can, and every decoder below takes it.
45//
46// The depths, from `geomprimitives.schema.json` and CityJSON 2.0 ยง6 --
47// identical to the table at the top of geom_decoder.rs:
48//
49// type boundaries semantics material texture
50// MultiPoint 1 1 forbidden forbidden
51// MultiLineString 2 1 forbidden forbidden
52// MultiSurface, CompositeSurface 3 1 1 3
53// Solid 4 2 2 4
54// MultiSolid, CompositeSolid 5 3 3 5
55//
56// An earlier version of this file dispatched on the outermost populated array
57// and collapsed a single-element level into that element. That inference cost
58// a nesting level on every one-solid MultiSolid and CompositeSolid, in both
59// `material.values` and `texture.values`; see conformance/inputs/
60// appearance_depths.city.jsonl, which fails for any reader that infers.
61// ---------------------------------------------------------------------------
62
88nlohmann::json decode_boundaries(GeometryKind type, UIntView solids, UIntView shells,
90
101nlohmann::json decode_semantics_values(GeometryKind type, UIntView solids, UIntView shells,
102 UIntView values);
103
119nlohmann::json decode_material_values(GeometryKind type, UIntView solids, UIntView shells,
121
134nlohmann::json decode_texture_values(GeometryKind type, UIntView solids, UIntView shells,
136
137#endif // FCB_WITH_JSON
138
148std::string geometry_type_name(std::uint8_t type);
149
150} // namespace fcb
Minimal C++17 stand-in for std::span: a non-owning view over contiguous memory.
Definition span.hpp:13
UIntView shells
Definition geometry.cpp:123
UIntView strings
Definition geometry.cpp:125
UIntView surfaces
Definition geometry.cpp:124
UIntView vertices
Definition geometry.cpp:126
nlohmann::json decode_boundaries(GeometryKind type, UIntView solids, UIntView shells, UIntView surfaces, UIntView strings, UIntView indices)
Rebuild CityJSON's nested boundaries from the five flattened arrays, at the depth type implies.
Definition geometry.cpp:164
nlohmann::json decode_texture_values(GeometryKind type, UIntView solids, UIntView shells, UIntView surfaces, UIntView strings, UIntView vertices)
Rebuild the values array of one texture theme from a TextureMapping.
Definition geometry.cpp:331
span< const std::uint32_t > UIntView
Definition geometry.hpp:16
nlohmann::json decode_material_values(GeometryKind type, UIntView solids, UIntView shells, UIntView vertices)
Rebuild the values array of one material theme from a MaterialMapping.
Definition geometry.cpp:268
nlohmann::json decode_semantics_values(GeometryKind type, UIntView solids, UIntView shells, UIntView values)
Rebuild the nested semantics values array from the flat run of semantic indices.
Definition geometry.cpp:224
GeometryKind
The FlatBuffers GeometryType enumerators, mirrored here so a caller can name a geometry type without ...
Definition geometry.hpp:22
std::string geometry_type_name(std::uint8_t type)
CityJSON name for a GeometryType enumerator, e.g.
Definition geometry.cpp:376