From 4b8edd8e6b60783b13bad6d0497499f8c56bc7cc Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 2 Jun 2008 18:07:07 +0300 Subject: [PATCH] MapIntegration: A bit more work --- do-configure.sh | 2 +- src/cb.c | 23 +++++++++++------------ src/map-download.c | 3 +-- src/path.c | 30 ++++++++++++++++++++---------- src/path.h | 2 +- src/route.c | 6 +++--- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/do-configure.sh b/do-configure.sh index 7a28416..80d6675 100755 --- a/do-configure.sh +++ b/do-configure.sh @@ -11,7 +11,7 @@ case "$1" in ./configure --prefix=/usr --sysconfdir=/etc \ --enable-maintainer-mode --enable-debug \ --enable-gpsd --enable-gst --enable-hal \ - --enable-btdbus \ + --enable-btdbus --enable-gtk-doc \ --enable-cairo --enable-opengl ;; hildon) diff --git a/src/cb.c b/src/cb.c index 57979e7..afe97fb 100644 --- a/src/cb.c +++ b/src/cb.c @@ -109,14 +109,14 @@ return TRUE; gboolean menu_cb_route_distnext(GtkAction *action) { -route_show_distance_to_next(_route); +path_show_distance_to_next(_route); return TRUE; } gboolean menu_cb_route_distlast(GtkAction *action) { -route_show_distance_to_last(_route); +path_show_distance_to_last(_route); return TRUE; } @@ -125,7 +125,6 @@ menu_cb_route_reset(GtkAction *action) { path_find_nearest_point(_route); gtk_map_refresh(_map); -MACRO_QUEUE_DRAW_AREA(); return TRUE; } @@ -169,7 +168,7 @@ return TRUE; gboolean menu_cb_track_insert_mark(GtkAction *action) { -if (track_insert_mark(_track)) { +if (path_insert_mark(_track)) { path_tree_view_update_store(track_tree_view, _track); } return TRUE; @@ -178,21 +177,21 @@ return TRUE; gboolean menu_cb_track_distlast(GtkAction *action) { -track_show_distance_from_last(_track); +path_show_distance_from_last(_track); return TRUE; } gboolean menu_cb_track_distfirst(GtkAction *action) { -track_show_distance_from_first(_track); +path_show_distance_from_first(_track); return TRUE; } gboolean menu_cb_track_clear(GtkAction *action) { -track_clear(_track); +path_clear(_track); path_tree_view_update_store(track_tree_view, _track); return TRUE; } @@ -471,7 +470,7 @@ if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) { if (_gps->io.conn > RCVR_OFF) gps_conn_set_state(_gps, RCVR_OFF); gps_disconnect(_gps); - track_add(_track, NULL); + path_add_break(_track); _speed_excess=FALSE; } if (_enable_gps==FALSE) @@ -708,19 +707,19 @@ switch (_action[custom_key]) { } break; case CUSTOM_ACTION_ROUTE_DISTNEXT: - route_show_distance_to_next(_route); + path_show_distance_to_next(_route); break; case CUSTOM_ACTION_ROUTE_DISTLAST: - route_show_distance_to_last(_route); + path_show_distance_to_last(_route); break; case CUSTOM_ACTION_TRACK_BREAK: path_insert_break(_track); break; case CUSTOM_ACTION_TRACK_DISTLAST: - track_show_distance_from_last(_track); + path_show_distance_from_last(_track); break; case CUSTOM_ACTION_TRACK_DISTFIRST: - track_show_distance_from_first(_track); + path_show_distance_from_first(_track); break; case CUSTOM_ACTION_TOGGLE_GPS: set_action_activate("gps_enable", !_enable_gps); diff --git a/src/map-download.c b/src/map-download.c index fd6b66e..2f07bad 100644 --- a/src/map-download.c +++ b/src/map-download.c @@ -133,8 +133,7 @@ while (_curl_multi && (msg = curl_multi_info_read(_curl_multi, &num_msgs))) { /* Now, parse the autoroute and update the display. */ if (_autoroute_data.enabled && gpx_parse(&_route, _autoroute_data.rdl_data.bytes, _autoroute_data.rdl_data.bytes_read, 0)) { /* Find the nearest route point, if we're connected. */ - route_find_nearest_point(_route); - map_force_redraw(); + path_find_nearest_point(_route); } route_cancel_autoroute(_route, TRUE); /* We're done. Clean up. */ } else { diff --git a/src/path.c b/src/path.c index 8c1567a..06a5221 100644 --- a/src/path.c +++ b/src/path.c @@ -206,6 +206,9 @@ if (path->whead + wsize != path->wcap) { return FALSE; } +/** + * Append a waypoint to path at given lat, lon with description desc + */ gboolean path_add_waypoint(Path *path, gdouble lat, gdouble lon, gchar *desc) { @@ -213,20 +216,27 @@ guint unitx, unity; latlon2unit(lat, lon, unitx, unity); MACRO_PATH_INCREMENT_TAIL(*path); -path->tail->unitx = unitx; -path->tail->unity = unity; -path->tail->time = 0; -path->tail->altitude = NAN; +path->tail->unitx=unitx; +path->tail->unity=unity; +path->tail->time=0; +path->tail->altitude=NAN; MACRO_PATH_INCREMENT_WTAIL(*path); -path->wtail->point = path->tail; -path->wtail->desc = desc; +path->wtail->point=path->tail; +path->wtail->desc=desc; path_find_nearest_point(path); +g_signal_emit(G_OBJECT(path), signals[NEW_WAYPOINT], 0, NULL); + return TRUE; } +/** + * Append a path point to path + * + * Returns: TRUE if the new point was added. FALSE is returned if new point distance was under sensitivity setting. + */ gboolean path_add_point(Path *path, GpsData *gps) { @@ -235,8 +245,7 @@ guint unitx, unity; g_return_val_if_fail(path, FALSE); if (!gps) { - MACRO_PATH_INCREMENT_TAIL(*path); - *path->tail=_point_null; + path_add_break(path); return FALSE; } @@ -261,13 +270,14 @@ if (abs((gint)unitx-path->tail->unitx) > path->sensitivity || abs((gint)unity-pa g_debug("TRACK: %f %f (%d)", path->length, path->avgspeed, path->points); g_signal_emit(G_OBJECT(path), signals[NEW_POINT], 0, NULL); + return TRUE; } -return TRUE; +return FALSE; } gboolean -path_insert_break(Path *path) +path_add_break(Path *path) { g_return_val_if_fail(path, FALSE); g_return_val_if_fail(path->tail, FALSE); diff --git a/src/path.h b/src/path.h index b0c5ff2..d212009 100644 --- a/src/path.h +++ b/src/path.h @@ -169,7 +169,7 @@ gdouble path_get_distance_to(Path *path, Point *point, gdouble lat, gdouble lon) void path_find_nearest_point(Path *path); gboolean path_update_nears(Path *route, Point *point, gboolean quick); -gboolean path_insert_break(Path *path); +gboolean path_add_break(Path *path); void path_insert_mark_text(Path *path, gchar *text); void path_insert_mark_autonumber(Path *path); void path_insert_mark_audio(Path *path, gchar *audio); diff --git a/src/route.c b/src/route.c index 5347024..d5d9ac2 100644 --- a/src/route.c +++ b/src/route.c @@ -64,7 +64,7 @@ if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) { route_cancel_autoroute(route, FALSE); announced_waypoint=NULL; path_clear(route); - route_find_nearest_point(route); + path_find_nearest_point(route); r=TRUE; } @@ -129,7 +129,7 @@ if (file_open_get_contents(&_route_dir_uri, &buffer, &size)) { MACRO_BANNER_SHOW_INFO(_window, _("Route Opened")); /* Find the nearest route point, if we're connected. */ - route_find_nearest_point(route); + path_find_nearest_point(route); route_set_destination_from_last(route, &_dest); return TRUE; } else { @@ -445,7 +445,7 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { GtkTreeIter iter; /* Find the nearest route point, if we're connected. */ - route_find_nearest_point(route); + path_find_nearest_point(route); /* Cancel any autoroute that might be occurring. */ route_cancel_autoroute(route, FALSE); -- 2.39.5