]> git.street.me.uk Git - andy/viking.git/commitdiff
Restore Google Directions feature
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Fri, 4 Jan 2013 07:32:52 +0000 (08:32 +0100)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Fri, 4 Jan 2013 07:32:52 +0000 (08:32 +0100)
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 <guilhem.bonnefille@gmail.com>
configure.ac
help/C/viking.xml
src/Makefile.am
src/acquire.c
src/babel.c
src/datasource_google.c
src/datasources.h
src/menu.xml.h
src/viktrwlayer.c
src/vikwindow.c

index 92fc6979090dab15d779d4a4e2d70077ed332c62..5333f58df351db5ec9dca86fd1d6fc49a4cf2c3d 100644 (file)
@@ -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"
index 2b3adbe1c4cd8005ef576b21a7b6ae89c9fe1c02..fb403d36dcdedc1b194aa526138fb4fecfc8853d 100644 (file)
@@ -872,13 +872,11 @@ Changes the current tool to add trackpoints to the end of the track.
 </para>
 </section>
 
-<!--
 <section><title>Extend Using Route Finder</title>
 <para>
 Enables the Route Finder tool. Thus on a subsequent left click in the viewport, a route is calculated from the end of track to that point using Google's route service and applied to the track.
 </para>
 </section>
--->
 
 <section><title>Upload</title>
 
@@ -902,7 +900,6 @@ This selects the track to be used in the <link linkend="filter_with_track">Filte
 </para>
 </section>
 
-<!--
 <section><title>View Google Directions</title>
 <para>
 This option is only available on a track created using the Route Finder tool.
@@ -916,7 +913,7 @@ The record of the Google route is stored in the track's comment, so if the comme
 </para>
 </note>
 </section>
--->
+
 </section><!-- End Track Options -->
 
 <section><title>Waypoint Properties</title>
@@ -1328,7 +1325,6 @@ For Linux you can override this with the setting in the <link linkend="prefs_ext
 </para>
 </section>
 
-<!--
 <section><title>Route Finder</title>
 <para>
 Enable this tool by clicking on the toolbar icon: <guiicon><inlinegraphic fileref="figures/route_finder_18.png"/></guiicon>
@@ -1344,7 +1340,7 @@ Right-click: undo last routing (only track removed - not any waypoints)
 <keycap>Ctrl</keycap>: continue previous track
 </para>
 </section>
--->
+
 </section>
 
 <section><title>Georef Map Layer Tools</title>
index cd7f79711001909fd2d211d362bb3a079a937f03..111e88e22d6f784fb4563e7c7d5f3d625541f0c5 100644 (file)
@@ -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 \
index a9d428983f40c3bdbcded59059715b46c89c847e..0cd79dc77228f00b2afda31e57cc2ad6386aab3d 100644 (file)
@@ -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;
index 20ef0a29ef26dee7090d7dcb1332899abebebf1b..32105398e87766cff5597ea79b23f2e007040bbc 100644 (file)
@@ -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;
index 10d4991a73ce7fa7831866a7ab8dd95ef8371713..e85d673844ac75132a5ad0ab2721472e58fb1a95 100644 (file)
@@ -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);
index 366fd1172a2ebd9519c4e719deca6e1e4efbe268..419fbf0e616349eee9db765537d8a833c59df10c 100644 (file)
@@ -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
index e60d6835aab8131eead29815214836cc6ee3ca00..f06f773094b31d05c978ff54b5b8831b878dceaf 100644 (file)
@@ -15,7 +15,7 @@ static const char *menu_xml =
        "      <menu action='Acquire'>"
        "        <menuitem action='AcquireGPS'/>"
        "        <menuitem action='AcquireGPSBabel'/>"
-#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS
+#ifdef VIK_CONFIG_GOOGLE
        "        <menuitem action='AcquireGoogle'/>"
 #endif
 #ifdef VIK_CONFIG_OPENSTREETMAP
index 6615f0bb18253d444628957d231a451eb762056c..88ca865120c5886137fd191f5585731b89be5868 100644 (file)
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 
-#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"), "<control><shift>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 */
index 55f58ea0f903dc7966b930a20f623ea96e2fff02..378aec2e23144682b4a32f9af08fcfb502290770 100644 (file)
@@ -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