libosmscout  1.1.1
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>
28 #include <osmscout/OSMScoutTypes.h>
29 #include <osmscout/TypeConfig.h>
30 
33 
34 namespace 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;
78  uint16_t objectVariantIndex;
79  };
80 
87  {
88  ObjectFileRef source;
89  uint8_t targetIndex;
90  };
91 
98  {
99  Distance distance;
100  Id id;
101  uint8_t objectIndex;
102  uint8_t flags;
103  //uint8_t bearing; //!< Encoded initial and final bearing of this path
104 
105  bool IsRestricted(Vehicle vehicle) const
106  {
107  switch (vehicle) {
108  case vehicleFoot:
109  return (flags & restrictedForFoot) != 0;
110  case vehicleBicycle:
111  return (flags & restrictedForBicycle) != 0;
112  case vehicleCar:
113  return (flags & restrictedForCar) != 0;
114  }
115 
116  return false;
117  }
118  };
119 
120  private:
121  FileOffset fileOffset;
122  Point point;
123 
124  public:
125  std::vector<ObjectData> objects;
126  std::vector<Path> paths;
127  std::vector<Exclude> excludes;
128 
130  {
131  return fileOffset;
132  }
133 
134  Id GetId() const
135  {
136  return point.GetId();
137  }
138 
139  GeoCoord GetCoord() const
140  {
141  return point.GetCoord();
142  }
143 
144  void Initialize(FileOffset fileOffset,
145  const Point& point)
146  {
147  this->fileOffset=fileOffset;
148  this->point=point;
149  }
150 
151  uint8_t AddObject(const ObjectFileRef& object,
152  uint16_t objectVariantIndex);
153 
154  void Read(FileScanner& scanner);
155  void Read(const TypeConfig& typeConfig,
156  FileScanner& scanner);
157  void Write(FileWriter& writer) const;
158  };
159 
160  using RouteNodeRef = std::shared_ptr<RouteNode>;
161 }
162 
163 #endif
uint64_t Id
Definition: OSMScoutTypes.h:41
Definition: OSMScoutTypes.h:59
bool IsRestricted(Vehicle vehicle) const
Definition: RouteNode.h:105
uint8_t targetIndex
The index of the target path.
Definition: RouteNode.h:89
Distance distance
Distance from the current route node to the target route node.
Definition: RouteNode.h:99
uint8_t grade
Quality of road/track 1 (good)...5 (bad)
Definition: RouteNode.h:47
GeoCoord GetCoord() const
Definition: RouteNode.h:139
Vehicle
Definition: OSMScoutTypes.h:55
TypeInfoRef type
The type of the object.
Definition: RouteNode.h:45
Definition: RouteNode.h:86
uint16_t objectVariantIndex
Index into the lookup table, holding object specific routing data.
Definition: RouteNode.h:78
Id id
id of the targeting route node
Definition: RouteNode.h:100
Definition: OSMScoutTypes.h:57
uint8_t flags
Certain flags.
Definition: RouteNode.h:102
Definition: Area.h:38
std::vector< Exclude > excludes
List of potential excludes regarding use of paths.
Definition: RouteNode.h:127
Definition: RouteNode.h:75
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
bool operator<(const TileCacheKey &a, const TileCacheKey &b)
Definition: RouteNode.h:42
std::shared_ptr< RouteNode > RouteNodeRef
Definition: RouteNode.h:160
std::vector< ObjectData > objects
List of objects (ways, areas) that cross this route node.
Definition: RouteNode.h:125
Id GetId() const
Definition: RouteNode.h:134
ObjectFileRef object
Reference to the object.
Definition: RouteNode.h:77
bool operator==(const MapView &a, const MapView &b)
Definition: InputHandler.h:222
void Initialize(FileOffset fileOffset, const Point &point)
Definition: RouteNode.h:144
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
uint8_t objectIndex
The index of the way to use from this route node to the target route node.
Definition: RouteNode.h:101
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
Definition: RouteNode.h:97
FileOffset GetFileOffset() const
Definition: RouteNode.h:129
uint8_t maxSpeed
Maximum speed allowed on the way.
Definition: RouteNode.h:46
std::vector< Path > paths
List of paths that can in principle be used from this node.
Definition: RouteNode.h:126
ObjectFileRef source
The source object.
Definition: RouteNode.h:88
Definition: OSMScoutTypes.h:58
Definition: RouteNode.h:61