[GRASS-dev] Re: [grass-code I][394] scripts using g.message
fail if message contains "="
Hamish
hamish_nospam at yahoo.com
Wed May 9 07:02:53 EDT 2007
Markus Neteler wrote:
> I observed a similar problem in my new v.in.wfs script
> (get from http://mpa.itc.it/markus/grass63/): The WFS URL is
> disliked by g.parser. I worked around this with ugly hacks but
> I think that we need a new parameter type which accepts chars
> such as '=', '&' and so forth. I used file,file,file in v.in.wfs
> but would prefer something else.
It works fine for me with the attached changes.
* you can't use g.message outside of grass;
## g.message "..." >&2 ## is redundant
* be pedantic about quoting
G63> ./v.in.wfs \
wfs="http://mapserver.gdf-hannover.de/cgi-bin/grassuserwfs?REQUEST=GetF\
eature&SERVICE=WFS&VERSION=1.0.0" out=wfs_test
Over-riding projection check.
Proceeding with import...
Layer: myns:GRASS_users
WARNING: Column name changed: 'myns:ogc_fid' -> 'myns_ogc_fid'
WARNING: Column name changed: 'myns:name' -> 'myns_name'
WARNING: Width for column 'myns_name' set to 255 (was not specified by
OGR), some strings may be truncated!
WARNING: Column name changed: 'myns:company' -> 'myns_company'
WARNING: Width for column 'myns_company' set to 255 (was not specified
by OGR), some strings may be truncated!
Importing map 786 features...
-----------------------------------------------------
Building topology ...
786 primitives registered
Building areas: 100%
0 areas built
0 isles built
Attaching islands:
Attaching centroids: 100%
Topology was built.
Number of nodes : 784
Number of primitives: 786
Number of points : 786
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0
Vector points map <wfs_test> imported from WFS.
#silly test
G63> v.db.select wfs_test where="myns_name ~ 'Markus'"
cat|myns_ogc_f|myns_name|myns_compa
676|2|Markus Neteler|ITC-irst (Povo)
722|201|Markus Spring|RGU München
723|202|Markus Spring|RGU München
G63> d.vect wfs_test cat=676 col=green width=2
We should (finally) add a flag to v.db.select to allow output of x,y,z
info, or probably better* add to v.out.ascii where= and column(s)=
options to output DB values. There is my v.out.ascii.db, but it's a
slow hack.
[*] single cat can be linked to multiple vector features
Hamish
-------------- next part --------------
--- v.in.wfs.ORIGINAL 2007-05-09 22:23:14.000000000 +1200
+++ v.in.wfs 2007-05-09 22:39:52.000000000 +1200
@@ -20,66 +20,53 @@
#%End
#%option
#% key: wfs
-#% gisprompt: file,file,file
#% type: string
#% description: GetFeature URL starting with http
-#% required : no
#%End
#%option
#% key: output
#% type: string
#% gisprompt: new,vector,vector
-#% description: vector output map
+#% description: Vector output map
#% required : yes
#%End
if [ -z "$GISBASE" ] ; then
- g.message -e "You must be in GRASS GIS to run this program."
- exit 1
+ echo "You must be in GRASS GIS to run this program." 1>&2
+ exit 1
fi
-
-
if [ "$1" != "@ARGS_PARSED@" ] ; then
- CMDLINE="`basename $0`"
- for arg in "$@" ; do
- CMDLINE="$CMDLINE \"$arg\""
- done
- export CMDLINE
- # $2 is a dirty hack:
- exec g.parser "$0" "$2"
+ exec g.parser "$0" "$@"
fi
-PROG=`basename $0`
-
# xerces support compiled in?
OGRINFO=`which ogrinfo`
-if [ "`ldd $OGRINFO | grep xerces`" = "" ] ; then
+if [ -z "`ldd $OGRINFO | grep xerces`" ] ; then
g.message -e "OGR needs to be compiled with xerces-c support"
exit 1
fi
#### check if we have lynx
if [ ! -x "`which lynx`" ] ; then
- g.message -e "$PROG: lynx required, please install first" 2>&1
+ g.message -e "'lynx' is required, please install first"
exit 1
fi
TMP="`g.tempfile pid=$$`"
if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
- g.message -e "Unable to create temporary files" 1>&2
+ g.message -e "Unable to create temporary files"
exit 1
fi
OUT=$GIS_OPT_output
+WFS_URL="$GIS_OPT_WFS"
+
+g.message "Retrieving data ..."
+lynx -dump "$WFS_URL" > "$TMP.xml"
-# hack the hack
-WFS="`echo $CMDLINE | cut -d' ' -f2 | cut -d'=' -f2- | tr -s '"' ' '`"
-WFS="`echo $WFS | sed 's+ $++g'`"
-
-lynx -dump "$WFS" > $TMP.xml
-
-v.in.ogr dsn=$TMP.xml out=$OUT -o
-rm -f $TMP.xml
-g.message "Vector points map <$OUT> imported from WFS"
+v.in.ogr dsn="$TMP.xml" out=$OUT -o
+rm -f "$TMP.xml"
+g.message "Vector points map <$OUT> imported from WFS."
+exit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v.in.wfs.NEW
Type: application/octet-stream
Size: 1726 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20070509/0dc12019/v.in.wfs.obj
More information about the grass-dev
mailing list