Skip to content

Commit b5a90c6

Browse files
committed
Changed namespace from Grimzy\LaravelSpatial to Grimzy\LaravelMysqlSpatial
1 parent 422e3f3 commit b5a90c6

40 files changed

+201
-191
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"autoload": {
2525
"psr-4": {
26-
"Grimzy\\LaravelSpatial\\": "src/"
26+
"Grimzy\\LaravelMysqlSpatial\\": "src/"
2727
}
2828
},
2929
"autoload-dev" : {

src/Connectors/ConnectionFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Connectors;
32

4-
use Grimzy\LaravelSpatial\MysqlConnection;
3+
namespace Grimzy\LaravelMysqlSpatial\Connectors;
4+
5+
use Grimzy\LaravelMysqlSpatial\MysqlConnection;
56
use PDO;
67

78
class ConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactory

src/Eloquent/Builder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Eloquent;
32

4-
use Grimzy\LaravelSpatial\Types\GeometryInterface;
3+
namespace Grimzy\LaravelMysqlSpatial\Eloquent;
4+
5+
use Grimzy\LaravelMysqlSpatial\Types\GeometryInterface;
56
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
67

78
class Builder extends EloquentBuilder
@@ -19,6 +20,6 @@ public function update(array $values)
1920

2021
protected function asWKT(GeometryInterface $geometry)
2122
{
22-
return $this->getQuery()->raw("GeomFromText('" . $geometry->toWKT() . "')");
23+
return $this->getQuery()->raw("GeomFromText('".$geometry->toWKT()."')");
2324
}
2425
}

src/Eloquent/SpatialTrait.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Eloquent;
32

4-
use Grimzy\LaravelSpatial\Exceptions\SpatialFieldsNotDefinedException;
5-
use Grimzy\LaravelSpatial\Types\Geometry;
6-
use Grimzy\LaravelSpatial\Types\GeometryInterface;
7-
use Grimzy\LaravelSpatial\Types\Point;
3+
namespace Grimzy\LaravelMysqlSpatial\Eloquent;
4+
5+
use Grimzy\LaravelMysqlSpatial\Exceptions\SpatialFieldsNotDefinedException;
6+
use Grimzy\LaravelMysqlSpatial\Types\Geometry;
7+
use Grimzy\LaravelMysqlSpatial\Types\GeometryInterface;
88
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
99

1010
trait SpatialTrait
@@ -25,7 +25,7 @@ trait SpatialTrait
2525
*
2626
* @param \Illuminate\Database\Query\Builder $query
2727
*
28-
* @return \Grimzy\LaravelSpatial\Eloquent\Builder
28+
* @return \Grimzy\LaravelMysqlSpatial\Eloquent\Builder
2929
*/
3030
public function newEloquentBuilder($query)
3131
{
@@ -68,47 +68,54 @@ public function getSpatialFields()
6868
if (property_exists($this, 'spatialFields')) {
6969
return $this->spatialFields;
7070
} else {
71-
throw new SpatialFieldsNotDefinedException(__CLASS__ . ' has to define $spatialFields');
71+
throw new SpatialFieldsNotDefinedException(__CLASS__.' has to define $spatialFields');
7272
}
7373
}
7474

