1#ifndef OSMSCOUT_FEATURE_READER_H
2#define OSMSCOUT_FEATURE_READER_H
42 std::vector<size_t> lookupTable;
57 bool GetIndex(
const FeatureValueBuffer& buffer,
67 bool IsSet(
const FeatureValueBuffer& buffer)
const;
73 FeatureRef feature=typeConfig.GetFeature(F::NAME);
75 lookupTable.resize(typeConfig.GetTypeCount(),
76 std::numeric_limits<size_t>::max());
78 for (
const auto &type : typeConfig.GetTypes()) {
81 if (type->GetFeature(F::NAME,
83 lookupTable[type->GetIndex()]=index;
92 index=lookupTable[buffer.GetType()->GetIndex()];
94 return index!=std::numeric_limits<size_t>::max();
100 size_t index=lookupTable[buffer.GetType()->GetIndex()];
102 if (index!=std::numeric_limits<size_t>::max()) {
103 return buffer.HasFeature(index);
117 std::string featureName;
118 std::vector<size_t> lookupTable;
141 template<
class F,
class V>
145 std::vector<size_t> lookupTable;
147 static_assert(std::is_base_of<Feature, F>::value,
"F have to be subtype of Feature");
148 static_assert(std::is_base_of<FeatureValue, V>::value,
"V have to be subtype of FeatureValue");
164 size_t& index)
const;
174 V*
GetValue(
const FeatureValueBuffer& buffer)
const;
183 V
GetValue(
const FeatureValueBuffer& buffer,
const V& defaultValue)
const;
186 template<
class F,
class V>
189 FeatureRef feature=typeConfig.GetFeature(F::NAME);
193 lookupTable.resize(typeConfig.GetTypeCount(),
194 std::numeric_limits<size_t>::max());
196 for (
const auto &type : typeConfig.GetTypes()) {
199 if (type->GetFeature(F::NAME,
201 lookupTable[type->GetIndex()]=index;
206 template<
class F,
class V>
210 assert(buffer.GetType()->GetIndex() < lookupTable.size());
211 index=lookupTable[buffer.GetType()->GetIndex()];
213 return index!=std::numeric_limits<size_t>::max();
216 template<
class F,
class V>
219 assert(buffer.GetType()->GetIndex()<lookupTable.size());
220 size_t index=lookupTable[buffer.GetType()->GetIndex()];
222 if (index!=std::numeric_limits<size_t>::max() &&
223 buffer.HasFeature(index)) {
227 assert(val==
nullptr ||
dynamic_cast<V*
>(val)!=
nullptr);
228 return static_cast<V*
>(val);
234 template<
class F,
class V>
237 assert(buffer.GetType()->GetIndex() < lookupTable.size());
238 size_t index=lookupTable[buffer.GetType()->GetIndex()];
240 if (index!=std::numeric_limits<size_t>::max() &&
241 buffer.HasFeature(index)) {
245 assert(val ==
nullptr ||
dynamic_cast<V*
>(val) !=
nullptr);
246 return *
static_cast<V*
>(val);
252 template <
class F,
class V>
256 std::vector<size_t> lookupTable;
268 std::string
GetLabel(
const FeatureValueBuffer& buffer)
const;
271 template<
class F,
class V>
274 FeatureRef feature=typeConfig.GetFeature(F::NAME);
278 lookupTable.resize(typeConfig.GetTypeCount(),
279 std::numeric_limits<size_t>::max());
281 for (
const auto &type : typeConfig.GetTypes()) {
284 if (type->GetFeature(F::NAME,
286 lookupTable[type->GetIndex()]=index;
291 template<
class F,
class V>
294 size_t index=lookupTable[buffer.GetType()->GetIndex()];
296 if (index!=std::numeric_limits<size_t>::max() &&
297 buffer.HasFeature(index)) {
298 auto* value=
dynamic_cast<V*
>(buffer.GetValue(index));
300 if (value!=
nullptr) {
301 return value->GetLabel(Locale(), 0);
#define OSMSCOUT_API
Definition CoreImportExport.h:45
DynamicFeatureReader(const TypeConfig &typeConfig, const Feature &feature)
FeatureValue * GetValue(const FeatureValueBuffer &buffer) const
bool IsSet(const FeatureValueBuffer &buffer) const
std::string GetFeatureName() const
Definition FeatureReader.h:124
Vertex2D * buffer
Definition Transformation.h:343
FeatureValueBuffer()=default
Definition TypeFeature.h:99
virtual bool HasValue() const
Definition TypeFeature.h:165
virtual bool HasLabel() const
Definition TypeFeature.h:173
FeatureLabelReader(const TypeConfig &typeConfig)
Definition FeatureReader.h:272
std::string GetLabel(const FeatureValueBuffer &buffer) const
Definition FeatureReader.h:292
FeatureReader(const TypeConfig &typeConfig)
Definition FeatureReader.h:71
bool IsSet(const FeatureValueBuffer &buffer) const
Definition FeatureReader.h:98
bool GetIndex(const FeatureValueBuffer &buffer, size_t &index) const
Definition FeatureReader.h:89
Definition TypeFeature.h:41
FeatureValueReader(const TypeConfig &typeConfig)
Definition FeatureReader.h:187
V GetValue(const FeatureValueBuffer &buffer, const V &defaultValue) const
Definition FeatureReader.h:235
bool GetIndex(const FeatureValueBuffer &buffer, size_t &index) const
Definition FeatureReader.h:207
V * GetValue(const FeatureValueBuffer &buffer) const
Definition FeatureReader.h:217
std::shared_ptr< Feature > FeatureRef
Definition TypeFeature.h:219