libosmscout  1.1.1
Node.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_NODE_H
2 #define OSMSCOUT_NODE_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 <vector>
25 
26 #include <osmscout/GeoCoord.h>
27 #include <osmscout/Tag.h>
28 #include <osmscout/TypeConfig.h>
29 
32 #include <osmscout/util/Progress.h>
33 
35 
36 namespace osmscout {
37 
38  class OSMSCOUT_API Node CLASS_FINAL
39  {
40  private:
41  FeatureValueBuffer featureValueBuffer;
42 
43  FileOffset fileOffset=0;
44  FileOffset nextFileOffset=0;
45 
46  GeoCoord coords;
47 
48  public:
49  Node() = default;
50 
52  {
53  return fileOffset;
54  }
55 
57  {
58  return nextFileOffset;
59  }
60 
61  ObjectFileRef GetObjectFileRef() const
62  {
63  return ObjectFileRef(fileOffset,refNode);
64  }
65 
67  {
68  return featureValueBuffer.GetType();
69  }
70 
71  const GeoCoord& GetCoords() const
72  {
73  return coords;
74  }
75 
84  bool Intersects(const GeoBox& boundingBox) const
85  {
86  return boundingBox.Includes(coords);
87  }
88 
89  size_t GetFeatureCount() const
90  {
91  return featureValueBuffer.GetType()->GetFeatureCount();
92  }
93 
94  bool HasFeature(size_t idx) const
95  {
96  return featureValueBuffer.HasFeature(idx);
97  }
98 
99  const FeatureInstance& GetFeature(size_t idx) const
100  {
101  return featureValueBuffer.GetType()->GetFeature(idx);
102  }
103 
104  void UnsetFeature(size_t idx)
105  {
106  featureValueBuffer.FreeValue(idx);
107  }
108 
109  const FeatureValueBuffer& GetFeatureValueBuffer() const
110  {
111  return featureValueBuffer;
112  }
113 
114  void SetType(const TypeInfoRef& type);
115  void SetCoords(const GeoCoord& coords);
116  void SetFeatures(const FeatureValueBuffer& buffer);
117 
118  void Read(const TypeConfig& typeConfig,
119  FileScanner& scanner);
120  void Write(const TypeConfig& typeConfig,
121  FileWriter& writer) const;
122  };
123 
124  using NodeRef = std::shared_ptr<Node>;
125 }
126 
127 #endif
FileOffset GetFileOffset() const
Definition: Node.h:51
bool Intersects(const GeoBox &boundingBox) const
Definition: Node.h:84
const FeatureValueBuffer & GetFeatureValueBuffer() const
Definition: Node.h:109
std::shared_ptr< Node > NodeRef
Definition: Node.h:124
ObjectFileRef GetObjectFileRef() const
Definition: Node.h:61
TypeInfoRef GetType() const
Definition: Node.h:66
FileOffset GetNextFileOffset() const
Definition: Node.h:56
const GeoCoord & GetCoords() const
Definition: Node.h:71
bool HasFeature(size_t idx) const
Definition: Node.h:94
Definition: Area.h:38
size_t GetFeatureCount() const
Definition: Node.h:89
#define CLASS_FINAL
Definition: Compiler.h:26
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
Definition: ObjectRef.h:134
void UnsetFeature(size_t idx)
Definition: Node.h:104
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
const FeatureInstance & GetFeature(size_t idx) const
Definition: Node.h:99