Hi Ivan,
fixed in CVS.
спасибо, Martin
2007/11/24, Ivan Shmakov <ivan@theory.asu.ru>:
>>>>> Martin Landa <landa.martin@gmail.com> writes:
[...]
>> I would like to import points data in GRASS (with v.in.ascii). My
>> data includes number written with the scientific notation (for
>> example 1.2e+23). During the import, I am defining them as double.
>> Unfortunately, it doesn't work...>> I get the following message :
>> " ERROR: Column 9 defined as double has string values ">> Can GRASS actualy deal with number written with scientific notation ?
>> Is there a specific way to deal with these numbers ?> no, it seems, v.in.ascii doesn't support it...
It seems that it's the is_double () function which behaves in a
wrong way:$ nl -ba grass-6.3.cvs_src_snapshot_2007_11_03/vector/v.in.ascii/points.c
...
30 /* Determine if the string is double, e.g. 123.456, +123.456, -123.456
31 * return 1 if double, 0 otherwise */
32 static int is_double(char *str)
33 {
34 int i = -1, ndots = 0;
35
36 while (str[++i] != '\0') {
37 if (i == 0 && (str[i] == '+' || str[i] == '-'))
38 continue;
39
40 if (str[i] == '.') {
41 if (ndots > 0)
42 return 0; /* > 1 dot */
43
44 ndots++;
45 continue;
46 }
47
48 if (!isdigit(str[i]))
49 return 0;
50 }
51
52 return 1;
53 }
...
$IIUC, the number is to be converted from its string
representation by atof () later. Since, I assume, atof ()
supports e-notation, there's no necessity in such a strict check
like is_double () currently performs. Therefore, I suggest
is_double () to be reimplemented on top of strtod () instead,
e. g.:static int
is_double (char *s)
{
char *tail;if (strtod (s, &tail),
tail == s || *tail != '\0') {
/* doesn't look like a number,
or has extra characters after what looks to be a number */
return 0;
}return 1;
}BTW, is_int () could be rewritten as well.
--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *