summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-05-05 18:42:04 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-05-05 18:42:04 +0000
commit78d1861332f1e28f6ede1c84e8fe06ba1c84afbe (patch)
treea0960ef4c3b7ea8c685ac48c6ec806649e2cf0fb /navit
parentb8a5b0475b998acd9a7730712fd1dc7e43ce5d43 (diff)
downloadnavit-78d1861332f1e28f6ede1c84e8fe06ba1c84afbe.tar.gz
Add:Core:Made routing optionally asynchronous
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2254 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/navit/binding/dbus/binding_dbus.c2
-rw-r--r--navit/navit/binding/python/navit.c5
-rw-r--r--navit/navit/gui/gtk/destination.c2
-rw-r--r--navit/navit/gui/gtk/gui_gtk_action.c2
-rw-r--r--navit/navit/gui/gtk/gui_gtk_window.c2
-rw-r--r--navit/navit/gui/internal/gui_internal.c4
-rw-r--r--navit/navit/navit.c8
-rw-r--r--navit/navit/navit.h2
-rw-r--r--navit/navit/popup.c2
-rw-r--r--navit/navit/route.c31
-rw-r--r--navit/navit/route.h2
11 files changed, 34 insertions, 28 deletions
diff --git a/navit/navit/binding/dbus/binding_dbus.c b/navit/navit/binding/dbus/binding_dbus.c
index 677e27aa5..b4ead6d87 100644
--- a/navit/navit/binding/dbus/binding_dbus.c
+++ b/navit/navit/binding/dbus/binding_dbus.c
@@ -681,7 +681,7 @@ request_navit_set_destination(DBusConnection *connection, DBusMessage *message)
dbus_message_iter_get_basic(&iter, &description);
dbg(0, " destination -> %s\n", description);
- navit_set_destination(navit, &pc, description);
+ navit_set_destination(navit, &pc, description, 1);
return empty_reply(connection, message);
}
diff --git a/navit/navit/binding/python/navit.c b/navit/navit/binding/python/navit.c
index e83619b7b..0a92210c7 100644
--- a/navit/navit/binding/python/navit.c
+++ b/navit/navit/binding/python/navit.c
@@ -56,9 +56,10 @@ navit_set_destination_py(navitObject *self, PyObject *args)
{
PyObject *pcoord;
const char *description;
- if (!PyArg_ParseTuple(args, "O!s", &pcoord_Type, &pcoord, &description))
+ int async;
+ if (!PyArg_ParseTuple(args, "O!si", &pcoord_Type, &pcoord, &description, &async))
return NULL;
- navit_set_destination(self->navit, pcoord_py_get(pcoord), description);
+ navit_set_destination(self->navit, pcoord_py_get(pcoord), description, async);
Py_RETURN_NONE;
}
diff --git a/navit/navit/gui/gtk/destination.c b/navit/navit/gui/gtk/destination.c
index e7f95fe06..b65cba5f0 100644
--- a/navit/navit/gui/gtk/destination.c
+++ b/navit/navit/gui/gtk/destination.c
@@ -101,7 +101,7 @@ static void button_destination(GtkWidget *widget, struct search_param *search)
gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
if (c) {
desc=description(search, &iter);
- navit_set_destination(search->nav, c, desc);
+ navit_set_destination(search->nav, c, desc, 1);
g_free(desc);
}
}
diff --git a/navit/navit/gui/gtk/gui_gtk_action.c b/navit/navit/gui/gtk/gui_gtk_action.c
index 37c99ba83..144a82706 100644
--- a/navit/navit/gui/gtk/gui_gtk_action.c
+++ b/navit/navit/gui/gtk/gui_gtk_action.c
@@ -176,7 +176,7 @@ info_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
static void
route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
{
- navit_set_destination(gui->nav, NULL, NULL);
+ navit_set_destination(gui->nav, NULL, NULL, 0);
}
static void
diff --git a/navit/navit/gui/gtk/gui_gtk_window.c b/navit/navit/gui/gtk/gui_gtk_window.c
index 29dafe29c..05e212993 100644
--- a/navit/navit/gui/gtk/gui_gtk_window.c
+++ b/navit/navit/gui/gtk/gui_gtk_window.c
@@ -305,7 +305,7 @@ gui_gtk_action_activate(GtkAction *action, struct action_cb_data *data)
if(data->attr.type == attr_destination) {
char * label;
g_object_get(G_OBJECT(action), "label", &label,NULL);
- navit_set_destination(data->gui->nav, data->attr.u.pcoord, label);
+ navit_set_destination(data->gui->nav, data->attr.u.pcoord, label, 1);
g_free(label);
}
}
diff --git a/navit/navit/gui/internal/gui_internal.c b/navit/navit/gui/internal/gui_internal.c
index cd35fbf8b..bd9d6a143 100644
--- a/navit/navit/gui/internal/gui_internal.c
+++ b/navit/navit/gui/internal/gui_internal.c
@@ -1646,7 +1646,7 @@ gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void
{
struct widget *w=wm->data;
dbg(0,"c=%d:0x%x,0x%x\n", w->c.pro, w->c.x, w->c.y);
- navit_set_destination(this->nav, &w->c, w->name);
+ navit_set_destination(this->nav, &w->c, w->name, 1);
if (this->flags & 512) {
struct attr follow;
follow.type=attr_follow;
@@ -2865,7 +2865,7 @@ gui_internal_cmd_quit(struct gui_priv *this, struct widget *wm, void *data)
static void
gui_internal_cmd_abort_navigation(struct gui_priv *this, struct widget *wm, void *data)
{
- navit_set_destination(this->nav, NULL, NULL);
+ navit_set_destination(this->nav, NULL, NULL, 0);
}
diff --git a/navit/navit/navit.c b/navit/navit/navit.c
index 039e2fbc0..3ba6180bb 100644
--- a/navit/navit/navit.c
+++ b/navit/navit/navit.c
@@ -934,7 +934,7 @@ navit_write_center_to_file(struct navit *this_, char *file)
* @returns nothing
*/
void
-navit_set_destination(struct navit *this_, struct pcoord *c, const char *description)
+navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async)
{
if (c) {
this_->destination=*c;
@@ -946,7 +946,7 @@ navit_set_destination(struct navit *this_, struct pcoord *c, const char *descrip
g_free(destination_file);
callback_list_call_attr_0(this_->attr_cbl, attr_destination);
if (this_->route) {
- route_set_destination(this_->route, c);
+ route_set_destination(this_->route, c, async);
if (this_->ready == 3)
navit_draw(this_);
@@ -1047,7 +1047,7 @@ navit_add_former_destinations_from_file(struct navit *this_)
pc.x=c.x;
pc.y=c.y;
if (valid) {
- route_set_destination(this_->route, &pc);
+ route_set_destination(this_->route, &pc, 1);
this_->destination=pc;
this_->destination_valid=1;
}
@@ -2065,7 +2065,7 @@ navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
/* Finally, if we reached our destination, stop navigation. */
if (this_->route && route_destination_reached(this_->route)) {
- navit_set_destination(this_, NULL, NULL);
+ navit_set_destination(this_, NULL, NULL, 0);
}
profile(0,"return 5\n");
}
diff --git a/navit/navit/navit.h b/navit/navit/navit.h
index d0d6d9bfd..3208b69c0 100644
--- a/navit/navit/navit.h
+++ b/navit/navit/navit.h
@@ -63,7 +63,7 @@ void navit_zoom_in(struct navit *this_, int factor, struct point *p);
void navit_zoom_out(struct navit *this_, int factor, struct point *p);
struct navit *navit_new(struct attr *parent, struct attr **attrs);
struct graphics *navit_get_graphics(struct navit *this_);
-void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description);
+void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async);
void navit_add_bookmark(struct navit *this_, struct pcoord *c, const char *description);
void navit_say(struct navit *this_, char *text);
int navit_speech_estimate(struct navit *this_, char *str);
diff --git a/navit/navit/popup.c b/navit/navit/popup.c
index 67f8ecd2d..1f347c186 100644
--- a/navit/navit/popup.c
+++ b/navit/navit/popup.c
@@ -72,7 +72,7 @@ popup_set_destination(struct navit *nav, struct pcoord *pc)
transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
sprintf(buffer,"Map Point %s", buffer_geo);
- navit_set_destination(nav, pc, buffer);
+ navit_set_destination(nav, pc, buffer, 1);
}
static void
diff --git a/navit/navit/route.c b/navit/navit/route.c
index 19e833dff..375225d96 100644
--- a/navit/navit/route.c
+++ b/navit/navit/route.c
@@ -251,12 +251,12 @@ struct route_graph_point_iterator {
static struct route_info * route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms, struct pcoord *c);
static struct route_graph_point *route_graph_get_point(struct route_graph *this, struct coord *c);
-static void route_graph_update(struct route *this, struct callback *cb);
+static void route_graph_update(struct route *this, struct callback *cb, int async);
static void route_graph_build_done(struct route_graph *rg, int cancel);
static struct route_path *route_path_new(struct route_graph *this, struct route_path *oldpath, struct route_info *pos, struct route_info *dst, struct vehicleprofile *profile);
static void route_process_street_graph(struct route_graph *this, struct item *item);
static void route_graph_destroy(struct route_graph *this);
-static void route_path_update(struct route *this, int cancel);
+static void route_path_update(struct route *this, int cancel, int async);
/**
* @brief Returns the projection used for this route
@@ -651,7 +651,7 @@ route_path_update_done(struct route *this, int new_graph)
* @param this The route to update
*/
static void
-route_path_update(struct route *this, int cancel)
+route_path_update(struct route *this, int cancel, int async)
{
dbg(1,"enter %d\n", cancel);
if (! this->pos || ! this->dst) {
@@ -682,7 +682,7 @@ route_path_update(struct route *this, int cancel)
if (! this->route_graph_flood_done_cb)
this->route_graph_flood_done_cb=callback_new_2(callback_cast(route_path_update_done), this, 1);
dbg(1,"route_graph_update\n");
- route_graph_update(this, this->route_graph_flood_done_cb);
+ route_graph_update(this, this->route_graph_flood_done_cb, async);
}
}
@@ -727,7 +727,7 @@ route_set_position(struct route *this, struct pcoord *pos)
if (! this->pos)
return;
route_info_distances(this->pos, pos->pro);
- route_path_update(this, 0);
+ route_path_update(this, 0, 1);
}
/**
@@ -767,7 +767,7 @@ route_set_position_from_tracking(struct route *this, struct tracking *tracking)
dbg(3,"street 0=(0x%x,0x%x) %d=(0x%x,0x%x)\n", ret->street->c[0].x, ret->street->c[0].y, ret->street->count-1, ret->street->c[ret->street->count-1].x, ret->street->c[ret->street->count-1].y);
this->pos=ret;
if (this->dst)
- route_path_update(this, 0);
+ route_path_update(this, 0, 1);
dbg(2,"ret\n");
}
@@ -875,7 +875,7 @@ route_free_selection(struct map_selection *sel)
* @param dst Coordinates to set as destination
*/
void
-route_set_destination(struct route *this, struct pcoord *dst)
+route_set_destination(struct route *this, struct pcoord *dst, int async)
{
profile(0,NULL);
if (this->dst)
@@ -896,7 +896,7 @@ route_set_destination(struct route *this, struct pcoord *dst)
/* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
route_graph_destroy(this->graph);
this->graph=NULL;
- route_path_update(this, 1);
+ route_path_update(this, 1, async);
profile(0,"end");
}
@@ -1889,7 +1889,7 @@ route_graph_build_idle(struct route_graph *rg)
* @return The new route graph.
*/
static struct route_graph *
-route_graph_build(struct mapset *ms, struct coord *c1, struct coord *c2, struct callback *done_cb)
+route_graph_build(struct mapset *ms, struct coord *c1, struct coord *c2, struct callback *done_cb, int async)
{
struct route_graph *ret=g_new0(struct route_graph, 1);
@@ -1900,8 +1900,13 @@ route_graph_build(struct mapset *ms, struct coord *c1, struct coord *c2, struct
ret->done_cb=done_cb;
ret->busy=1;
if (route_graph_build_next_map(ret)) {
- ret->idle_cb=callback_new_1(callback_cast(route_graph_build_idle), ret);
- ret->idle_ev=event_add_idle(50, ret->idle_cb);
+ if (async) {
+ ret->idle_cb=callback_new_1(callback_cast(route_graph_build_idle), ret);
+ ret->idle_ev=event_add_idle(50, ret->idle_cb);
+ } else {
+ while (ret->busy)
+ route_graph_build_idle(ret);
+ }
} else
route_graph_build_done(ret, 0);
@@ -1923,7 +1928,7 @@ route_graph_update_done(struct route *this, struct callback *cb)
* @param this The route to update the graph for
*/
static void
-route_graph_update(struct route *this, struct callback *cb)
+route_graph_update(struct route *this, struct callback *cb, int async)
{
struct attr route_status;
@@ -1933,7 +1938,7 @@ route_graph_update(struct route *this, struct callback *cb)
this->route_graph_done_cb=callback_new_2(callback_cast(route_graph_update_done), this, cb);
route_status.u.num=route_status_building_graph;
route_set_attr(this, &route_status);
- this->graph=route_graph_build(this->ms, &this->pos->c, &this->dst->c, this->route_graph_done_cb);
+ this->graph=route_graph_build(this->ms, &this->pos->c, &this->dst->c, this->route_graph_done_cb, async);
}
/**
diff --git a/navit/navit/route.h b/navit/navit/route.h
index 19cf06978..b629581e7 100644
--- a/navit/navit/route.h
+++ b/navit/navit/route.h
@@ -91,7 +91,7 @@ int route_contains(struct route *this, struct item *item);
void route_set_position(struct route *this, struct pcoord *pos);
void route_set_position_from_tracking(struct route *this, struct tracking *tracking);
struct map_selection *route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs);
-void route_set_destination(struct route *this, struct pcoord *dst);
+void route_set_destination(struct route *this, struct pcoord *dst, int async);
struct route_path_handle *route_path_open(struct route *this);
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);