[GRASS-SVN] r39646 - grass/branches/releasebranch_6_4/scripts/m.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 30 08:13:41 EDT 2009


Author: neteler
Date: 2009-10-30 08:13:40 -0400 (Fri, 30 Oct 2009)
New Revision: 39646

Modified:
   grass/branches/releasebranch_6_4/scripts/m.proj/m.proj
Log:
restored default strange formatting and added correct output formatting as flag

Modified: grass/branches/releasebranch_6_4/scripts/m.proj/m.proj
===================================================================
--- grass/branches/releasebranch_6_4/scripts/m.proj/m.proj	2009-10-29 10:41:59 UTC (rev 39645)
+++ grass/branches/releasebranch_6_4/scripts/m.proj/m.proj	2009-10-30 12:13:40 UTC (rev 39646)
@@ -71,6 +71,10 @@
 #% description: Output long/lat in decimal degrees or other projections with many decimal places
 #%end
 #%flag
+#% key: g
+#% description: Script style output in CSV format respecting the field separator settings
+#%end
+#%flag
 #% key: v
 #% description: Verbose mode (print projection parameters and filenames to stderr)
 #%end
@@ -229,16 +233,33 @@
 # Convert cs2cs DMS format to GRASS DMS format:
 #   cs2cs | sed -e 's/d/:/g' -e "s/'/:/g"  -e 's/"//g'
 
-if [ -z "$outfile" ] ; then
-   cat "$infile" | tr "$fs" ' ' | cs2cs $OUTFMT $IN_PROJ +to $OUT_PROJ | tr -s "\t" "$GIS_OPT_FS" | tr -s " " "$GIS_OPT_FS"
-   EXITCODE=$?
+# reformat strange cs2cs output to pretty CSV format
+if [ "$GIS_FLAG_G" -eq 1 ] ; then
+   if [ -z "$outfile" ] ; then
+      cat "$infile" | tr "$fs" ' ' | cs2cs $OUTFMT $IN_PROJ +to $OUT_PROJ | tr -s "\t" "$GIS_OPT_FS" | tr -s " " "$GIS_OPT_FS"
+      EXITCODE=$?
+   else
+      cat "$infile" | tr "$fs" ' ' | cs2cs $OUTFMT $IN_PROJ +to $OUT_PROJ | tr -s "\t" "$GIS_OPT_FS" | tr -s " " "$GIS_OPT_FS" > "$outfile"
+      EXITCODE=$?
+
+      #### check if transform REALLY worked (e.g. bogus output if grid file not found)
+      if [ -n "`head -n 1 "$outfile" | grep '^\*'`" ] ; then
+         EXITCODE=1
+      fi
+   fi
 else
-   cat "$infile" | tr "$fs" ' ' | cs2cs $OUTFMT $IN_PROJ +to $OUT_PROJ | tr -s "\t" "$GIS_OPT_FS" | tr -s " " "$GIS_OPT_FS" > "$outfile"
-   EXITCODE=$?
+   # write cs2cs output as is
+   if [ -z "$outfile" ] ; then
+      cat "$infile" | tr "$fs" ' ' | cs2cs $OUTFMT $IN_PROJ +to $OUT_PROJ
+      EXITCODE=$?
+   else
+      cat "$infile" | tr "$fs" ' ' | cs2cs $OUTFMT $IN_PROJ +to $OUT_PROJ > "$outfile"
+      EXITCODE=$?
 
-   #### check if transform REALLY worked (e.g. bogus output if grid file not found)
-   if [ -n "`head -n 1 "$outfile" | grep '^\*'`" ] ; then
-      EXITCODE=1
+      #### check if transform REALLY worked (e.g. bogus output if grid file not found)
+      if [ -n "`head -n 1 "$outfile" | grep '^\*'`" ] ; then
+         EXITCODE=1
+      fi
    fi
 fi
 



More information about the grass-commit mailing list