Expand description
gpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the primitives provided by geo-types to allow for storage of GPS data.
§Examples
use std::io::BufReader;
use std::fs::File;
use gpx::read;
use gpx::{Gpx, Track, TrackSegment};
// This XML file actually exists — try it for yourself!
let file = File::open("tests/fixtures/wikipedia_example.gpx").unwrap();
let reader = BufReader::new(file);
// read takes any io::Read and gives a Result<Gpx, Error>.
let gpx: Gpx = read(reader).unwrap();
// Each GPX file has multiple "tracks", this takes the first one.
let track: &Track = &gpx.tracks[0];
assert_eq!(track.name, Some(String::from("Example GPX Document")));
// Each track will have different segments full of waypoints, where a
// waypoint contains info like latitude, longitude, and elevation.
let segment: &TrackSegment = &track.segments[0];
// This is an example of retrieving the elevation (in meters) at certain points.
assert_eq!(segment.points[0].elevation, Some(4.46));
assert_eq!(segment.points[1].elevation, Some(4.94));
assert_eq!(segment.points[2].elevation, Some(6.87));
Modules§
- errors
- errors provides error generics for the gpx parser.
Structs§
- Gpx
- Gpx is the root element in the XML file.
- GpxCopyright
- Information about the copyright holder and any license governing use of this file.
- Link
- Link represents a link to an external resource.
- Metadata
- Metadata is information about the GPX file, author, and copyright restrictions.
- Person
- Person represents a person or organization.
- Route
- Route represents an ordered list of waypoints representing a series of turn points leading to a destination.
- Time
- Track
- Track represents an ordered list of points describing a path.
- Track
Segment - TrackSegment represents a list of track points.
- Waypoint
- Waypoint represents a waypoint, point of interest, or named feature on a map.
Enums§
- Fix
- Type of the GPS fix.
- GpxVersion
- Allowable GPX versions. Currently, only GPX 1.0 and GPX 1.1 are accepted.
Functions§
- read
- Reads an activity in GPX format.
- write
- Writes an activity to GPX format.
- write_
with_ event_ writer - Writes an activity to GPX format.