Opened 12 years ago

Closed 11 years ago

#1515 closed enhancement (fixed)

gpx format support

Reported by: tom.kralidis@… Owned by: Even Rouault
Priority: normal Milestone: 1.5.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: gpx
Cc: warmerdam, Mateusz Łoskot

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

sample.gpx (1.1 KB) - added by Even Rouault 11 years ago.
A sample GPX file
gdal_svn_trunk_gpx_driver.patch (61.1 KB) - added by Even Rouault 11 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 12 years ago by tom.kralidis@…

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)

comment:2 Changed 12 years ago by warmerdam

Component: defaultOGR_SF
Description: modified (diff)
Priority: highlow
Severity: minornormal

re-prioritized...

comment:3 Changed 11 years ago by Even Rouault

Cc: warmerdam added
Keywords: gpx added
Milestone: 1.5.0
Owner: changed from warmerdam to Even Rouault
Priority: lownormal

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

Changed 11 years ago by Even Rouault

Attachment: sample.gpx added

A sample GPX file

Changed 11 years ago by Even Rouault

comment:4 Changed 11 years ago 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.

comment:5 Changed 11 years ago by Mateusz Łoskot

Cc: Mateusz Łoskot added

comment:6 Changed 11 years ago by Even Rouault

Resolution: fixed
Status: newclosed

Patch commited in trunk in r12731 and small autotest in r12732

Note: See TracTickets for help on using tickets.