[GRASS-SVN] r39647 - grass/branches/develbranch_6/scripts/m.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 30 08:17:45 EDT 2009


Author: neteler
Date: 2009-10-30 08:17:45 -0400 (Fri, 30 Oct 2009)
New Revision: 39647

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

Modified: grass/branches/develbranch_6/scripts/m.proj/m.proj
===================================================================
--- grass/branches/develbranch_6/scripts/m.proj/m.proj	2009-10-30 12:13:40 UTC (rev 39646)
+++ grass/branches/develbranch_6/scripts/m.proj/m.proj	2009-10-30 12:17:45 UTC (rev 39647)
@@ -79,6 +79,10 @@
 #% description: Include input coordinates in output file
 #%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
@@ -245,18 +249,37 @@
 # 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 $COPYINP $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 $COPYINP $OUTFMT $IN_PROJ +to $OUT_PROJ | tr -s "\t" "$GIS_OPT_FS" | tr -s " " "$GIS_OPT_FS"
+      EXITCODE=$?
+   else
+      cat "$infile" | tr "$fs" ' ' | cs2cs $COPYINP $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 $COPYINP $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 $COPYINP $OUTFMT $IN_PROJ +to $OUT_PROJ
+      EXITCODE=$?
+   else
+      cat "$infile" | tr "$fs" ' ' | cs2cs $COPYINP $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
 
 if [ $EXITCODE -ne 0 ] ; then



More information about the grass-commit mailing list