libosmscout 1.1.1
Loading...
Searching...
No Matches
ConstructionYearFeature.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_FEATURE_CONSTRUCTION_YEAR_FEATURE_H
2#define OSMSCOUT_FEATURE_CONSTRUCTION_YEAR_FEATURE_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2014 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 <osmscout/TypeConfig.h>
25
27
28namespace osmscout {
29
31 {
32 private:
33 int startYear=0;
34 int endYear=0;
35
36 public:
38
39 ConstructionYearFeatureValue(int startYear, int endYear)
40 : startYear(startYear),
41 endYear(endYear)
42 {
43 // no code
44 }
45
46 void SetStartYear(int year)
47 {
48 this->startYear=year;
49 }
50
51 int GetStartYear() const
52 {
53 return startYear;
54 }
55
56 void SetEndYear(int year)
57 {
58 this->endYear=year;
59 }
60
61 int GetEndYear() const
62 {
63 return endYear;
64 }
65
66 std::string GetLabel(const Locale &/*locale*/, size_t /*labelIndex*/) const override
67 {
68 if (startYear==endYear) {
69 return std::to_string(startYear);
70 }
71
72 return std::to_string(startYear)+"-"+std::to_string(endYear);
73 }
74
75 void Read(FileScanner& scanner) override;
76 void Write(FileWriter& writer) override;
77
79 bool operator==(const FeatureValue& other) const override;
80 };
81
83 {
84 private:
85 TagId tagConstructionYear;
86 TagId tagStartDate;
87
88 public:
90 static const char* const NAME;
91
93 static const char* const YEAR_LABEL;
94
96 static const size_t YEAR_LABEL_INDEX;
97
98 public:
100 void Initialize(TagRegistry& tagRegistry) override;
101
102 std::string GetName() const override;
103
104 size_t GetValueAlignment() const override;
105 size_t GetValueSize() const override;
106 FeatureValue* AllocateValue(void* buffer) override;
107
108 void Parse(TagErrorReporter& reporter,
109 const TagRegistry& tagRegistry,
110 const FeatureInstance& feature,
111 const ObjectOSMRef& object,
112 const TagMap& tags,
113 FeatureValueBuffer& buffer) const override;
114 };
115
117}
118
119#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
size_t GetValueSize() const override
void Initialize(TagRegistry &tagRegistry) override
FeatureValue * AllocateValue(void *buffer) override
static const size_t YEAR_LABEL_INDEX
Definition ConstructionYearFeature.h:96
std::string GetName() const override
size_t GetValueAlignment() const override
static const char *const NAME
Definition ConstructionYearFeature.h:90
void Parse(TagErrorReporter &reporter, const TagRegistry &tagRegistry, const FeatureInstance &feature, const ObjectOSMRef &object, const TagMap &tags, FeatureValueBuffer &buffer) const override
static const char *const YEAR_LABEL
Definition ConstructionYearFeature.h:93
void Write(FileWriter &writer) override
int GetEndYear() const
Definition ConstructionYearFeature.h:61
ConstructionYearFeatureValue & operator=(const FeatureValue &other) override
void SetEndYear(int year)
Definition ConstructionYearFeature.h:56
void SetStartYear(int year)
Definition ConstructionYearFeature.h:46
void Read(FileScanner &scanner) override
bool operator==(const FeatureValue &other) const override
ConstructionYearFeatureValue(int startYear, int endYear)
Definition ConstructionYearFeature.h:39
int GetStartYear() const
Definition ConstructionYearFeature.h:51
std::string GetLabel(const Locale &, size_t) const override
Definition ConstructionYearFeature.h:66
Definition TypeFeature.h:41
Definition FeatureReader.h:143
Definition TagErrorReporter.h:33
Definition Area.h:39
FeatureValueReader< ConstructionYearFeature, ConstructionYearFeatureValue > ConstructionYearFeatureValueReader
Definition ConstructionYearFeature.h:116
std::unordered_map< TagId, std::string > TagMap
Definition Tag.h:41
uint16_t TagId
Definition Tag.h:39