From b22233bdbe84cee4af1cd2433cd25d63a300088c Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 9 Jun 2014 21:39:02 +0100 Subject: [PATCH] SF Features#120: Add Nautical Miles preference for distance units. --- src/globals.c | 2 +- src/globals.h | 5 ++ src/viktrwlayer.c | 38 +++++++++++--- src/viktrwlayer_propwin.c | 108 +++++++++++++++++++++++++++++--------- src/viktrwlayer_tpwin.c | 1 + src/vikutils.c | 6 ++- src/vikviewport.c | 26 +++++++-- src/vikwindow.c | 42 ++++++++++----- 8 files changed, 178 insertions(+), 50 deletions(-) diff --git a/src/globals.c b/src/globals.c index b4f2ab27..b4f2b5f9 100644 --- a/src/globals.c +++ b/src/globals.c @@ -65,7 +65,7 @@ gint viking_version_to_number ( gchar *version ) } static gchar * params_degree_formats[] = {"DDD", "DMM", "DMS", N_("Raw"), NULL}; -static gchar * params_units_distance[] = {"Kilometres", "Miles", NULL}; +static gchar * params_units_distance[] = {N_("Kilometres"), N_("Miles"), N_("Nautical Miles"), NULL}; static gchar * params_units_speed[] = {"km/h", "mph", "m/s", "knots", NULL}; static gchar * params_units_height[] = {"Metres", "Feet", NULL}; static VikLayerParamScale params_scales_lat[] = { {-90.0, 90.0, 0.05, 2} }; diff --git a/src/globals.h b/src/globals.h index 29a5b49e..28646523 100644 --- a/src/globals.h +++ b/src/globals.h @@ -43,6 +43,10 @@ G_BEGIN_DECLS #define VIK_METERS_TO_MILES(X) ((X)*VIK_MILES_IN_METER) #define VIK_MILES_TO_METERS(X) ((X)/VIK_MILES_IN_METER) +#define VIK_NAUTICAL_MILES_IN_METER 0.000539957 +#define VIK_METERS_TO_NAUTICAL_MILES(X) ((X)*VIK_NAUTICAL_MILES_IN_METER) +#define VIK_NAUTICAL_MILES_TO_METERS(X) ((X)/VIK_NAUTICAL_MILES_IN_METER) + /* MPS - Metres Per Second */ /* MPH - Metres Per Hour */ #define VIK_MPH_IN_MPS 2.23693629 @@ -99,6 +103,7 @@ vik_degree_format_t a_vik_get_degree_format ( ); typedef enum { VIK_UNITS_DISTANCE_KILOMETRES, VIK_UNITS_DISTANCE_MILES, + VIK_UNITS_DISTANCE_NAUTICAL_MILES, } vik_units_distance_t; vik_units_distance_t a_vik_get_units_distance ( ); diff --git a/src/viktrwlayer.c b/src/viktrwlayer.c index 8bd6cb29..9aa427df 100644 --- a/src/viktrwlayer.c +++ b/src/viktrwlayer.c @@ -1740,6 +1740,9 @@ static gdouble distance_in_preferred_units ( gdouble dist ) case VIK_UNITS_DISTANCE_MILES: mydist = VIK_METERS_TO_MILES(dist); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + mydist = VIK_METERS_TO_NAUTICAL_MILES(dist); + break; // VIK_UNITS_DISTANCE_KILOMETRES: default: mydist = dist/1000.0; @@ -1785,6 +1788,9 @@ static void trw_layer_draw_dist_labels ( struct DrawingParams *dp, VikTrack *trk case VIK_UNITS_DISTANCE_MILES: dist_i = VIK_MILES_TO_METERS(dist_i); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + dist_i = VIK_NAUTICAL_MILES_TO_METERS(dist_i); + break; // VIK_UNITS_DISTANCE_KILOMETRES: default: dist_i = dist_i*1000.0; @@ -2843,13 +2849,19 @@ static const gchar* trw_layer_layer_tooltip ( VikTrwLayer *vtl ) gdouble len_in_units; // Setup info dependent on distance units - if ( a_vik_get_units_distance() == VIK_UNITS_DISTANCE_MILES ) { - g_snprintf (tbuf4, sizeof(tbuf4), "miles"); - len_in_units = VIK_METERS_TO_MILES(tt.length); - } - else { - g_snprintf (tbuf4, sizeof(tbuf4), "kms"); - len_in_units = tt.length/1000.0; + switch ( a_vik_get_units_distance() ) { + case VIK_UNITS_DISTANCE_MILES: + g_snprintf (tbuf4, sizeof(tbuf4), "miles"); + len_in_units = VIK_METERS_TO_MILES(tt.length); + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf (tbuf4, sizeof(tbuf4), "NM"); + len_in_units = VIK_METERS_TO_NAUTICAL_MILES(tt.length); + break; + default: + g_snprintf (tbuf4, sizeof(tbuf4), "kms"); + len_in_units = tt.length/1000.0; + break; } // Timing information if available @@ -2938,6 +2950,9 @@ static const gchar* trw_layer_sublayer_tooltip ( VikTrwLayer *l, gint subtype, g case VIK_UNITS_DISTANCE_MILES: g_snprintf (tmp_buf, sizeof(tmp_buf), _("%s%.1f miles %s"), time_buf1, VIK_METERS_TO_MILES(tr_len), time_buf2); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf (tmp_buf, sizeof(tmp_buf), _("%s%.1f NM %s"), time_buf1, VIK_METERS_TO_NAUTICAL_MILES(tr_len), time_buf2); + break; default: break; } @@ -9421,6 +9436,15 @@ static gchar* distance_string (gdouble distance) g_sprintf(str, "%d miles", (int)VIK_METERS_TO_MILES(distance)); } break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + if (distance >= VIK_NAUTICAL_MILES_TO_METERS(1) && distance < VIK_NAUTICAL_MILES_TO_METERS(100)) { + g_sprintf(str, "%3.2f NM", VIK_METERS_TO_NAUTICAL_MILES(distance)); + } else if (distance < VIK_NAUTICAL_MILES_TO_METERS(1)) { + g_sprintf(str, "%d yards", (int)(distance*1.0936133)); + } else { + g_sprintf(str, "%d NM", (int)VIK_METERS_TO_NAUTICAL_MILES(distance)); + } + break; default: // VIK_UNITS_DISTANCE_KILOMETRES if (distance >= 1000 && distance < 100000) { diff --git a/src/viktrwlayer_propwin.c b/src/viktrwlayer_propwin.c index f8cbf9cc..7e8071e2 100644 --- a/src/viktrwlayer_propwin.c +++ b/src/viktrwlayer_propwin.c @@ -748,6 +748,9 @@ void track_profile_move( GtkWidget *event_box, GdkEventMotion *event, PropWidget case VIK_UNITS_DISTANCE_MILES: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f miles", VIK_METERS_TO_MILES(meters_from_start) ); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f NM", VIK_METERS_TO_NAUTICAL_MILES(meters_from_start) ); + break; default: g_critical("Houston, we've had a problem. distance=%d", dist_units); } @@ -828,6 +831,9 @@ void track_gradient_move( GtkWidget *event_box, GdkEventMotion *event, PropWidge case VIK_UNITS_DISTANCE_MILES: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f miles", VIK_METERS_TO_MILES(meters_from_start) ); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f NM", VIK_METERS_TO_NAUTICAL_MILES(meters_from_start) ); + break; default: g_critical("Houston, we've had a problem. distance=%d", dist_units); } @@ -1031,10 +1037,17 @@ void track_dt_move( GtkWidget *event_box, GdkEventMotion *event, PropWidgets *wi if (trackpoint && widgets->w_cur_dist_dist) { static gchar tmp_buf[20]; - if ( a_vik_get_units_distance () == VIK_UNITS_DISTANCE_MILES ) + switch ( a_vik_get_units_distance () ) { + case VIK_UNITS_DISTANCE_MILES: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f miles", widgets->distances[ix]); - else + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f NM", widgets->distances[ix]); + break; + default: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f km", widgets->distances[ix]); + break; + } gtk_label_set_text(GTK_LABEL(widgets->w_cur_dist_dist), tmp_buf); } @@ -1181,6 +1194,9 @@ void track_sd_move( GtkWidget *event_box, GdkEventMotion *event, PropWidgets *wi case VIK_UNITS_DISTANCE_MILES: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f miles", VIK_METERS_TO_MILES(meters_from_start) ); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f NM", VIK_METERS_TO_NAUTICAL_MILES(meters_from_start) ); + break; default: g_critical("Houston, we've had a problem. distance=%d", dist_units); } @@ -1409,16 +1425,27 @@ static void draw_grid_x_time ( GtkWidget *window, GtkWidget *image, PropWidgets static void draw_grid_x_distance ( GtkWidget *window, GtkWidget *image, PropWidgets *widgets, GdkPixmap *pix, guint ii, gdouble dd, guint xx, vik_units_distance_t dist_units ) { gchar *label_markup = NULL; - if ( dist_units == VIK_UNITS_DISTANCE_MILES ) + switch ( dist_units ) { + case VIK_UNITS_DISTANCE_MILES: if ( ii > 4 ) label_markup = g_strdup_printf ( "%d %s", (guint)dd, _("miles") ); else label_markup = g_strdup_printf ( "%.1f %s", dd, _("miles") ); - else + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + if ( ii > 4 ) + label_markup = g_strdup_printf ( "%d %s", (guint)dd, _("NM") ); + else + label_markup = g_strdup_printf ( "%.1f %s", dd, _("NM") ); + break; + default: + // VIK_UNITS_DISTANCE_KILOMETRES: if ( ii > 4 ) label_markup = g_strdup_printf ( "%d %s", (guint)dd, _("km") ); else label_markup = g_strdup_printf ( "%.1f %s", dd, _("km") ); + break; + } if ( label_markup ) { PangoLayout *pl = gtk_widget_create_pango_layout (GTK_WIDGET(image), NULL); @@ -1456,12 +1483,18 @@ static void draw_distance_divisions ( GtkWidget *window, GtkWidget *image, GdkPi { // Set to display units from length in metres. gdouble length = widgets->track_length_inc_gaps; - if ( dist_units == VIK_UNITS_DISTANCE_MILES ) - length = VIK_METERS_TO_MILES(length); - else - // KM - length = length/1000.0; - + switch (dist_units) { + case VIK_UNITS_DISTANCE_MILES: + length = VIK_METERS_TO_MILES(length); + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + length = VIK_METERS_TO_NAUTICAL_MILES(length); + break; + default: + // KM + length = length/1000.0; + break; + } guint index = get_distance_chunk_index ( length ); gdouble dist_per_pixel = length/widgets->profile_width; @@ -1875,16 +1908,23 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets ) // Convert into appropriate units vik_units_distance_t dist_units = a_vik_get_units_distance (); - if ( dist_units == VIK_UNITS_DISTANCE_MILES ) { - for ( i = 0; i < widgets->profile_width; i++ ) { - widgets->distances[i] = VIK_METERS_TO_MILES(widgets->distances[i]); - } - } - else { - // Metres - but want in kms - for ( i = 0; i < widgets->profile_width; i++ ) { - widgets->distances[i] = widgets->distances[i]/1000.0; - } + switch ( dist_units ) { + case VIK_UNITS_DISTANCE_MILES: + for ( i = 0; i < widgets->profile_width; i++ ) { + widgets->distances[i] = VIK_METERS_TO_MILES(widgets->distances[i]); + } + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + for ( i = 0; i < widgets->profile_width; i++ ) { + widgets->distances[i] = VIK_METERS_TO_NAUTICAL_MILES(widgets->distances[i]); + } + break; + default: + // Metres - but want in kms + for ( i = 0; i < widgets->profile_width; i++ ) { + widgets->distances[i] = widgets->distances[i]/1000.0; + } + break; } widgets->duration = vik_track_get_duration ( widgets->tr ); @@ -1901,10 +1941,17 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets ) // Assign locally // mind = 0.0; - Thus not used gdouble maxd; - if ( dist_units == VIK_UNITS_DISTANCE_MILES ) + switch ( dist_units ) { + case VIK_UNITS_DISTANCE_MILES: maxd = VIK_METERS_TO_MILES(vik_track_get_length_including_gaps (tr)); - else + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + maxd = VIK_METERS_TO_NAUTICAL_MILES(vik_track_get_length_including_gaps (tr)); + break; + default: maxd = vik_track_get_length_including_gaps (tr) / 1000.0; + break; + } /* Find suitable chunk index */ gdouble dummy = 0.0; // expect this to remain the same! (not that it's used) @@ -1917,10 +1964,17 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets ) for (i=0; i<=LINES; i++) { gchar s[32]; - if ( dist_units == VIK_UNITS_DISTANCE_MILES ) + switch ( dist_units ) { + case VIK_UNITS_DISTANCE_MILES: sprintf(s, _("%.1f miles"), ((LINES-i)*chunksd[widgets->cid])); - else + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + sprintf(s, _("%.1f NM"), ((LINES-i)*chunksd[widgets->cid])); + break; + default: sprintf(s, _("%.1f km"), ((LINES-i)*chunksd[widgets->cid])); + break; + } draw_grid_y ( window, image, widgets, pix, s, i ); } @@ -3142,6 +3196,9 @@ void vik_trw_layer_propwin_run ( GtkWindow *parent, case VIK_UNITS_DISTANCE_MILES: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f miles", VIK_METERS_TO_MILES(tr_len) ); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf(tmp_buf, sizeof(tmp_buf), "%.2f NM", VIK_METERS_TO_NAUTICAL_MILES(tr_len) ); + break; default: g_critical("Houston, we've had a problem. distance=%d", dist_units); } @@ -3243,6 +3300,9 @@ void vik_trw_layer_propwin_run ( GtkWindow *parent, case VIK_UNITS_DISTANCE_MILES: g_snprintf(tmp_buf, sizeof(tmp_buf), "%.3f miles", (tp_count - seg_count) == 0 ? 0 : VIK_METERS_TO_MILES(tr_len / ( tp_count - seg_count )) ); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + g_snprintf(tmp_buf, sizeof(tmp_buf), "%.3f NM", (tp_count - seg_count) == 0 ? 0 : VIK_METERS_TO_NAUTICAL_MILES(tr_len / ( tp_count - seg_count )) ); + break; default: g_critical("Houston, we've had a problem. distance=%d", dist_units); } diff --git a/src/viktrwlayer_tpwin.c b/src/viktrwlayer_tpwin.c index 84f91071..22c84903 100644 --- a/src/viktrwlayer_tpwin.c +++ b/src/viktrwlayer_tpwin.c @@ -430,6 +430,7 @@ void vik_trw_layer_tpwin_set_tp ( VikTrwLayerTpwin *tpwin, GList *tpl, const gch g_snprintf ( tmp_str, sizeof(tmp_str), "%.2f m", vik_coord_diff(&(tp->coord), &(tpwin->cur_tp->coord))); break; case VIK_UNITS_DISTANCE_MILES: + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: g_snprintf ( tmp_str, sizeof(tmp_str), "%.2f yards", vik_coord_diff(&(tp->coord), &(tpwin->cur_tp->coord))*1.0936133); break; default: diff --git a/src/vikutils.c b/src/vikutils.c index 30f5b243..bbe36583 100644 --- a/src/vikutils.c +++ b/src/vikutils.c @@ -166,6 +166,7 @@ gchar* vu_trackpoint_formatted_message ( gchar *format_code, VikTrackpoint *trkp // expect the difference between track points to be small hence use metres or yards switch (dist_units) { case VIK_UNITS_DISTANCE_MILES: + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: dist_units_str = g_strdup ( _("yards") ); break; default: @@ -212,12 +213,15 @@ gchar* vu_trackpoint_formatted_message ( gchar *format_code, VikTrackpoint *trkp gdouble distd = vik_track_get_length_to_trackpoint (trk, trkpt); gchar *dist_units_str = NULL; vik_units_distance_t dist_units = a_vik_get_units_distance (); - // expect the difference between track points to be small hence use metres or yards switch (dist_units) { case VIK_UNITS_DISTANCE_MILES: dist_units_str = g_strdup ( _("miles") ); distd = VIK_METERS_TO_MILES(distd); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + dist_units_str = g_strdup ( _("NM") ); + distd = VIK_METERS_TO_NAUTICAL_MILES(distd); + break; default: // VIK_UNITS_DISTANCE_KILOMETRES: dist_units_str = g_strdup ( _("km") ); diff --git a/src/vikviewport.c b/src/vikviewport.c index 44ef982e..b15e9acf 100644 --- a/src/vikviewport.c +++ b/src/vikviewport.c @@ -503,6 +503,10 @@ void vik_viewport_draw_scale ( VikViewport *vvp ) // in 0.1 miles (copes better when zoomed in as 1 mile can be too big) base = VIK_METERS_TO_MILES(vik_coord_diff ( &left, &right )) * 10.0; break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + // in 0.1 NM (copes better when zoomed in as 1 NM can be too big) + base = VIK_METERS_TO_NAUTICAL_MILES(vik_coord_diff ( &left, &right )) * 10.0; + break; default: base = 1; // Keep the compiler happy g_critical("Houston, we've had a problem. distance=%d", dist_units); @@ -561,21 +565,33 @@ void vik_viewport_draw_scale ( VikViewport *vvp ) switch (dist_units) { case VIK_UNITS_DISTANCE_KILOMETRES: if (unit >= 1000) { - sprintf(s, "%d km", (int)unit/1000); + sprintf(s, "%d km", (int)unit/1000); } else { - sprintf(s, "%d m", (int)unit); + sprintf(s, "%d m", (int)unit); } break; case VIK_UNITS_DISTANCE_MILES: // Handle units in 0.1 miles if (unit < 10.0) { - sprintf(s, "%0.1f miles", unit/10.0); + sprintf(s, "%0.1f miles", unit/10.0); + } + else if ((int)unit == 10.0) { + sprintf(s, "1 mile"); + } + else { + sprintf(s, "%d miles", (int)(unit/10.0)); + } + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + // Handle units in 0.1 NM + if (unit < 10.0) { + sprintf(s, "%0.1f NM", unit/10.0); } else if ((int)unit == 10.0) { - sprintf(s, "1 mile"); + sprintf(s, "1 NM"); } else { - sprintf(s, "%d miles", (int)(unit/10.0)); + sprintf(s, "%d NMs", (int)(unit/10.0)); } break; default: diff --git a/src/vikwindow.c b/src/vikwindow.c index 20d65aae..e783e9a6 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -1447,20 +1447,29 @@ static void draw_ruler(VikViewport *vvp, GdkDrawable *d, GdkGC *gc, gint x1, gin switch (dist_units) { case VIK_UNITS_DISTANCE_KILOMETRES: if (distance >= 1000 && distance < 100000) { - g_sprintf(str, "%3.2f km", distance/1000.0); + g_sprintf(str, "%3.2f km", distance/1000.0); } else if (distance < 1000) { - g_sprintf(str, "%d m", (int)distance); + g_sprintf(str, "%d m", (int)distance); } else { - g_sprintf(str, "%d km", (int)distance/1000); + g_sprintf(str, "%d km", (int)distance/1000); } break; case VIK_UNITS_DISTANCE_MILES: if (distance >= VIK_MILES_TO_METERS(1) && distance < VIK_MILES_TO_METERS(100)) { - g_sprintf(str, "%3.2f miles", VIK_METERS_TO_MILES(distance)); + g_sprintf(str, "%3.2f miles", VIK_METERS_TO_MILES(distance)); } else if (distance < VIK_MILES_TO_METERS(1)) { - g_sprintf(str, "%d yards", (int)(distance*1.0936133)); + g_sprintf(str, "%d yards", (int)(distance*1.0936133)); } else { - g_sprintf(str, "%d miles", (int)VIK_METERS_TO_MILES(distance)); + g_sprintf(str, "%d miles", (int)VIK_METERS_TO_MILES(distance)); + } + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + if (distance >= VIK_NAUTICAL_MILES_TO_METERS(1) && distance < VIK_NAUTICAL_MILES_TO_METERS(100)) { + g_sprintf(str, "%3.2f NM", VIK_METERS_TO_NAUTICAL_MILES(distance)); + } else if (distance < VIK_NAUTICAL_MILES_TO_METERS(1)) { + g_sprintf(str, "%d yards", (int)(distance*1.0936133)); + } else { + g_sprintf(str, "%d NM", (int)VIK_METERS_TO_NAUTICAL_MILES(distance)); } break; default: @@ -1547,14 +1556,17 @@ static VikLayerToolFuncStatus ruler_click (VikLayer *vl, GdkEventButton *event, vik_units_distance_t dist_units = a_vik_get_units_distance (); switch (dist_units) { case VIK_UNITS_DISTANCE_KILOMETRES: - temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) ); - break; + temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) ); + break; case VIK_UNITS_DISTANCE_MILES: - temp = g_strdup_printf ( "%s %s DIFF %f miles", lat, lon, VIK_METERS_TO_MILES(vik_coord_diff( &coord, &(s->oldcoord) )) ); - break; + temp = g_strdup_printf ( "%s %s DIFF %f miles", lat, lon, VIK_METERS_TO_MILES(vik_coord_diff( &coord, &(s->oldcoord) )) ); + break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + temp = g_strdup_printf ( "%s %s DIFF %f NM", lat, lon, VIK_METERS_TO_NAUTICAL_MILES(vik_coord_diff( &coord, &(s->oldcoord) )) ); + break; default: - temp = g_strdup_printf ("Just to keep the compiler happy"); - g_critical("Houston, we've had a problem. distance=%d", dist_units); + temp = g_strdup_printf ("Just to keep the compiler happy"); + g_critical("Houston, we've had a problem. distance=%d", dist_units); } s->has_oldcoord = FALSE; @@ -1624,6 +1636,9 @@ static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventMotion *event, r case VIK_UNITS_DISTANCE_MILES: temp = g_strdup_printf ( "%s %s DIFF %f miles", lat, lon, VIK_METERS_TO_MILES (vik_coord_diff( &coord, &(s->oldcoord) )) ); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + temp = g_strdup_printf ( "%s %s DIFF %f NM", lat, lon, VIK_METERS_TO_NAUTICAL_MILES (vik_coord_diff( &coord, &(s->oldcoord) )) ); + break; default: temp = g_strdup_printf ("Just to keep the compiler happy"); g_critical("Houston, we've had a problem. distance=%d", dist_units); @@ -3609,6 +3624,9 @@ static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointe case VIK_UNITS_DISTANCE_MILES: label_text = g_strdup_printf ( _("Total area: %ldm x %ldm (%.3f sq. miles)"), (glong)w, (glong)h, (w*h/2589988.11)); break; + case VIK_UNITS_DISTANCE_NAUTICAL_MILES: + label_text = g_strdup_printf ( _("Total area: %ldm x %ldm (%.3f sq. NM)"), (glong)w, (glong)h, (w*h/(1852.0*1852.0))); + break; default: label_text = g_strdup_printf ("Just to keep the compiler happy"); g_critical("Houston, we've had a problem. distance=%d", dist_units); -- 2.39.5