Download the PHP package derickr/gpx-utils without Composer

On this page you can find all versions of the php package derickr/gpx-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gpx-utils

GPX Utils

A set of utilities to operate on GPX files and sets of GPX files.

Reading GPX Files

The GPX reader class DerickR/GPX/Reader can be used to read a GPX file.

It can read GPX routes (rte/rtept) and if none are present, it will read a GPX track (trk/trkseg/trkpt) instead.

You can read a GPX file with:

To access the tracks, you can use the getTrack() method which returns a DerickR/GPX/Track object, which encapsulates a ordered set of coordinate pairs. If the GPX file had multiple tracks, these are merged into one:

$track = $gpxInformation->getTrack();

To get individual tracks out of a GPX file, you can use the getTracks() method to obtain an array of Track objects:

$tracks = $gpxInformation->getTracks();
foreach ( $tracks as $track )
{
	/* Do something with $track */
}

For GPX files that contain routes (rte/rtept) this will still return a merged track.

For GPX files that contain tracks (trk/trkseg) this return an array of tracks, with each Track object representing a track as stored in the GPX file.

To merge tracks stored in multiple GPX files, see Merging GPX Files.

Writing GPX Files

The GPX writer class DerickR/GPX/Writer can be used to write a Track object as a GPX track using trk/trkseg/trkpt elements. It only supports the lat and lon XML elements.

You can write a track to GPX file with:

Instead of writing GPX XML directly to a file, it is also possible to retrieve a string with this information, by using the `getGpxString()` method:

Operating on Tracks

The Track class has several methods to operate on GPX tracks. The following methods are supported:

getTrackData Returns an array with lat/lon coordinate pairs.

getFirstPointAsGeoJson Returns the first element in the track as a GeoJson formatted array.

getLastPointAsGeoJson Returns the last element in the track as a GeoJson formatted array.

appendTrack( Track $newTrack ) Adds all the coordinate pairs from $newTrack in sequence to the track.

reverse() Reverses the array of coordinate pairs that make up the track.

truncatePrecision( int $decimals ) Loops over all the coordinate pairs in the track, and truncates the number of decimals in the coordinate pair to $decimals. In a second loop, it merges two consecutive coordinate pairs if they are the same after truncation.

Merging GPX Files

The Utils::createMergedTrack static method can be used to combine a set of GPX files. The method automatically reverses and selects the order in which the tracks are merged, based on the first and last points in the track.

The second argument to createMergedTrack determines how far (in metres) the different points of different tracks might lay away from each other to be considered as consecutive. By default, this is 25.0 metres.

If the GPX files are not consecutive then an Exception in thrown.

For example to merge all GPX files in a directory, you would use:

Changelog

ReleaseChanges
0.1.0 0.2.0 0.3.0Initial Release Added the DerickR\GPX\Writer::getGpxString() method Added the DerickR\GPX\Reader::getTracks() method

All versions of gpx-utils with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
ext-geospatial Version ^0.3.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package derickr/gpx-utils contains the following files

Loading the files please wait ....