[GRASS-SVN] r73641 - sandbox/wenzeslaus/r.mapcalculator

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 4 19:16:21 PST 2018


Author: wenzeslaus
Date: 2018-11-04 19:16:21 -0800 (Sun, 04 Nov 2018)
New Revision: 73641

Added:
   sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.html
   sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.py
Removed:
   sandbox/wenzeslaus/r.mapcalculator/description.html
   sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator
Log:
r.mapcalculator: v7 dir structure

Deleted: sandbox/wenzeslaus/r.mapcalculator/description.html
===================================================================
--- sandbox/wenzeslaus/r.mapcalculator/description.html	2018-11-05 03:14:34 UTC (rev 73640)
+++ sandbox/wenzeslaus/r.mapcalculator/description.html	2018-11-05 03:16:21 UTC (rev 73641)
@@ -1,43 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>r.mapcalculator</em> provides a GUI frontend to <em>r.mapcalc</em>.
-Up to 5 maps can be combined using simple expressions.
-In the expert mode, it runs <em>r.mapcalc</em> for more complex expressions.
-
-Enter an <em>r.mapcalc</em> expression in the formula field using the
-format:<br>
-<tt>A+B</tt> or <tt>exp(A+C)+(B-2)*7</tt> where A, B, C are raster maps
-entered in the A field, B field, and C field. 
-<p>
-Do not enter output file in the formula field, hence:
-<ul>
-<li>correct: <tt>A+B</tt></li>
-<li>incorrect: <tt>newfile = A+B</tt></li>
-<li>Use no spaces or blanks.</li>
-</ul>
-
-<p>
-The expert mode runs <em>r.mapcalc</em> for more complex expressions.
-
-<h2>EXAMPLES</h2>
-
-<div class="code"><pre>
-A+B
-</pre></div>
-
-<p>
-<div class="code"><pre>
-exp(A+C)+(B-2)*7
-</pre></div>
-
-<h2>SEE ALSO</h2>
-
-<em><a href="r.mapcalc.html">r.mapcalc</a></em>
-
-
-<h2>AUTHOR</h2>
-
-R. Brunzema (r.brunzema at web.de)<br>
-Updated to GRASS 5.7 by Michael Barton, Arizona State University
-
-<p><i>Last changed: $Date$</i>

