Skip to content

latest code from source repo #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 111 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
7dff1f3
Use the schema defined in the Laravel configuration (database.connect…
grimzy Apr 3, 2018
e2c786d
Added config and code to publish it. Adjusted reference to the config.
grimzy Apr 3, 2018
1412576
Merge pull request #97 from grimzy/master
njbarrett Apr 4, 2018
ead7ad1
tag specific version of bosnadev/database in composer.json
njbarrett Jun 8, 2018
bab919c
fix failing tests as config function does not exist
nickbarrettjb Jun 8, 2018
a1c5e47
add support to geometry update and separate some functions
luizguilhermefr Jul 3, 2018
6261e1c
fix support on builder update
luizguilhermefr Jul 4, 2018
7c2b8cf
Merge pull request #101 from mypharmabr/master
njbarrett Jul 4, 2018
26f96fe
add third dimension to all simple types
v1r0x Jul 31, 2018
1055ccd
fix copy&waste
v1r0x Jul 31, 2018
c6fdfe7
add missing parameter
v1r0x Jul 31, 2018
8481a9b
fix regex for 3d
v1r0x Aug 1, 2018
d5c86b1
add 3d tests
v1r0x Aug 1, 2018
1a691ea
add more tests
v1r0x Aug 1, 2018
bc9f24b
Merge pull request #102 from v1r0x/3d-geometries
njbarrett Aug 22, 2018
5ee418e
:fire: remove hhvm support
nickbarrettjb Mar 6, 2019
c0a47a9
:construction_worker: test against php 7.1, 7.2, 7.3
nickbarrettjb Mar 6, 2019
36db592
:green_heart: allow failures in nightly
nickbarrettjb Mar 6, 2019
0a10f6d
:memo: update README with version info
nickbarrettjb Mar 6, 2019
2f74c7b
:bug: fix issue with multipoints only containing one point
nickbarrettjb Mar 21, 2019
b29f5e2
Merge pull request #108 from njbarrett/bugfix/multipoint-one-point
njbarrett Mar 21, 2019
ff4ff60
Fix creation of geometry outside public schema
chrudosvorlicek Jul 16, 2019
c0b9526
Merge pull request #116 from chrudosvorlicek/create_geometry_outside_…
njbarrett Jul 17, 2019
3836642
Add Support for Laravel 6.0
gueroverde Sep 4, 2019
adb0417
Merge pull request #117 from gueroverde/enhancement/support-for-laravel6
njbarrett Sep 5, 2019
00662d2
deps update
mirzap Sep 11, 2019
59edd60
Merge pull request #119 from bosnadev/master
njbarrett Sep 11, 2019
0f67c1c
add multipolygonz type
Gerzhelinazhit Oct 3, 2019
935417a
Update composer.json
olegmelnik Mar 3, 2020
a275381
Merge pull request #121 from olegmelnik/patch-1
njbarrett Mar 11, 2020
55ee06f
cleanup
Mar 11, 2020
1320767
ci work
Mar 11, 2020
9f2a492
prepare github actions
Mar 11, 2020
a590997
Merge branch 'master' into add-MultiPolygonZ-type
mstaack Mar 11, 2020
7f6f375
Merge pull request #120 from Gerzhelinazhit/add-MultiPolygonZ-type
mstaack Mar 11, 2020
fda6447
Merge branch 'master' into next
mstaack Mar 11, 2020
126e5fb
Merge pull request #126 from mstaack/next
mstaack Mar 11, 2020
19810ba
fix folder
Mar 11, 2020
4a4c5a8
fix ci
Mar 11, 2020
e715e59
remove mapping
Mar 11, 2020
f5df5d7
cleanup
Mar 11, 2020
6f2d29b
remove database refs
Mar 11, 2020
4109ad4
add badge
Mar 11, 2020
f2e8ff6
wip
Mar 11, 2020
f77f9c9
more work
Mar 11, 2020
f2a02af
use phpunit8
Mar 11, 2020
6f3c9bc
Deps update
mirzap Mar 11, 2020
228e277
remove for now
Mar 11, 2020
67b7e03
Merge pull request #127 from mstaack/update-deps-and-code
mstaack Mar 11, 2020
7a2e757
Merge pull request #128 from bosnadev/master
mstaack Mar 11, 2020
4de6f51
fix badge url
Mar 11, 2020
8b8d116
update readme
Mar 11, 2020
4a7ee20
update
Mar 11, 2020
bc5d73e
update readme
Mar 11, 2020
922d21f
cleanup
Mar 11, 2020
abbbe1e
add contributors
Mar 11, 2020
9c417da
rename
Mar 11, 2020
4e60b4a
cleanup and namespaces
Mar 11, 2020
c3b8025
cleanup namespaces
Mar 11, 2020
951754b
update readme
Mar 11, 2020
dd9ddb9
test on push is enough
Mar 11, 2020
d065660
name
Mar 11, 2020
98f9b19
Merge pull request #129 from mstaack/rework-tests
mstaack Mar 11, 2020
a3bb482
update readme
Mar 11, 2020
87f252f
fix connecting to database when registering package
vlktomas Aug 15, 2020
9e3fbcb
Merge pull request #138 from forsalio/master
mstaack Sep 1, 2020
40224de
Laravel 8 support
dena-a Sep 12, 2020
700a3d5
composer.json updated
dena-a Sep 14, 2020
0c23d58
undo composer.json updated
dena-a Sep 14, 2020
67c8eab
Merge pull request #139 from dena-a/master
mstaack Sep 22, 2020
1e9b896
bump bosnadev dep
Oct 22, 2020
a9dc605
Create PostGIS extension if it doesn’t exist
gbuckingham89 Jan 28, 2021
dbc285a
Drop PostGIS extension if it exists
gbuckingham89 Jan 28, 2021
f343b5d
Add instructions to README for enabling PostGIS
gbuckingham89 Jan 28, 2021
9c477ab
Merge pull request #152 from gbuckingham89/postgis-existence
mstaack Jan 29, 2021
3f8ecd7
fixes multipoint fromwkt without nested parenthesis (default with geo…
opengisdev Feb 16, 2021
ab24f9f
rename testFromWKTWithoutNestedParentesis
opengisdev Feb 16, 2021
7cf7e58
creates the test for 3D points without nested parentesis
opengisdev Feb 16, 2021
e51ca77
replaces \d in with [+-]?([0-9]+([.][0-9]*)?|[.][0-9]+) to support fl…
opengisdev Feb 16, 2021
858890c
Add publishable migration
studnitz Jun 2, 2021
5be106f
Update README with easier migrations installation
studnitz Jun 2, 2021
1726acd
Merge pull request #157 from studnitz/add-publishable-migrations
mstaack Jan 12, 2022
413f155
Adds use InvalidArgumentException to Geometries/MutltiPoint
opengisdev Jan 12, 2022
fe6a29e
Add Laravel 9 support
gbuckingham89 Jan 27, 2022
6dbeb62
Merge pull request #163 from gbuckingham89/dev/laravel9-support
mstaack Mar 3, 2022
9a30600
Merge pull request #153 from opengis/master
mstaack Mar 3, 2022
7e5527a
Added support for branch master on bosnadev/database
Apr 21, 2022
a3c00e0
Merge pull request #168 from robertosanval/laravel-9
mstaack Apr 25, 2022
b309f08
Add linestringz
May 9, 2022
15d88e4
Add pointz
May 16, 2022
577f0d6
import missing GeometryCollection
rogervila May 31, 2022
0ce123e
Merge pull request #172 from rogervila/fix-missing-import
mstaack Jun 1, 2022
68e522e
Merge pull request #171 from rvdveen/add-linestringz-and-pointz
mstaack Jun 1, 2022
effdefa
Added support for custom float precision to Point.
scottlimmer Jun 12, 2022
b447927
Added tests for customisable Point precision
scottlimmer Jun 12, 2022
06f8d06
Added sensible default to config for customisable Point precision
scottlimmer Jun 12, 2022
a0755be
Updated readme for customisable Point precision
scottlimmer Jun 12, 2022
cd19db2
Merge pull request #173 from scottlimmer/fix-167-coordinate-precision
mstaack Jun 14, 2022
50cc71c
Added return type
Jul 16, 2022
940855e
Added abstract class to add return type
Jul 16, 2022
8e9ac21
Merge pull request #174 from tdomy/add-return-type-for-php81
mstaack Jul 17, 2022
d450e36
fix default
Aug 11, 2022
f842b1d
Update run-tests.yml
mstaack Aug 15, 2022
509adba
fix build
Aug 15, 2022
2483bd8
fixup
Aug 15, 2022
801b129
Support upsert
RomainMazB Dec 6, 2022
eddd725
Bump dependencies for Laravel 10
laravel-shift Feb 1, 2023
1c96de3
Merge pull request #182 from laravel-shift/l10-compatibility
mstaack Mar 27, 2023
97c294f
Merge pull request #180 from RomainMazB/patch-1
mstaack Mar 27, 2023
5065630
Update composer.json
mstaack Mar 28, 2023
8bd236a
Update README.md
mstaack Apr 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test Suite

on:
push:
pull_request:

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.1 8.0 7.4]
release: [stable, lowest]

services:
postgres:
image: kartoza/postgis:12.1
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DBNAME: postgres
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3

steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: mbstring, dom, fileinfo, pgsql, intl
coverage: ${{ matrix.coverage }}
- run: composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-${{ matrix.release }}
- run: |
vendor/bin/phpunit
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

109 changes: 85 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,86 @@
Laravel postgis extension
=========================
Laravel Wrapper for PostgreSQL's Geo-Extension Postgis
======================================================

[![Build Status](https://travis-ci.org/njbarrett/laravel-postgis.svg?branch=master)](https://travis-ci.org/njbarrett/laravel-postgis.svg?branch=master)
[![Code Climate](https://codeclimate.com/github/njbarrett/laravel-postgis/badges/gpa.svg)](https://codeclimate.com/github/njbarrett/laravel-postgis)
[![Coverage Status](https://coveralls.io/repos/github/njbarrett/laravel-postgis/badge.svg?branch=master)](https://coveralls.io/github/njbarrett/laravel-postgis?branch=master)
![Build Status](https://github.com/mstaack/laravel-postgis/workflows/Test%20Suite/badge.svg)


# DEPRECATED
Consider using: https://github.com/clickbar/laravel-magellan

## Features

* Work with geometry classes instead of arrays. (`$myModel->myPoint = new Point(1,2)`)
* Adds helpers in migrations. (`$table->polygon('myColumn')`)
* Work with geometry classes instead of arrays.
```php
$model->myPoint = new Point(1,2); //lat, long
```

* Adds helpers in migrations.
```php
$table->polygon('myColumn');
```

## Warning
This Package has been moved to a new owner and aims for Laravel 6/7/8/9 and PHP 7 support only soon!

### Future plans
Replace all your references to the new namespace:
```
MStaack\LaravelPostgis
```

* Geometry functions on the geometry classes (contains(), equals(), distance(), etc… (HELP!))
Thanks to :
- https://github.com/njbarrett
- https://github.com/phaza
- https://github.com/mirzap

## Versions
- Use 2.* for Laravel 5.1.*
- Use 3.* for Laravel 5.2.*
- Use 3.* for Laravel 5.3.*
- Use 3.* for Laravel 5.4.*
- Use 3.* for Laravel 5.5.*
Fluent in Laravel Packages and Postgres/Postgis? Consider contributing! We are looking for anyone that wants to help out!

## Installation
- Use 3.* for Laravel 5

composer require phaza/laravel-postgis
```bash
composer require "mstaack/laravel-postgis:3.*"
```

- Use 5.* for Laravel 6/7/8/9
```bash
composer require mstaack/laravel-postgis
```

For laravel >=5.5 that's all. This package supports Laravel new [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery).

If you are using Laravel < 5.5, you also need to add the DatabaseServiceProvider to your `config/app.php` file.
```php
'MStaack\LaravelPostgis\DatabaseServiceProvider',
```
## Usage

'Phaza\LaravelPostgis\DatabaseServiceProvider',
To start, ensure you have PostGIS enabled in your database - you can do this in a Laravel migration or manually via SQL.

### Enable PostGIS via a Laravel migration

## Usage
You need to publish the migration to easily enable PostGIS:

First of all, make sure to enable postgis.
```sh
php artisan vendor:publish --provider="MStaack\LaravelPostgis\DatabaseServiceProvider" --tag="migrations"
```

And then you run the migrations:

```sh
php artisan migrate
```

These methods are safe to use and will only enable / disable the PostGIS extension if relevant - they won't cause an error if PostGIS is / isn't already enabled.

If you prefer, you can use the `enablePostgis()` method which will throw an error if PostGIS is already enabled, and the `disablePostgis()` method twhich will throw an error if PostGIS isn't enabled.

### Enable PostGIS manually

Use an SQL client to connect to your database and run the following command:

CREATE EXTENSION postgis;

To verify that postgis is enabled
To verify that PostGIS is enabled you can run:

SELECT postgis_full_version();

Expand All @@ -56,7 +98,7 @@ Open the created migrations with your editor.

```PHP
use Illuminate\Database\Migrations\Migration;
use Phaza\LaravelPostgis\Schema\Blueprint;
use MStaack\LaravelPostgis\Schema\Blueprint;

class CreateLocationsTable extends Migration {

Expand Down Expand Up @@ -118,8 +160,8 @@ what attributes/columns on your model are to be considered geometry objects. By

```PHP
use Illuminate\Database\Eloquent\Model;
use Phaza\LaravelPostgis\Eloquent\PostgisTrait;
use Phaza\LaravelPostgis\Geometries\Point;
use MStaack\LaravelPostgis\Eloquent\PostgisTrait;
use MStaack\LaravelPostgis\Geometries\Point;

class Location extends Model
{
Expand All @@ -137,7 +179,7 @@ class Location extends Model
'polygon',
'polygon2'
];

protected $postgisTypes = [
'location' => [
'geomtype' => 'geography',
Expand Down Expand Up @@ -195,3 +237,22 @@ Available geometry classes:
* Polygon
* MultiPolygon
* GeometryCollection

## Publishing config
A configuration file exists for overriding default values. To add to your project, run:

```sh
php artisan vendor:publish --provider="MStaack\LaravelPostgis\DatabaseServiceProvider" --tag="postgis"
```
### Coordinate precision
The precision of stored/displayed coordinated can be customised in the config.


```php
# config/postgis.php
return [
...
'precision' => 6,
];
```
See http://wiki.gis.com/wiki/index.php/Decimal_degrees#Accuracy for more information
33 changes: 19 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
{
"name": "phaza/laravel-postgis",
"name": "mstaack/laravel-postgis",
"description": "Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models",
"require": {
"php": ">=5.5",
"illuminate/database": "^5.2",
"php": ">=7.1",
"illuminate/database": "^6.0|^7.0|^8.0|^9.0|^10.0",
"geo-io/wkb-parser": "^1.0",
"jmikola/geojson": "^1.0",
"bosnadev/database": "~0.16"
"bosnadev/database": "^0.21|dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"mockery/mockery": "0.9.*",
"codeclimate/php-test-reporter": "~0.3",
"illuminate/pagination": "~5.0"
"illuminate/pagination": "^6.0|^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": ">=8.5.23",
"mockery/mockery": "^1.3"
},
"autoload": {
"psr-4": {
"Phaza\\LaravelPostgis\\": "src/"
"MStaack\\LaravelPostgis\\": "src/"
}
},
"autoload-dev": {
"classmap": [
"tests/BaseTestCase.php",
"tests/Stubs/"
]
"psr-4": {
"MStaack\\LaravelPostgis\\Tests\\": "tests/"
}
},
"license": "MIT",
"authors": [
Expand All @@ -34,13 +32,20 @@
{
"name": "Nicholas Barrett",
"email": "[email protected]"
},
{
"name": "Max Matteo Staack",
"email": "[email protected]"
}
],
"extra": {
"laravel": {
"providers": [
"Phaza\\LaravelPostgis\\DatabaseServiceProvider"
"MStaack\\LaravelPostgis\\DatabaseServiceProvider"
]
}
},
"scripts": {
"test": "./vendor/bin/phpunit"
}
}
6 changes: 6 additions & 0 deletions config/postgis.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'schema' => 'public', // Schema for the Postgis extension,
'precision' => 6, // Control precision of floats in stringifyFloat
];
27 changes: 27 additions & 0 deletions database/migrations/enable_postgis.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;

class EnablePostgis extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::enablePostgisIfNotExists();
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::disablePostgisIfExists();
}
}
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
syntaxCheck="true"
verbose="true">
<testsuites>
Expand Down
9 changes: 5 additions & 4 deletions src/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php namespace Phaza\LaravelPostgis\Connectors;
<?php namespace MStaack\LaravelPostgis\Connectors;

use Illuminate\Database\Connection;
use PDO;
use Phaza\LaravelPostgis\PostgisConnection;
use MStaack\LaravelPostgis\PostgisConnection;

class ConnectionFactory extends \Bosnadev\Database\Connectors\ConnectionFactory
{
Expand All @@ -15,8 +16,8 @@ class ConnectionFactory extends \Bosnadev\Database\Connectors\ConnectionFactory
*/
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
{
if ($this->container->bound($key = "db.connection.{$driver}")) {
return $this->container->make($key, [$connection, $database, $prefix, $config]);
if ($resolver = Connection::getResolver($driver)) {
return $resolver($connection, $database, $prefix, $config);
}

if ($driver === 'pgsql') {
Expand Down
27 changes: 20 additions & 7 deletions src/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<?php namespace Phaza\LaravelPostgis;
<?php

namespace MStaack\LaravelPostgis;

use Illuminate\Database\DatabaseManager;
use Phaza\LaravelPostgis\Connectors\ConnectionFactory;
use Bosnadev\Database\DatabaseServiceProvider as PostgresDatabaseServiceProvider;
use Illuminate\Database\DatabaseManager;
use MStaack\LaravelPostgis\Connectors\ConnectionFactory;

/**
* Class DatabaseServiceProvider
* @package Phaza\LaravelPostgis
*/
class DatabaseServiceProvider extends PostgresDatabaseServiceProvider
{
public function boot()
{
// Load the config
$config_path = __DIR__ . '/../config/postgis.php';
$this->publishes([$config_path => config_path('postgis.php')], 'postgis');

if (!class_exists('EnablePostgis')) {
$this->publishes([
__DIR__ . '/../database/migrations/enable_postgis.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_enable_postgis.php'),
], 'migrations');
}

$this->mergeConfigFrom($config_path, 'postgis');
}

/**
* Register the service provider.
*
Expand Down
Loading