djtommek/coordinates

Data object for Coordinates in WGS84 format.

2.0.0 2024-05-20 18:30 UTC

This package is auto-updated.

Last update: 2024-10-20 19:24:34 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