forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenlr_model.hpp
124 lines (110 loc) · 4.26 KB
/
openlr_model.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#pragma once
#include "geometry/latlon.hpp"
#include "geometry/point2d.hpp"
#include <cstdint>
#include <limits>
#include <string>
#include <vector>
namespace openlr
{
// The form of way (FOW) describes the physical road type of a line.
enum class FormOfWay
{
// The physical road type is unknown.
Undefined,
// A road permitted for motorized vehicles only in combination with a prescribed minimum speed.
// It has two or more physically separated carriageways and no single level-crossings.
Motorway,
// A road with physically separated carriageways regardless of the number of lanes.
// If a road is also a motorway, it should be coded as such and not as a multiple carriageway.
MultipleCarriageway,
// All roads without separate carriageways are considered as roads with a single carriageway.
SingleCarriageway,
// A road which forms a ring on which traffic traveling in only one direction is allowed.
Roundabout,
// An open area (partly) enclosed by roads which is used for non-traffic purposes
// and which is not a Roundabout.
Trafficsquare,
// A road especially designed to enter or leave a line.
Sliproad,
// The physical road type is known, but does not fit into one of the other categories.
Other,
// A path only allowed for bikes.
BikePath,
// A path only allowed for pedestrians.
Footpath,
NotAValue
};
// The functional road class (FRC) of a line is a road classification based on the importance
// of the road represented by the line.
enum class FunctionalRoadClass
{
// Main road, highest importance.
FRC0,
// First class road.
FRC1,
// Other road classes.
FRC2,
FRC3,
FRC4,
FRC5,
FRC6,
FRC7,
NotAValue
};
// LinearSegment structure may be filled from olr:locationReference xml tag,
// from coordinates tag or not valid.
enum class LinearSegmentSource
{
NotValid,
FromLocationReferenceTag,
FromCoordinatesTag,
};
struct LocationReferencePoint
{
// Coordinates of the point of interest.
ms::LatLon m_latLon = ms::LatLon::Zero();
// The bearing (BEAR) describes the angle between the true North and a line which is defined
// by the coordinate of the LocationReferencePoint and a coordinate which is BEARDIST along
// the line defined by the LocationReference-point attributes.
// For more information see OpenLR-Whitepaper `Bearing' section.
uint8_t m_bearing = 0;
FunctionalRoadClass m_functionalRoadClass = FunctionalRoadClass::NotAValue;
FormOfWay m_formOfWay = FormOfWay::NotAValue;
// The distance to next point field describes the distance to the next LocationReferencePoint
// in the topological connection of the LocationReferencePoints. The distance is measured in meters
// and is calculated along the location reference path between two subsequent LR-points.
// The last LRP has the distance value 0.
// Should not be used in the last point of a segment.
uint32_t m_distanceToNextPoint = 0;
// The lowest FunctionalRoadClass to the next point (LFRCNP) is the lowest FunctionalRoadClass
// value which appears in the location reference path between two consecutive LR-points.
// This information could be used to limit the number of road classes which need to be
// scanned during the decoding.
// Should not be used in the last point of a segment.
FunctionalRoadClass m_lfrcnp = FunctionalRoadClass::NotAValue;
bool m_againstDrivingDirection = false;
};
struct LinearLocationReference
{
std::vector<LocationReferencePoint> m_points;
uint32_t m_positiveOffsetMeters = 0;
uint32_t m_negativeOffsetMeters = 0;
};
struct LinearSegment
{
static auto constexpr kInvalidSegmentId = std::numeric_limits<uint32_t>::max();
std::vector<m2::PointD> GetMercatorPoints() const;
std::vector<LocationReferencePoint> const & GetLRPs() const;
std::vector<LocationReferencePoint> & GetLRPs();
LinearSegmentSource m_source = LinearSegmentSource::NotValid;
// TODO(mgsergio): Think of using openlr::PartnerSegmentId
uint32_t m_segmentId = kInvalidSegmentId;
// TODO(mgsergio): Make sure that one segment cannot contain
// more than one location reference.
LinearLocationReference m_locationReference;
uint32_t m_segmentLengthMeters = 0;
// uint32_t m_segmentRefSpeed; Always null in partners data. (No docs found).
};
std::string DebugPrint(LinearSegmentSource source);
} // namespace openlr