You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Laravel package to work with geospatial data types and functions.
7
+
This is a Laravel package to work with geospatial data types and functions.
8
8
9
-
For now, it supports only MySql Spatial Data Types and Functions.
9
+
It supports only MySQL Spatial Data Types and Functions, other RDBMS is on the roadmap.
10
10
11
11
**Supported data types:**
12
12
-`Point`
@@ -57,18 +57,22 @@ return new class extends SpatialMigration {
57
57
58
58
The migration above creates an `addresses` table with a `location` spatial column.
59
59
60
-
>Spatial columns with no SRID attribute are not SRID-restricted and accept values with any SRID. However, the optimizer cannot use SPATIAL indexes on them until the column definition is modified to include an SRID attribute, which may require that the column contents first be modified so that all values have the same SRID.
60
+
>Spatial columns with no SRID attribute are not SRID-restricted and accept values with any SRID. However, the optimizer cannot use SPATIAL indexes on them until the column definition is modified to include an SRID attribute, which may require that the column contents first be modified so that all values have the same SRID.
61
61
62
62
So you should give an SRID attribute to use spatial indexes in the migrations:
63
+
63
64
```php
64
65
Schema::create('addresses', function (Blueprint $table) {
65
-
$table->point('location', 4326);
66
+
$table->point(column: 'location', srid: 4326);
66
67
67
68
$table->spatialIndex('location');
68
69
})
69
70
```
71
+
70
72
***
73
+
71
74
### 2- Models:
75
+
72
76
Fill the `$fillable`, `$casts` arrays in the model:
73
77
74
78
```php
@@ -95,6 +99,7 @@ class Address extends Model {
95
99
```
96
100
97
101
### 3- Spatial Data Types:
102
+
98
103
#### ***Point:***
99
104
`Point` represents the coordinates of a location and contains `latitude`, `longitude`, and `srid` properties.
You can override the default SRID via the `laravel-spatial` config file. To do that, you should publish the config migration file using vendor:publish artisan command:
124
+
You can override the default SRID via the `laravel-spatial` config file. To do that, you should publish the config file using `vendor:publish` artisan command:
0 commit comments