libosmscout 1.1.1
Loading...
Searching...
No Matches
RouteNode.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_ROUTENODE_H
2#define OSMSCOUT_ROUTENODE_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2012 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/ObjectRef.h>
27#include <osmscout/Path.h>
29#include <osmscout/TypeConfig.h>
30
33
34namespace osmscout {
35
43 {
44 public:
46 uint8_t maxSpeed;
47 uint8_t grade;
48
49 bool operator==(const ObjectVariantData& other) const;
50 bool operator<(const ObjectVariantData& other) const;
51
52 void Read(const TypeConfig& typeConfig,
53 FileScanner& scanner);
54 void Write(FileWriter& writer) const;
55 };
56
62 {
63 public:
64 static const uint8_t usableByFoot = 1u << 0u;
65 static const uint8_t usableByBicycle = 1u << 1u;
66 static const uint8_t usableByCar = 1u << 2u;
67 static const uint8_t restrictedForFoot = 1u << 3u;
68 static const uint8_t restrictedForBicycle = 1u << 4u;
69 static const uint8_t restrictedForCar = 1u << 5u;
70
76 {
77 ObjectFileRef object;
79 };
80
87 {
88 ObjectFileRef source;
89 uint8_t targetIndex;
90 };
91
98 {
99 Distance distance;
101 uint8_t objectIndex;
102 uint8_t flags;
103
104 bool IsUsable(Vehicle vehicle) const
105 {
106 switch (vehicle) {
107 case vehicleFoot:
108 return (flags & usableByFoot) != 0;
109 case vehicleBicycle:
110 return (flags & usableByBicycle) != 0;
111 case vehicleCar:
112 return (flags & usableByCar) != 0;
113 }
114
115 return false;
116 }
117
118 bool IsRestricted(Vehicle vehicle) const
119 {
120 switch (vehicle) {
121 case vehicleFoot:
122 return (flags & restrictedForFoot) != 0;
123 case vehicleBicycle:
124 return (flags & restrictedForBicycle) != 0;
125 case vehicleCar:
126 return (flags & restrictedForCar) != 0;
127 }
128
129 return false;
130 }
131 };
132
133 private:
134 FileOffset fileOffset;
135 Point point;
136
137 public:
138 std::vector<ObjectData> objects;
139 std::vector<Path> paths;
140 std::vector<Exclude> excludes;
141
143 {
144 return fileOffset;
145 }
146
147 Id GetId() const
148 {
149 return point.GetId();
150 }
151
152 GeoCoord GetCoord() const
153 {
154 return point.GetCoord();
155 }
156
157 Point GetPoint() const {
158 return point;
159 }
160
161 void Initialize(FileOffset fileOffset,
162 const Point& point)
163 {
164 this->fileOffset=fileOffset;
165 this->point=point;
166 }
167
168 uint8_t AddObject(const ObjectFileRef& object,
169 uint16_t objectVariantIndex);
170
171 void Read(FileScanner& scanner);
172 void Read(const TypeConfig& typeConfig,
173 FileScanner& scanner);
174 void Write(FileWriter& writer) const;
175 };
176
177 using RouteNodeRef = std::shared_ptr<RouteNode>;
178}
179
180#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition RouteNode.h:62
void Initialize(FileOffset fileOffset, const Point &point)
Definition RouteNode.h:161
std::vector< Exclude > excludes
List of potential excludes regarding use of paths.
Definition RouteNode.h:140
static const uint8_t restrictedForFoot
Using this path ist restricted for foot.
Definition RouteNode.h:67
static const uint8_t usableByBicycle
This path can be traveled by bicycle.
Definition RouteNode.h:65
FileOffset GetFileOffset() const
Definition RouteNode.h:142
GeoCoord GetCoord() const
Definition RouteNode.h:152
std::vector< Path > paths
List of paths that can in principle be used from this node.
Definition RouteNode.h:139
std::vector< ObjectData > objects
List of objects (ways, areas) that cross this route node.
Definition RouteNode.h:138
static const uint8_t restrictedForBicycle
Using this path ist restricted for bicycle.
Definition RouteNode.h:68
void Read(FileScanner &scanner)
Id GetId() const
Definition RouteNode.h:147
Point GetPoint() const
Definition RouteNode.h:157
void Write(FileWriter &writer) const
static const uint8_t usableByCar
This path can be traveled by car.
Definition RouteNode.h:66
static const uint8_t restrictedForCar
Using this path ist restricted for car.
Definition RouteNode.h:69
static const uint8_t usableByFoot
This path can be traveled by foot.
Definition RouteNode.h:64
void Read(const TypeConfig &typeConfig, FileScanner &scanner)
uint8_t AddObject(const ObjectFileRef &object, uint16_t objectVariantIndex)
uint64_t Id
Definition OSMScoutTypes.h:40
uint64_t FileOffset
Definition OSMScoutTypes.h:46
Definition Area.h:39
std::shared_ptr< RouteNode > RouteNodeRef
Definition RouteNode.h:177
Vehicle
Definition OSMScoutTypes.h:55
@ vehicleBicycle
Definition OSMScoutTypes.h:57
@ vehicleFoot
Definition OSMScoutTypes.h:56
@ vehicleCar
Definition OSMScoutTypes.h:58
std::shared_ptr< TypeInfo > TypeInfoRef
Definition TypeConfig.h:61
Definition RouteNode.h:43
uint8_t grade
Quality of road/track 1 (good)...5 (bad).
Definition RouteNode.h:47
uint8_t maxSpeed
Maximum speed allowed on the way.
Definition RouteNode.h:46
void Write(FileWriter &writer) const
void Read(const TypeConfig &typeConfig, FileScanner &scanner)
bool operator==(const ObjectVariantData &other) const
TypeInfoRef type
The type of the object.
Definition RouteNode.h:45
bool operator<(const ObjectVariantData &other) const
Definition RouteNode.h:87
ObjectFileRef source
The source object.
Definition RouteNode.h:88
uint8_t targetIndex
The index of the target path.
Definition RouteNode.h:89
Definition RouteNode.h:76
ObjectFileRef object
Reference to the object.
Definition RouteNode.h:77
uint16_t objectVariantIndex
Index into the lookup table, holding object specific routing data.
Definition RouteNode.h:78
Definition RouteNode.h:98
bool IsUsable(Vehicle vehicle) const
Definition RouteNode.h:104
uint8_t flags
Certain flags.
Definition RouteNode.h:102
uint8_t objectIndex
The index of the way to use from this route node to the target route node.
Definition RouteNode.h:101
Distance distance
Distance from the current route node to the target route node.
Definition RouteNode.h:99
Id id
id of the targeting route node
Definition RouteNode.h:100
bool IsRestricted(Vehicle vehicle) const
Definition RouteNode.h:118