Ticket #1515 (closed enhancement: fixed)

Opened 1 year ago

Last modified 9 months ago

gpx format support

Reported by: tom.kralidis@ec.gc.ca Assigned to: rouault
Priority: normal Milestone: 1.5.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: gpx
Cc: warmerdam, mloskot

Description (Last modified by warmerdam)

Just wanted to get this listed.  From mailing list discussion:

http://www.nabble.com/GPX-format-support-t3377405.html#a9399990

GPX website:

http://www.topografix.com/gpx.asp

A couple of scenarios:

- user would like to upload / visualize their GPX formatted waypoints on
a web mapping application

- user would like to export their geospatial data into GPX format to
load onto their GPS unit

I think GPX read/write support would be a useful driver addition to OGR.

Attachments

sample.gpx (1.1 kB) - added by rouault on 11/11/07 13:14:17.
A sample GPX file
gdal_svn_trunk_gpx_driver.patch (61.1 kB) - added by rouault on 11/11/07 13:21:16.

Change History

03/10/07 21:33:37 changed by tom.kralidis@ec.gc.ca

I'm not too familiar with the inner workings of OGR, but here's what I know about GPX:

Current official schema:

http://www.topografix.com/GPX/1/1/gpx.xsd

Basic structure

- XML-based
- parts
 - <metadata> element
  - header info (contact, links, keywords, bounds, etc.)
  - <wpt> (1..*) list of waypoints
   - lat / long attributes
   - ancillary information elements
   - other
    - analogous to a Point feature type
  - <rte> (1..*)
    - ancillary information elements
    - <rtept> (1..*) a list of route points
     - lat / long attributes
    - analogous to a Line feature type
  - <trk> (1..*)
    - ancillary information elements
    - <trkseg> (1..*) a list of track segments
     - lat / long attributes
    - analogous to a Line feature type

Other notes:
- looks like GPX is fixed on lat/long (4326) type coordinate system.  One can use the <extension> element if they want to record coordinates in alternate coordinate systems
- GPX documents are not constrained to one data type.  Any combination of waypoints, routes, of tracks may exist
- As Matthew (Perry) suggests, gpx2shp (http://gpx2shp.sourceforge.jp/) provides some useful info w.r.t. an GPX implementation.  Looks like not much activity in this project since February 2005.

Implementation

One could see OGR's GPX support to potentially operate in the following manner:

Read (i.e. GPX to some other vector format)
- read .gpx document (probably test to see if it's an XML document, if yes, look  for a root element of gpx)
- output some other vector format depending on how many different types of data is in the .gpx document, i.e.:

$ ogr2ogr -f "GML" output input.gpx
$ ls
output.gpx (source gpx)
output_meta.txt (meta data)
output_rte.gml (route)
output_trk.gml (trackpoint)
output_wpt.gml (waypoint)

This is how gpx2shp handles different data types in a .gpx file (http://gpx2shp.sourceforge.jp/#usage)

Write (i.e. some other vector format)

$ ogr2ogr -f "GPX" output input.shp

- if shapefile is point, ogr2ogr outputs a .gpx with wpt point features
- if shapefile is a line, ogr2ogr has to figure out whether the user wants these output as routes or tracks.  No idea how this can be done, other than some sort of flag to ogr2ogr or ancillary metadata somewhere?

Integration with other software

- I could see this as an output format type which MapServer could provide (i.e. offer up GPX as a possible OGC:WFS GetFeature format)

04/03/07 00:44:06 changed by warmerdam

  • priority changed from high to low.
  • component changed from default to OGR_SF.
  • description changed.
  • severity changed from minor to normal.

re-prioritized...

11/11/07 13:05:13 changed by rouault

  • priority changed from low to normal.
  • keywords set to gpx.
  • cc set to warmerdam.
  • owner changed from warmerdam to rouault.
  • milestone set to 1.5.0.

The attached patch adds support for GPX reading (EXPAT needed) and writing.

11/11/07 13:14:17 changed by rouault

  • attachment sample.gpx added.

A sample GPX file

11/11/07 13:21:16 changed by rouault

  • attachment gdal_svn_trunk_gpx_driver.patch added.

11/11/07 23:31:35 changed by warmerdam

Even,

Go ahead and apply the patch. Please also add a some degree of testing for gpx to the autotest suite and drop a line about this new feature to gdal-dev.

11/12/07 14:09:08 changed by mloskot

  • cc changed from warmerdam to warmerdam, mloskot.

11/12/07 14:29:54 changed by rouault

  • status changed from new to closed.
  • resolution set to fixed.

Patch commited in trunk in r12731 and small autotest in r12732