From 73569386051dc6f5625c433688577ba20c8d3617 Mon Sep 17 00:00:00 2001 From: mdankov Date: Wed, 22 Aug 2012 16:46:14 +0000 Subject: Add:core:Made routing parameters vehicleprofile dependent by adding route_depth tag. Fixes #456 if there are enough memory and CPU. git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5216 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/attr_def.h | 1 + navit/navit.dtd | 1 + navit/navit_shipped.xml | 73 +++++++++++++++++++++++++++++++++++++++++++++---- 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 @@ + 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 - + @@ -327,8 +327,71 @@ Waypoint - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -389,7 +452,7 @@ Waypoint - + @@ -438,7 +501,7 @@ Waypoint - + diff --git a/navit/route.c b/navit/route.c index 91aa3a656..de20a13f8 100644 --- a/navit/route.c +++ b/navit/route.c @@ -940,22 +940,36 @@ route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs) return sel; } +/** + * @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; -- cgit v1.2.1