Deleted: sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator
===================================================================
--- sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator	2018-11-05 03:14:34 UTC (rev 73640)
+++ sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator	2018-11-05 03:16:21 UTC (rev 73641)
@@ -1,203 +0,0 @@
-#!/bin/sh
-############################################################################
-#
-# MODULE:	r.mapcalculator v.1.0 for GRASS 5.7 (2004/05/15)
-#		based on mapcalculator.sh for GRASS 5
-# AUTHOR(S):	R. Brunzema (r.brunzema at web.de);
-#		updated to GRASS 5.7 by Michael Barton (michael.barton at asu.edu)
-#		removed bashism by Huidae Cho (grass4u at gmail.com)
-# PURPOSE:	Provides GUI front-end to r.mapcalc
-# COPYRIGHT:	(C) 2004 by the GRASS Development Team
-#
-#		This program is free software under the GNU General Public
-#		License (>=v2). Read the file COPYING that comes with GRASS
-#		for details.
-#
-#############################################################################
-
-#%Module
-#% description: Calculate new raster map from a r.mapcalc expression.
-#%End
-#%option
-#% key: amap
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: A
-#% required : no
-#%end
-#%option
-#% key: bmap
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: B
-#% required : no
-#%end
-#%option
-#% key: cmap
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: C
-#% required : no
-#%end
-#%option
-#% key: dmap
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: D
-#% required : no
-#%end
-#%option
-#% key: emap
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: E
-#% required : no
-#%end
-#%option
-#% key: fmap
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: F
-#% required : no
-#%end
-#%option
-#% key: formula
-#% type: string
-#% description: Formula (e.g. A-B or A*C+B)
-#% required : yes
-#%end
-#%option
-#% key: outfile
-#% type: string
-#% gisprompt: new,cell,raster
-#% description: Name for output raster map
-#% required : yes
-#%end
-#%option
-#% key: help
-#% type: string
-#% description: Show help
-#% options: -,help,man
-#% answer: -
-#% required : no
-#%end
-#%flag
-#% key: e
-#% description: Expert mode (enter a set of r.mapcalc expressions)
-#%end
-#%flag
-#% key: o
-#% description: Do not overwrite existing map
-#%end
-
-
-display_help(){
-	echo "" >&2
-	echo "BRIEF HELP" >&2
-	echo "" >&2
-	echo "Enter an r.mapcalc expression in the" >&2
-	echo "formula field using this format:" >&2
-	echo "A+C or (more complex:) exp(A+C)+(B-2)*7" >&2
-	echo "Where A, B, C are raster maps entered" >&2
-	echo "in the A field, B field, and C field." >&2
-	echo "" >&2
-	echo "Do not enter output file in the formula field:" >&2
-	echo "Correct: A+B" >&2
-	echo "Incorrect: newfile = A+B" >&2
-	echo "Use no blanks!" >&2
-	echo "" >&2
-	echo "For details on creating an r.mapcalc expression," >&2
-	echo "select 'man' in the help field to see the r.mapcalc manual page" >&2
-	echo "(or type g.manual r.mapcalc from the command line)." >&2
-}
-
-if  [ -z "$GISBASE" ]
-then
-	echo "You must be in GRASS GIS to run this program" >&2
-	exit 1
-fi
-
-if   [ "$1" != "@ARGS_PARSED@" ]
-then
-	exec g.parser "$0" "$@"
-fi
-
-case $GIS_OPT_HELP in
-	help)
-	display_help
-	exit 0
-	;;
-	man)
-	g.manual r.mapcalc
-	exit
-	;;
-esac
-
-# use old style mapcalc
-
-if [ "$GIS_FLAG_E" = 1 ] ; then
-	exec "$GISBASE/etc/grass-xterm-wrapper" -e r.mapcalc &
-	exit
-fi
-
-
-# Check for required arguments
-if [ -z "$GIS_OPT_FORMULA" ]; then
-	g.message -e message='Missing formula!'
-	g.message -e "Please enter a formula in the field formula"
-	exit 1
-fi
-
-if [ -z "$GIS_OPT_OUTFILE" ]; then
-	g.message -e message='Missing name of outputfile!'
-	g.message -e "Please enter a name for the resulting map and try again."
-	exit 1
-elif [ "$GIS_FLAG_O" = 1 ]; then
-	echo `g.list type=rast | grep -w "$GIS_OPT_OUTFILE" `
-	outtest=`g.list type=rast | grep -w $GIS_OPT_OUTFILE`
-	if [ -n "$outtest" ]; then
-		g.message -e "File $GIS_OPT_OUTFILE exists. Exiting."
-		exit 0
-	fi
-fi
-
-# replace map names: two passes are needed to make sure that sed parses all map
-# names. e.g., A+B => amap+B => amap+bmap
-command=`
-echo "(${GIS_OPT_FORMULA})" | sed \
-	-e "s/\([^a-zA-Z0-9]\)A\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_AMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)A\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_AMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)B\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_BMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)B\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_BMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)C\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_CMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)C\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_CMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)D\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_DMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)D\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_DMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)E\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_EMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)E\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_EMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)F\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_FMAP\" \2/g" \
-	-e "s/\([^a-zA-Z0-9]\)F\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_FMAP\" \2/g"
-`
-
-if [ -z "$GRASS_VERBOSE" ] ; then
-   GRASS_VERBOSE=2   # default
-fi
-
-if [ "$GRASS_VERBOSE" -ge 1 ] ; then
-    # Show the resulting commandline
-    g.message message="r.mapcalc \"$GIS_OPT_OUTFILE\" = \"$command\""
-fi
-
-r.mapcalc "$GIS_OPT_OUTFILE" = "$command" # Start the command
-
-# Check for errors
-if [ $? -ne 0 ]; then
-    g.message -e "Calculating $GIS_OPT_OUTFILE. Try expert mode."
-    exit 1
-fi
-
-if [ "$GRASS_VERBOSE" -ge 2 ] ; then
-    g.message "Done."
-fi
-
-exit 0

