{"id":13496640,"url":"https://github.com/georust/gpx","last_synced_at":"2025-12-15T02:13:36.416Z","repository":{"id":25611784,"uuid":"29046894","full_name":"georust/gpx","owner":"georust","description":"Rust read/write support for GPS Exchange Format (GPX)","archived":false,"fork":false,"pushed_at":"2024-10-08T13:26:39.000Z","size":424,"stargazers_count":101,"open_issues_count":3,"forks_count":46,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-29T20:19:39.437Z","etag":null,"topics":["geospatial","gps-data","gpx","gpx-parser","hacktoberfest","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/gpx","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/georust.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-10T04:16:00.000Z","updated_at":"2024-10-16T14:10:51.000Z","dependencies_parsed_at":"2024-11-06T21:44:49.227Z","dependency_job_id":null,"html_url":"https://github.com/georust/gpx","commit_stats":{"total_commits":196,"total_committers":40,"mean_commits":4.9,"dds":0.8928571428571429,"last_synced_commit":"838c904d05725545f166cfedf42a4489fd79878a"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georust%2Fgpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georust%2Fgpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georust%2Fgpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georust%2Fgpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georust","download_url":"https://codeload.github.com/georust/gpx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247723965,"owners_count":20985440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geospatial","gps-data","gpx","gpx-parser","hacktoberfest","rust"],"created_at":"2024-07-31T19:01:53.962Z","updated_at":"2025-12-15T02:13:31.355Z","avatar_url":"https://github.com/georust.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# gpx\n\n[![Crates.io](https://img.shields.io/crates/v/gpx.svg)](https://crates.io/crates/gpx)\n[![Build Status](https://github.com/georust/gpx/actions/workflows/test.yml/badge.svg)](https://github.com/georust/gpx/actions/workflows/test.yml)\n[![docs.rs](https://docs.rs/gpx/badge.svg)](https://docs.rs/gpx)\n\ngpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the\nprimitives provided by [geo-types](https://github.com/georust/geo) to allow for storage\nof GPS data.\n\n## Examples\n\n### Read a GPX file\n```rust\nextern crate gpx;\n\nuse std::io::BufReader;\nuse std::fs::File;\n\nuse gpx::read;\nuse gpx::{Gpx, Track, TrackSegment};\n\nfn main() {\n    // This XML file actually exists — try it for yourself!\n    let file = File::open(\"tests/fixtures/wikipedia_example.gpx\").unwrap();\n    let reader = BufReader::new(file);\n\n    // read takes any io::Read and gives a Result\u003cGpx, Error\u003e.\n    let gpx: Gpx = read(reader).unwrap();\n\n    // Each GPX file has multiple \"tracks\", this takes the first one.\n    let track: \u0026Track = \u0026gpx.tracks[0];\n    assert_eq!(track.name, Some(String::from(\"Example GPX Document\")));\n\n    // Each track will have different segments full of waypoints, where a\n    // waypoint contains info like latitude, longitude, and elevation.\n    let segment: \u0026TrackSegment = \u0026track.segments[0];\n\n    // This is an example of retrieving the elevation (in meters) at certain points.\n    assert_eq!(segment.points[0].elevation, Some(4.46));\n    assert_eq!(segment.points[1].elevation, Some(4.94));\n    assert_eq!(segment.points[2].elevation, Some(6.87));\n}\n```\n\n### Generate a new GPX file\nThis example only generates tracks. You can add waypoints and routes as well by instantiating new ``Waypoint``s and ``Route``s.\n\n```rust\nuse geo_types::{coord, Point};\nuse gpx::{Gpx, GpxVersion, Track, TrackSegment, Waypoint};\nuse std::{error::Error, fs::File, io::BufWriter, path::Path};\n\npub fn to_gpx\u003cP: AsRef\u003cPath\u003e\u003e(out_path: P) -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    // Instantiate Gpx struct\n    let track_segment = TrackSegment {\n        points: vec![]\n    };\n    let track = Track {\n        name: Some(\"Track 1\".to_string()),\n        comment: None,\n        description: None,\n        source: None,\n        links: vec![],\n        type_: None,\n        number: None,\n        segments: vec![track_segment],\n    };\n    let mut gpx = Gpx {\n        version: GpxVersion::Gpx11,\n        creator: None,\n        metadata: None,\n        waypoints: vec![],\n        tracks: vec![track],\n        routes: vec![],\n    };\n\n    // Create file at path\n    let gpx_file = File::create(out_path)?;\n    let buf = BufWriter::new(gpx_file);\n\n    // Add track point\n    let geo_coord = coord! { x: -121.1, y: 38.82 };\n    let geo_point: Point = geo_coord.into();\n    gpx.tracks[0].segments[0].points.push(Waypoint::new(geo_point));\n\n    // Write to file\n    gpx::write(\u0026gpx, buf)?;\n\n    Ok(())\n}\n```\n\n### Write to string\n`write` will write the GPX output to anything that implements `std::io::Write`. To save the output to a string, write it to a `u8` vector, and then convert the vector to a string.\n```rust\nlet mut vec = Vec::new();\ngpx::write(\u0026gpx, \u0026mut vec)?;\nlet string = String::from_utf8(vec)?;\n```\n\n## Current Status\n\nrust-gpx currently supports reading and writing both GPX 1.1 and 1.0.\nGPX extensions are not yet supported.\n\n## Contributing\nAll contributions are welcome! Please open an issue if you find a bug / have any\nquestions, and pull requests are always appreciated.\n\n## License\nrust-gpx is licensed under the [MIT license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorust%2Fgpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorust%2Fgpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorust%2Fgpx/lists"}