1. Go to this page and download the library: Download zero-config/geo-distance library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zero-config / geo-distance example snippets
use function ZeroConfig\GeoDistance\coordinates;
use function ZeroConfig\GeoDistance\distance;
// Returns a distance of approximately 361 kilometers.
// The distance function uses the distance calculator under the hood.
// It assumes earth as base sphere for calculations.
echo distance(
coordinates(50.0, 5.0),
coordinates(53.0, 3.0)
) . PHP_EOL;
use function ZeroConfig\GeoDistance\coordinates;
// This outputs: 50.6 °
echo coordinates(50.6, 5.0)->getLatitude() . PHP_EOL;
use function ZeroConfig\GeoDistance\coordinates;
use function ZeroConfig\GeoDistance\distance;
use Measurements\Units\UnitLength;
// Outputs: 36113.471850273 dam
echo distance(
coordinates(50.0, 5.0),
coordinates(53.0, 3.0)
)->convertTo(UnitLength::decameters()) . PHP_EOL;
use ZeroConfig\GeoDistance\ConvertedDistanceCalculator;
use ZeroConfig\GeoDistance\DistanceCalculator;
use ZeroConfig\GeoDistance\Position;
use ZeroConfig\GeoDistance\Sphere\CelestialBody\Mars;
use Measurements\Units\UnitLength;
$marsDistanceCalculator = new ConvertedDistanceCalculator(
new DistanceCalculator(new Mars()),
UnitLength::kilometers()
);
// On Mars, the same coordinates as on earth, give a distance of only 192 kilometers.
echo $marsDistanceCalculator->calculate(
Position::create(50.0, 5.0),
Position::create(53.0, 3.0)
) . PHP_EOL;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.