[GRASS-dev] [GRASS GIS] #577: v.in.ogr: imported GPX file results in N=0, W=0

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------------+------------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Keywords: v.in.ogr, gpx | Platform: Linux
      Cpu: x86-32 |
---------------------------+------------------------------------------------
Hi,

after importing a GPX file with v.in.ogr I get bounds like this:

{{{
north=0
south=-46.05588896
east=170.72404666
west=0
top=0.000000
bottom=0.000000
}}}

v.out.ascii, etc confirms that all the data points are no where near 0,0.

(GDAL 1.5.2)

?
Hamish

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by neteler):

Does ogr2ogr work, for example by creating a SHAPE file (ogrinfo to figure
out the extent)?

Markus

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hamish):

a shapefile from ogr2ogr gives ok extent.
(another bug is stopping me importing that, duplicate column names)

{{{
$ ogrinfo -ro -al track_points.shp
INFO: Open of `track_points.shp'
       using driver `ESRI Shapefile' successful.

Layer name: track_points
Geometry: Point
Feature Count: 4532
Extent: (170.168993, -46.055889) - (170.724047, -45.742630)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
     DATUM["WGS_1984",
...
}}}

aaaah, here is why:

{{{
INFO: Open of `waypoints.shp'
       using driver `ESRI Shapefile' successful.

Layer name: waypoints
Geometry: Point
Feature Count: 0
Extent: (0.000000, 0.000000) - (0.000000, 0.000000)
Layer SRS WKT:
...
}}}

the GPX import creates 5 layers:
{{{
route_points
routes
track_points
tracks
waypoints
}}}

but my GPX file only has tracks in it. so some of the other layers have no
extent (and no features), but v.info picks up the 0.0 anyway.

Hamish

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by mmetz):

Grass vector extends are calculated when topology is built, based on the
primitives, which happens after all layers were imported by v.in.ogr, IOW
grass vector extends should be calculated independent of the OGR layer
extends. If all features are somewhere around 170, -46 and nowhere near
0,0, v.info should report extends accordingly. That's why I think there
may be a bug in the vector libraries when building topology because
v.out.ascii confirmed that no points where anywhere near 0,0.

Hamish, can you do a bit more testing? Are the extends still wrong
   * after rebuilding topology with v.build?
   * when importing track_points only from the GPX file?
   * when importing all shapefiles at once into one grass vector?
   * when importing the shapefile track_points only?

v.in.ogr could also be modified to skip empty OGR layers (Feature Count:
0). I don't know if there are OGR-recognized vector formats where there
can be some info in a layer with no features, then empty layers should not
be skipped.

Markus M

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hamish):

Replying to [comment:3 mmetz]:
> Grass vector extends are calculated when topology is built,
> based on the primitives, which happens after all layers were
> imported by v.in.ogr, IOW grass vector extends should be
> calculated independent of the OGR layer extends. If all features
> are somewhere around 170, -46 and nowhere near 0,0, v.info
> should report extends accordingly. That's why I think there may
> be a bug in the vector libraries when building topology because
> v.out.ascii confirmed that no points where anywhere near 0,0.
>
> Hamish, can you do a bit more testing? Are the extends still wrong
> * after rebuilding topology with v.build?

yes

hmmm.... nodes 1 & 2:

{{{
G65> v.build gps_trk_gpx_import option=dump
---------- TOPOLOGY DUMP ----------
N,S,E,W,T,B: 0.000000, -46.055889, 170.724047, 0.000000, 0.000000,
0.000000
Nodes (3838 nodes, alive + dead ):
node = 1, n_lines = 1, xy = 0.000000, 0.000000
   line = 1, type = 2, angle = -9.000000
node = 2, n_lines = 1, xy = 0.000000, 0.000000
   line = -1, type = 2, angle = -9.000000
node = 3, n_lines = 4, xy = 170.641103, -45.827688
   line = 7, type = 1, angle = -9.000000
   line = 707, type = 1, angle = -9.000000
   line = 2, type = 2, angle = 2.753561
   line = 3, type = 2, angle = 2.753561
node = 4, n_lines = 2, xy = 170.189732, -46.050674
   line = 706, type = 1, angle = -9.000000
   line = -2, type = 2, angle = 0.575716
...
}}}

> * when importing track_points only from the GPX file?

> * when importing all shapefiles at once into one grass vector?
> * when importing the shapefile track_points only?
>
> v.in.ogr could also be modified to skip empty OGR layers (Feature Count:
0). I don't know if there are OGR-recognized vector formats where there
can be some info in a layer with no features, then empty layers should not
be skipped.
>
> Markus M

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hamish):

Replying to [comment:3 mmetz]:
> v.in.ogr could also be modified to skip empty OGR layers (Feature
> Count: 0). I don't know if there are OGR-recognized vector formats
> where there can be some info in a layer with no features, then
> empty layers should not be skipped.

maybe someone importing many similar maps expects layer 4 to always to be
the same regardless of if layer 3 for one of the maps has values or not?

Hamish

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by mmetz):

Replying to [comment:4 hamish]:
> Replying to [comment:3 mmetz]:
> > Hamish, can you do a bit more testing? Are the extends still wrong
> > * after rebuilding topology with v.build?
>
> yes
>
> hmmm.... nodes 1 & 2:
>
> {{{
> G65> v.build gps_trk_gpx_import option=dump
> ---------- TOPOLOGY DUMP ----------
> N,S,E,W,T,B: 0.000000, -46.055889, 170.724047, 0.000000, 0.000000,
0.000000
> Nodes (3838 nodes, alive + dead ):
> node = 1, n_lines = 1, xy = 0.000000, 0.000000
> line = 1, type = 2, angle = -9.000000
> node = 2, n_lines = 1, xy = 0.000000, 0.000000
> line = -1, type = 2, angle = -9.000000
> ...
> }}}
>
There must be one point each at these two nodes because n_lines = 1, angle
= -9.000000 (point or degenerate line/boundary). If there is really no
point with x = 0 y = 0 int he vector this looks very much like a bug in
the vector libs.

> maybe someone importing many similar maps expects layer 4 to always to
be the same regardless of if layer 3 for one of the maps has values or
not?

OK, forget about skipping empty layers, that would have been a workaround
only anyway.

Markus M

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hamish):

Ok, I think I found it.

The GPX file as created by GpsBabel (direct download from the Garmin GPS
unit) includes an empty track:

{{{
<trk>
   <name>ACTIVE LOG</name>
<trkseg>
</trkseg>
</trk>
}}}

which seems to be the cause.

test track uploaded to this ticket.

{{{
db.connect driver=sqlite
database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'

v.in.ogr dsn=test_5.gpx out=test5
}}}

Hamish

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by mmetz):

This empty track makes its way into the grass vector as an empty feature
(primitive with no vertices). This should not happen because the vector
libraries can't handle empty features. Could be fixed either in v.in.ogr
or in the vector libraries, i.e. in Vect_write_line().

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: fixed | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Changes (by mmetz):

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

Comment:

fixed in trunk r37033, devbr6 r37034, and relbr64 r37035

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

#577: v.in.ogr: imported GPX file results in N=0, W=0
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: svn-develbranch6
Resolution: fixed | Keywords: v.in.ogr, gpx
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hamish):

tested; works well; thanks.

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