diff options
-rw-r--r-- | navit/attr_def.h | 1 | ||||
-rw-r--r-- | navit/navit.dtd | 1 | ||||
-rw-r--r-- | navit/navit_shipped.xml | 73 | ||||
-rw-r--r-- | navit/route.c | 60 |
4 files changed, 113 insertions, 22 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h index e4eb067d7..202c72cf2 100644 --- a/navit/attr_def.h +++ b/navit/attr_def.h @@ -356,6 +356,7 @@ ATTR(map_name) ATTR(item_name) ATTR(state_file) ATTR(on_map_click) +ATTR(route_depth) ATTR2(0x0003ffff,type_string_end) ATTR2(0x00040000,type_special_begin) ATTR(order) diff --git a/navit/navit.dtd b/navit/navit.dtd index 8bf09d37c..81dc083e4 100644 --- a/navit/navit.dtd +++ b/navit/navit.dtd @@ -50,6 +50,7 @@ <!ATTLIST vehicleprofile flags_reverse_mask CDATA #REQUIRED> <!ATTLIST vehicleprofile maxspeed_handling CDATA #REQUIRED> <!ATTLIST vehicleprofile route_mode CDATA #REQUIRED> +<!ATTLIST vehicleprofile route_depth CDATA #IMPLIED> <!ELEMENT coord EMPTY> <!ATTLIST coord x CDATA #REQUIRED> <!ATTLIST coord y CDATA #REQUIRED> diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml index 2d1c7844f..98f1e3ccd 100644 --- a/navit/navit_shipped.xml +++ b/navit/navit_shipped.xml @@ -133,7 +133,7 @@ Waypoint</text></img> <!-- For the cumulative displacement filter to be enabled, set cdf_histsize="x" here, with x being an integer somewhere around 4 --> <tracking cdf_histsize="0"/> - <vehicleprofile name="car" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0" static_speed="5" static_distance="25"> + <vehicleprofile name="car" route_depth="4:25%,8:40000,18:10000" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0" static_speed="5" static_distance="25"> <roadprofile item_types="street_0,street_1_city,living_street,street_service,track_gravelled,track_unpaved,street_parking_lane" speed="10" route_weight="10"> <announcement level="0" distance_metric="25"/> <announcement level="1" distance_metric="100"/> @@ -327,8 +327,71 @@ Waypoint</text></img> <roadprofile item_types="roundabout" speed="10" route_weight="10"/> <roadprofile item_types="ferry" speed="40" route_weight="40"/> </vehicleprofile> - - <vehicleprofile name="bike" flags="0x40000000" flags_forward_mask="0x40000000" flags_reverse_mask="0x40000000" maxspeed_handling="1" route_mode="0" static_speed="5" static_distance="25"> + <vehicleprofile name="car_pedantic" route_depth="18:25%,18:40000" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0" static_speed="5" static_distance="25"> + <roadprofile item_types="street_0,street_1_city,living_street,street_service,track_gravelled,track_unpaved,street_parking_lane" speed="10" route_weight="10"> + <announcement level="0" distance_metric="25"/> + <announcement level="1" distance_metric="100"/> + <announcement level="2" distance_metric="200"/> + </roadprofile> + <roadprofile item_types="street_2_city,track_paved" speed="30" route_weight="30"> + <announcement level="0" distance_metric="50"/> + <announcement level="1" distance_metric="200"/> + <announcement level="2" distance_metric="500"/> + </roadprofile> + <roadprofile item_types="street_3_city" speed="40" route_weight="40"> + <announcement level="0" distance_metric="50"/> + <announcement level="1" distance_metric="200"/> + <announcement level="2" distance_metric="500"/> + </roadprofile> + <roadprofile item_types="street_4_city" speed="50" route_weight="50"> + <announcement level="0" distance_metric="50"/> + <announcement level="1" distance_metric="200"/> + <announcement level="2" distance_metric="500"/> + </roadprofile> + <roadprofile item_types="highway_city" speed="80" route_weight="80"> + <announcement level="0" distance_metric="100"/> + <announcement level="1" distance_metric="400"/> + <announcement level="2" distance_metric="1000"/> + </roadprofile> + <roadprofile item_types="street_1_land" speed="60" route_weight="60"> + <announcement level="0" distance_metric="100"/> + <announcement level="1" distance_metric="400"/> + <announcement level="2" distance_metric="1000"/> + </roadprofile> + <roadprofile item_types="street_2_land" speed="65" route_weight="65"> + <announcement level="0" distance_metric="100"/> + <announcement level="1" distance_metric="400"/> + <announcement level="2" distance_metric="1000"/> + </roadprofile> + <roadprofile item_types="street_3_land" speed="70" route_weight="70"> + <announcement level="0" distance_metric="100"/> + <announcement level="1" distance_metric="400"/> + <announcement level="2" distance_metric="1000"/> + </roadprofile> + <roadprofile item_types="street_4_land" speed="80" route_weight="80"> + <announcement level="0" distance_metric="100"/> + <announcement level="1" distance_metric="400"/> + <announcement level="2" distance_metric="1000"/> + </roadprofile> + <roadprofile item_types="street_n_lanes" speed="120" route_weight="120"> + <announcement level="0" distance_metric="300"/> + <announcement level="1" distance_metric="1000"/> + <announcement level="2" distance_metric="2000"/> + </roadprofile> + <roadprofile item_types="highway_land" speed="120" route_weight="120"> + <announcement level="0" distance_metric="300"/> + <announcement level="1" distance_metric="1000"/> + <announcement level="2" distance_metric="2000"/> + </roadprofile> + <roadprofile item_types="ramp" speed="40" route_weight="40"> + <announcement level="0" distance_metric="50"/> + <announcement level="1" distance_metric="200"/> + <announcement level="2" distance_metric="500"/> + </roadprofile> + <roadprofile item_types="roundabout" speed="10" route_weight="10"/> + <roadprofile item_types="ferry" speed="40" route_weight="40"/> + </vehicleprofile> + <vehicleprofile name="bike" route_depth="18:25%,18:40000" flags="0x40000000" flags_forward_mask="0x40000000" flags_reverse_mask="0x40000000" maxspeed_handling="1" route_mode="0" static_speed="5" static_distance="25"> <roadprofile item_types="steps" speed="2" route_weight="5"> <announcement level="0" distance_metric="25"/> <announcement level="1" distance_metric="100"/> @@ -389,7 +452,7 @@ Waypoint</text></img> <roadprofile item_types="ferry" speed="40" route_weight="40"/> </vehicleprofile> - <vehicleprofile name="pedestrian" flags="0x80000000" flags_forward_mask="0x80000000" flags_reverse_mask="0x80000000" maxspeed_handling="1" route_mode="0" static_speed="3" static_distance="10"> + <vehicleprofile name="pedestrian" route_depth="18:25%,18:10000" flags="0x80000000" flags_forward_mask="0x80000000" flags_reverse_mask="0x80000000" maxspeed_handling="1" route_mode="0" static_speed="3" static_distance="10"> <roadprofile item_types="footway,bridleway,path,steps" speed="5" route_weight="5"> <announcement level="0" distance_metric="25"/> <announcement level="1" distance_metric="100"/> @@ -438,7 +501,7 @@ Waypoint</text></img> <roadprofile item_types="roundabout" speed="5" route_weight="5"/> <roadprofile item_types="ferry" speed="40" route_weight="40"/> </vehicleprofile> - <vehicleprofile name="horse" flags="0x20000000" flags_forward_mask="0x20000000" flags_reverse_mask="0x20000000" maxspeed_handling="1" route_mode="0" static_speed="3" static_distance="10"> + <vehicleprofile name="horse" route_depth="18:25%,18:40000" flags="0x20000000" flags_forward_mask="0x20000000" flags_reverse_mask="0x20000000" maxspeed_handling="1" route_mode="0" static_speed="3" static_distance="10"> <roadprofile item_types="bridleway" speed="10" route_weight="10"> <announcement level="0" distance_metric="25"/> <announcement level="1" distance_metric="100"/> diff --git a/navit/route.c b/navit/route.c index 91aa3a656..de20a13f8 100644 --- a/navit/route.c +++ b/navit/route.c @@ -941,21 +941,35 @@ route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs) } /** + * @brief Appends a map selection to the selection list. Selection list may be NULL. + */ +static struct map_selection * +route_rect_add(struct map_selection *sel, int order, struct coord *c1, struct coord *c2, int rel, int abs) +{ + struct map_selection *ret; + ret=route_rect(order, c1, c2, rel, abs); + ret->next=sel; + return ret; +} + +/** * @brief Returns a list of map selections useable to create a route graph * - * Returns a list of map selections useable to get a map rect from which items can be - * retrieved to build a route graph. The selections are a rectangle with - * c1 and c2 as two corners. + * Returns a list of map selections useable to get a map rect from which items can be + * retrieved to build a route graph. * - * @param c1 Corner 1 of the rectangle - * @param c2 Corder 2 of the rectangle + * @param c Array containing route points, including start, intermediate and destination ones. + * @param count number of route points + * @param proifle vehicleprofile */ static struct map_selection * -route_calc_selection(struct coord *c, int count) +route_calc_selection(struct coord *c, int count, struct vehicleprofile *profile) { - struct map_selection *ret,*sel; + struct map_selection *ret=NULL; int i; struct coord_rect r; + char *str, *tok; + struct attr attr; if (!count) return NULL; @@ -963,15 +977,27 @@ route_calc_selection(struct coord *c, int count) r.rl=c[0]; for (i = 1 ; i < count ; i++) coord_rect_extend(&r, &c[i]); - sel=route_rect(4, &r.lu, &r.rl, 25, 0); - ret=sel; - for (i = 0 ; i < count ; i++) { - sel->next=route_rect(8, &c[i], &c[i], 0, 40000); - sel=sel->next; - sel->next=route_rect(18, &c[i], &c[i], 0, 10000); - sel=sel->next; - } - /* route_selection=ret; */ + + if(!vehicleprofile_get_attr(profile,attr_route_depth, &attr, NULL) || attr.u.str==NULL) { + attr.u.str="4:25%,8:40000,18:10000"; + } + + attr.u.str=str=g_strdup(attr.u.str); + + while((tok=strtok(str,","))!=NULL) { + int order=0, dist=0; + sscanf(tok,"%d:%d",&order,&dist); + if(strchr(tok,'%')) + ret=route_rect_add(ret, order, &r.lu, &r.rl, dist, 0); + else + for (i = 0 ; i < count ; i++) { + ret=route_rect_add(ret, order, &c[i], &c[i], 0, dist); + } + str=NULL; + } + + g_free(attr.u.str); + return ret; } @@ -2678,7 +2704,7 @@ route_graph_build(struct mapset *ms, struct coord *c, int count, struct callback dbg(1,"enter\n"); - ret->sel=route_calc_selection(c, count); + ret->sel=route_calc_selection(c, count, profile); ret->h=mapset_open(ms); ret->done_cb=done_cb; ret->busy=1; |