[GRASS-windows] whitespace bug?

5 messages Options
Embed this post
Permalink
Stefan Muthers

[GRASS-windows] whitespace bug?

Reply Threaded More More options
Print post
Permalink
hello,

I use Qgis 0.11.0 under Windows 2000, but I also tried with grass for
Windows (version 6.3.0) directly.

When I import shapefiles with whitespace in the pathname, I get an error
message.

for example:

$ v.in.ogr 'C:/Dokumente und
Einstellungen/user/Desktop/Daten/Bsp/Example.shp' output=line

$ v.db.addcol map=line columns='test double'

ERROR: value <und> out of range for parameter <driver>
         Legal range: dbf,ogr,pg,sqlite

Description:
   Executes any SQL statement.

...

Is this a bug?

Are there any possibilities to escape the white space?

regards
   stefan

_______________________________________________
grass-windows mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-windows
Marco Pasetti

Re: [GRASS-windows] whitespace bug?

Reply Threaded More More options
Print post
Permalink
Stefan,


> When I import shapefiles with whitespace in the pathname, I get an error
> message.
>
> $ v.in.ogr 'C:/Dokumente und
> Einstellungen/user/Desktop/Daten/Bsp/Example.shp' output=line
>
> ERROR: value <und> out of range for parameter <driver>
>         Legal range: dbf,ogr,pg,sqlite
>
> Is this a bug?

No. You simply typed the wrong command!
Use the command GUI or type:

v.in.ogr 'dsn=C:/Dokumente und
Einstellungen/user/Desktop/Daten/Bsp/Example.shp' output=line

Regards,

Marco

_______________________________________________
grass-windows mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-windows
Stefan Muthers

Re: [GRASS-windows] whitespace bug?

Reply Threaded More More options
Print post
Permalink
Hello Marco,

Marco Pasetti schrieb:

>> When I import shapefiles with whitespace in the pathname, I get an
>> error message.
>> ...
>
> No. You simply typed the wrong command!
> Use the command GUI or type:
>
> v.in.ogr 'dsn=C:/Dokumente und
> Einstellungen/user/Desktop/Daten/Bsp/Example.shp' output=line
>


yes, I forgot dsn=, when writing the mail.  The GUI was a good hint. In
Grass the dns parameter needs to be enclosed by {}

$ v.in.ogr {dsn=C:/Dokumente und
Einstellungen/muthers/Desktop/Rauigkeit/shapes/Example.shp} output=test

In Qgis your command works.


But the v.in.ogr command should be only an example.

I figured out, that in general there s a problem when using a grass
workspace with whitespace in the path.
For example:
  - copy the workspace from above to C:/Dokumente und
      Einstellungen/muthers/Desktop/grass
  - open it with grass

$ v.db.addcol map=test columns='test INT'

ERROR: value <und> out of range for parameter <driver>
        Legal range: dbf,ogr,pg,sqlite

but

$ echo ' ALTER TABLE test ADD test INT' |  db.execute

works.




regards
   stefan
_______________________________________________
grass-windows mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-windows
Markus Neteler

Re: [GRASS-windows] whitespace bug?

Reply Threaded More More options
Print post
Permalink
On Wed, Oct 22, 2008 at 1:02 PM, Stefan Muthers
<[hidden email]> wrote:
...

(v.in.ogr works)

I have inserted a white space in my grassdata/ path on Linux and can replicate
your problem:

> I figured out, that in general there s a problem when using a grass
> workspace with whitespace in the path.
> For example:
>  - copy the workspace from above to C:/Dokumente und
>     Einstellungen/muthers/Desktop/grass
>  - open it with grass
>
> $ v.db.addcol map=test columns='test INT'
>
> ERROR: value <und> out of range for parameter <driver>
>       Legal range: dbf,ogr,pg,sqlite

Yes, because in v.db.addcol and many other scripts, the following is called:

v.db.connect test2 -g
1 test2 cat /home/neteler/grass data/spearfish60/neteler/dbf/ dbf

The output is parsed based on white space, indeed the script line looks
like this:
database=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk
'{print $4}'`

Since awk uses white space here, it separates on the wrong column.

Proposed solution (@ grass-devs):

* revisit all scripts and add fs=";" to v.db.connect -g and use
 that as field separator also for awk (-F ';'), so:
 database=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w
$GIS_OPT_LAYER | awk -F ";" '{print $4}'`
* Likewise for driver=...
* and use ... db.execute database="${database}" driver=${driver}
everywhere instead of
  ... db.execute database=$database driver=$driver

diff:
@@ -90,8 +90,8 @@
    exit 1
 fi

-database=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk
'{print $4}'`
-driver=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk
'{print $5}'`
+database="`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w
$GIS_OPT_LAYER | awk -F ";" '{print $4}'`"
+driver="`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w $GIS_OPT_LAYER
| awk -F ";" '{print $5}'`"

 colnum=`echo $GIS_OPT_COLUMNS | awk -F, '{print NF}'`

@@ -105,7 +105,7 @@
       exit 1
     fi

-    echo "ALTER TABLE $table ADD COLUMN $col" | db.execute
database=$database driver=$driver
+    echo "ALTER TABLE $table ADD COLUMN $col" | db.execute
database="${database}" driver=${driver}
     if [ $? -eq 1 ] ; then
       g.message -e "Cannot continue (problem adding column)."
       exit 1


Then it works.

Markus
_______________________________________________
grass-windows mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-windows
Markus Neteler

Re: [GRASS-windows] whitespace bug?

Reply Threaded More More options
Print post
Permalink
On Wed, Oct 22, 2008 at 1:45 PM, Markus Neteler <[hidden email]> wrote:
> On Wed, Oct 22, 2008 at 1:02 PM, Stefan Muthers <[hidden email]> wrote:
> ...
>
> I have inserted a white space in my grassdata/ path on Linux and can replicate
> your problem:

I have fixed these whitespace-in-path problems (hopefully) in:

        scripts/db.dropcol/db.dropcol
        scripts/db.droptable/db.droptable
        scripts/d.vect.thematic/d.vect.thematic
        scripts/v.db.addcol/v.db.addcol
        scripts/v.db.addtable/v.db.addtable
        scripts/v.db.dropcol/v.db.dropcol
        scripts/v.db.droptable/v.db.droptable
        scripts/v.db.join/v.db.join
        scripts/v.db.reconnect.all/v.db.reconnect.all
        scripts/v.db.renamecol/v.db.renamecol
        scripts/v.db.update/v.db.update
        scripts/v.dissolve/v.dissolve
        scripts/v.rast.stats/v.rast.stats
        scripts/v.report/v.report

in GRASS 6.4.svn and 7.svn.

Markus
_______________________________________________
grass-windows mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-windows