9namespace fishnet::__impl {
20 template<FieldValueType T>
21 FieldValue(T value,
int fieldID):value(value),fieldID(fieldID) {}
23 template<FieldValueType T>
25 return std::get<T>(value);
28 [[nodiscard]]
constexpr FieldType getVariant() const noexcept {
32 [[nodiscard]]
constexpr int getFieldID() const noexcept{
36 constexpr bool operator==(
const FieldValue & other)
const noexcept{
37 return fieldID==other.fieldID && value == other.value;
50template<geometry::AnyGeometry G>
54 std::vector<__impl::FieldValue> attributes;
56 template<FieldValueType T>
57 constexpr auto getItPosOfAttribute(
const FieldDefinition<T> & fieldDefinition)
const noexcept{
58 return std::ranges::find_if(attributes,[&fieldDefinition](
const auto & value){
59 return fieldDefinition.
getFieldID() == value.getFieldID();
63 template<FieldValueType T>
64 constexpr auto getItPosOfAttribute(
const FieldDefinition<T> & fieldDefinition)
noexcept{
65 return std::ranges::find_if(attributes,[&fieldDefinition](
const auto & value){
66 return fieldDefinition.
getFieldID() == value.getFieldID();
70 template<geometry::AnyGeometry O>
74 constexpr explicit Feature(
const G & geometry):geometry(geometry){}
75 constexpr explicit Feature(G && geometry):geometry(
std::move(geometry)){}
77 template<IFieldDefinition FieldDef>
81 attributes.emplace_back(
static_cast<typename FieldDef::value_type
>(value), fieldDefinition.
getFieldID());
86 return std::ranges::any_of(attributes,[&fieldDefinition](
const auto & fieldValue){
87 return fieldDefinition.
getFieldID() == fieldValue.getFieldID();
91 template<IFieldDefinition FieldDef>
93 using T =
typename FieldDef::value_type;
94 auto valueIt = getItPosOfAttribute(fieldDefinition);
95 if(valueIt == std::ranges::end(attributes))
100 template<IFieldDefinition FieldDef>
103 *getItPosOfAttribute(fieldDefinition) = __impl::FieldValue(
static_cast<typename FieldDef::value_type
>(value), fieldDefinition.
getFieldID());
108 std::erase_if(attributes,[&fieldDefinition](
const auto & value){
return value.getFieldID() == fieldDefinition.
getFieldID();});
111 template<geometry::AnyGeometry O>
113 std::ranges::for_each(source.attributes,[
this](
const auto & value){this->attributes.push_back(value);});
117 return this->geometry;
121 return this->geometry;
125 return std::move(this->geometry);
129 return this->geometry == feature.getGeometry() &&
130 std::ranges::is_permutation(this->attributes, feature.attributes);
Feature implementation storing a geometry and associated attributes.
Definition Feature.hpp:51
constexpr bool operator==(const Feature< G > &feature) const noexcept
Definition Feature.hpp:128
constexpr void setAttribute(const FieldDef &fieldDefinition, math::convertible_without_loss< typename FieldDef::value_type > auto value) noexcept
Definition Feature.hpp:101
constexpr Feature(const G &geometry)
Definition Feature.hpp:74
constexpr const G & getGeometry() const &noexcept
Definition Feature.hpp:116
constexpr G & getGeometry() &noexcept
Definition Feature.hpp:120
constexpr fishnet::Option< typename FieldDef::value_type > getAttribute(const FieldDef &fieldDefinition) const noexcept
Definition Feature.hpp:92
constexpr G && getGeometry() &&noexcept
Definition Feature.hpp:124
constexpr Feature(G &&geometry)
Definition Feature.hpp:75
constexpr void removeAttribute(const IFieldDefinition auto fieldDefinition) noexcept
Definition Feature.hpp:107
constexpr bool addAttribute(const FieldDef &fieldDefinition, math::convertible_without_loss< typename FieldDef::value_type > auto value) noexcept
Definition Feature.hpp:78
constexpr void copyAttributes(const Feature< O > &source) noexcept
Definition Feature.hpp:112
constexpr bool hasAttribute(const IFieldDefinition auto &fieldDefinition) const noexcept
Definition Feature.hpp:85
Field definition implementation. Defines name, id and data type of a field.
Definition FieldDefinition.hpp:43
constexpr int getFieldID() const noexcept
Definition FieldDefinition.hpp:63
Defines an Interface for FieldDefinitions, which can be used as generic parameter.
Definition FieldDefinition.hpp:30
Definition NumericConcepts.hpp:10
Definition BFSClustering.hpp:5
std::variant< double, float, int, long, size_t, long long, std::string, const char * > FieldType
Definition FieldType.hpp:7