libosmscout 1.1.1
Loading...
Searching...
No Matches
LabelProvider.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_LABELPROVIDER_H
2#define OSMSCOUT_LABELPROVIDER_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2017 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23#include <vector>
24
26
27#include <osmscout/TypeConfig.h>
28
30
31namespace osmscout {
32
39 {
40 public:
41 virtual ~LabelProvider() = default;
42
51 virtual std::string GetLabel(const MapParameter& parameter,
52 const FeatureValueBuffer& buffer) const = 0;
53
57 virtual std::string GetName() const = 0;
58 };
59
60 using LabelProviderRef = std::shared_ptr<LabelProvider>;
61
67 {
68 public:
69 virtual ~LabelProviderFactory() = default;
70
71 virtual LabelProviderRef Create(const TypeConfig& typeConfig) const = 0;
72 };
73
74 using LabelProviderFactoryRef = std::shared_ptr<LabelProviderFactory>;
75
81 {
82 private:
83 class INameLabelProvider : public LabelProvider
84 {
85 private:
86 std::vector<size_t> nameLookupTable;
87 std::vector<size_t> nameAltLookupTable;
88
89 public:
90 explicit INameLabelProvider(const TypeConfig& typeConfig);
91
92 std::string GetLabel(const MapParameter& parameter,
93 const FeatureValueBuffer& buffer) const override;
94
95 inline std::string GetName() const override
96 {
97 return "IName";
98 }
99 };
100
101 private:
102 mutable LabelProviderRef instance;
103
104 public:
105 LabelProviderRef Create(const TypeConfig& typeConfig) const override;
106 };
107
117 {
118 private:
119 std::vector<size_t> lookupTable;
120 std::string featureName;
121 std::string labelName;
122 size_t labelIndex;
123
124 public:
135 DynamicFeatureLabelReader(const TypeConfig& typeConfig,
136 const std::string& featureName,
137 const std::string& labelName);
138
139 std::string GetLabel(const MapParameter& parameter,
140 const FeatureValueBuffer& buffer) const override;
141
142 inline std::string GetName() const override
143 {
144 return featureName + "." + labelName;
145 }
146 };
147}
148
149#endif
#define OSMSCOUT_MAP_API
Definition MapImportExport.h:45
DynamicFeatureLabelReader(const TypeConfig &typeConfig, const std::string &featureName, const std::string &labelName)
std::string GetName() const override
Definition LabelProvider.h:142
std::string GetLabel(const MapParameter &parameter, const FeatureValueBuffer &buffer) const override
Definition LabelProvider.h:81
LabelProviderRef Create(const TypeConfig &typeConfig) const override
Definition LabelProvider.h:67
virtual LabelProviderRef Create(const TypeConfig &typeConfig) const =0
virtual ~LabelProviderFactory()=default
Definition LabelProvider.h:39
virtual ~LabelProvider()=default
virtual std::string GetLabel(const MapParameter &parameter, const FeatureValueBuffer &buffer) const =0
virtual std::string GetName() const =0
Definition Area.h:39
std::shared_ptr< LabelProvider > LabelProviderRef
Definition LabelProvider.h:60
std::shared_ptr< LabelProviderFactory > LabelProviderFactoryRef
Definition LabelProvider.h:74