• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

wind_format.c

Go to the documentation of this file.
00001 
00017 #include <stdio.h>
00018 #include <grass/gis.h>
00019 
00020 
00021 static void format_double(double, char *, int);
00022 
00023 
00036 int G_format_northing(double north, char *buf, int projection)
00037 {
00038     if (projection == PROJECTION_LL)
00039         G_lat_format(north, buf);
00040     else if (projection == -1)
00041         format_double(north, buf, TRUE);
00042     else
00043         format_double(north, buf, FALSE);
00044 
00045     return 0;
00046 }
00047 
00048 
00061 int G_format_easting(double east, char *buf, int projection)
00062 {
00063     if (projection == PROJECTION_LL)
00064         G_lon_format(east, buf);
00065     else if (projection == -1)
00066         format_double(east, buf, TRUE);
00067     else
00068         format_double(east, buf, FALSE);
00069 
00070     return 0;
00071 }
00072 
00073 
00086 int G_format_resolution(double res, char *buf, int projection)
00087 {
00088     if (projection == PROJECTION_LL)
00089         G_llres_format(res, buf);
00090     else if (projection == -1)
00091         format_double(res, buf, TRUE);
00092     else
00093         format_double(res, buf, FALSE);
00094 
00095     return 0;
00096 }
00097 
00098 /*
00099  * 'full_prec' is boolean, FALSE uses %.8f,  TRUE uses %.15g
00100  * The reason to have this is that for lat/lon "%.8f" is not
00101  * enough to preserve fidelity once converted back into D:M:S,
00102  * which leads to rounding errors, especially for resolution.
00103  */
00104 static void format_double(double value, char *buf, int full_prec)
00105 {
00106     if (full_prec)
00107         sprintf(buf, "%.15g", value);
00108     else
00109         sprintf(buf, "%.8f", value);
00110 
00111     G_trim_decimal(buf);
00112 
00113     return;
00114 }

Generated on Thu Dec 9 2010 20:46:05 for GRASS Programmer's Manual by  doxygen 1.7.2