djtommek / coordinates
Data object for Coordinates in WGS84 format.
2.1.0
2024-11-21 21:01 UTC
Requires
- php: >=8.1
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
README
Data object for storing valid coordinates on Earth in decimal WGS-84 format.
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