FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
fcb::Feature Class Reference

One decoded feature that OWNS the bytes it points into. More...

#include <fcb/feature.hpp>

Public Member Functions

 Feature ()=default
 
 Feature (std::shared_ptr< const std::vector< std::uint8_t > > buffer, std::uint64_t byte_offset, std::size_t body_offset)
 
bool empty () const
 True for a default-constructed Feature.
 
std::string id () const
 The feature's CityJSON id. Empty when empty().
 
std::size_t city_object_count () const
 How many CityObjects this feature carries. Zero when empty().
 
bytes_view object_attributes (std::size_t i) const
 Raw attribute blob of CityObject i, or empty if it has none.
 
bool object_has_attributes (std::size_t i) const
 Whether CityObject i declares an attributes vector at all.
 
bool object_extent (std::size_t i, std::array< double, 6 > &out) const
 CityObject i's own bounding box, if it declares one.
 
bool object_has_columns (std::size_t i) const
 CityObject i's own column schema, if it declares one.
 
std::vector< ColumnInfoobject_columns (std::size_t i) const
 
std::string object_id (std::size_t i) const
 CityObject i's id.
 
std::uint64_t byte_offset () const
 Byte offset of this feature RELATIVE to the start of the features section, matching the offsets stored in the R-tree leaves.
 
const ::CityFeature * raw () const
 The generated CityFeature table behind this Feature.
 

Friends

struct detail::FeatureAccess
 

Detailed Description

One decoded feature that OWNS the bytes it points into.

Copying a Feature copies a shared_ptr, not the buffer, so features stay valid after the iterator and reader that produced them are destroyed.

The generated ::CityFeature pointer is deliberately not public: a caller could retain it past this object's destruction. Internal decoders reach it via detail::FeatureAccess.

Definition at line 33 of file feature.hpp.

Constructor & Destructor Documentation

◆ Feature() [1/2]

fcb::Feature::Feature ( )
default

◆ Feature() [2/2]

fcb::Feature::Feature ( std::shared_ptr< const std::vector< std::uint8_t > >  buffer,
std::uint64_t  byte_offset,
std::size_t  body_offset 
)

Definition at line 22 of file reader.cpp.

Member Function Documentation

◆ byte_offset()

std::uint64_t fcb::Feature::byte_offset ( ) const
inline

Byte offset of this feature RELATIVE to the start of the features section, matching the offsets stored in the R-tree leaves.

Definition at line 81 of file feature.hpp.

Referenced by fcb::FcbReader::select_attr().

◆ city_object_count()

std::size_t fcb::Feature::city_object_count ( ) const

How many CityObjects this feature carries. Zero when empty().

Definition at line 111 of file reader.cpp.

Referenced by fcb::FcbReader::select_attr(), and fcb::to_cityjson_feature().

◆ empty()

bool fcb::Feature::empty ( ) const
inline

True for a default-constructed Feature.

Definition at line 40 of file feature.hpp.

◆ id()

std::string fcb::Feature::id ( ) const

The feature's CityJSON id. Empty when empty().

Definition at line 34 of file reader.cpp.

Referenced by fcb::to_cityjson_feature().

◆ object_attributes()

bytes_view fcb::Feature::object_attributes ( std::size_t  i) const

Raw attribute blob of CityObject i, or empty if it has none.

Objects commonly differ: in the 3DBAG data a Building parent carries no attributes while its BuildingPart child carries them all.

Definition at line 51 of file reader.cpp.

Referenced by fcb::FcbReader::select_attr(), and fcb::to_cityjson_feature().

◆ object_columns()

std::vector< ColumnInfo > fcb::Feature::object_columns ( std::size_t  i) const

Definition at line 85 of file reader.cpp.

References fcb::ColumnInfo::index.

Referenced by fcb::FcbReader::select_attr(), and fcb::to_cityjson_feature().

◆ object_extent()

bool fcb::Feature::object_extent ( std::size_t  i,
std::array< double, 6 > &  out 
) const

CityObject i's own bounding box, if it declares one.

Returns false when absent.

Definition at line 64 of file reader.cpp.

Referenced by fcb::to_cityjson_feature().

◆ object_has_attributes()

bool fcb::Feature::object_has_attributes ( std::size_t  i) const

Whether CityObject i declares an attributes vector at all.

Distinct from object_attributes(i).empty(): a present-but-empty vector is emitted as "attributes": {}, an absent one is omitted.

Definition at line 59 of file reader.cpp.

Referenced by fcb::to_cityjson_feature().

◆ object_has_columns()

bool fcb::Feature::object_has_columns ( std::size_t  i) const

CityObject i's own column schema, if it declares one.

feature.fbs documents CityObject.columns as overriding the header schema when set. Decoding with the wrong schema silently desynchronises the blob – records are not self-delimiting – so this must be consulted before decode_attributes(). Empty means "use the header's columns". Whether CityObject i DECLARES its own column schema. FlatBuffers presence is what selects the override, not vector non-emptiness: an explicitly empty schema must not silently fall back to the header's.

Definition at line 80 of file reader.cpp.

Referenced by fcb::FcbReader::select_attr(), and fcb::to_cityjson_feature().

◆ object_id()

std::string fcb::Feature::object_id ( std::size_t  i) const

CityObject i's id.

Definition at line 104 of file reader.cpp.

Referenced by fcb::to_cityjson_feature().

◆ raw()

const ::CityFeature * fcb::Feature::raw ( ) const

The generated CityFeature table behind this Feature.

This is the supported way to reach the ENCODED geometry – the format's own five count arrays (solids/shells/surfaces/strings plus the flat boundaries index list) and the quantised vertices they index into – for analysis that does not want CityJSON built first. Nothing has to be nested or allocated to compute over them. See examples/geometry_analysis.cpp.

NESTING DEPTH COMES FROM Geometry::type(), NEVER FROM THE ARRAYS: a Solid with one shell and a MultiSolid with one solid flatten to byte-identical arrays. Inferring depth from which array is populated is upstream finding #8.

Include <fcb/generated/feature_generated.h> for the complete type; this header only forward-declares it.

Definition at line 26 of file reader.cpp.

Referenced by fcb::detail::FeatureAccess::get().

Friends And Related Symbol Documentation

◆ detail::FeatureAccess

friend struct detail::FeatureAccess
friend

Definition at line 102 of file feature.hpp.


The documentation for this class was generated from the following files: