libosmscout  1.1.1
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 #include <osmscout/TypeFeatures.h>
29 
30 #include <osmscout/MapParameter.h>
31 
32 namespace osmscout {
33 
40  {
41  public:
42  virtual ~LabelProvider() = default;
43 
52  virtual std::string GetLabel(const MapParameter& parameter,
53  const FeatureValueBuffer& buffer) const = 0;
54 
58  virtual std::string GetName() const = 0;
59  };
60 
61  using LabelProviderRef = std::shared_ptr<LabelProvider>;
62 
68  {
69  public:
70  virtual ~LabelProviderFactory() = default;
71 
72  virtual LabelProviderRef Create(const TypeConfig& typeConfig) const = 0;
73  };
74 
75  using LabelProviderFactoryRef = std::shared_ptr<LabelProviderFactory>;
76 
82  {
83  private:
84  class INameLabelProvider : public LabelProvider
85  {
86  private:
87  std::vector<size_t> nameLookupTable;
88  std::vector<size_t> nameAltLookupTable;
89 
90  public:
91  explicit INameLabelProvider(const TypeConfig& typeConfig);
92 
93  std::string GetLabel(const MapParameter& parameter,
94  const FeatureValueBuffer& buffer) const override;
95 
96  inline std::string GetName() const override
97  {
98  return "IName";
99  }
100  };
101 
102  private:
103  mutable LabelProviderRef instance;
104 
105  public:
106  LabelProviderRef Create(const TypeConfig& typeConfig) const override;
107  };
108 
118  {
119  private:
120  std::vector<size_t> lookupTable;
121  std::string featureName;
122  std::string labelName;
123  size_t labelIndex;
124 
125  public:
136  DynamicFeatureLabelReader(const TypeConfig& typeConfig,
137  const std::string& featureName,
138  const std::string& labelName);
139 
140  std::string GetLabel(const MapParameter& parameter,
141  const FeatureValueBuffer& buffer) const override;
142 
143  inline std::string GetName() const override
144  {
145  return featureName + "." + labelName;
146  }
147  };
148 }
149 
150 #endif
std::string GetName() const override
Definition: LabelProvider.h:143
Definition: LabelProvider.h:117
std::shared_ptr< LabelProvider > LabelProviderRef
Definition: LabelProvider.h:61
Definition: Area.h:38
std::shared_ptr< LabelProviderFactory > LabelProviderFactoryRef
Definition: LabelProvider.h:75
#define OSMSCOUT_MAP_API
Definition: MapImportExport.h:45
Definition: LabelProvider.h:39
Definition: LabelProvider.h:81
Definition: LabelProvider.h:67