1 | Index: maptool/osm.c |
---|
2 | =================================================================== |
---|
3 | --- maptool/osm.c (Revision 5715) |
---|
4 | +++ maptool/osm.c (Arbeitskopie) |
---|
5 | @@ -54,13 +54,31 @@ |
---|
6 | |
---|
7 | |
---|
8 | int maxspeed_attr_value; |
---|
9 | +int vehicle_width_attr_value; |
---|
10 | +int vehicle_length_attr_value; |
---|
11 | +int vehicle_height_attr_value; |
---|
12 | +int vehicle_weight_attr_value; |
---|
13 | +int vehicle_axle_weight_attr_value; |
---|
14 | |
---|
15 | char debug_attr_buffer[BUFFER_SIZE]; |
---|
16 | |
---|
17 | -int flags[4]; |
---|
18 | -int flagsa[4]; |
---|
19 | +/* |
---|
20 | + * meaning of index i of flags (flag[i]): |
---|
21 | + * i=0 general flags |
---|
22 | + * i=1 flagged road users are allowed |
---|
23 | + * i=2 flagged road users are not allowed |
---|
24 | + * i=3 flagged road users have permission for destination |
---|
25 | + * i=4 key value not evaluated (unused) |
---|
26 | + */ |
---|
27 | +int flags[5]; // collect individual tags related to a single flag, e.x. 'bicycle=' -> AF_BIKE, ... |
---|
28 | +int flagsa[5]; // collect 'access=' tags |
---|
29 | +int flagsv[5]; // collect 'vehicle=' tags (subset of 'access' group) |
---|
30 | +int flagsmv[5]; // collect 'motor_vehicle=' tags (subset of 'vehicle' group) |
---|
31 | +int flagspsv[5];// collect 'psv=' tags (subset of 'motor vehicle' group) |
---|
32 | |
---|
33 | int flags_attr_value; |
---|
34 | +int through_traffic_flags_attr_value; // Tell us which road users have the osm key value 'destination'. (Index 3 of all kind of flags) |
---|
35 | + // Flagged road users here will be allowed, but they get the through_traffic_penalty. |
---|
36 | |
---|
37 | struct attr_bin osmid_attr; |
---|
38 | long int osmid_attr_value; |
---|
39 | @@ -966,9 +984,11 @@ |
---|
40 | return 2; |
---|
41 | if (!strcmp(v,"delivery")) |
---|
42 | return 2; |
---|
43 | - if (!strcmp(v,"destination")) |
---|
44 | - return 2; |
---|
45 | - return 3; |
---|
46 | + if (!strcmp(v,"destination")) { |
---|
47 | + flags[0] |= AF_THROUGH_TRAFFIC_LIMIT; |
---|
48 | + return 3; |
---|
49 | + } |
---|
50 | + return 4; |
---|
51 | } |
---|
52 | |
---|
53 | static void |
---|
54 | @@ -1026,24 +1046,71 @@ |
---|
55 | flags[0] |= AF_SPEED_LIMIT; |
---|
56 | level=5; |
---|
57 | } |
---|
58 | + if (! strcmp(k,"maxwidth")) { |
---|
59 | + if (strstr(v, "'")) { |
---|
60 | + vehicle_width_attr_value = (int)floor((atof(v) + atof(strstr(v,"'")+1) / 12) * 30.48); // target dimension is [cm] |
---|
61 | + } else { |
---|
62 | + vehicle_width_attr_value = (int)floor(atof(v) * 100); |
---|
63 | + } |
---|
64 | + if (vehicle_width_attr_value) |
---|
65 | + flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; |
---|
66 | + level=5; |
---|
67 | + } |
---|
68 | + if (! strcmp(k,"maxlength")) { |
---|
69 | + if (strstr(v, "'")) { |
---|
70 | + vehicle_length_attr_value = (int)floor((atof(v) + atof(strstr(v,"'")+1) / 12) * 30.48); // target dimension is [cm] |
---|
71 | + } else { |
---|
72 | + vehicle_length_attr_value = (int)floor(atof(v) * 100); |
---|
73 | + } |
---|
74 | + if (vehicle_length_attr_value) |
---|
75 | + flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; |
---|
76 | + level=5; |
---|
77 | + } |
---|
78 | + if (! strcmp(k,"maxheight")) { |
---|
79 | + if (strstr(v, "'")) { |
---|
80 | + vehicle_height_attr_value = (int)floor((atof(v) + atof(strstr(v,"'")+1) / 12) * 30.48); // target dimension is [cm] |
---|
81 | + } else { |
---|
82 | + vehicle_height_attr_value = (int)floor(atof(v) * 100); |
---|
83 | + } |
---|
84 | + if (vehicle_height_attr_value) |
---|
85 | + flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; |
---|
86 | + level=5; |
---|
87 | + } |
---|
88 | + if (! strcmp(k,"maxweight")) { |
---|
89 | + if (strstr(v, "kg")) { |
---|
90 | + vehicle_weight_attr_value = atoi(v); // target dimension is [kg] |
---|
91 | + } else { |
---|
92 | + vehicle_weight_attr_value = (int)floor(atof(v) * 1000); |
---|
93 | + } |
---|
94 | + if (vehicle_weight_attr_value) |
---|
95 | + flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; |
---|
96 | + level=5; |
---|
97 | + } |
---|
98 | + if (! strcmp(k,"maxaxleload")) { |
---|
99 | + if (strstr(v, "kg")) { |
---|
100 | + vehicle_axle_weight_attr_value = atoi(v); // target dimension is [kg] |
---|
101 | + } else { |
---|
102 | + vehicle_axle_weight_attr_value = (int)floor(atof(v) * 1000); |
---|
103 | + } |
---|
104 | + if (vehicle_axle_weight_attr_value) |
---|
105 | + flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; |
---|
106 | + level=5; |
---|
107 | + } |
---|
108 | if (! strcmp(k,"toll")) { |
---|
109 | if (!strcmp(v,"1")) { |
---|
110 | flags[0] |= AF_TOLL; |
---|
111 | } |
---|
112 | } |
---|
113 | if (! strcmp(k,"access")) { |
---|
114 | - if (strcmp(v,"destination")) |
---|
115 | - flagsa[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_HORSE|AF_BIKE|AF_PEDESTRIAN; |
---|
116 | - else |
---|
117 | - flags[0] |= AF_THROUGH_TRAFFIC_LIMIT; |
---|
118 | + flagsa[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_HORSE|AF_BIKE|AF_PEDESTRIAN; |
---|
119 | level=5; |
---|
120 | } |
---|
121 | if (! strcmp(k,"vehicle")) { |
---|
122 | - flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE; |
---|
123 | + flagsv[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE; |
---|
124 | level=5; |
---|
125 | } |
---|
126 | if (! strcmp(k,"motor_vehicle")) { |
---|
127 | - flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED; |
---|
128 | + flagsmv[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED; |
---|
129 | level=5; |
---|
130 | } |
---|
131 | if (! strcmp(k,"bicycle")) { |
---|
132 | @@ -1074,6 +1141,10 @@ |
---|
133 | flags[access_value(v)] |= AF_HIGH_OCCUPANCY_CAR; |
---|
134 | level=5; |
---|
135 | } |
---|
136 | + if (! strcmp(k,"psv")) { |
---|
137 | + flagspsv[access_value(v)] |= AF_PUBLIC_BUS|AF_TAXI; |
---|
138 | + level=5; |
---|
139 | + } |
---|
140 | if (! strcmp(k,"bus")) { |
---|
141 | flags[access_value(v)] |= AF_PUBLIC_BUS; |
---|
142 | level=5; |
---|
143 | @@ -1479,9 +1550,18 @@ |
---|
144 | item.type=type_street_unkn; |
---|
145 | debug_attr_buffer[0]='\0'; |
---|
146 | maxspeed_attr_value=0; |
---|
147 | + vehicle_width_attr_value=0; |
---|
148 | + vehicle_length_attr_value=0; |
---|
149 | + vehicle_height_attr_value=0; |
---|
150 | + vehicle_weight_attr_value=0; |
---|
151 | + vehicle_axle_weight_attr_value=0; |
---|
152 | flags_attr_value = 0; |
---|
153 | + through_traffic_flags_attr_value = 0; |
---|
154 | memset(flags, 0, sizeof(flags)); |
---|
155 | memset(flagsa, 0, sizeof(flagsa)); |
---|
156 | + memset(flagsv, 0, sizeof(flagsv)); |
---|
157 | + memset(flagsmv, 0, sizeof(flagsmv)); |
---|
158 | + memset(flagspsv, 0, sizeof(flagspsv)); |
---|
159 | debug_attr_buffer[0]='\0'; |
---|
160 | osmid_attr_value=id; |
---|
161 | if (wayid < wayid_last && !way_hash) { |
---|
162 | @@ -1715,9 +1795,35 @@ |
---|
163 | nodes_ref_item_bin(item_bin); |
---|
164 | def_flags=item_get_default_flags(types[i]); |
---|
165 | if (def_flags) { |
---|
166 | - flags_attr_value=((*def_flags & ~flagsa[2]) | flags[0] | flags[1] | flagsa[1]) & ~flags[2]; |
---|
167 | + /* |
---|
168 | + * Evaluation of collected tags: |
---|
169 | + * Tags of a subset dominate enclosing groups. |
---|
170 | + * e.g. 'bicycle=...' overrules 'vehicle=...' |
---|
171 | + * 'motor_vehicle=...' overrules 'vehicle=...' |
---|
172 | + * 'vehicle=...' overrules 'access=...' |
---|
173 | + * Allowing dominates forbidding if a tag is used twice. |
---|
174 | + * e.g. 'motor_vehicle=permissive' and 'motor_vehicle=agricultural' |
---|
175 | + * -> results in permission |
---|
176 | + */ |
---|
177 | + flags_attr_value=((((((((( |
---|
178 | + *def_flags & ~flagsa[2] ) | flagsa[1] | flagsa[3] ) |
---|
179 | + & ~flagsv[2] ) | flagsv[1] | flagsv[3] ) |
---|
180 | + & ~flagsmv[2]) | flagsmv[1] | flagsmv[3] ) |
---|
181 | + & ~flagspsv[2])| flagspsv[1]| flagspsv[3]) |
---|
182 | + & ~flags[2] ) | flags[1] | flags[3] | flags[0]; |
---|
183 | + /* |
---|
184 | + * Road users allowed by a '=yes' have to get removed the through traffic flag. |
---|
185 | + */ |
---|
186 | + through_traffic_flags_attr_value=((((((((( |
---|
187 | + flagsa[3] )& ~flagsa[1] ) |
---|
188 | + | flagsv[3] )& ~flagsv[1] ) |
---|
189 | + | flagsmv[3] )& ~flagsmv[1] ) |
---|
190 | + | flagspsv[3])& ~flagspsv[1]) |
---|
191 | + | flags[3] )& ~flags[1]; |
---|
192 | if (flags_attr_value != *def_flags) |
---|
193 | add_flags=1; |
---|
194 | + if (through_traffic_flags_attr_value) |
---|
195 | + add_flags=1; |
---|
196 | } |
---|
197 | item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]); |
---|
198 | item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]); |
---|
199 | @@ -1729,6 +1835,18 @@ |
---|
200 | item_bin_add_attr_int(item_bin, attr_flags, flags_attr_value); |
---|
201 | if (maxspeed_attr_value) |
---|
202 | item_bin_add_attr_int(item_bin, attr_maxspeed, maxspeed_attr_value); |
---|
203 | + if (vehicle_width_attr_value) |
---|
204 | + item_bin_add_attr_int(item_bin, attr_vehicle_width, vehicle_width_attr_value); |
---|
205 | + if (vehicle_length_attr_value) |
---|
206 | + item_bin_add_attr_int(item_bin, attr_vehicle_length, vehicle_length_attr_value); |
---|
207 | + if (vehicle_height_attr_value) |
---|
208 | + item_bin_add_attr_int(item_bin, attr_vehicle_height, vehicle_height_attr_value); |
---|
209 | + if (vehicle_weight_attr_value) |
---|
210 | + item_bin_add_attr_int(item_bin, attr_vehicle_weight, vehicle_weight_attr_value); |
---|
211 | + if (vehicle_axle_weight_attr_value) |
---|
212 | + item_bin_add_attr_int(item_bin, attr_vehicle_axle_weight, vehicle_axle_weight_attr_value); |
---|
213 | + if (add_flags && through_traffic_flags_attr_value) |
---|
214 | + item_bin_add_attr_int(item_bin, attr_through_traffic_flags, through_traffic_flags_attr_value); |
---|
215 | if(i>0) |
---|
216 | item_bin_add_attr_int(item_bin, attr_duplicate, 1); |
---|
217 | item_bin_write(item_bin,osm->ways); |
---|
218 | Index: route.c |
---|
219 | =================================================================== |
---|
220 | --- route.c (Revision 5715) |
---|
221 | +++ route.c (Arbeitskopie) |
---|
222 | @@ -2195,6 +2195,11 @@ |
---|
223 | else |
---|
224 | data.size_weight.axle_weight=-1; |
---|
225 | } |
---|
226 | + if (data.flags & AF_THROUGH_TRAFFIC_LIMIT) { |
---|
227 | + if (item_attr_get(item, attr_through_traffic_flags, &attr)) |
---|
228 | + if (!(profile->flags & attr.u.num)) // If the through_traffic_flags do not meet the current vehicle, |
---|
229 | + data.flags &= ~AF_THROUGH_TRAFFIC_LIMIT; // unset AF_THROUGH_TRAFFIC_LIMIT. |
---|
230 | + } |
---|
231 | |
---|
232 | s_pnt=route_graph_add_point(this,&l); |
---|
233 | if (!segmented) { |
---|