LuciadCPillar 2023.1.02
luciad::Feature Class Referencefinal

A Feature is a (partial) copy of a domain object. More...

#include <luciad/models/features/Feature.h>


class  Builder
 Allows the incremental creation of a Feature object. More...

Public Member Functions

Builder asBuilder () const
 Returns this Feature as a Feature::Builder. More...
std::shared_ptr< GeometryfindGeometry () const
 Tries to find a geometry for this feature. More...
const DataTypegetDataType () const
FeatureId getId () const
 Returns the id of this feature. More...
template<typename T >
std::optional< T > getValue (const DataPropertyPath &propertyPath) const
 Accesses the value for the given property. More...
bool hasId () const
 Returns if this Feature has an id. More...
bool operator!= (const Feature &other) const
bool operator== (const Feature &other) const

Static Public Member Functions

static Builder newBuilder ()
 Returns a new Feature Builder. More...

Detailed Description

A Feature is a (partial) copy of a domain object.

It allows the rest of the API to easily access the domain object's properties, including any geometry. If you do a query on the model, and retrieve a Feature from it, the caller of the query receives ownership of the Feature. I.e. the caller can decide what to do with it, and when to dispose it.

This means that the Map and Layer API's are allowed to keep references to a Feature and have unrestricted lock-less access to its properties. The caller of the IFeatureModel::query method is responsible for managing the lifetime of a Feature.

To make Feature instances easy to use in a multi-threaded environment, they are

  • immutable
  • thread safe for reading

See article for more details on this class.

Member Function Documentation

◆ asBuilder()

Builder luciad::Feature::asBuilder ( ) const

Returns this Feature as a Feature::Builder.

This makes it possible to copy a Feature, and modify values. Note that when using this builder, it is not possible to change the datatype. Only the values and the id of the Feature. Otherwise a LogicException will be thrown.

this Feature as a Feature::Builder.

◆ findGeometry()

std::shared_ptr< Geometry > luciad::Feature::findGeometry ( ) const

Tries to find a geometry for this feature.

If this feature's data type is annotated with GeometryDataAnnotation, the value of the corresponding property is returned. Otherwise, the result will be nullptr.

the annotated geometry, if any, else nullptr.
See also

◆ getDataType()

const DataType & luciad::Feature::getDataType ( ) const

◆ getId()

FeatureId luciad::Feature::getId ( ) const

Returns the id of this feature.

A feature id should be unique across a model.

When no id is set, this method will throw an exception.

the id of this feature.
LogicExceptionwhen the feature has no id.

◆ getValue()

template<typename T >
std::optional< T > luciad::Feature::getValue ( const DataPropertyPath propertyPath) const

Accesses the value for the given property.


auto optBool = feature.getValue<bool>(boolPropertyPath);
auto optInt = feature.getValue<int32_t>(intPropertyPath);
auto optLong = feature.getValue<int64_t>(longPropertyPath);
auto optFloat = feature.getValue<float>(floatPropertyPath);
auto optDouble = feature.getValue<double>(doublePropertyPath);
auto optString = feature.getValue<std::string>(stringPropertyPath);
auto optGeometry = feature.getValue<std::shared_ptr<Geometry>>(geometryPropertyPath);
auto unsetValue = feature.getValue<std::string>(unsetPropertyPath); // Unset property -> empty optional
Template Parameters
Tthe supported types are bool, int32_t, int64_t, float, double, std::string, std::shared_ptr<luciad::Geometry> or a subtype of Geometry.
propertyPaththe property for which to return a value
the value for the given property. If the property does exist in the DataType, but is not set for this particular feature, std::nullopt is returned.
InvalidArgumentExceptionwhen the property is not of a known type, if it doesn't exist in the DataType, or when the type of the value doesn't correspond with the provided type parameter (for example when the property value is a Point geometry, but it is requested using ArcBand as type parameter).

◆ hasId()

bool luciad::Feature::hasId ( ) const

Returns if this Feature has an id.

If this method returns false, it is not allowed to call Feature::getId.

if this Feature has an id.
See also

◆ newBuilder()

static Builder luciad::Feature::newBuilder ( )

Returns a new Feature Builder.

a new Feature Builder.

◆ operator!=()

bool luciad::Feature::operator!= ( const Feature other) const

◆ operator==()

bool luciad::Feature::operator== ( const Feature other) const