forked from Tristramg/osm4routing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameters.cc
189 lines (171 loc) · 5.62 KB
/
parameters.cc
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
This file is part of osm4routing.
osm4routing is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mumoro is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with osm4routing. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parse.h"
#include <iostream>
Edge_property::Edge_property() :
car_direct(unknown),
car_reverse(unknown),
bike_direct(unknown),
bike_reverse(unknown),
foot(unknown)
{
}
bool Edge_property::accessible()
{
return direct_accessible() || reverse_accessible();
}
bool Edge_property::direct_accessible()
{
return car_direct > 0 || bike_direct > 0 || foot > 0;
}
bool Edge_property::reverse_accessible()
{
return car_reverse > 0 || bike_reverse > 0 || foot > 0;
}
void Edge_property::reset()
{
car_direct = unknown;
car_reverse = unknown;
bike_direct = unknown;
bike_reverse = unknown;
foot = unknown;
}
void Edge_property::normalize()
{
if(car_reverse == unknown && car_direct != unknown)
car_reverse = car_direct;
if(bike_reverse == unknown && bike_direct != unknown)
bike_reverse = bike_direct;
if(car_direct == unknown) car_direct = car_forbiden;
if(bike_direct == unknown) bike_direct = bike_forbiden;
if(car_reverse == unknown) car_reverse = car_forbiden;
if(bike_reverse == unknown) bike_reverse = bike_forbiden;
if(foot == unknown) foot = foot_forbiden;
}
bool Edge_property::update(const std::string & key, const std::string & val)
{
if(key == "highway")
{
if(val == "cycleway" || val == "path" || val == "footway" ||
val == "steps" || val == "pedestrian")
{
bike_direct = bike_track;
foot = foot_allowed;
}
else if(val == "primary" || val == "primary_link")
{
car_direct = car_primary;
foot = foot_allowed;
bike_direct = bike_allowed;
}
else if(val == "secondary")
{
car_direct = car_secondary;
foot = foot_allowed;
bike_direct = bike_allowed;
}
else if(val == "tertiary")
{
car_direct = car_tertiary;
foot = foot_allowed;
bike_direct = bike_allowed;
}
else if(val == "unclassified" || val == "residential" || val == "living_street" ||
val == "road" || val == "service" || val == "track")
{
car_direct = car_residential;
foot = foot_allowed;
bike_direct = bike_allowed;
}
else if(val == "motorway" || val == "motorway_link")
{
car_direct = car_motorway;
foot = foot_forbiden;
bike_direct = bike_forbiden;
}
else if(val == "trunk" || val == "trunk_link")
{
car_direct = car_trunk;
foot = foot_forbiden;
bike_direct = bike_forbiden;
}
}
else if(key == "pedestrian" || key == "foot")
{
if(val == "yes" || val == "designated" || val == "permissive")
foot = foot_allowed;
else if(val == "no")
foot = foot_forbiden;
else
std::cerr << "I don't know what to do with: " << key << "=" << val << std::endl;
}
// http://wiki.openstreetmap.org/wiki/Cycleway
// http://wiki.openstreetmap.org/wiki/Map_Features#Cycleway
else if(key == "cycleway")
{
if(val == "lane" || val == "yes" || val == "true" || val == "lane_in_the_middle")
bike_direct = bike_lane;
else if(val == "track")
bike_direct = bike_track;
else if(val == "opposite_lane")
bike_reverse = bike_lane;
else if(val == "opposite_track")
bike_reverse = bike_track;
else if(val == "opposite")
bike_reverse = bike_allowed;
else if(val == "share_busway")
bike_direct = bike_busway;
else if(val == "lane_left")
bike_reverse = bike_lane;
else
bike_direct = bike_lane;
}
else if(key == "bicycle")
{
if(val == "yes" || val == "permissive" || val == "destination" || val == "designated" || val == "private" || val == "true")
bike_direct = bike_allowed;
else if(val == "no" || val == "true")
bike_direct = bike_forbiden;
else
std::cerr << "I don't know what to do with: " << key << "=" << val << std::endl;
}
else if(key == "busway")
{
if(val == "yes" || val == "track" || val == "lane")
bike_direct = bike_busway;
else if(val == "opposite_lane" || val == "opposite_track")
bike_reverse = bike_busway;
else
bike_direct = bike_busway;
}
else if(key == "oneway")
{
if(val == "yes" || val == "true" || val == "1")
{
car_reverse = car_forbiden;
if(bike_reverse == unknown)
bike_reverse = bike_forbiden;
}
}
else if(key == "junction")
{
if(val == "roundabout")
{
car_reverse = car_forbiden;
if(bike_reverse == unknown)
bike_reverse = bike_forbiden;
}
}
return this->accessible();
}