15 releases (8 breaking)

0.8.6 May 28, 2022
0.8.5 Oct 16, 2021
0.8.3 Aug 3, 2021
0.8.2 Jul 15, 2021
0.0.1 Jan 21, 2015

#103 in Parser implementations

Download history 71/week @ 2022-08-14 128/week @ 2022-08-21 66/week @ 2022-08-28 127/week @ 2022-09-04 79/week @ 2022-09-11 57/week @ 2022-09-18 59/week @ 2022-09-25 133/week @ 2022-10-02 83/week @ 2022-10-09 56/week @ 2022-10-16 94/week @ 2022-10-23 98/week @ 2022-10-30 108/week @ 2022-11-06 92/week @ 2022-11-13 80/week @ 2022-11-20 37/week @ 2022-11-27

330 downloads per month
Used in 2 crates

MIT license

140KB
2K SLoC

gpx

Crates.io Build Status docs.rs

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.

Example

extern crate gpx;

use std::io::BufReader;
use std::fs::File;

use gpx::read;
use gpx::{Gpx, Track, TrackSegment};

fn main() {
    // 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));
}

Current Status

rust-gpx currently supports reading and writing both GPX 1.1 and 1.0. GPX extensions are not yet supported.

Contributing

All contributions are welcome! Please open an issue if you find a bug / have any questions, and pull requests are always appreciated.

License

rust-gpx is licensed under the MIT license.

Dependencies

~5.5MB
~115K SLoC