djtommek/coordinates

Data object for Coordinates in WGS84 format.

2.1.0 2024-11-21 21:01 UTC

This package is auto-updated.

Last update: 2024-11-21 21:03:48 UTC


README

Data object for storing valid coordinates on Earth in decimal WGS-84 format.

Packagist Version GitHub Repo stars

Installation

composer require djtommek/coordinates

Usage example

<?php
$prague = new \DJTommek\Coordinates\Coordinates(50.0875, 14.4213);
printf('Prague: %s', $prague); // Prague: 50.087500,14.421300

$berlin = new \DJTommek\Coordinates\CoordinatesImmutable(52.518611, 13.408333);
$distance = $prague->distance($berlin);

printf('Distance between Prague and Berlin is %d km', $distance / 1000);
// 'Distance between Prague and Berlin is 279 km'

See source code for more methods and tests for more examples.

Testing

composer test