wind_scan.c

Go to the documentation of this file.
00001 #include "gis.h"
00002 static int scan_double(char *,double *);
00003 
00004 
00017 int G_scan_northing ( char *buf, double *northing, int projection)
00018 {
00019     if (projection == PROJECTION_LL)
00020     {
00021         if(G_lat_scan (buf, northing))
00022             return 1;
00023         if (!scan_double (buf, northing))
00024             return 0;
00025         return (*northing <= 90.0 && *northing >= -90.0);
00026     }
00027     return scan_double (buf, northing);
00028 }
00029 
00030 
00043 int G_scan_easting ( char *buf, double *easting, int projection)
00044 {
00045     if (projection == PROJECTION_LL)
00046     {
00047         if (G_lon_scan (buf, easting))
00048             return 1;
00049         if (!scan_double (buf, easting))
00050             return 0;
00051         while (*easting > 180.0)
00052             *easting -= 360.0;
00053         while (*easting < -180.0)
00054             *easting += 360.0;
00055         return 1;
00056     }
00057     return scan_double (buf, easting);
00058 }
00059 
00060 
00073 int G_scan_resolution ( char *buf, double *res,int projection)
00074 {
00075     if (projection == PROJECTION_LL)
00076     {
00077         if(G_llres_scan (buf, res))
00078                 return 1;
00079     }
00080     return (scan_double (buf, res) && *res > 0.0);
00081 }
00082 
00083 static int scan_double(char *buf, double *value)
00084 {
00085     char junk[2];
00086 
00087 /* use sscanf to convert buf to double
00088  * make sure value doesn't have other characters after it
00089  */
00090     *junk = 0;
00091     *value = 0.0;
00092     if(sscanf (buf, "%lf%1s", value, junk) == 1 && *junk == 0)
00093     {
00094        while(*buf) buf++;
00095        buf--;
00096        if(*buf>='A'&&*buf<='Z')
00097           return 0;
00098        if(*buf>='a'&&*buf<='z')
00099           return 0;
00100        return 1;
00101      }
00102      return 0;
00103 }

Generated on Wed Aug 23 17:49:23 2006 for GRASS by  doxygen 1.4.7