https://github.com/ralphschindler/laragis
A standalone Geo/GIS Provider for Laravel
https://github.com/ralphschindler/laragis
Last synced: about 1 month ago
JSON representation
A standalone Geo/GIS Provider for Laravel
- Host: GitHub
- URL: https://github.com/ralphschindler/laragis
- Owner: ralphschindler
- Created: 2016-10-02T14:23:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-22T22:23:02.000Z (over 8 years ago)
- Last Synced: 2025-06-08T18:05:42.477Z (5 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- Awesome-Geospatial - laragis - A standalone Geo/GIS Provider for Laravel. (PHP)
- awesome-gis - laragis - A standalone Geo/GIS Provider for Laravel. (Geospatial Library / PHP)
README
# LaraGis
LaraGis provides geospatial database and Eloquent features to Laravel.
Features:
- Simple Entity API, for use in casting model properties
- Fast serialization of geospatial data from MySql (not PHP userland) via `ST_AsGeoJSON()`
## Installation
To get started with Socialite, add to your `composer.json` file as a dependency:
composer require ralphschindler/laragis
### Configuration
After installing the Socialite library, register the `LaraGis\LaraGisProvider` in your `config/app.php` configuration file:
```php
'providers' => [
// Other service providers...
LaraGis\LaraGisProvider::class,
],
```
## Basic Usage
To use in `Eloquent` based models, use the `LaraGisTrait`, and specify a column to be cast into a geospatial datatype with the `laragis` key in the $casts array:
```php
class Place extends Model
{
use LaraGisTrait;
protected $table = 'places';
protected $casts = [
'coordinates' => 'laragis'
];
}
```
```php
$place = App\Places::find(1);
$coordinates = $place->coordinates;
echo $coordinates->getLatitudeLongitude(); // "30, -90"
```
## Entity API
```php
/**
* @property double $latitude
* @property double $longitude
*/
class Coordinates {
public function __construct($latitude = null, $longitude = null);
public function setLatitude($latitude);
public function getLatitude();
public function setLongitude($longitude);
public function getLongitude();
public function castToString($separator, $coordinatesOrder = self::LATITUDE_FIRST)
}
class Area implements \IteratorAggregate, \Countable {
public function addCoordinates(Coordinates $coordinates);
public function getCoordinates();
}
```