Download the PHP package opensource-labs-gh/laravel-geo-utils without Composer

On this page you can find all versions of the php package opensource-labs-gh/laravel-geo-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-geo-utils

Laravel Geo Utils

Latest Version on Packagist Total Downloads GitHub Tests Action Status

A comprehensive Laravel utility package for geographic operations, including polygon point checks, distance calculations, and spatial data manipulation. This package provides both pure PHP implementations and MySQL spatial function integration.

Features

Installation

Install the package via Composer:

The package will automatically register its service provider and facade.

Publishing Configuration

Optionally, you can publish the configuration file:

Usage

Basic Point-in-Polygon Check

Optimized Point-in-Polygon Check

For better performance with large polygons, use the optimized version that includes bounding box pre-filtering:

MySQL Spatial Functions

Use MySQL's built-in spatial functions for potentially better performance:

Distance Calculations

Calculate distances between two points using the Haversine formula:

Bounding Box Operations

Get the bounding box of a polygon:

WKT Conversion

Convert array coordinates to Well-Known Text format:

Artisan Commands

The package includes a command-line tool for testing and validation:

Basic Point-in-Polygon Test

Custom Polygon and Point Test

Distance Calculation Test

Bounding Box Test

Configuration

The package includes a configuration file with the following options:

API Reference

GeoHelper Methods

Method Parameters Return Description
isPointInPolygon() array $polygon, array $point bool Check if point is inside polygon using ray-casting
isPointInPolygonOptimized() array $polygon, array $point bool Optimized point-in-polygon with bounding box pre-check
isPointInPolygonMySQL() string $polygonWkt, float $lat, float $lng bool MySQL spatial function point-in-polygon check
calculateDistance() array $point1, array $point2, string $unit float Calculate distance between two points
getBoundingBox() array $polygon array Get polygon bounding box
isPointInBoundingBox() array $boundingBox, array $point bool Check if point is in bounding box
arrayToWktPolygon() array $polygon string Convert array coordinates to WKT format

Data Formats

Point Format:

Polygon Format:

Bounding Box Format:

Performance Considerations

  1. Bounding Box Optimization: For large polygons, use isPointInPolygonOptimized() which performs a quick bounding box check before the full polygon test.

  2. MySQL Spatial Functions: When working with large datasets, consider using isPointInPolygonMySQL() which leverages MySQL's optimized spatial functions.

  3. Coordinate Precision: Adjust coordinate_precision in config based on your needs - higher precision means more accuracy but potentially slower performance.

Error Handling

The package validates input data and throws InvalidArgumentException for:

Testing

Run the package tests:

Or run tests with coverage:

Contributing

Please see CONTRIBUTING.md for details on how to contribute to this project.

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.

Changelog

Please see CHANGELOG.md for more information about recent changes.

Support


Made with โค๏ธ by Opensource Labs Ghana


All versions of laravel-geo-utils with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package opensource-labs-gh/laravel-geo-utils contains the following files

Loading the files please wait ...