FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
feature.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <fcb/span.hpp>
4
5#include <array>
6#include <cstdint>
7#include <memory>
8#include <string>
9#include <vector>
10
11namespace fcb {
12struct ColumnInfo;
13}
14
15// Generated FlatBuffers types are in the GLOBAL namespace. Forward declare
16// so this public header does not drag them into consumers' scope.
17struct CityFeature;
18
19namespace fcb {
20
21namespace detail {
22struct FeatureAccess;
23}
24
33class Feature {
34 public:
35 Feature() = default;
36 Feature(std::shared_ptr<const std::vector<std::uint8_t>> buffer, std::uint64_t byte_offset,
37 std::size_t body_offset);
38
40 bool empty() const { return buffer_ == nullptr; }
41
43 std::string id() const;
44
46 std::size_t city_object_count() const;
47
51 bytes_view object_attributes(std::size_t i) const;
52
56 bool object_has_attributes(std::size_t i) const;
57
60 bool object_extent(std::size_t i, std::array<double, 6>& out) const;
61
72 bool object_has_columns(std::size_t i) const;
73
74 std::vector<ColumnInfo> object_columns(std::size_t i) const;
75
77 std::string object_id(std::size_t i) const;
78
81 std::uint64_t byte_offset() const { return byte_offset_; }
82
99 const ::CityFeature* raw() const;
100
101 private:
103
104 std::shared_ptr<const std::vector<std::uint8_t>> buffer_;
105 std::uint64_t byte_offset_ = 0;
106 std::size_t body_offset_ = 0;
107};
108
109} // namespace fcb
One decoded feature that OWNS the bytes it points into.
Definition feature.hpp:33
bool object_extent(std::size_t i, std::array< double, 6 > &out) const
CityObject i's own bounding box, if it declares one.
Definition reader.cpp:64
bool object_has_attributes(std::size_t i) const
Whether CityObject i declares an attributes vector at all.
Definition reader.cpp:59
bytes_view object_attributes(std::size_t i) const
Raw attribute blob of CityObject i, or empty if it has none.
Definition reader.cpp:51
const ::CityFeature * raw() const
The generated CityFeature table behind this Feature.
Definition reader.cpp:26
std::uint64_t byte_offset() const
Byte offset of this feature RELATIVE to the start of the features section, matching the offsets store...
Definition feature.hpp:81
std::string object_id(std::size_t i) const
CityObject i's id.
Definition reader.cpp:104
bool object_has_columns(std::size_t i) const
CityObject i's own column schema, if it declares one.
Definition reader.cpp:80
std::string id() const
The feature's CityJSON id. Empty when empty().
Definition reader.cpp:34
Feature()=default
bool empty() const
True for a default-constructed Feature.
Definition feature.hpp:40
std::vector< ColumnInfo > object_columns(std::size_t i) const
Definition reader.cpp:85
std::size_t city_object_count() const
How many CityObjects this feature carries. Zero when empty().
Definition reader.cpp:111
Minimal C++17 stand-in for std::span: a non-owning view over contiguous memory.
Definition span.hpp:13
Internal gateway to Feature's generated FlatBuffers pointer.