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 return 0;
00045 }
00046
00047
00060 int G_format_easting(double east, char *buf, int projection)
00061 {
00062 if (projection == PROJECTION_LL)
00063 G_lon_format(east, buf);
00064 else if (projection == -1)
00065 format_double(east, buf, TRUE);
00066 else
00067 format_double(east, buf, FALSE);
00068
00069 return 0;
00070 }
00071
00072
00085 int G_format_resolution(double res, char *buf, int projection)
00086 {
00087 if (projection == PROJECTION_LL)
00088 G_llres_format(res, buf);
00089 else if (projection == -1)
00090 format_double(res, buf, TRUE);
00091 else
00092 format_double(res, buf, FALSE);
00093
00094 return 0;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 static void format_double(double value, char *buf, int full_prec)
00104 {
00105
00106
00107
00108
00109 if (full_prec)
00110 sprintf(buf, "%.15g", value);
00111 else
00112 sprintf(buf, "%.8f", value);
00113 G_trim_decimal(buf);
00114
00115 return;
00116 }