Componette

Componette

stanislav-janu

stanislav-janu / gps

Tool for work with GPS points.

download-cloud-line composer require stanislav-janu/gps

GPS

GPS Point with useful detection and method.

Composer Code style Tester PhpStan

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

composer require stanislav-janu/gps

Usage

try {
    $point = \JCode\GPS\GpsPoint::from('49°3\'6.630"N, 14°26\'7.763"E');
    echo $point; // 49.0518417, 14.4354897
    echo $point->lat; // 49.0518417
    echo $point->lng; // 14.4354897
} catch (\JCode\GPS\GpsPointException $exception) {
    echo $exception->getMessage();
}

Accepted formats:

  • Google maps URL
  • Mapy.cz URL
  • 49°3'6.630"N, 14°26'7.763"E
  • N 49°3.11050', E 14°26.12938'
  • 49.0518417N, 14.4354897E
  • 49.0518417N,14.4354897E
  • 49.0518417, 14.4354897
  • 49.0518417,14.4354897
  • 49.0518417 14.4354897
  • -47.338388,-0.990228
  • -47.338388 -0.990228

Distance

$point1 = \JCode\GPS\GpsPoint::from('some coordinates');
$point2 = \JCode\GPS\GpsPoint::from('some coordinates');
$distance =  $point1->distanceTo($point2); // distance in meters

Google Maps Distance Matrix

...
$distance = $point1->distanceTo($point2, 'Google Maps API key'); // distance in meters

No release at this moment. Try to create first one.

bar-chart-fill

Statistics

download-cloud-fill
2200
star-fill
0
bug-fill
0
flashlight-fill
124d
price-tag-2-line

Badges

guide-fill

Dependencies

php (>=8.0)
Componette Componette felix@nette.org