Copied: sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.html (from rev 73640, sandbox/wenzeslaus/r.mapcalculator/description.html)
===================================================================
--- sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.html	                        (rev 0)
+++ sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.html	2018-11-05 03:16:21 UTC (rev 73641)
@@ -0,0 +1,43 @@
+<h2>DESCRIPTION</h2>
+
+<em>r.mapcalculator</em> provides a GUI frontend to <em>r.mapcalc</em>.
+Up to 5 maps can be combined using simple expressions.
+In the expert mode, it runs <em>r.mapcalc</em> for more complex expressions.
+
+Enter an <em>r.mapcalc</em> expression in the formula field using the
+format:<br>
+<tt>A+B</tt> or <tt>exp(A+C)+(B-2)*7</tt> where A, B, C are raster maps
+entered in the A field, B field, and C field. 
+<p>
+Do not enter output file in the formula field, hence:
+<ul>
+<li>correct: <tt>A+B</tt></li>
+<li>incorrect: <tt>newfile = A+B</tt></li>
+<li>Use no spaces or blanks.</li>
+</ul>
+
+<p>
+The expert mode runs <em>r.mapcalc</em> for more complex expressions.
+
+<h2>EXAMPLES</h2>
+
+<div class="code"><pre>
+A+B
+</pre></div>
+
+<p>
+<div class="code"><pre>
+exp(A+C)+(B-2)*7
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em><a href="r.mapcalc.html">r.mapcalc</a></em>
+
+
+<h2>AUTHOR</h2>
+
+R. Brunzema (r.brunzema at web.de)<br>
+Updated to GRASS 5.7 by Michael Barton, Arizona State University
+
+<p><i>Last changed: $Date$</i>

