[GRASS-SVN] r45879 -
grass/branches/releasebranch_6_4/scripts/v.in.mapgen
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 8 23:58:53 EDT 2011
Author: hamish
Date: 2011-04-08 20:58:52 -0700 (Fri, 08 Apr 2011)
New Revision: 45879
Modified:
grass/branches/releasebranch_6_4/scripts/v.in.mapgen/v.in.mapgen
Log:
bugfix: work without decimal points in matlab mode;
skip commented and blank lines;
use %.15g instead of %.8f
(merge from devbr6 r45789)
Modified: grass/branches/releasebranch_6_4/scripts/v.in.mapgen/v.in.mapgen
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.in.mapgen/v.in.mapgen 2011-04-09 03:51:54 UTC (rev 45878)
+++ grass/branches/releasebranch_6_4/scripts/v.in.mapgen/v.in.mapgen 2011-04-09 03:58:52 UTC (rev 45879)
@@ -124,14 +124,16 @@
# $1~/ .*/ { printf(" %lf %lf\n", $2, $1) ; ++R }
# $1~/END/ { }' | tac > "$TMPFILE"
- ## matlab format. Cleanse with NaN->nan and spaces to tabs
- tac "$FILE" | awk '{print $1 "\t" $2 "\t" $3}
+ ## matlab format. Cleanse with NaN->nan and spaces to tabs,
+ ## and skip blank and comment lines
+ grep -v '^#\|^$' "$FILE" | tac | awk '
+ {print $1 "\t" $2 "\t" $3}
END {if ($3~/[0-9Nna]/) print "NaN\tNaN\tNaN"
else print "NaN\tNaN"}' | \
tr 'N' 'n' | awk '
BEGIN { FS="\t" ; R=0 }
- $1~/nan.*/ { printf("L %d\n", R) ; R=0 }
- $1~/\d*\.\d*/ { printf(" %.8f %.8f %.8f\n", $1, $2, $3) ; ++R }
+ $1~/nan.*/ { printf("L %d\n", R) ; R=0 ; next }
+ $1~/\d*\d*/ { printf(" %.15g %.15g %.15g\n", $1, $2, $3) ; ++R }
END {;}' | \
grep -v "^L 0$" | tac > "$TMPFILE"
More information about the grass-commit
mailing list