libosmscout  1.1.1
RawWay.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORT_RAWWAY_H
2 #define OSMSCOUT_IMPORT_RAWWAY_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2009 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 <memory>
24 #include <unordered_map>
25 
26 #include <osmscout/Tag.h>
27 #include <osmscout/TypeConfig.h>
28 
31 
33 
34 namespace osmscout {
35 
36  class RawWay CLASS_FINAL
37  {
38  private:
39  OSMId id=0;
40  bool isArea=false;
41  std::vector<OSMId> nodes;
42  FeatureValueBuffer featureValueBuffer;
43 
44  public:
45  RawWay() = default;
46 
47  inline OSMId GetId() const
48  {
49  return id;
50  }
51 
52  inline bool IsArea() const
53  {
54  return isArea;
55  }
56 
57  inline TypeInfoRef GetType() const
58  {
59  return featureValueBuffer.GetType();
60  }
61 
62  inline const std::vector<OSMId>& GetNodes() const
63  {
64  return nodes;
65  }
66 
67  inline size_t GetNodeCount() const
68  {
69  return nodes.size();
70  }
71 
72  inline OSMId GetNodeId(size_t idx) const
73  {
74  return nodes[idx];
75  }
76 
77  inline OSMId GetFirstNodeId() const
78  {
79  return nodes[0];
80  }
81 
82  inline OSMId GetLastNodeId() const
83  {
84  return nodes[nodes.size()-1];
85  }
86 
87  inline size_t GetFeatureCount() const
88  {
89  return featureValueBuffer.GetType()->GetFeatureCount();
90  }
91 
92  inline bool HasFeature(size_t idx) const
93  {
94  return featureValueBuffer.HasFeature(idx);
95  }
96 
97  inline const FeatureInstance& GetFeature(size_t idx) const
98  {
99  return featureValueBuffer.GetType()->GetFeature(idx);
100  }
101 
102  inline FeatureValue* GetFeatureValue(size_t idx) const
103  {
104  return featureValueBuffer.GetValue(idx);
105  }
106 
107  inline const FeatureValueBuffer& GetFeatureValueBuffer() const
108  {
109  return featureValueBuffer;
110  }
111 
112  inline void SetFeatureValueBuffer(const FeatureValueBuffer& other)
113  {
114  featureValueBuffer.Set(other);
115  }
116 
117  bool IsOneway() const;
118 
119  void SetId(OSMId id);
120  void SetType(const TypeInfoRef& type,
121  bool area);
122  void SetNodes(const std::vector<OSMId>& nodes);
123 
124  template<typename Iterator>
125  void SetNodes(Iterator first, Iterator end)
126  {
127  nodes.assign(first,end);
128  }
129 
130  void Parse(TagErrorReporter& errorReporter,
131  const TagRegistry& tagRegistry,
132  const TagMap& tags);
133  void Read(const TypeConfig& typeConfig,
134  FileScanner& scanner);
135  void Write(const TypeConfig& typeConfig,
136  FileWriter& writer) const;
137  };
138 
139  using RawWayRef = std::shared_ptr<RawWay>;
140 }
141 
142 #endif
const FeatureValueBuffer & GetFeatureValueBuffer() const
Definition: RawWay.h:107
int64_t OSMId
Definition: OSMScoutTypes.h:34
TypeInfoRef GetType() const
Definition: RawWay.h:57
bool HasFeature(size_t idx) const
Definition: RawWay.h:92
const std::vector< OSMId > & GetNodes() const
Definition: RawWay.h:62
std::shared_ptr< RawWay > RawWayRef
Definition: RawWay.h:139
Definition: Area.h:38
size_t GetFeatureCount() const
Definition: RawWay.h:87
OSMId GetLastNodeId() const
Definition: RawWay.h:82
void SetNodes(Iterator first, Iterator end)
Definition: RawWay.h:125
Definition: TypeFeature.h:40
FeatureValue * GetFeatureValue(size_t idx) const
Definition: RawWay.h:102
#define CLASS_FINAL
Definition: Compiler.h:26
size_t GetNodeCount() const
Definition: RawWay.h:67
Definition: TagErrorReporter.h:32
OSMId GetId() const
Definition: RawWay.h:47
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
const FeatureInstance & GetFeature(size_t idx) const
Definition: RawWay.h:97
std::unordered_map< TagId, std::string > TagMap
Definition: Tag.h:41
OSMId GetFirstNodeId() const
Definition: RawWay.h:77
void SetFeatureValueBuffer(const FeatureValueBuffer &other)
Definition: RawWay.h:112
OSMId GetNodeId(size_t idx) const
Definition: RawWay.h:72
bool IsArea() const
Definition: RawWay.h:52