patrickkempff / location
一个用于处理(地理)位置的简单库。
dev-master
2016-08-15 10:42 UTC
Requires
- php: >=5.4.0
- beberlei/assert: ~2.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.11
- phpunit/phpunit: ~4.0|~5.0
- satooshi/php-coveralls: ~1.0
This package is not auto-updated.
Last update: 2024-09-28 19:47:16 UTC
README
一个用于处理(地理)位置的简单库。
use Location\Location; use Location\Coordinate\Coordinate2d; use Location\Distance\Haversine; // Amsterdam, NL. $amsterdam = new Location(new Coordinate2d(52.3079989, 4.9715451)); // Venlo, NL. $venlo = new Location(new Coordinate2d(51.3703748, 6.1724031)); // The distance between Venlo and Amsterdam is 132950 meters (132km 950m) // using the Haversine formula. $distance = $amsterdam->calculateDistanceFromLocation($venlo, new Haversine());
安装
使用 Composer
$ composer require patrickkempff/location
{ "require": { "patrickkempff/location": "dev-master" } }
<?php require 'vendor/autoload.php'; use Location\Location; use Location\Coordinate\Coordinate2d; use Location\Distance\Haversine; // Amsterdam, NL. $amsterdam = new Location(new Coordinate2d(52.3079989, 4.9715451)); // Venlo, NL. $venlo = new Location(new Coordinate2d(51.3703748, 6.1724031)); // The distance between Venlo and Amsterdam is 132950 meters (132km 950m) // using the Haversine formula. $distance = $amsterdam->calculateDistanceFromLocation($venlo, new Haversine());
手动安装
请注意,推荐通过 composer 安装 Location。如果您确实想手动安装 Location,可以从Location 仓库下载并解压文件到您的项目目录中。
<?php require 'path/to/Location.php'; require 'path/to/Coordinate/Coordinate2d.php'; require 'path/to/Distance/Haversine.php'; use Location\Location; use Location\Coordinate\Coordinate2d; use Location\Distance\Haversine; // Amsterdam, NL. $amsterdam = new Location(new Coordinate2d(52.3079989, 4.9715451)); // Venlo, NL. $venlo = new Location(new Coordinate2d(51.3703748, 6.1724031)); // The distance between Venlo and Amsterdam is 132950 meters (132km 950m) // using the Haversine formula. $distance = $amsterdam->calculateDistanceFromLocation($venlo, new Haversine());