summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/bookmarks.c5
-rw-r--r--navit/navit.c37
-rw-r--r--navit/route.c17
-rw-r--r--navit/route.h68
4 files changed, 80 insertions, 47 deletions
diff --git a/navit/bookmarks.c b/navit/bookmarks.c
index c05d24901..393849872 100644
--- a/navit/bookmarks.c
+++ b/navit/bookmarks.c
@@ -666,7 +666,10 @@ bookmarks_append_coord(struct bookmarks *this_, char *file, struct pcoord *c, in
if (f) {
if (c) {
int i;
- fprintf(f,"type=%s label=\"%s\"\n", type, description);
+ if (description)
+ fprintf(f,"type=%s label=\"%s\"\n", type, description);
+ else
+ fprintf(f,"type=%s\n", type);
for (i = 0 ; i < count ; i++) {
prostr = projection_to_name(c[i].pro,NULL);
fprintf(f,"%s%s%s0x%x %s0x%x\n",
diff --git a/navit/navit.c b/navit/navit.c
index 5952cbcf7..5361407be 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -860,6 +860,34 @@ navit_set_destination(struct navit *this_, struct pcoord *c, const char *descrip
}
/**
+ * Start the route computing to a given set of coordinates including waypoints
+ *
+ * @param navit The navit instance
+ * @param c The coordinate to start routing to
+ * @param description A label which allows the user to later identify this destination in the former destinations selection
+ * @returns nothing
+ */
+void
+navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async)
+{
+ if (c && count) {
+ this_->destination=c[count-1];
+ this_->destination_valid=1;
+ } else
+ this_->destination_valid=0;
+ char *destination_file = bookmarks_get_destination_file(TRUE);
+ bookmarks_append_coord(this_->bookmarks, destination_file, c, count, "former_itinerary", description, NULL, this_->recentdest_count);
+ g_free(destination_file);
+ callback_list_call_attr_0(this_->attr_cbl, attr_destination);
+ if (this_->route) {
+ route_set_destinations(this_->route, c, count, async);
+
+ if (this_->ready == 3)
+ navit_draw(this_);
+ }
+}
+
+/**
* @brief Checks if a route is calculated
*
* This function checks if a route is calculated.
@@ -899,7 +927,7 @@ navit_add_former_destinations_from_file(struct navit *this_)
{
char *destination_file = bookmarks_get_destination_file(FALSE);
struct attr parent={attr_navit, .u.navit=this_};
- struct attr type={attr_type, {"textfile"}}, data={attr_data, {destination_file}}, flags={attr_flags, {1}};
+ struct attr type={attr_type, {"textfile"}}, data={attr_data, {destination_file}}, flags={attr_flags, {(void *)1}};
struct attr *attrs[]={&type, &data, &flags, NULL};
struct map_rect *mr;
struct item *item;
@@ -1987,10 +2015,12 @@ navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
struct pcoord cursor_pc;
struct point cursor_pnt, *pnt=&cursor_pnt;
struct tracking *tracking=NULL;
+ struct pcoord pc[16];
enum projection pro=transform_get_projection(this_->trans);
- int border=16;
+ int count,border=16;
int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
void *attr_object;
+ char *destination_file;
profile(0,NULL);
if (this_->ready != 3) {
@@ -2057,6 +2087,9 @@ navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
switch(route_destination_reached(this_->route)) {
case 1:
route_remove_waypoint(this_->route);
+ count=route_get_destinations(this_->route, pc, 16);
+ destination_file = bookmarks_get_destination_file(TRUE);
+ bookmarks_append_coord(this_->bookmarks, destination_file, pc, count, "former_itinerary_part", NULL, NULL, this_->recentdest_count);
break;
case 2:
navit_set_destination(this_, NULL, NULL, 0);
diff --git a/navit/route.c b/navit/route.c
index b6571b361..4b9d41720 100644
--- a/navit/route.c
+++ b/navit/route.c
@@ -1035,6 +1035,23 @@ route_set_destinations(struct route *this, struct pcoord *dst, int count, int as
route_path_update(this, 1, async);
profile(0,"end");
}
+
+int
+route_get_destinations(struct route *this, struct pcoord *pc, int count)
+{
+ int ret=0;
+ GList *l=this->destinations;
+ while (l && ret < count) {
+ struct route_info *dst=l->data;
+ pc->x=dst->c.x;
+ pc->y=dst->c.y;
+ pc->pro=projection_mg; /* FIXME */
+ pc++;
+ ret++;
+ l=g_list_next(l);
+ }
+ return ret;
+}
void
route_set_destination(struct route *this, struct pcoord *dst, int async)
diff --git a/navit/route.h b/navit/route.h
index 3878ec4dc..0781339d4 100644
--- a/navit/route.h
+++ b/navit/route.h
@@ -66,63 +66,46 @@ struct street_data {
};
/* prototypes */
-enum item_type;
+enum attr_type;
+enum projection;
+struct attr;
+struct attr_iter;
struct coord;
-struct displaylist;
struct item;
+struct map;
struct map_selection;
struct mapset;
+struct pcoord;
struct route;
struct route_info;
-struct route_info_handle;
-struct route_path_coord_handle;
-struct route_path_handle;
-struct route_path_segment;
-struct route_preferences;
struct street_data;
struct tracking;
-struct transformation;
+struct vehicleprofile;
struct route *route_new(struct attr *parent, struct attr **attrs);
-void route_set_mapset(struct route *, struct mapset *ms);
-void route_set_profile(struct route *, struct vehicleprofile *prof);
-struct mapset *route_get_mapset(struct route *);
-struct route_info *route_get_pos(struct route *);
-struct route_info *route_get_dst(struct route *);
-int *route_get_speedlist(struct route *);
-int route_get_path_set(struct route *);
-int route_set_speed(struct route *, enum item_type type, int value);
-int route_contains(struct route *, struct item *item);
-void route_set_position(struct route *, struct pcoord *pos);
-void route_set_position_from_tracking(struct route *, struct tracking *tracking, enum projection pro);
+void route_set_mapset(struct route *this, struct mapset *ms);
+void route_set_profile(struct route *this, struct vehicleprofile *prof);
+struct mapset *route_get_mapset(struct route *this);
+struct route_info *route_get_pos(struct route *this);
+struct route_info *route_get_dst(struct route *this);
+int route_get_path_set(struct route *this);
+int route_contains(struct route *this, struct item *item);
+int route_destination_reached(struct route *this);
+void route_set_position(struct route *this, struct pcoord *pos);
+void route_set_position_from_tracking(struct route *this, struct tracking *tracking, enum projection pro);
struct map_selection *route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs);
-void route_set_destination(struct route *, struct pcoord *dst, int async);
-struct route_path_handle *route_path_open(struct route *);
-struct route_path_segment *route_path_get_segment(struct route_path_handle *h);
-struct coord *route_path_segment_get_start(struct route_path_segment *s);
-struct coord *route_path_segment_get_end(struct route_path_segment *s);
-struct item *route_path_segment_get_item(struct route_path_segment *s);
-int route_path_segment_get_length(struct route_path_segment *s);
-int route_path_segment_get_time(struct route_path_segment *s);
-void route_path_close(struct route_path_handle *h);
-struct route_path_coord_handle *route_path_coord_open(struct route *);
-struct coord *route_path_coord_get(struct route_path_coord_handle *h);
-void route_path_coord_close(struct route_path_coord_handle *h);
-int route_time(struct route_preferences *preferences, struct item *item, int len, int maxspeed);
-int route_info_length(struct route_info *pos, struct route_info *dst, int dir);
+void route_set_destinations(struct route *this, struct pcoord *dst, int count, int async);
+int route_get_destinations(struct route *this, struct pcoord *pc, int count);
+void route_set_destination(struct route *this, struct pcoord *dst, int async);
+void route_remove_waypoint(struct route *this);
+struct coord route_get_coord_dist(struct route *this_, int dist);
struct street_data *street_get_data(struct item *item);
struct street_data *street_data_dup(struct street_data *orig);
void street_data_free(struct street_data *sd);
void route_info_free(struct route_info *inf);
struct street_data *route_info_street(struct route_info *rinf);
-struct coord *route_info_point(struct route_info *rinf, int point);
-struct route_info_handle *route_info_open(struct route_info *start, struct route_info *end, int dir);
-struct coord *route_info_get(struct route_info_handle *h);
-void route_info_close(struct route_info_handle *h);
-void route_draw(struct route *, struct transformation *t, struct displaylist *dsp);
-struct map *route_get_map(struct route *route);
-struct map *route_get_graph_map(struct route *route);
+struct map *route_get_map(struct route *this_);
+struct map *route_get_graph_map(struct route *this_);
void route_set_projection(struct route *this_, enum projection pro);
-int route_destination_reached(struct route *);
void route_set_destinations(struct route *this_, struct pcoord *dst, int count, int async);
int route_set_attr(struct route *this_, struct attr *attr);
int route_add_attr(struct route *this_, struct attr *attr);
@@ -131,10 +114,7 @@ struct attr_iter * route_attr_iter_new(void);
void route_attr_iter_destroy(struct attr_iter *iter);
int route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
void route_init(void);
-int route_pos_contains(struct route *, struct item *item);
-struct coord route_get_coord_dist(struct route *this_, int dist);
void route_destroy(struct route *this_);
-
/* end of prototypes */
#ifdef __cplusplus
}