Ticket #1178: through-traffic_size-weight_psv.patch
File through-traffic_size-weight_psv.patch, 8.8 KB (added by chr, 9 years ago) |
---|
-
maptool/osm.c
54 54 55 55 56 56 int maxspeed_attr_value; 57 int vehicle_width_attr_value; 58 int vehicle_length_attr_value; 59 int vehicle_height_attr_value; 60 int vehicle_weight_attr_value; 61 int vehicle_axle_weight_attr_value; 57 62 58 63 char debug_attr_buffer[BUFFER_SIZE]; 59 64 60 int flags[4]; 61 int flagsa[4]; 65 /* 66 * meaning of index i of flags (flag[i]): 67 * i=0 general flags 68 * i=1 flagged road users are allowed 69 * i=2 flagged road users are not allowed 70 * i=3 flagged road users have permission for destination 71 * i=4 key value not evaluated (unused) 72 */ 73 int flags[5]; // collect individual tags related to a single flag, e.x. 'bicycle=' -> AF_BIKE, ... 74 int flagsa[5]; // collect 'access=' tags 75 int flagsv[5]; // collect 'vehicle=' tags (subset of 'access' group) 76 int flagsmv[5]; // collect 'motor_vehicle=' tags (subset of 'vehicle' group) 77 int flagspsv[5];// collect 'psv=' tags (subset of 'motor vehicle' group) 62 78 63 79 int flags_attr_value; 80 int through_traffic_flags_attr_value; // Tell us which road users have the osm key value 'destination'. (Index 3 of all kind of flags) 81 // Flagged road users here will be allowed, but they get the through_traffic_penalty. 64 82 65 83 struct attr_bin osmid_attr; 66 84 long int osmid_attr_value; … … 966 984 return 2; 967 985 if (!strcmp(v,"delivery")) 968 986 return 2; 969 if (!strcmp(v,"destination")) 970 return 2; 971 return 3; 987 if (!strcmp(v,"destination")) { 988 flags[0] |= AF_THROUGH_TRAFFIC_LIMIT; 989 return 3; 990 } 991 return 4; 972 992 } 973 993 974 994 static void … … 1026 1046 flags[0] |= AF_SPEED_LIMIT; 1027 1047 level=5; 1028 1048 } 1049 if (! strcmp(k,"maxwidth")) { 1050 if (strstr(v, "'")) { 1051 vehicle_width_attr_value = (int)floor((atof(v) + atof(strstr(v,"'")+1) / 12) * 30.48); // target dimension is [cm] 1052 } else { 1053 vehicle_width_attr_value = (int)floor(atof(v) * 100); 1054 } 1055 if (vehicle_width_attr_value) 1056 flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; 1057 level=5; 1058 } 1059 if (! strcmp(k,"maxlength")) { 1060 if (strstr(v, "'")) { 1061 vehicle_length_attr_value = (int)floor((atof(v) + atof(strstr(v,"'")+1) / 12) * 30.48); // target dimension is [cm] 1062 } else { 1063 vehicle_length_attr_value = (int)floor(atof(v) * 100); 1064 } 1065 if (vehicle_length_attr_value) 1066 flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; 1067 level=5; 1068 } 1069 if (! strcmp(k,"maxheight")) { 1070 if (strstr(v, "'")) { 1071 vehicle_height_attr_value = (int)floor((atof(v) + atof(strstr(v,"'")+1) / 12) * 30.48); // target dimension is [cm] 1072 } else { 1073 vehicle_height_attr_value = (int)floor(atof(v) * 100); 1074 } 1075 if (vehicle_height_attr_value) 1076 flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; 1077 level=5; 1078 } 1079 if (! strcmp(k,"maxweight")) { 1080 if (strstr(v, "kg")) { 1081 vehicle_weight_attr_value = atoi(v); // target dimension is [kg] 1082 } else { 1083 vehicle_weight_attr_value = (int)floor(atof(v) * 1000); 1084 } 1085 if (vehicle_weight_attr_value) 1086 flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; 1087 level=5; 1088 } 1089 if (! strcmp(k,"maxaxleload")) { 1090 if (strstr(v, "kg")) { 1091 vehicle_axle_weight_attr_value = atoi(v); // target dimension is [kg] 1092 } else { 1093 vehicle_axle_weight_attr_value = (int)floor(atof(v) * 1000); 1094 } 1095 if (vehicle_axle_weight_attr_value) 1096 flags[0] |= AF_SIZE_OR_WEIGHT_LIMIT; 1097 level=5; 1098 } 1029 1099 if (! strcmp(k,"toll")) { 1030 1100 if (!strcmp(v,"1")) { 1031 1101 flags[0] |= AF_TOLL; 1032 1102 } 1033 1103 } 1034 1104 if (! strcmp(k,"access")) { 1035 if (strcmp(v,"destination")) 1036 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; 1037 else 1038 flags[0] |= AF_THROUGH_TRAFFIC_LIMIT; 1105 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; 1039 1106 level=5; 1040 1107 } 1041 1108 if (! strcmp(k,"vehicle")) { 1042 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;1109 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; 1043 1110 level=5; 1044 1111 } 1045 1112 if (! strcmp(k,"motor_vehicle")) { 1046 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;1113 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; 1047 1114 level=5; 1048 1115 } 1049 1116 if (! strcmp(k,"bicycle")) { … … 1074 1141 flags[access_value(v)] |= AF_HIGH_OCCUPANCY_CAR; 1075 1142 level=5; 1076 1143 } 1144 if (! strcmp(k,"psv")) { 1145 flags[access_value(v)] |= AF_PUBLIC_BUS|AF_TAXI; 1146 level=5; 1147 } 1077 1148 if (! strcmp(k,"bus")) { 1078 1149 flags[access_value(v)] |= AF_PUBLIC_BUS; 1079 1150 level=5; … … 1479 1550 item.type=type_street_unkn; 1480 1551 debug_attr_buffer[0]='\0'; 1481 1552 maxspeed_attr_value=0; 1553 vehicle_width_attr_value=0; 1554 vehicle_length_attr_value=0; 1555 vehicle_height_attr_value=0; 1556 vehicle_weight_attr_value=0; 1557 vehicle_axle_weight_attr_value=0; 1482 1558 flags_attr_value = 0; 1559 through_traffic_flags_attr_value = 0; 1483 1560 memset(flags, 0, sizeof(flags)); 1484 1561 memset(flagsa, 0, sizeof(flagsa)); 1562 memset(flagsv, 0, sizeof(flagsv)); 1563 memset(flagsmv, 0, sizeof(flagsmv)); 1564 memset(flagspsv, 0, sizeof(flagspsv)); 1485 1565 debug_attr_buffer[0]='\0'; 1486 1566 osmid_attr_value=id; 1487 1567 if (wayid < wayid_last && !way_hash) { … … 1715 1795 nodes_ref_item_bin(item_bin); 1716 1796 def_flags=item_get_default_flags(types[i]); 1717 1797 if (def_flags) { 1718 flags_attr_value=((*def_flags & ~flagsa[2]) | flags[0] | flags[1] | flagsa[1]) & ~flags[2]; 1798 /* 1799 * Evaluation of collected tags: 1800 * Tags of a subset dominate enclosing groups. 1801 * e.g. 'bicycle=...' overrules 'vehicle=...' 1802 * 'motor_vehicle=...' overrules 'vehicle=...' 1803 * 'vehicle=...' overrules 'access=...' 1804 * Allowing dominates forbidding if a tag is used twice. 1805 * e.g. 'motor_vehicle=permissive' and 'motor_vehicle=agricultural' 1806 * -> results in permission 1807 */ 1808 flags_attr_value=((((((((( 1809 *def_flags & ~flagsa[2] ) | flagsa[1] | flagsa[3] ) 1810 & ~flagsv[2] ) | flagsv[1] | flagsv[3] ) 1811 & ~flagsmv[2]) | flagsmv[1] | flagsmv[3] ) 1812 & ~flagspsv[2])| flagspsv[1]| flagspsv[3]) 1813 & ~flags[2] ) | flags[1] | flags[3] | flags[0]; 1814 /* 1815 * Road users allowed by a '=yes' have to get removed the through traffic flag. 1816 */ 1817 through_traffic_flags_attr_value=((((((((( 1818 flagsa[3] )& ~flagsa[1] ) 1819 | flagsv[3] )& ~flagsv[1] ) 1820 | flagsmv[3] )& ~flagsmv[1] ) 1821 | flagspsv[3])& ~flagspsv[1]) 1822 | flags[3] )& ~flags[1]; 1719 1823 if (flags_attr_value != *def_flags) 1720 1824 add_flags=1; 1825 if (through_traffic_flags_attr_value) 1826 add_flags=1; 1721 1827 } 1722 1828 item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]); 1723 1829 item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]); … … 1729 1835 item_bin_add_attr_int(item_bin, attr_flags, flags_attr_value); 1730 1836 if (maxspeed_attr_value) 1731 1837 item_bin_add_attr_int(item_bin, attr_maxspeed, maxspeed_attr_value); 1838 if (vehicle_width_attr_value) 1839 item_bin_add_attr_int(item_bin, attr_vehicle_width, vehicle_width_attr_value); 1840 if (vehicle_length_attr_value) 1841 item_bin_add_attr_int(item_bin, attr_vehicle_length, vehicle_length_attr_value); 1842 if (vehicle_height_attr_value) 1843 item_bin_add_attr_int(item_bin, attr_vehicle_height, vehicle_height_attr_value); 1844 if (vehicle_weight_attr_value) 1845 item_bin_add_attr_int(item_bin, attr_vehicle_weight, vehicle_weight_attr_value); 1846 if (vehicle_axle_weight_attr_value) 1847 item_bin_add_attr_int(item_bin, attr_vehicle_axle_weight, vehicle_axle_weight_attr_value); 1848 if (add_flags && through_traffic_flags_attr_value) 1849 item_bin_add_attr_int(item_bin, attr_through_traffic_flags, through_traffic_flags_attr_value); 1732 1850 if(i>0) 1733 1851 item_bin_add_attr_int(item_bin, attr_duplicate, 1); 1734 1852 item_bin_write(item_bin,osm->ways); -
route.c
2195 2195 else 2196 2196 data.size_weight.axle_weight=-1; 2197 2197 } 2198 if (data.flags & AF_THROUGH_TRAFFIC_LIMIT) { 2199 if (item_attr_get(item, attr_through_traffic_flags, &attr)) 2200 if (!(profile->flags & attr.u.num)) // If the through_traffic_flags do not meet the current vehicle, 2201 data.flags &= ~AF_THROUGH_TRAFFIC_LIMIT; // unset AF_THROUGH_TRAFFIC_LIMIT. 2202 } 2198 2203 2199 2204 s_pnt=route_graph_add_point(this,&l); 2200 2205 if (!segmented) {