[GRASS-SVN] r56206 - grass/branches/develbranch_6/scripts/r.in.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 11 18:02:39 PDT 2013
Author: hamish
Date: 2013-05-11 18:02:39 -0700 (Sat, 11 May 2013)
New Revision: 56206
Modified:
grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms
grass/branches/develbranch_6/scripts/r.in.wms/wms.download
grass/branches/develbranch_6/scripts/r.in.wms/wms.request
Log:
quoting and whitespace cleanup
Modified: grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms 2013-05-11 20:12:16 UTC (rev 56205)
+++ grass/branches/develbranch_6/scripts/r.in.wms/r.in.wms 2013-05-12 01:02:39 UTC (rev 56206)
@@ -263,10 +263,10 @@
# usage: message level text
message () {
- if [ $1 -lt $GIS_OPT_V ] ; then
- shift
- echo "$@" 1>&2
- fi
+ if [ "$1" -lt "$GIS_OPT_V" ] ; then
+ shift
+ echo "$@" 1>&2
+ fi
}
#######################################################################
@@ -275,9 +275,9 @@
#
exitprocedure()
{
- g.message -e 'User break!'
- \rm -f "${TEMPFILE}"*
- exit 1
+ g.message -e 'User break!'
+ rm -f "$TEMPFILE"*
+ exit 1
}
trap "exitprocedure" 2 3 15
@@ -289,11 +289,11 @@
# purpose: make arguments for a sub command
#
addargument() {
- if [ -z "$3" ] ; then
- message 1 "Skipping argument for $2"
- else
- eval "$1=\"\$$1 '$2=$3'\""
- fi
+ if [ -z "$3" ] ; then
+ message 1 "Skipping argument for $2"
+ else
+ eval "$1=\"\$$1 '$2=$3'\""
+ fi
}
#######################################################################
@@ -301,9 +301,9 @@
# purpose: make arguments for a sub command
#
addflag() {
- if [ $3 -eq 1 ] ; then
- eval "$1=\"\$$1 -$2\""
- fi
+ if [ $3 -eq 1 ] ; then
+ eval "$1=\"\$$1 -$2\""
+ fi
}
######################
@@ -312,9 +312,9 @@
# usage: varname "expr"
calculate() {
- message 3 "$2"
- c_tmp=`echo "$2" | $BC $BCARGS`
- eval $1=$c_tmp
+ message 3 "$2"
+ c_tmp=`echo "$2" | "$BC" "$BCARGS"`
+ eval $1=$c_tmp
}
@@ -347,7 +347,7 @@
if [ ! -e "$CAPABILITIES_FILE" ] ; then
g.message -e "Downloading XML file"
- \rm "$TEMPFILE"
+ rm -f "$TEMPFILE"
exit 1
fi
@@ -375,13 +375,13 @@
if [ ! -e "$CAPABILITIES_FILE" ] ; then
g.message -e "Downloading XML file"
- \rm "$TEMPFILE"
+ rm -f "$TEMPFILE"
exit 1
fi
if [ `wc -c < "$CAPABILITIES_FILE"` -eq 0 ] ; then
g.message -e "Downloaded XML file was empty"
- \rm -f "$CAPABILITIES_FILE" "$TEMPFILE"
+ rm -f "$CAPABILITIES_FILE" "$TEMPFILE"
exit 1
fi
@@ -476,9 +476,9 @@
PREFIX="$GIS_OPT_OUTPUT"
if [ -x "`which wget`" ] ; then
- REQUESTFILE="${GIS_OPT_FOLDER}/${PREFIX}_${GIS_OPT_REGION}.wget"
+ REQUESTFILE="$GIS_OPT_FOLDER/${PREFIX}_$GIS_OPT_REGION.wget"
else
- REQUESTFILE="${GIS_OPT_FOLDER}/${PREFIX}_${GIS_OPT_REGION}.curl"
+ REQUESTFILE="$GIS_OPT_FOLDER/${PREFIX}_$GIS_OPT_REGION.curl"
fi
if [ ! -z "$GIS_OPT_REGION" ] ; then
@@ -494,21 +494,21 @@
LAYERS=`echo ${GIS_OPT_LAYERS} | sed -e 's/ /%20/g'`
-addflag REQUEST o ${GIS_FLAG_O}
-addflag REQUEST c ${GIS_FLAG_C}
-addflag REQUEST p ${GIS_FLAG_P}
-addargument REQUEST folder "${GIS_OPT_FOLDER}"
-addargument REQUEST prefix "${PREFIX}"
-addargument REQUEST region "${GIS_OPT_REGION}"
-addargument REQUEST mapserver "${GIS_OPT_MAPSERVER}"
-addargument REQUEST layers "${LAYERS}"
-addargument REQUEST styles "${GIS_OPT_STYLES}"
-addargument REQUEST srs "${GIS_OPT_SRS}"
-addargument REQUEST format "${GIS_OPT_FORMAT}"
-addargument REQUEST wmsquery "${GIS_OPT_WMSQUERY}"
-addargument REQUEST maxcols "${GIS_OPT_MAXCOLS}"
-addargument REQUEST maxrows "${GIS_OPT_MAXROWS}"
-addargument REQUEST tileoptions "${GIS_OPT_TILEOPTIONS}"
+addflag REQUEST o "$GIS_FLAG_O"
+addflag REQUEST c "$GIS_FLAG_C"
+addflag REQUEST p "$GIS_FLAG_P"
+addargument REQUEST folder "$GIS_OPT_FOLDER"
+addargument REQUEST prefix "$PREFIX"
+addargument REQUEST region "$GIS_OPT_REGION"
+addargument REQUEST mapserver "$GIS_OPT_MAPSERVER"
+addargument REQUEST layers "$LAYERS"
+addargument REQUEST styles "$GIS_OPT_STYLES"
+addargument REQUEST srs "$GIS_OPT_SRS"
+addargument REQUEST format "$GIS_OPT_FORMAT"
+addargument REQUEST wmsquery "$GIS_OPT_WMSQUERY"
+addargument REQUEST maxcols "$GIS_OPT_MAXCOLS"
+addargument REQUEST maxrows "$GIS_OPT_MAXROWS"
+addargument REQUEST tileoptions "$GIS_OPT_TILEOPTIONS"
if [ $GIS_FLAG_D -eq 0 ] ; then
message 1 "wms.request $REQUEST"
@@ -519,17 +519,18 @@
fi
fi
-addflag DOWNLOAD g ${GIS_FLAG_G}
-addargument DOWNLOAD requestfile "${REQUESTFILE}"
-addargument DOWNLOAD wgetoptions "${GIS_OPT_WGETOPTIONS}"
-addargument DOWNLOAD curloptions "${GIS_OPT_CURLOPTIONS}"
+addflag DOWNLOAD g "$GIS_FLAG_G"
+addargument DOWNLOAD requestfile "$REQUESTFILE"
+addargument DOWNLOAD wgetoptions "$GIS_OPT_WGETOPTIONS"
+addargument DOWNLOAD curloptions "$GIS_OPT_CURLOPTIONS"
message 1 "wms.download $DOWNLOAD"
eval "\"$GISBASE/etc/r.in.wms/wms.download\" $DOWNLOAD"
+
# Job 2: make list of files
-CONTENTS=`cat "${REQUESTFILE}"`
+CONTENTS=`cat "$REQUESTFILE"`
FILES=""
COUNT=0
@@ -544,19 +545,19 @@
done
addflag GDALWARP c 1
-addflag GDALWARP k ${GIS_FLAG_K}
-addflag GDALWARP p ${GIS_FLAG_P}
+addflag GDALWARP k "$GIS_FLAG_K"
+addflag GDALWARP p "$GIS_FLAG_P"
addargument GDALWARP input "$FILES"
-addargument GDALWARP output "${GIS_OPT_OUTPUT}"
-addargument GDALWARP method "${GIS_OPT_METHOD}"
-addargument GDALWARP s_srs "${GIS_OPT_SRS}"
+addargument GDALWARP output "$GIS_OPT_OUTPUT"
+addargument GDALWARP method "$GIS_OPT_METHOD"
+addargument GDALWARP s_srs "$GIS_OPT_SRS"
# check for error like 'Service Exception Report'
if [ `file -b "$FILES" | grep -c "^HTML\|^XML"` -eq 1 ] ; then
g.message "#################################"
cat "$FILES"
g.message message=""
- \rm -f "${TEMPFILE}"*
+ rm -f "$TEMPFILE"*
exit 1
fi
@@ -579,20 +580,20 @@
r.support map="$GIS_OPT_OUTPUT" history="layers: $GIS_OPT_LAYERS"
if [ -n "$GIS_OPT_STYLES" ] ; then
- r.support map="$GIS_OPT_OUTPUT" history="styles: $GIS_OPT_STYLES"
+ r.support map="$GIS_OPT_OUTPUT" history="styles: $GIS_OPT_STYLES"
fi
r.support map="$GIS_OPT_OUTPUT" history=""
r.support map="$GIS_OPT_OUTPUT" history="Source projection: $GIS_OPT_SRS"
if [ "$GIS_FLAG_P" -eq 1 ] ; then
- r.support map="$GIS_OPT_OUTPUT" history=" (imported without reprojection)"
+ r.support map="$GIS_OPT_OUTPUT" history=" (imported without reprojection)"
fi
r.support map="$GIS_OPT_OUTPUT" description="generated by r.in.wms" history=""
r.support map="$GIS_OPT_OUTPUT" history="$CMDLINE"
-g.message -v message="Map <${GIS_OPT_OUTPUT}> written"
+g.message -v message="Map <$GIS_OPT_OUTPUT> written"
# Clean up:
-\rm -f "${TEMPFILE}"*
+rm -f "$TEMPFILE"*
exit
Modified: grass/branches/develbranch_6/scripts/r.in.wms/wms.download
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.wms/wms.download 2013-05-11 20:12:16 UTC (rev 56205)
+++ grass/branches/develbranch_6/scripts/r.in.wms/wms.download 2013-05-12 01:02:39 UTC (rev 56206)
@@ -58,7 +58,7 @@
fi
if [ "$1" != "@ARGS_PARSED@" ] ; then
- exec g.parser "$0" "$@"
+ exec g.parser "$0" "$@"
fi
g.message -d "[wms.download]"
@@ -92,7 +92,7 @@
exitprocedure()
{
g.message -e 'User break!'
- rm -f "${TEMPFILE}"*
+ rm -f "$TEMPFILE"*
exit 1
}
trap "exitprocedure" 2 3 15
@@ -106,9 +106,9 @@
# usage: varname "expr"
calculate() {
- g.message message="$2"
- c_tmp=`echo "$2" | $BC $BCARGS`
- eval $1=$c_tmp
+ g.message message="$2"
+ c_tmp=`echo "$2" | $BC $BCARGS`
+ eval $1=$c_tmp
}
################################################################
@@ -123,7 +123,7 @@
POST_DATA_OK=0
fi
- CONTENTS=`cat "${REQUESTFILE}"`
+ CONTENTS=`cat "$REQUESTFILE"`
NUMBER_OF_TILES=0
for line in $CONTENTS ; do
@@ -186,9 +186,9 @@
if [ "$POST_DATA_OK" -eq 0 ] ; then
g.message -v message=""
if [ "$USE_WGET" ] ; then
- wget ${WGET_OPTIONS} "${SERVER}?${STRING}" -O "${OUTPUT_FILE}"
+ wget $WGET_OPTIONS "${SERVER}?${STRING}" -O "$OUTPUT_FILE"
else
- curl ${CURL_OPTIONS} -o "${OUTPUT_FILE}" "${SERVER}?${STRING}"
+ curl $CURL_OPTIONS -o "$OUTPUT_FILE" "${SERVER}?${STRING}"
fi
if [ $? -ne 0 ] ; then
g.message -e "Failed while downloading the data"
@@ -205,13 +205,13 @@
# Initialize variables:
#wget has many options
-WGET_OPTIONS="${GIS_OPT_WGETOPTIONS}"
-CURL_OPTIONS="${GIS_OPT_CURLOPTIONS}"
-REQUESTFILE="${GIS_OPT_REQUESTFILE}"
+WGET_OPTIONS="$GIS_OPT_WGETOPTIONS"
+CURL_OPTIONS="$GIS_OPT_CURLOPTIONS"
+REQUESTFILE="$GIS_OPT_REQUESTFILE"
#Get all the data
GetTiles
# Clean up:
-rm -f "${TEMPFILE}"*
+rm -f "$TEMPFILE"*
Modified: grass/branches/develbranch_6/scripts/r.in.wms/wms.request
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.wms/wms.request 2013-05-11 20:12:16 UTC (rev 56205)
+++ grass/branches/develbranch_6/scripts/r.in.wms/wms.request 2013-05-12 01:02:39 UTC (rev 56206)
@@ -143,10 +143,10 @@
# usage: message level text
message () {
- if [ $1 -lt $GIS_OPT_V ] ; then
- shift
- echo "$@"
- fi
+ if [ "$1" -lt "$GIS_OPT_V" ] ; then
+ shift
+ echo "$@"
+ fi
}
@@ -159,9 +159,9 @@
# usage: varname "expr"
calculate() {
- message 3 "$2"
- c_tmp=`echo "$2" | $BC $BCARGS`
- eval $1=$c_tmp
+ message 3 "$2"
+ c_tmp=`echo "$2" | "$BC" "$BCARGS"`
+ eval $1=$c_tmp
}
####################################
@@ -173,8 +173,8 @@
#################################################
# ############## TILE SETTINGS ################ #
#################################################
- MAXCOLS=${GIS_OPT_MAXCOLS} #The maximum cols of the biggest tile
- MAXROWS=${GIS_OPT_MAXROWS} #The maximum rows of the biggest tile
+ MAXCOLS="$GIS_OPT_MAXCOLS" #The maximum cols of the biggest tile
+ MAXROWS="$GIS_OPT_MAXROWS" #The maximum rows of the biggest tile
#Calculate the number of tiles and set up the arrays
@@ -188,10 +188,10 @@
NUMBER_OF_TILES=0 #The number of the tiles
#Calculate the number of tiles
for i in $TILES ; do
- NUMBER_OF_TILES=`expr $NUMBER_OF_TILES + 1`
+ NUMBER_OF_TILES=`expr "$NUMBER_OF_TILES" + 1`
done
- g.message "Requesting ${NUMBER_OF_TILES} tiles."
+ g.message "Requesting $NUMBER_OF_TILES tiles."
if [ "$NUMBER_OF_TILES" -gt 200 ] ; then
g.message -w "Proceed with care. This number of tiles may exceed \
the maximum command line argument length available from your \
@@ -202,9 +202,9 @@
NUMBER_OF_TILES=0 #The number of the tiles
- mkdir -p "${GIS_OPT_FOLDER}"
+ mkdir -p "$GIS_OPT_FOLDER"
- FOLDERPLUS="${GIS_OPT_FOLDER}/${GIS_OPT_PREFIX}_${GIS_OPT_REGION}"
+ FOLDERPLUS="$GIS_OPT_FOLDER/${GIS_OPT_PREFIX}_$GIS_OPT_REGION"
if [ $GIS_FLAG_C -eq 1 ] ; then
g.message -v message="Removing files <${FOLDERPLUS}*>"
@@ -212,21 +212,21 @@
fi
if [ -x "`which wget`" ] ; then
- REQUESTFILE="${FOLDERPLUS}.wget"
+ REQUESTFILE="$FOLDERPLUS.wget"
else
- REQUESTFILE="${FOLDERPLUS}.curl"
+ REQUESTFILE="$FOLDERPLUS.curl"
fi
#reset the requestfile
- echo > "${REQUESTFILE}"
+ echo > "$REQUESTFILE"
- echo "$PROJ4_SRS" > "${FOLDERPLUS}.proj4"
+ echo "$PROJ4_SRS" > "$FOLDERPLUS.proj4"
for i in $TILES ; do
eval "$i"
SIZE="bbox=$w,$s,$e,$n&width=$cols&height=$rows"
message 1 "$SIZE"
- IMAGEFILE="${FOLDERPLUS}_${NUMBER_OF_TILES}"
+ IMAGEFILE="${FOLDERPLUS}_$NUMBER_OF_TILES"
OUTPUT_FILE="${IMAGEFILE}${FILE_EXTENT}"
# We could add world files here to help out gdalwarp.
# And here it is:
@@ -247,17 +247,17 @@
STRING="request=GetMap&layers=${GIS_OPT_LAYERS}&styles=${GIS_OPT_STYLES}&srs=${SRS}&${SIZE}&format=${FORMAT}&${TRANSPARENCY}&${WMS_QUERY}"
echo "OUTPUT_FILE=\"${OUTPUT_FILE}\";SERVER=\"${SERVER}\";STRING=\"${STRING}\"" >> "${REQUESTFILE}"
- NUMBER_OF_TILES=`expr $NUMBER_OF_TILES + 1`
+ NUMBER_OF_TILES=`expr "$NUMBER_OF_TILES" + 1`
done
}
# Initialize variables:
-SERVER="${GIS_OPT_MAPSERVER}"
-SRS="${GIS_OPT_SRS}"
+SERVER="$GIS_OPT_MAPSERVER"
+SRS="$GIS_OPT_SRS"
# use `tr '[:upper:]' '[:lower:]'` instead?
-SRS_lower=`echo $SRS | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"`
+SRS_lower=`echo "$SRS" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"`
# If the user asserts that this projection is the same as the source
@@ -279,7 +279,7 @@
SRS_SCALE=1
fi
-WMS_QUERY="${GIS_OPT_WMSQUERY}"
+WMS_QUERY="$GIS_OPT_WMSQUERY"
if [ -z "$GIS_OPT_REGION" ] ; then
TILESET_OPTIONS="$GIS_OPT_TILEOPTIONS"
@@ -287,13 +287,13 @@
TILESET_OPTIONS="region=$GIS_OPT_REGION $GIS_OPT_TILEOPTIONS"
fi
-if [ $GIS_FLAG_O -eq 1 ] ; then
+if [ "$GIS_FLAG_O" -eq 1 ] ; then
TRANSPARENCY="transparent=FALSE"
else
TRANSPARENCY="transparent=TRUE"
fi
-case "${GIS_OPT_FORMAT}" in
+case "$GIS_OPT_FORMAT" in
"geotiff") FORMAT="image/geotiff"
WORLDFILE=".tfw"
FILE_EXTENT=".geotiff"
More information about the grass-commit
mailing list