[GRASS-dev] [GRASS GIS] #991: v.out.gpsbabel export fails with layer=2

#991: v.out.gpsbabel export fails with layer=2
----------------------------+-----------------------------------------------
Reporter: needelsd | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: Translations | Version: 6.4.0 RCs
Keywords: GPS GPX export | Platform: Unspecified
      Cpu: Unspecified |
----------------------------+-----------------------------------------------
It appears that v.out.gpsbabel fails when used with the layer=2 option.

I am running William Kyngesburye's 6.4RC5-3 on Mac OS X Leopard.

[A] All exports using v.out.gpsbabel generate the following error, even
when the exports seem to have worked correctly.

/Applications/GRASS-6.4.app/Contents/MacOS/scripts/m.proj: line 197: [: :
integer expression expected

Spearfish example:
v.out.gpsbabel -w input=bugsites type=point output=bugsites.gpx

[B] With several exports using layer=2 (including data generated from
v.to.points), v.out.gpsbabel fails with the following message (this one is
from a WGS84 lat/lon location).

/Applications/GRASS-6.4.app/Contents/MacOS/scripts/m.proj: line 197: [: :
integer expression expected
ERROR: Error reading categories: [ 2.00000000 1.00000000 0.00000000]
ERROR: Error reprojecting data

Spearfish example:
v.category input=bugsites output=bugsites_two option=add layer=2
v.out.gpsbabel -w input=bugsites_two type=point output=bugsites_two.gpx

/Applications/GRASS-6.4.app/Contents/MacOS/scripts/m.proj: line 197: [: :
integer expression expected
ERROR: Error reading categories: [ -109.48867688 0.00000902 0.00000000]
ERROR: Error reprojecting data

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/991&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
--------------------------+-------------------------------------------------
  Reporter: needelsd | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: GPS GPX export
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by martinl):

  * component: Translations => Vector

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/991#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
--------------------------+-------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: assigned
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: GPS GPX export, v.out.gpsbabel
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by hamish):

* cc: grass-dev@lists.osgeo.org (added)
  * keywords: GPS GPX export => GPS GPX export, v.out.gpsbabel
  * status: new => assigned
  * owner: grass-dev@lists.osgeo.org => hamish

Comment:

you are automatically cc'd if you report or comment to a ticket

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/991#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
--------------------------+-------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: assigned
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by hamish):

  * keywords: GPS GPX export, v.out.gpsbabel => GPS GPX export,
               v.out.gpsbabel, m.proj

Comment:

works for me in 6.5svn on linux; I'll try later today on Mac.

I do get this warning, which should be wrong, bugsites has an attribute
table.

{{{
WARNING: No attribute table found -> using only category numbers as
          attributes
}}}

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/991#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
--------------------------+-------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: assigned
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by hamish):

> I am running William Kyngesburye's 6.4RC5-3 on Mac OS X Leopard.

I guess m.proj is choking on the '`wc -l`'. I'll have to check that the
usage & output is the same for OSX/Dawin/BSD.

{{{
     # make sure we have at least one line of data
     if [ "`wc -l "$TMPFILE" | cut -f1 -d' '`" -eq 0 ] ; then
        g.message -e "ERROR reading data from stdin"
        exit 1
     fi
}}}

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/991#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
--------------------------+-------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: fixed | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by hamish):

  * status: assigned => closed
  * resolution: => fixed

Comment:

> I guess m.proj is choking on the 'wc -l'. I'll have to check
> that the usage & output is the same for OSX/Dawin/BSD.

yes, that's it.

hopefully fixed in svn with r41371. (and fixed another newly introduced
bug too)

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/991#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
-----------------------+----------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: fixed | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: MacOSX | Cpu: Unspecified
-----------------------+----------------------------------------------------
Changes (by hamish):

  * platform: Unspecified => MacOSX

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/991#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
-----------------------+----------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: fixed | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: MacOSX | Cpu: Unspecified
-----------------------+----------------------------------------------------
Changes (by donxfive):

* cc: donxfive (added)

Comment:

I still get "Error reading categories" with vectors that have layers other
than 1.

I'm using GRASS version 6.4.0svn on my Ubuntu laptop (w/ GNU sed version
4.1.5), and I fixed the problem by replacing

{{{
sed -e 's/^\([PLBCFKA]\)/#\1/' -e 's/^ 1 /# 1 /'
}}}
with

{{{
sed -r -e 's/^[PLBCFKA]/#&/' -e 's/^ [1-9]+ /#&/'
}}}
on line 253 of the
[http://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/scripts/v.out.gpsbabel/v.out.gpsbabel
v.out.gpsbabel script]. (The problem sed command is also used in
v.out.gpsbabel for 6.5-svn, and in v.out.gps for 7.0-svn.)

I've had no problems since I did this, but I'm not sure if it would work
for everyone.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/991#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
-----------------------+----------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: MacOSX | Cpu: Unspecified
-----------------------+----------------------------------------------------
Changes (by hamish):

  * status: closed => reopened
  * resolution: fixed =>
  * milestone: 6.4.0 => 6.4.1

Comment:

is the change to the first sed expression just a simplification, or does
it contribute to the bug?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/991#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#991: v.out.gpsbabel export fails with layer=2
-----------------------+----------------------------------------------------
  Reporter: needelsd | Owner: hamish
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: GPS GPX export, v.out.gpsbabel, m.proj
  Platform: MacOSX | Cpu: Unspecified
-----------------------+----------------------------------------------------

Comment(by donxfive):

{{{
is the change to the first sed expression just a simplification, or does
it contribute to the bug?
}}}

The answer is "yes and no:" when I used the plus sign in the second
expression, I needed to invoke sed with the "-r" option to get it to work,
and that caused sed to choke on the first expression so I changed it.

By the way, I just tried
{{{
sed -e 's/^\([PLBCFKA]\)/#\1/' -e 's/^ [1-9]\+ /#&/'
}}}
(ie using sed without the "-r" option, and using "\+" rather than "+" in
the second expression), and now the first expression works fine. I think
that both the "-r" option and "\+" are specific to GNU sed, so I'm not
sure about the portability of my workaround. Maybe something like this
would be better:
{{{
sed -e 's/^\([PLBCFKA]\)/#\1/' -e 's/^ [1-9][1-9]* /#&/'
}}}
This works the same as my first workaround, but is probably more portable.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/991#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>