From: Guilhem Bonnefille Date: Fri, 4 Jan 2013 07:32:52 +0000 (+0100) Subject: Restore Google Directions feature X-Git-Url: https://git.street.me.uk/andy/viking.git/commitdiff_plain/55340efac3ba71a35fab6efb0e492f967a140aeb?hp=19a0d58f05c8ac9ee09b74c810f7894727ec7402 Restore Google Directions feature KML is no more supported but gpsbabel support JSON format in HTML page. Google Directions is no more a separated configure option: there is no reason to distinguish from other Google feature. I also disabled the file checking when data is downloaded via a_babel_convert_from_url function. The reason is this function can be used to download any sort of data, not only XML. Currently, it is used to download GPX (for OSM) and HTML (for Google). An other solution was to select the checking function using the input type (with a nice serie of tests on strcmp). But as gpsbabel will do the check, I consider this check is not needed. Signed-off-by: Guilhem Bonnefille --- diff --git a/configure.ac b/configure.ac index 92fc6979..5333f58d 100644 --- a/configure.ac +++ b/configure.ac @@ -130,7 +130,7 @@ esac AM_CONDITIONAL([BING], [test x$ac_cv_enable_bing = xyes]) AC_ARG_ENABLE(google, AC_HELP_STRING([--enable-google], - [enable Google stuff (Goto and External Open) (default is enable)]), + [enable Google stuff (default is enable)]), [ac_cv_enable_google=$enableval], [ac_cv_enable_google=yes]) AC_CACHE_CHECK([whether to enable Google stuff], @@ -142,19 +142,6 @@ case $ac_cv_enable_google in esac AM_CONDITIONAL([GOOGLE], [test x$ac_cv_enable_google = xyes]) - -AC_ARG_ENABLE(google-directions, AC_HELP_STRING([--enable-google-directions], - [enable Google Directions (default is disabled because it does not work)]), - [ac_cv_enable_google_directions=$enableval], - [ac_cv_enable_google_directions=no]) -AC_CACHE_CHECK([whether to enable Google directions], - [ac_cv_enable_google_directions], [ac_cv_enable_google_directions=yes]) -case $ac_cv_enable_google_directions in - yes) - AC_DEFINE(VIK_CONFIG_GOOGLE_DIRECTIONS, [], [GOOGLE DIRECTIONS]) - ;; -esac - AC_ARG_ENABLE(terraserver, AC_HELP_STRING([--enable-terraserver], [enable Terraserver stuff (default is enable)]), [ac_cv_enable_terraserver=$enableval], @@ -383,8 +370,7 @@ echo "$PACKAGE $VERSION" echo "-------------------------------------------" echo "Alphabetized track & waypoints : $ac_cv_enable_alpha_trw" echo "Bing Maps : $ac_cv_enable_bing" -echo "Google Goto : $ac_cv_enable_google" -echo "Google Directions (Broken) : $ac_cv_enable_google_directions" +echo "Google : $ac_cv_enable_google" echo "Terraserver Maps : $ac_cv_enable_terraserver" echo "Expedia Maps : $ac_cv_enable_expedia" echo "Open Street Map : $ac_cv_enable_openstreetmap" diff --git a/help/C/viking.xml b/help/C/viking.xml index 2b3adbe1..fb403d36 100644 --- a/help/C/viking.xml +++ b/help/C/viking.xml @@ -872,13 +872,11 @@ Changes the current tool to add trackpoints to the end of the track. -
Upload @@ -902,7 +900,6 @@ This selects the track to be used in the Filte
- +
Waypoint Properties @@ -1328,7 +1325,6 @@ For Linux you can override this with the setting in the @@ -1344,7 +1340,7 @@ Right-click: undo last routing (only track removed - not any waypoints) Ctrl: continue previous track
---> +
Georef Map Layer Tools diff --git a/src/Makefile.am b/src/Makefile.am index cd7f7971..111e88e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -108,7 +108,6 @@ libviking_a_SOURCES = \ datasource_gc.c \ datasource_bfilter.c \ datasources.h \ - google.c google.h \ googlesearch.c googlesearch.h \ dem.c dem.h \ vikdemlayer.h vikdemlayer.c \ @@ -131,6 +130,11 @@ libviking_a_SOURCES += \ bing.c bing.h endif +if GOOGLE +libviking_a_SOURCES += \ + google.c google.h +endif + if TERRASERVER libviking_a_SOURCES += \ terraservermapsource.c terraservermapsource.h \ diff --git a/src/acquire.c b/src/acquire.c index a9d42898..0cd79dc7 100644 --- a/src/acquire.c +++ b/src/acquire.c @@ -34,7 +34,6 @@ /************************ FILTER LIST *******************/ // extern VikDataSourceInterface vik_datasource_gps_interface; -// extern VikDataSourceInterface vik_datasource_google_interface; /*** Input is TRWLayer ***/ extern VikDataSourceInterface vik_datasource_bfilter_simplify_interface; diff --git a/src/babel.c b/src/babel.c index 20ef0a29..32105398 100644 --- a/src/babel.c +++ b/src/babel.c @@ -305,7 +305,7 @@ gboolean a_babel_convert_from_shellcommand ( VikTrwLayer *vt, const char *input_ gboolean a_babel_convert_from_url ( VikTrwLayer *vt, const char *url, const char *input_type, BabelStatusFunc cb, gpointer user_data ) { - static DownloadMapOptions options = { FALSE, FALSE, NULL, 0, a_check_kml_file}; + static DownloadMapOptions options = { FALSE, FALSE, NULL, 0, NULL}; gint fd_src; int fetch_ret; gboolean ret = FALSE; diff --git a/src/datasource_google.c b/src/datasource_google.c index 10d4991a..e85d6738 100644 --- a/src/datasource_google.c +++ b/src/datasource_google.c @@ -31,7 +31,7 @@ #include "gpx.h" #include "acquire.h" -#define GOOGLE_DIRECTIONS_STRING "maps.google.com/maps?q=from:%s+to:%s&output=kml" +#define GOOGLE_DIRECTIONS_STRING "maps.google.com/maps?q=from:%s+to:%s&output=js" typedef struct { GtkWidget *from_entry, *to_entry; @@ -103,7 +103,7 @@ static void datasource_google_get_cmd_string ( datasource_google_widgets_t *widg to_quoted = g_strjoinv( "%20", to_split); *cmd = g_strdup_printf( GOOGLE_DIRECTIONS_STRING, from_quoted, to_quoted ); - *input_file_type = g_strdup("kml"); + *input_file_type = g_strdup("google"); g_free(last_from_str); g_free(last_to_str); diff --git a/src/datasources.h b/src/datasources.h index 366fd117..419fbf0e 100644 --- a/src/datasources.h +++ b/src/datasources.h @@ -27,7 +27,9 @@ G_BEGIN_DECLS extern VikDataSourceInterface vik_datasource_gps_interface; extern VikDataSourceInterface vik_datasource_file_interface; +#ifdef VIK_CONFIG_GOOGLE extern VikDataSourceInterface vik_datasource_google_interface; +#endif #ifdef VIK_CONFIG_OPENSTREETMAP extern VikDataSourceInterface vik_datasource_osm_interface; #endif diff --git a/src/menu.xml.h b/src/menu.xml.h index e60d6835..f06f7730 100644 --- a/src/menu.xml.h +++ b/src/menu.xml.h @@ -15,7 +15,7 @@ static const char *menu_xml = " " " " " " -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE " " #endif #ifdef VIK_CONFIG_OPENSTREETMAP diff --git a/src/viktrwlayer.c b/src/viktrwlayer.c index 6615f0bb..88ca8651 100644 --- a/src/viktrwlayer.c +++ b/src/viktrwlayer.c @@ -73,12 +73,8 @@ #include #include -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS -// This is currently broken as Google have disabled the KML output in Google Maps API v3 -// It has been ifdefed out in the hope that Route Finding functionality will be restored one day... -// Only have 'JSON' and 'XML' see: -// https://developers.google.com/maps/documentation/directions/#DirectionsResponses -#define GOOGLE_DIRECTIONS_STRING "maps.google.com/maps?q=from:%s,%s+to:%s,%s&output=kml" +#ifdef VIK_CONFIG_GOOGLE +#define GOOGLE_DIRECTIONS_STRING "maps.google.com/maps?q=from:%s,%s+to:%s,%s&output=js" #endif #define VIK_TRW_LAYER_TRACK_GC 16 @@ -287,7 +283,7 @@ static void trw_layer_geotagging_track ( gpointer pass_along[6] ); static void trw_layer_geotagging ( gpointer lav[2] ); #endif static void trw_layer_acquire_gps_cb ( gpointer lav[2] ); -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE static void trw_layer_acquire_google_cb ( gpointer lav[2] ); #endif #ifdef VIK_CONFIG_OPENSTREETMAP @@ -335,7 +331,7 @@ static void tool_new_track_release ( VikTrwLayer *vtl, GdkEventButton *event, Vi static gboolean tool_new_track_key_press ( VikTrwLayer *vtl, GdkEventKey *event, VikViewport *vvp ); static gpointer tool_new_waypoint_create ( VikWindow *vw, VikViewport *vvp); static gboolean tool_new_waypoint_click ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp ); -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE static gpointer tool_route_finder_create ( VikWindow *vw, VikViewport *vvp); static gboolean tool_route_finder_click ( VikTrwLayer *vtl, GdkEventButton *event, VikViewport *vvp ); #endif @@ -404,7 +400,7 @@ static VikToolInterface trw_layer_tools[] = { FALSE, GDK_CURSOR_IS_PIXMAP, &cursor_showpic_pixbuf }, -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE { { "RouteFinder", "vik-icon-Route Finder", N_("Route _Finder"), "F", N_("Route Finder"), 0 }, (VikToolConstructorFunc) tool_route_finder_create, NULL, NULL, NULL, (VikToolMouseFunc) tool_route_finder_click, NULL, NULL, (VikToolKeyFunc) NULL, @@ -2757,7 +2753,7 @@ static void trw_layer_acquire_gps_cb ( gpointer lav[2] ) a_acquire ( vw, vlp, vvp, &vik_datasource_gps_interface ); } -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE /* * Acquire into this TRW Layer from Google Directions */ @@ -3098,7 +3094,7 @@ static void trw_layer_add_menu_items ( VikTrwLayer *vtl, GtkMenu *menu, gpointer gtk_menu_shell_append (GTK_MENU_SHELL (acquire_submenu), item); gtk_widget_show ( item ); -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE item = gtk_menu_item_new_with_mnemonic ( _("From G_oogle Directions...") ); g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_acquire_google_cb), pass_along ); gtk_menu_shell_append (GTK_MENU_SHELL (acquire_submenu), item); @@ -3716,7 +3712,7 @@ static void trw_layer_extend_track_end ( gpointer pass_along[6] ) goto_coord ( pass_along[1], pass_along[0], pass_along[5], &(((VikTrackpoint *)g_list_last(track->trackpoints)->data)->coord) ); } -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE /** * extend a track using route finder */ @@ -4972,7 +4968,7 @@ static void trw_layer_track_use_with_filter ( gpointer pass_along[6] ) a_acquire_set_filter_track ( trk ); } -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE static gboolean is_valid_google_route ( VikTrwLayer *vtl, const gpointer track_id ) { VikTrack *tr = g_hash_table_lookup ( vtl->tracks, track_id ); @@ -5345,7 +5341,7 @@ static gboolean trw_layer_sublayer_add_menu_items ( VikTrwLayer *l, GtkMenu *men gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item ); gtk_widget_show ( item ); -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE item = gtk_image_menu_item_new_with_mnemonic ( _("Extend _Using Route Finder") ); gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock ("Route Finder", GTK_ICON_SIZE_MENU) ); // Own icon - see stock_icons in vikwindow.c g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_extend_track_end_route_finder), pass_along ); @@ -5376,7 +5372,7 @@ static gboolean trw_layer_sublayer_add_menu_items ( VikTrwLayer *l, GtkMenu *men gtk_menu_shell_append ( GTK_MENU_SHELL(upload_submenu), item ); gtk_widget_show ( item ); -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE if ( is_valid_google_route ( l, sublayer ) ) { item = gtk_image_menu_item_new_with_mnemonic ( _("_View Google Directions") ); @@ -6707,7 +6703,7 @@ static gboolean tool_edit_trackpoint_release ( VikTrwLayer *vtl, GdkEventButton } -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE /*** Route Finder ***/ static gpointer tool_route_finder_create ( VikWindow *vw, VikViewport *vvp) { @@ -6760,7 +6756,7 @@ static gboolean tool_route_finder_click ( VikTrwLayer *vtl, GdkEventButton *even g_ascii_dtostr (startlon, G_ASCII_DTOSTR_BUF_SIZE, (gdouble) start.lon), g_ascii_dtostr (endlat, G_ASCII_DTOSTR_BUF_SIZE, (gdouble) end.lat), g_ascii_dtostr (endlon, G_ASCII_DTOSTR_BUF_SIZE, (gdouble) end.lon)); - a_babel_convert_from_url ( vtl, url, "kml", NULL, NULL ); + a_babel_convert_from_url ( vtl, url, "google", NULL, NULL ); g_free ( url ); /* see if anything was done -- a track was added or appended to */ diff --git a/src/vikwindow.c b/src/vikwindow.c index 55f58ea0..378aec2e 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -2445,7 +2445,7 @@ static void acquire_from_file ( GtkAction *a, VikWindow *vw ) a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_file_interface ); } -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE static void acquire_from_google ( GtkAction *a, VikWindow *vw ) { a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_google_interface ); @@ -3122,7 +3122,7 @@ static GtkActionEntry entries[] = { { "Acquire", GTK_STOCK_GO_DOWN, N_("A_cquire"), NULL, NULL, (GCallback)NULL }, { "AcquireGPS", NULL, N_("From _GPS..."), NULL, N_("Transfer data from a GPS device"), (GCallback)acquire_from_gps }, { "AcquireGPSBabel", NULL, N_("Import File With GPS_Babel..."), NULL, N_("Import file via GPSBabel converter"), (GCallback)acquire_from_file }, -#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS +#ifdef VIK_CONFIG_GOOGLE { "AcquireGoogle", NULL, N_("Google _Directions..."), NULL, N_("Get driving directions from Google"), (GCallback)acquire_from_google }, #endif #ifdef VIK_CONFIG_OPENSTREETMAP