Page
Library
Module
Module type
Parameter
Class
Class type
Source
Gpx_eio
SourceThis module provides a direct-style API for GPX operations using Eio's effects-based concurrent I/O system. It offers convenient functions for common GPX operations while maintaining structured concurrency.
open Gpx_eio
let main env =
let fs = Eio.Stdenv.fs env in
(* Create a GPX document *)
let lat = Gpx.Coordinate.latitude 37.7749 |> Result.get_ok in
let lon = Gpx.Coordinate.longitude (-122.4194) |> Result.get_ok in
let wpt = Gpx.Waypoint.make lat lon |> Gpx.Waypoint.with_name "San Francisco" in
let gpx = Gpx.make_gpx ~creator:"eio-example" |> Gpx.Doc.add_waypoint wpt in
(* Write with validation *)
write ~validate:true fs "output.gpx" gpx;
(* Read it back *)
let gpx2 = read ~validate:true fs "output.gpx" in
Printf.printf "Read %d waypoints\n" (List.length (Gpx.Doc.waypoints gpx2))
let () = Eio_main.run main
These functions provide simple file I/O with the filesystem from Eio.Stdenv.fs
.
Read and parse GPX file.
Write GPX to file.
val write_with_backup :
?validate:bool ->
fs:[> Eio.Fs.dir_ty ] Eio.Path.t ->
string ->
Gpx.t ->
string
Write GPX to file with automatic backup.
Operations for reading/writing GPX from/to Eio flows.
Read GPX from Eio source.
Write GPX to Eio sink.
Print GPX statistics to sink.