endurance / gpx
Streaming GPX tracks, routes and waypoints for PHP
v0.2.0
2026-11-23 19:02 UTC
Requires
- php: ^8.5
- ext-xmlreader: *
Requires (Dev)
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-23 19:12:03 UTC
README
Streaming GPX 1.0/1.1 subset reader for PHP 8.5 with XMLReader.
composer require endurance/gpx
use Endurance\Gpx\Reader; $input = fopen('recording.gpx', 'rb'); try { $points = new Reader()->points($input); foreach ($points as $point) { $stage($point); } $document = $points->getReturn(); } finally { fclose($input); }
objects() yields source-scoped track, route and waypoint descriptors.
objectPoints($input, 'gpx.v1/trk[1]') reads one selected object and returns
its completed read result through getReturn().
- All yields are provisional until the entire document, including its tail, completes. Publish staged data only then. A malformed unselected object also invalidates the source; stopping early does not validate it.
- Locators apply only to the same immutable source bytes. Missing objects and empty objects are distinct. The caller owns the stream; it need not be seekable.
- Coordinates, lexical times and recognized measurements remain source facts. Namespace aliases work; unknown extensions are omitted, not guessed.
- DTDs/external entities and structural/scalar limits are enforced. Invalid input
raises
InvalidGpx; this supported subset is not full XSD validation.
License: MPL-2.0.