|
@@ -37,6 +37,7 @@ int Vect_read_ascii(FILE *ascii, struct Map_info *Map)
|
|
|
{
|
|
|
char ctype;
|
|
|
char buff[BUFFSIZE];
|
|
|
+ char east_str[256], north_str[256];
|
|
|
double *xarray;
|
|
|
double *yarray;
|
|
|
double *zarray;
|
|
@@ -61,6 +62,8 @@ int Vect_read_ascii(FILE *ascii, struct Map_info *Map)
|
|
|
zarray = (double *)G_calloc(alloc_points, sizeof(double));
|
|
|
|
|
|
n_lines = 0;
|
|
|
+
|
|
|
+
|
|
|
while (G_getl2(buff, BUFFSIZE - 1, ascii) != 0) {
|
|
|
n_cats = 0;
|
|
|
if (buff[0] == '\0') {
|
|
@@ -134,9 +137,19 @@ int Vect_read_ascii(FILE *ascii, struct Map_info *Map)
|
|
|
}
|
|
|
|
|
|
*z = 0;
|
|
|
- if (sscanf(buff, "%lf%lf%lf", x, y, z) < 2)
|
|
|
- G_fatal_error(_("Error reading ASCII file: (bad point) [%s]"),
|
|
|
- buff);
|
|
|
+ if (sscanf(buff, "%lf%lf%lf", x, y, z) < 2) {
|
|
|
+ if (sscanf(buff, " %s %s %lf", east_str, north_str, z) < 2) {
|
|
|
+ G_fatal_error(_("Error reading ASCII file: (bad point) [%s]"),
|
|
|
+ buff);
|
|
|
+ } else {
|
|
|
+ if( ! G_scan_easting(east_str, x, G_projection()) )
|
|
|
+ G_fatal_error(_("Unparsable longitude value: [%s]"),
|
|
|
+ east_str);
|
|
|
+ if( ! G_scan_northing(north_str, y, G_projection()) )
|
|
|
+ G_fatal_error(_("Unparsable latitude value: [%s]"),
|
|
|
+ north_str);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
G_debug(5, "coor in: %s -> x = %f y = %f z = %f", G_chop(buff),
|
|
|
*x, *y, *z);
|