SDSDevelopment.GPXReaderLib
1.0.0
dotnet add package SDSDevelopment.GPXReaderLib --version 1.0.0
NuGet\Install-Package SDSDevelopment.GPXReaderLib -Version 1.0.0
<PackageReference Include="SDSDevelopment.GPXReaderLib" Version="1.0.0" />
<PackageVersion Include="SDSDevelopment.GPXReaderLib" Version="1.0.0" />
<PackageReference Include="SDSDevelopment.GPXReaderLib" />
paket add SDSDevelopment.GPXReaderLib --version 1.0.0
#r "nuget: SDSDevelopment.GPXReaderLib, 1.0.0"
#:package SDSDevelopment.GPXReaderLib@1.0.0
#addin nuget:?package=SDSDevelopment.GPXReaderLib&version=1.0.0
#tool nuget:?package=SDSDevelopment.GPXReaderLib&version=1.0.0
GPX Reader Library
A .NET 10 library for reading and parsing GPX (GPS Exchange Format) files. This library provides a simple and efficient way to extract waypoints, routes, and tracks from GPX files.
Features
- Waypoint Parsing: Extract waypoints with latitude, longitude, elevation, name, description, symbol, type, and timestamp
- Route Parsing: Parse routes with route points containing coordinates and metadata
- Track Parsing: Read track segments with track points and their associated data
- Namespace Support: Handles GPX files with or without XML namespaces
- Async Support: Asynchronous file processing for better performance
Installation
This library is available as a NuGet package:
dotnet add package SDSDevelopment.GPXReaderLib
Or via the Package Manager Console:
Install-Package SDSDevelopment.GPXReaderLib
Quick Start
Basic Usage
using GPXReaderLib;
using GPXReaderLib.Models;
// Parse a GPX file
GpxData gpxData = await GPXReaderService.ParseGpxFileAsync("path/to/your/file.gpx");
// Access waypoints
foreach (var waypoint in gpxData.Waypoints)
{
Console.WriteLine($"Waypoint: {waypoint.Name}");
Console.WriteLine($" Latitude: {waypoint.Latitude}");
Console.WriteLine($" Longitude: {waypoint.Longitude}");
Console.WriteLine($" Elevation: {waypoint.Elevation}m");
}
// Access routes
foreach (var route in gpxData.Routes)
{
Console.WriteLine($"Route: {route.Name}");
Console.WriteLine($" Points: {route.RoutePoints.Count}");
}
// Access tracks
foreach (var track in gpxData.Tracks)
{
Console.WriteLine($"Track: {track.Name}");
Console.WriteLine($" Segments: {track.Segments.Count}");
}
Data Models
GpxData
The main container for all GPX data.
public class GpxData
{
public List<Waypoint> Waypoints { get; set; }
public List<Route> Routes { get; set; }
public List<Track> Tracks { get; set; }
}
Waypoint
Represents a single waypoint with location and metadata.
public class Waypoint
{
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
public decimal? Elevation { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public string? Symbol { get; set; }
public string? Type { get; set; }
public DateTime? Time { get; set; }
}
Route
Represents a route with multiple route points.
public class Route
{
public string? Name { get; set; }
public string? Description { get; set; }
public List<RoutePoint> RoutePoints { get; set; }
}
Track
Represents a track with multiple segments.
public class Track
{
public string? Name { get; set; }
public string? Description { get; set; }
public List<TrackSegment> Segments { get; set; }
}
API Reference
GPXReaderService
ParseGpxFileAsync
Parses a GPX file and returns the extracted data.
public static async Task<GpxData> ParseGpxFileAsync(string filePath)
Parameters:
filePath(string): The path to the GPX file to parse
Returns:
Task<GpxData>: A task that returns the parsed GPX data
Example:
try
{
var gpxData = await GPXReaderService.ParseGpxFileAsync("my-route.gpx");
Console.WriteLine($"Parsed {gpxData.Waypoints.Count} waypoints");
}
catch (Exception ex)
{
Console.WriteLine($"Error parsing GPX file: {ex.Message}");
}
Supported GPX Format
This library supports the standard GPX 1.1 format with the following elements:
Waypoints
wpt- Waypoint elementlat- Latitude (required)lon- Longitude (required)ele- Elevation (optional)name- Waypoint name (optional)desc- Description (optional)sym- Symbol (optional)type- Type (optional)time- Timestamp (optional)
Routes
rte- Route elementname- Route name (optional)desc- Description (optional)rtept- Route point (contains lat, lon, ele, name, time)
Tracks
trk- Track elementname- Track name (optional)desc- Description (optional)trkseg- Track segmenttrkpt- Track point (contains lat, lon, ele, name, time)
Requirements
- .NET 10 or later
- C# 12 or later
Dependencies
- System.Xml.Linq (included in .NET SDK)
Performance Considerations
- The library loads the entire GPX file into memory for parsing
- For very large GPX files (>100MB), consider processing in chunks
- The async API is recommended for I/O-bound operations
Error Handling
The parser will:
- Skip invalid or missing optional elements
- Use default values for latitude/longitude if parsing fails
- Handle files with or without XML namespaces transparently
License
This library is provided by SDSDevelopment. See LICENSE file for details.
Support
For use with project POIViewerMap .NET MAUI app only, see: https://github.com/stevegdavis/POIViewerMap
Changelog
Version 1.0.0
- Initial release
- Support for waypoints, routes, and tracks
- Async parsing with namespace support
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 117 | 6/23/2026 |