]> git.street.me.uk Git - andy/viking.git/commitdiff
Check size of route before refining it
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Tue, 23 Jul 2013 21:01:29 +0000 (23:01 +0200)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Tue, 23 Jul 2013 21:01:29 +0000 (23:01 +0200)
Before computing a route refining on an excessively long route,
request confirmation from user.

Signed-off-by: Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
src/viktrwlayer.c

index a34ba3b4eef5c99b91fc57bb04a7c5f81911b028..8991ef763c603e176a67b6935e3e02f9ce1d36be 100644 (file)
@@ -4720,6 +4720,20 @@ static void trw_layer_route_refine ( gpointer pass_along[6] )
 
   if ( trk && trk->trackpoints )
   {
+    /* Check size of the route */
+    int nb = vik_track_get_tp_count(trk);
+    if (nb > 100) {
+      GtkWidget *dialog = gtk_message_dialog_new (VIK_GTK_WINDOW_FROM_LAYER (vtl),
+                                                  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  GTK_MESSAGE_WARNING,
+                                                  GTK_BUTTONS_OK_CANCEL,
+                                                  _("Refining a track with many points (%d) is unlikely to yield sensible results. Do you want to Continue?"),
+                                                  nb);
+      gint response = gtk_dialog_run ( GTK_DIALOG(dialog) );
+      gtk_widget_destroy ( dialog );
+      if (response != GTK_RESPONSE_OK )
+        return;
+    }
     /* Select engine from dialog */
     GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Refine Route with Routing Engine..."),
                                                   VIK_GTK_WINDOW_FROM_LAYER (vtl),