Skip to content

Commit 1c8b18e

Browse files
authored
Merge pull request #2 from tarfin-labs/refactor/update-readme
Refactor/update readme
2 parents f0d6274 + 4e61d0f commit 1c8b18e

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

README.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[![Total Downloads](https://img.shields.io/packagist/dt/tarfin-labs/laravel-spatial.svg?style=flat-square)](https://packagist.org/packages/tarfin-labs/laravel-spatial)
55
![GitHub Actions](https://github.com/tarfin-labs/laravel-spatial/actions/workflows/main.yml/badge.svg)
66

7-
Laravel package to work with geospatial data types and functions.
7+
This is a Laravel package to work with geospatial data types and functions.
88

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.
1010

1111
**Supported data types:**
1212
- `Point`
@@ -57,18 +57,22 @@ return new class extends SpatialMigration {
5757

5858
The migration above creates an `addresses` table with a `location` spatial column.
5959

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.
6161
6262
So you should give an SRID attribute to use spatial indexes in the migrations:
63+
6364
```php
6465
Schema::create('addresses', function (Blueprint $table) {
65-
$table->point('location', 4326);
66+
$table->point(column: 'location', srid: 4326);
6667

6768
$table->spatialIndex('location');
6869
})
6970
```
71+
7072
***
73+
7174
### 2- Models:
75+
7276
Fill the `$fillable`, `$casts` arrays in the model:
7377

7478
```php
@@ -95,6 +99,7 @@ class Address extends Model {
9599
```
96100

97101
### 3- Spatial Data Types:
102+
98103
#### ***Point:***
99104
`Point` represents the coordinates of a location and contains `latitude`, `longitude`, and `srid` properties.
100105

@@ -116,22 +121,27 @@ $location->getLng(); // 39.123456
116121
$locatipn->getSrid(); // 4326
117122
```
118123

119-
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:
120125

121126
```bash
122127
php artisan vendor:publish --provider="TarfinLabs\LaravelSpatial\LaravelSpatialServiceProvider"
123128
```
124129

125-
Then change the value of `default_srid` in `config/laravel-spatial.php`
130+
After that, you can change the value of `default_srid` in `config/laravel-spatial.php`
131+
126132
```php
127133
return [
128134
'default_srid' => 4326,
129135
];
130136
```
131137
***
132138
### 4- Scopes:
139+
133140
#### ***withinDistanceTo()***
134-
Filter addresses within 10 km of the given coordinate:
141+
142+
You can use the `withinDistanceTo()` scope to filter locations by given distance:
143+
144+
To filter addresses within the range of 10 km from the given coordinate:
135145

136146
```php
137147
use TarfinLabs\LaravelSpatial\Types\Point;
@@ -143,7 +153,8 @@ Address::query()
143153
```
144154

145155
#### ***selectDistanceTo()***
146-
Select distance to given coordinates as meter:
156+
157+
You can get the distance between two points by using `selectDistanceTo()` scope. The distance will be in meters:
147158

148159
```php
149160
use TarfinLabs\LaravelSpatial\Types\Point;
@@ -155,7 +166,8 @@ Address::query()
155166
```
156167

157168
#### ***orderByDistanceTo()***
158-
Order data by distance to given coordinates:
169+
170+
You can order your models by distance to given coordinates:
159171

160172
```php
161173
use TarfinLabs\LaravelSpatial\Types\Point;
@@ -172,7 +184,7 @@ Address::query()
172184
->get();
173185
```
174186

175-
Get latitude and longitude of the location:
187+
#### Get latitude and longitude of the location:
176188

177189
```php
178190
use App\Models\Address;
@@ -184,7 +196,7 @@ $address->location->getLat();
184196
$address->location->getLng();
185197
```
186198

187-
Create a new address with location:
199+
#### Create a new address with location:
188200

189201
```php
190202
use App\Models\Address;
@@ -202,13 +214,13 @@ Address::create([
202214
composer test
203215
```
204216

205-
### Todo
206-
- MultiPoint
207-
- LineString
208-
- MultiLineString
209-
- Polygon
210-
- MultiPolygon
211-
- GeometryCollection
217+
### Road Map
218+
- [ ] MultiPoint
219+
- [ ] LineString
220+
- [ ] MultiLineString
221+
- [ ] Polygon
222+
- [ ] MultiPolygon
223+
- [ ] GeometryCollection
212224

213225
### Changelog
214226

0 commit comments

Comments
 (0)