#! /bin/sh /usr/share/dpatch/dpatch-run ## newlocation.dpatch by Francesco Paolo Lovergine ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: No description. @DPATCH@ diff -urNad grass-6.4.0~rc5~/general/g.region/printwindow.c grass-6.4.0~rc5/general/g.region/printwindow.c --- grass-6.4.0~rc5~/general/g.region/printwindow.c 2009-07-13 13:35:34.000000000 +0200 +++ grass-6.4.0~rc5/general/g.region/printwindow.c 2009-07-13 14:29:28.000000000 +0200 @@ -23,7 +23,7 @@ double longitude, latitude; if (print_flag & PRINT_SH) - x = -1; + x = G_projection() == PROJECTION_LL ? -1 : 0; else x = window->proj; diff -urNad grass-6.4.0~rc5~/lib/gis/wind_format.c grass-6.4.0~rc5/lib/gis/wind_format.c --- grass-6.4.0~rc5~/lib/gis/wind_format.c 2009-07-13 13:35:34.000000000 +0200 +++ grass-6.4.0~rc5/lib/gis/wind_format.c 2009-07-13 14:29:57.000000000 +0200 @@ -18,7 +18,7 @@ #include -static int format_double(double, char *); +static void format_double(double , char *, int ); /** @@ -37,9 +37,10 @@ { if (projection == PROJECTION_LL) G_lat_format(north, buf); + else if (projection == -1) + format_double(north, buf, TRUE); else - format_double(north, buf); - + format_double(north, buf, FALSE); return 0; } @@ -59,10 +60,12 @@ int G_format_easting(double east, char *buf, int projection) { if (projection == PROJECTION_LL) - G_lon_format(east, buf); + G_lon_format(east, buf); + else if (projection == -1) + format_double(east, buf, TRUE); else - format_double(east, buf); - + format_double(east, buf, FALSE); + return 0; } @@ -82,24 +85,32 @@ int G_format_resolution(double res, char *buf, int projection) { if (projection == PROJECTION_LL) - G_llres_format(res, buf); + G_llres_format(res, buf); + else if (projection == -1) + format_double(res, buf, TRUE); else - format_double(res, buf); - + format_double(res, buf, FALSE); + return 0; } -static int format_double(double value, char *buf) +/* + * 'full_prec' is boolean, FALSE uses %.8f, TRUE uses %.15g + * The reason to have this is that for lat/lon "%.8f" is not + * enough to preserve fidelity once converted back into D:M:S, + * which leads to rounding errors, especially for resolution. + */ +static void format_double(double value, char *buf, int full_prec) { /* if the programmer has lied to G_format_resolution() about the projection type in order to get FP values for lat/lon coords, "%.8f" is not enough to preserve fidelity once converted back into D:M:S, which leads to rounding errors. */ - if (G_projection() == PROJECTION_LL) + if (full_prec) sprintf(buf, "%.15g", value); else sprintf(buf, "%.8f", value); G_trim_decimal(buf); - return 0; + return; }