libosmscout  1.1.1
RawNode.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_IMPORT_RAWNODE_H
2 #define OSMSCOUT_IMPORT_RAWNODE_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 #include <vector>
26 
27 #include <osmscout/GeoCoord.h>
28 #include <osmscout/Tag.h>
29 #include <osmscout/TypeConfig.h>
30 
33 
35 
36 namespace osmscout {
37 
38  class RawNode CLASS_FINAL
39  {
40  private:
41  OSMId id;
42  GeoCoord coord;
43  FeatureValueBuffer featureValueBuffer;
44 
45  private:
46  public:
47  RawNode();
48 
49  inline OSMId GetId() const
50  {
51  return id;
52  }
53 
54  inline TypeInfoRef GetType() const
55  {
56  return featureValueBuffer.GetType();
57  }
58 
59  inline const GeoCoord& GetCoords() const
60  {
61  return coord;
62  }
63 
64  inline double GetLat() const
65  {
66  return coord.GetLat();
67  }
68 
69  inline double GetLon() const
70  {
71  return coord.GetLon();
72  }
73 
74  inline size_t GetFeatureCount() const
75  {
76  return featureValueBuffer.GetType()->GetFeatureCount();
77  }
78 
79  inline bool HasFeature(size_t idx) const
80  {
81  return featureValueBuffer.HasFeature(idx);
82  }
83 
84  inline const FeatureInstance& GetFeature(size_t idx) const
85  {
86  return featureValueBuffer.GetType()->GetFeature(idx);
87  }
88 
89  inline FeatureValue* GetFeatureValue(size_t idx) const
90  {
91  return featureValueBuffer.GetValue(idx);
92  }
93 
94  inline const FeatureValueBuffer& GetFeatureValueBuffer() const
95  {
96  return featureValueBuffer;
97  }
98 
99  inline bool IsIdentical(const RawNode& other) const
100  {
101  return id==other.id;
102  }
103 
104  inline bool IsSame(const RawNode& other) const
105  {
106  return coord==other.coord;
107  }
108 
109  inline bool IsEqual(const RawNode& other) const
110  {
111  return id==other.id || coord==other.coord;
112  }
113 
114  void SetId(OSMId id);
115  void SetType(const TypeInfoRef& type);
116 
117  void SetCoord(const GeoCoord& coord);
118 
119  void UnsetFeature(size_t idx);
120 
121  void Parse(TagErrorReporter& errorReporter,
122  const TagRegistry& tagRegistry,
123  const TagMap& tags);
124  void Read(const TypeConfig& typeConfig,
125  FileScanner& scanner);
126  void Write(const TypeConfig& typeConfig,
127  FileWriter& writer) const;
128  };
129 
130  typedef std::shared_ptr<RawNode> RawNodeRef;
131 }
132 
133 #endif
bool IsEqual(const RawNode &other) const
Definition: RawNode.h:109
bool IsSame(const RawNode &other) const
Definition: RawNode.h:104
const FeatureValueBuffer & GetFeatureValueBuffer() const
Definition: RawNode.h:94
bool IsIdentical(const RawNode &other) const
Definition: RawNode.h:99
int64_t OSMId
Definition: OSMScoutTypes.h:34
TypeInfoRef GetType() const
Definition: RawNode.h:54
const GeoCoord & GetCoords() const
Definition: RawNode.h:59
bool HasFeature(size_t idx) const
Definition: RawNode.h:79
Definition: Area.h:38
size_t GetFeatureCount() const
Definition: RawNode.h:74
Definition: TypeFeature.h:40
FeatureValue * GetFeatureValue(size_t idx) const
Definition: RawNode.h:89
#define CLASS_FINAL
Definition: Compiler.h:26
Definition: TagErrorReporter.h:32
OSMId GetId() const
Definition: RawNode.h:49
double GetLon() const
Definition: RawNode.h:69
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
const FeatureInstance & GetFeature(size_t idx) const
Definition: RawNode.h:84
std::unordered_map< TagId, std::string > TagMap
Definition: Tag.h:41
double GetLat() const
Definition: RawNode.h:64
std::shared_ptr< RawNode > RawNodeRef
Definition: RawNode.h:130