Opened 17 years ago

Last modified 17 years ago

#1515 closed enhancement

gpx format support — at Version 2

Reported by: tom.kralidis@… Owned by: warmerdam
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.

Change History (2)

comment:1 by tom.kralidis@…, 17 years ago

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 by warmerdam, 17 years ago

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

re-prioritized...

Note: See TracTickets for help on using tickets.