75-
public function scopeDistance($query, $distance, $geometry, $column_name, $exclude_self = false) {
75+
public function scopeDistance($query, $distance, $geometry, $column_name, $exclude_self = false)
76+
{
7677
$query->whereRaw("st_distance(`{$column_name}`, GeomFromText('{$geometry->toWkt()}')) <= {$distance}");
7778

78-
if($exclude_self) {
79+
if ($exclude_self) {
7980
$query->whereRaw("st_distance(`{$column_name}`, GeomFromText('{$geometry->toWkt()}')) != 0");
8081
}
82+
8183
return $query;
8284
}
8385

84-
public function scopeDistanceSphere($query, $distance, $geometry, $column_name, $exclude_self = false) {
86+
public function scopeDistanceSphere($query, $distance, $geometry, $column_name, $exclude_self = false)
87+
{
8588
$query->whereRaw("st_distance_sphere(`{$column_name}`, GeomFromText('{$geometry->toWkt()}')) <= {$distance}");
8689

87-
if($exclude_self) {
90+
if ($exclude_self) {
8891
$query->whereRaw("st_distance_sphere(`{$column_name}`, GeomFromText('{$geometry->toWkt()}')) != 0");
8992
}
93+
9094
return $query;
9195
}
9296

93-
public function scopeDistanceValue($query, $geometry, $column_name) {
97+
public function scopeDistanceValue($query, $geometry, $column_name)
98+
{
9499
$columns = $query->getQuery()->columns;
95100

96-
if(!$columns) {
101+
if (! $columns) {
97102
$query->select('*');
98103
}
99104
$query->selectRaw("st_distance(`{$column_name}`, GeomFromText('{$geometry->toWkt()}')) as distance");
100105
}
101106

102-
public function scopeDistanceSphereValue($query, $geometry, $column_name) {
107+
public function scopeDistanceSphereValue($query, $geometry, $column_name)
108+
{
103109
$columns = $query->getQuery()->columns;
104110

105-
if(!$columns) {
111+
if (! $columns) {
106112
$query->select('*');
107113
}
108114
$query->selectRaw("st_distance_sphere(`{$column_name}`, GeomFromText('{$geometry->toWkt()}')) as distance");
109115
}
110116

111-
public function scopeBounding($query, Geometry $bounds, $column_name) {
117+
public function scopeBounding($query, Geometry $bounds, $column_name)
118+
{
112119
return $query->whereRaw("st_intersects(GeomFromText('{$bounds->toWkt()}'), `{$column_name}`)");
113120
}
114121
}

src/Exceptions/SpatialFieldsNotDefinedException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Exceptions;
2+
3+
namespace Grimzy\LaravelMysqlSpatial\Exceptions;
34

45
class SpatialFieldsNotDefinedException extends \RuntimeException
56
{

src/Exceptions/UnknownWKTTypeException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Exceptions;
2+
3+
namespace Grimzy\LaravelMysqlSpatial\Exceptions;
34

45
class UnknownWKTTypeException extends \RuntimeException
56
{

src/MysqlConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial;
2+
3+
namespace Grimzy\LaravelMysqlSpatial;
34

45
class MysqlConnection extends \Illuminate\Database\MySqlConnection
56
{
@@ -21,7 +22,6 @@ protected function getDefaultSchemaGrammar()
2122
return $this->withTablePrefix(new Schema\Grammars\MySqlGrammar());
2223
}
2324

24-
2525
public function getSchemaBuilder()
2626
{
2727
if (is_null($this->schemaGrammar)) {

src/Schema/Blueprint.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Schema;
2+
3+
namespace Grimzy\LaravelMysqlSpatial\Schema;
34

45
class Blueprint extends \Illuminate\Database\Schema\Blueprint
56
{
@@ -94,18 +95,19 @@ public function geometryCollection($column)
9495
/**
9596
* Specify a spatial index for the table
9697
*
97-
* @param string|array $columns
98-
* @param string $name
98+
* @param string|array $columns
99+
* @param string $name
99100
* @return \Illuminate\Support\Fluent
100101
*/
101-
public function spatialIndex($columns, $name = null) {
102+
public function spatialIndex($columns, $name = null)
103+
{
102104
return $this->indexCommand('spatial', $columns, $name);
103105
}
104106

105107
/**
106108
* Indicate that the given index should be dropped.
107109
*
108-
* @param string|array $index
110+
* @param string|array $index
109111
* @return \Illuminate\Support\Fluent
110112
*/
111113
public function dropSpatialIndex($index)

src/Schema/Builder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Schema;
2+
3+
namespace Grimzy\LaravelMysqlSpatial\Schema;
34

45
use Closure;
56
use Illuminate\Database\Schema\MySqlBuilder;

src/Schema/Grammars/MySqlGrammar.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
2-
namespace Grimzy\LaravelSpatial\Schema\Grammars;
32

4-
use Grimzy\LaravelSpatial\Schema\Blueprint;
3+
namespace Grimzy\LaravelMysqlSpatial\Schema\Grammars;
4+
5+
use Grimzy\LaravelMysqlSpatial\Schema\Blueprint;
56
use Illuminate\Support\Fluent;
67

78
class MySqlGrammar extends \Illuminate\Database\Schema\Grammars\MySqlGrammar
@@ -97,8 +98,8 @@ public function typeGeometrycollection(Fluent $column)
9798
/**
9899
* Compile a spatial index key command.
99100
*
100-
* @param \Grimzy\LaravelSpatial\Schema\Blueprint $blueprint
101-
* @param \Illuminate\Support\Fluent $command
101+
* @param \Grimzy\LaravelMysqlSpatial\Schema\Blueprint $blueprint
102+
* @param \Illuminate\Support\Fluent $command
102103
* @return string
103104
*/
104105
public function compileSpatial(Blueprint $blueprint, Fluent $command)

0 commit comments

Comments
 (0)