Copied: sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.py (from rev 73640, sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator)
===================================================================
--- sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.py	                        (rev 0)
+++ sandbox/wenzeslaus/r.mapcalculator/r.mapcalculator.py	2018-11-05 03:16:21 UTC (rev 73641)
@@ -0,0 +1,203 @@
+#!/bin/sh
+############################################################################
+#
+# MODULE:	r.mapcalculator v.1.0 for GRASS 5.7 (2004/05/15)
+#		based on mapcalculator.sh for GRASS 5
+# AUTHOR(S):	R. Brunzema (r.brunzema at web.de);
+#		updated to GRASS 5.7 by Michael Barton (michael.barton at asu.edu)
+#		removed bashism by Huidae Cho (grass4u at gmail.com)
+# PURPOSE:	Provides GUI front-end to r.mapcalc
+# COPYRIGHT:	(C) 2004 by the GRASS Development Team
+#
+#		This program is free software under the GNU General Public
+#		License (>=v2). Read the file COPYING that comes with GRASS
+#		for details.
+#
+#############################################################################
+
+#%Module
+#% description: Calculate new raster map from a r.mapcalc expression.
+#%End
+#%option
+#% key: amap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: A
+#% required : no
+#%end
+#%option
+#% key: bmap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: B
+#% required : no
+#%end
+#%option
+#% key: cmap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: C
+#% required : no
+#%end
+#%option
+#% key: dmap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: D
+#% required : no
+#%end
+#%option
+#% key: emap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: E
+#% required : no
+#%end
+#%option
+#% key: fmap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: F
+#% required : no
+#%end
+#%option
+#% key: formula
+#% type: string
+#% description: Formula (e.g. A-B or A*C+B)
+#% required : yes
+#%end
+#%option
+#% key: outfile
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: Name for output raster map
+#% required : yes
+#%end
+#%option
+#% key: help
+#% type: string
+#% description: Show help
+#% options: -,help,man
+#% answer: -
+#% required : no
+#%end
+#%flag
+#% key: e
+#% description: Expert mode (enter a set of r.mapcalc expressions)
+#%end
+#%flag
+#% key: o
+#% description: Do not overwrite existing map
+#%end
+
+
+display_help(){
+	echo "" >&2
+	echo "BRIEF HELP" >&2
+	echo "" >&2
+	echo "Enter an r.mapcalc expression in the" >&2
+	echo "formula field using this format:" >&2
+	echo "A+C or (more complex:) exp(A+C)+(B-2)*7" >&2
+	echo "Where A, B, C are raster maps entered" >&2
+	echo "in the A field, B field, and C field." >&2
+	echo "" >&2
+	echo "Do not enter output file in the formula field:" >&2
+	echo "Correct: A+B" >&2
+	echo "Incorrect: newfile = A+B" >&2
+	echo "Use no blanks!" >&2
+	echo "" >&2
+	echo "For details on creating an r.mapcalc expression," >&2
+	echo "select 'man' in the help field to see the r.mapcalc manual page" >&2
+	echo "(or type g.manual r.mapcalc from the command line)." >&2
+}
+
+if  [ -z "$GISBASE" ]
+then
+	echo "You must be in GRASS GIS to run this program" >&2
+	exit 1
+fi
+
+if   [ "$1" != "@ARGS_PARSED@" ]
+then
+	exec g.parser "$0" "$@"
+fi
+
+case $GIS_OPT_HELP in
+	help)
+	display_help
+	exit 0
+	;;
+	man)
+	g.manual r.mapcalc
+	exit
+	;;
+esac
+
+# use old style mapcalc
+
+if [ "$GIS_FLAG_E" = 1 ] ; then
+	exec "$GISBASE/etc/grass-xterm-wrapper" -e r.mapcalc &
+	exit
+fi
+
+
+# Check for required arguments
+if [ -z "$GIS_OPT_FORMULA" ]; then
+	g.message -e message='Missing formula!'
+	g.message -e "Please enter a formula in the field formula"
+	exit 1
+fi
+
+if [ -z "$GIS_OPT_OUTFILE" ]; then
+	g.message -e message='Missing name of outputfile!'
+	g.message -e "Please enter a name for the resulting map and try again."
+	exit 1
+elif [ "$GIS_FLAG_O" = 1 ]; then
+	echo `g.list type=rast | grep -w "$GIS_OPT_OUTFILE" `
+	outtest=`g.list type=rast | grep -w $GIS_OPT_OUTFILE`
+	if [ -n "$outtest" ]; then
+		g.message -e "File $GIS_OPT_OUTFILE exists. Exiting."
+		exit 0
+	fi
+fi
+
+# replace map names: two passes are needed to make sure that sed parses all map
+# names. e.g., A+B => amap+B => amap+bmap
+command=`
+echo "(${GIS_OPT_FORMULA})" | sed \
+	-e "s/\([^a-zA-Z0-9]\)A\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_AMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)A\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_AMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)B\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_BMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)B\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_BMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)C\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_CMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)C\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_CMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)D\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_DMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)D\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_DMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)E\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_EMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)E\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_EMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)F\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_FMAP\" \2/g" \
+	-e "s/\([^a-zA-Z0-9]\)F\([^a-zA-Z0-9]\)/\1 \"$GIS_OPT_FMAP\" \2/g"
+`
+
+if [ -z "$GRASS_VERBOSE" ] ; then
+   GRASS_VERBOSE=2   # default
+fi
+
+if [ "$GRASS_VERBOSE" -ge 1 ] ; then
+    # Show the resulting commandline
+    g.message message="r.mapcalc \"$GIS_OPT_OUTFILE\" = \"$command\""
+fi
+
+r.mapcalc "$GIS_OPT_OUTFILE" = "$command" # Start the command
+
+# Check for errors
+if [ $? -ne 0 ]; then
+    g.message -e "Calculating $GIS_OPT_OUTFILE. Try expert mode."
+    exit 1
+fi
+
+if [ "$GRASS_VERBOSE" -ge 2 ] ; then
+    g.message "Done."
+fi
+
+exit 0



More information about the grass-commit mailing list