Skip to content

Utilities to calculate position, address and distance

Notifications You must be signed in to change notification settings

larriereguichet/geolocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeoLocation

Install

composer require lag/geolocation

Usage

Calculate distance between two points

use LAG\GeoLocation\Distance\Calculator\DistanceCalculator;
use Geokit\Position;

$position1 = Position::fromXY(45.25, 65.23); 
$position2 = Position::fromXY(23.94, 55.12); 

$calculator = new DistanceCalculator();
$distance = $calculator->distance($position1, $position2);

// Distance are returned in kilometers
// $distance = 45.23

Check if a position is in a circle

use LAG\GeoLocation\Locator\Locator;
use Geokit\Position;

$position1 = Position::fromXY(45.25, 65.23); 
$center = Position::fromXY(23.94, 55.12);

$locator = new Locator();
// will return true if the position is in the circle with center $center and radius 45km 
$locator->isInRange($position1, $center, 45.0);

About

Utilities to calculate position, address and distance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages