Download the PHP package vpro/geo-calculator without Composer
On this page you can find all versions of the php package vpro/geo-calculator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vpro/geo-calculator
More information about vpro/geo-calculator
Files in vpro/geo-calculator
Package geo-calculator
Short Description A PHP package for calculating geographical distances
License MIT
Informations about the package geo-calculator
PHP Geographic Distance Calculator
A PHP package for calculating geographic distances using the Haversine formula. Perfect for applications needing to determine distances between coordinates or check if locations are within a specific radius.
Features
- ๐ Calculate distances between geographic coordinates
- ๐ Support for both kilometers and miles
- ๐ฏ Check if points are within a given radius
- ๐ Convert between different distance units
- ๐ช Strong typing with PHP 7.4+ support
- ๐งช Comprehensive test suite
Installation
You can install the package via composer:
Usage
Basic Distance Calculation
Check if Point is Within Radius
Convert Between Units
API Reference
calculateDistance()
Calculate the distance between two geographic points.
Parameters:
$lat1
: Latitude of first point in degrees$lon1
: Longitude of first point in degrees$lat2
: Latitude of second point in degrees$lon2
: Longitude of second point in degrees$unit
: Unit of measurement ('km' or 'mi', defaults to 'km')
isWithinRadius()
Check if a point is within a specified radius of another point.
Parameters:
$lat1
: Latitude of center point in degrees$lon1
: Longitude of center point in degrees$lat2
: Latitude of point to check in degrees$lon2
: Longitude of point to check in degrees$radius
: Radius to check within$unit
: Unit of measurement ('km' or 'mi', defaults to 'km')
convertDistance()
Convert distances between different units.
Parameters:
$distance
: Distance to convert$from
: Original unit ('km' or 'mi')$to
: Target unit ('km' or 'mi')
Testing
Contributing
Please see CONTRIBUTING.md for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.