File: scan_misc.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (34 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "ps_info.h"
#include <string.h>

static int scan_percent(char *,double *,double,double);

int 
scan_easting (char *buf, double *f)
{
    if (scan_percent(buf, f, PS.w.west, PS.w.east)) return 1;
    return G_scan_easting(buf, f, PS.w.proj);
}

int 
scan_northing (char *buf, double *f)
{
    if (scan_percent(buf, f, PS.w.south, PS.w.north)) return 1;
    return G_scan_northing(buf, f, PS.w.proj);
}

int 
scan_resolution (char *buf, double *f)
{
    return G_scan_resolution(buf, f, PS.w.proj);
}

static int scan_percent(char *buf, double *f,double min,double max)
{
    char percent[3];
    *percent = 0;
    if (sscanf(buf, "%lf%2s", f, percent) != 2) return 0;
    if (strcmp(percent, "%") != 0) return 0;
    *f = min + (max-min) * (*f/100.0);
    return 1;
}