Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#577 closed defect (fixed)

v.in.ogr: imported GPX file results in N=0, W=0

Reported by: hamish Owned by: grass-dev@…
Priority: normal Milestone: 6.4.0
Component: Vector Version: svn-develbranch6
Keywords: v.in.ogr, gpx Cc:
CPU: x86-32 Platform: Linux

Description

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

Attachments (1)

test_5.gpx (1.0 KB ) - added by hamish 15 years ago.
gpx file with an empty track

Download all attachments as: .zip

Change History (11)

comment:1 by neteler, 15 years ago

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

Markus

comment:2 by hamish, 15 years ago

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

comment:3 by mmetz, 15 years ago

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

in reply to:  3 ; comment:4 by hamish, 15 years ago

Replying to 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

in reply to:  3 comment:5 by hamish, 15 years ago

Replying to 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

in reply to:  4 comment:6 by mmetz, 15 years ago

Replying to hamish:

Replying to 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

comment:7 by hamish, 15 years ago

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

by hamish, 15 years ago

Attachment: test_5.gpx added

gpx file with an empty track

comment:8 by mmetz, 15 years ago

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().

comment:9 by mmetz, 15 years ago

Resolution: fixed
Status: newclosed

fixed in trunk r37033, devbr6 r37034, and relbr64 r37035

comment:10 by hamish, 15 years ago

tested; works well; thanks.

Note: See TracTickets for help on using tickets.