libosmscout 1.1.1
Loading...
Searching...
No Matches
Way.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_WAY_H
2#define OSMSCOUT_WAY_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
25#include <osmscout/GeoCoord.h>
26#include <osmscout/Point.h>
27#include <osmscout/Tag.h>
28#include <osmscout/TypeConfig.h>
29
33
36
38
39namespace osmscout {
40
42 {
43 private:
44 FeatureValueBuffer featureValueBuffer;
45
46 FileOffset fileOffset=0;
47 FileOffset nextFileOffset=0;
48
49
50 public:
57 std::vector<Point> nodes;
58 std::vector<SegmentGeoBox> segments;
59 GeoBox bbox;
60
61 public:
62 Way() = default;
63
65 {
66 return fileOffset;
67 }
68
70 {
71 return nextFileOffset;
72 }
73
75 {
76 return {fileOffset,refWay};
77 }
78
80 {
81 return featureValueBuffer.GetType();
82 }
83
84 size_t GetFeatureCount() const
85 {
86 return featureValueBuffer.GetType()->GetFeatureCount();
87 }
88
89 bool HasFeature(size_t idx) const
90 {
91 return featureValueBuffer.HasFeature(idx);
92 }
93
94 const FeatureInstance& GetFeature(size_t idx) const
95 {
96 return featureValueBuffer.GetType()->GetFeature(idx);
97 }
98
99 FeatureValue* GetFeatureValue(size_t idx) const
100 {
101 return featureValueBuffer.GetValue(idx);
102 }
103
104 void UnsetFeature(size_t idx)
105 {
106 featureValueBuffer.FreeValue(idx);
107 }
108
110 {
111 return featureValueBuffer;
112 }
113
114 bool IsValid() const {
115 return nodes.size()>=2;
116 }
117
118 bool IsCircular() const
119 {
120 return nodes[0].GetId()!=0 &&
121 nodes[0].GetId()==nodes[nodes.size()-1].GetId();
122 }
123
124 Id GetSerial(size_t index) const
125 {
126 return nodes[index].GetSerial();
127 }
128
129 Id GetId(size_t index) const
130 {
131 return nodes[index].GetId();
132 }
133
135 {
136 return nodes.front().GetId();
137 }
138
139 Id GetBackId() const
140 {
141 return nodes.back().GetId();
142 }
143
144 const Point& GetFront() const
145 {
146 return nodes.front();
147 }
148
149 const Point& GetBack() const
150 {
151 return nodes.back();
152 }
153
154 const Point& GetPoint(size_t index) const
155 {
156 return nodes[index];
157 }
158
159 const GeoCoord& GetCoord(size_t index) const
160 {
161 return nodes[index].GetCoord();
162 }
163
165 {
166 if (bbox.IsValid() || nodes.empty()) {
167 return bbox;
168 }
169
171 }
172
182 bool Intersects(const GeoBox& boundingBox) const
183 {
184 return GetBoundingBox().Intersects(boundingBox);
185 }
186
187 bool GetCenter(GeoCoord& center) const;
188
190 size_t& index) const;
191
193 {
194 featureValueBuffer.SetType(type);
195 }
196
198 {
199 featureValueBuffer.Set(buffer);
200 }
201
202 void Read(const TypeConfig& typeConfig,
203 FileScanner& scanner);
204 void ReadOptimized(const TypeConfig& typeConfig,
205 FileScanner& scanner);
206
207 void Write(const TypeConfig& typeConfig,
208 FileWriter& writer) const;
209 void WriteOptimized(const TypeConfig& typeConfig,
210 FileWriter& writer) const;
211 };
212
213 using WayRef = std::shared_ptr<Way>;
214}
215
216#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition Area.h:88
void UnsetFeature(size_t idx)
Definition Way.h:104
TypeInfoRef GetType() const
Definition Way.h:79
void WriteOptimized(const TypeConfig &typeConfig, FileWriter &writer) const
bool GetNodeIndexByNodeId(Id id, size_t &index) const
std::vector< Point > nodes
List of nodes.
Definition Way.h:57
bool IsCircular() const
Definition Way.h:118
bool Intersects(const GeoBox &boundingBox) const
Definition Way.h:182
Id GetBackId() const
Definition Way.h:139
void Write(const TypeConfig &typeConfig, FileWriter &writer) const
GeoBox GetBoundingBox() const
Definition Way.h:164
bool IsValid() const
Definition Way.h:114
bool GetCenter(GeoCoord &center) const
FileOffset GetFileOffset() const
Definition Way.h:64
bool HasFeature(size_t idx) const
Definition Way.h:89
FeatureValue * GetFeatureValue(size_t idx) const
Definition Way.h:99
ObjectFileRef GetObjectFileRef() const
Definition Way.h:74
FileOffset GetNextFileOffset() const
Definition Way.h:69
void SetFeatures(const FeatureValueBuffer &buffer)
Definition Way.h:197
const Point & GetBack() const
Definition Way.h:149
std::vector< Segment > segments
Definition Route.h:68
Id GetFrontId() const
Definition Way.h:134
const Point & GetPoint(size_t index) const
Definition Way.h:154
const FeatureValueBuffer & GetFeatureValueBuffer() const
Definition Way.h:109
Id GetSerial(size_t index) const
Definition Way.h:124
Type type
The type of the cell.
Definition GroundTile.h:92
const Point & GetFront() const
Definition Way.h:144
void ReadOptimized(const TypeConfig &typeConfig, FileScanner &scanner)
void SetType(const TypeInfoRef &type)
Definition Way.h:192
Vertex2D * buffer
Definition Transformation.h:343
FeatureValueBuffer()=default
GeoBox bbox
Precomputed (cache) bounding box.
Definition DataAgent.h:53
const FeatureInstance & GetFeature(size_t idx) const
Definition Way.h:94
void Read(const TypeConfig &typeConfig, FileScanner &scanner)
const GeoCoord & GetCoord(size_t index) const
Definition Way.h:159
Id GetId(size_t index) const
Definition Way.h:129
size_t GetFeatureCount() const
Definition Way.h:84
Definition TypeFeature.h:41
void GetBoundingBox(const InputIt first, const InputIt last, GeoBox &boundingBox)
Definition Geometry.h:103
uint64_t Id
Definition OSMScoutTypes.h:40
uint64_t FileOffset
Definition OSMScoutTypes.h:46
Definition Area.h:39
std::shared_ptr< Way > WayRef
Definition Way.h:213
@ refWay
Definition ObjectRef.h:143
std::shared_ptr< TypeInfo > TypeInfoRef
Definition TypeConfig.h:61