2017 © Pedro Peláez
 

library laravel-spatial

Mysql Geometry extensions for laravel. Aims to make it easy to work with geometries from laravel models

image

mammutgroup/laravel-spatial

Mysql Geometry extensions for laravel. Aims to make it easy to work with geometries from laravel models

  • Sunday, January 8, 2017
  • by honarkhah
  • Repository
  • 3 Watchers
  • 2 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 72 Forks
  • 0 Open issues
  • 33 Versions
  • 0 % Grown

The README.md

Laravel Mysql Geometry extension

Build Status Code Climate Coverage Status, (*1)

Features

  • Work with geometry classes instead of arrays. ($myModel->myPoint = new Point(1,2))
  • Adds helpers in migrations. ($table->polygon('myColumn'))

Future plans

  • Geometry functions on the geometry classes (contains(), equals(), distance(), etc… (HELP!))

Versions

Use 2.* for Laravel 5.1.*
Use 3.* for Laravel 5.2.*, (*2)

Installation

composer require phaza/laravel-postgis 

Next add the DatabaseServiceProvider to your config/app.php file., (*3)

'Mammutgroup\LaravelPostgis\DatabaseServiceProvider',

That's all., (*4)

Usage

First of all, make sure to enable postgis., (*5)

CREATE EXTENSION postgis;

To verify that postgis is enabled, (*6)

SELECT postgis_full_version();

Migrations

Now create a model with a migration by running, (*7)

php artisan make:model Location

If you don't want a model and just a migration run, (*8)

php artisan make:migration create_locations_table

Open the created migrations with your editor., (*9)

use Illuminate\Database\Migrations\Migration;
use Mammutgroup\LaravelPostgis\Schema\Blueprint;

class CreateLocationsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('locations', function(Blueprint $table)
        {
            $table->increments('id');
            $table->string('name');
            $table->string('address')->unique();
            $table->point('location');
            $table->polygon('polygon');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('locations');
    }

}

Available blueprint geometries:, (*10)

  • point
  • multipoint
  • linestring
  • multilinestring
  • polygon
  • multipolygon
  • geometrycollection

other methods:, (*11)

  • enablePostgis
  • disablePostgis

Models

All models which are to be PostGis enabled must use the PostgisTrait., (*12)

You must also define an array called $postgisFields which defines what attributes/columns on your model are to be considered geometry objects., (*13)

use Illuminate\Database\Eloquent\Model;
use Mammutgroup\LaravelPostgis\Eloquent\PostgisTrait;
use Mammutgroup\LaravelPostgis\Geometries\Point;

class Location extends Model
{
    use PostgisTrait;

    protected $fillable = [
        'name',
        'address'
    ];

    protected $postgisFields = [
        'location',
        'polygon',
    ];

}

$location1 = new Location();
$location1->name = 'Googleplex';
$location1->address = '1600 Amphitheatre Pkwy Mountain View, CA 94043';
$location1->location = new Point(37.422009, -122.084047);
$location1->save();

$location2 = Location::first();
$location2->location instanceof Point // true

Available geometry classes:, (*14)

  • Point
  • MultiPoint
  • LineString
  • MultiLineString
  • Polygon
  • MultiPolygon
  • GeometryCollection

The Versions

08/01 2017

dev-master

9999999-dev

Mysql Geometry extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza
by Nicholas Barrett
by Sayad Azami

08/01 2017

3.1.3

3.1.3.0

Mysql Geometry extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza
by Nicholas Barrett
by Sayad Azami

07/01 2017

3.1.2

3.1.2.0

Mysql Geometry extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza
by Nicholas Barrett
by Sayad Azami

03/01 2017

3.1.1

3.1.1.0

Mysql Geometry extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza
by Nicholas Barrett
by Sayad Azami

17/08 2016

5.1.x-dev

5.1.9999999.9999999-dev

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

26/07 2016

2.18

2.18.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

26/07 2016

dev-fix-for-5.1-connection

dev-fix-for-5.1-connection

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

15/06 2016

dev-add-query-scopes

dev-add-query-scopes

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza
by Nicholas Barrett

21/05 2016

3.1

3.1.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza
by Nicholas Barrett

26/01 2016

2.17

2.17.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

04/01 2016

2.16

2.16.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

11/11 2015

2.15

2.15.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

21/09 2015

2.14

2.14.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

10/06 2015

2.13

2.13.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

10/06 2015

2.12

2.12.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

20/05 2015

2.11

2.11.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

08/05 2015

2.10

2.10.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

06/05 2015

2.9

2.9.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

29/04 2015

2.8

2.8.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

17/04 2015

2.7

2.7.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

17/04 2015

2.6

2.6.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

17/04 2015

2.5

2.5.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

17/04 2015

2.4

2.4.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

15/04 2015

2.3

2.3.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

13/04 2015

2.2

2.2.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

13/04 2015

2.1

2.1.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

13/04 2015

2.0

2.0.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

27/03 2015

1.2

1.2.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

24/03 2015

1.1

1.1.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

24/03 2015

1.0

1.0.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

22/03 2015

0.2

0.2.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza

21/03 2015

0.1

0.1.0.0

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Haza