laravel-eloquent-spatial icon indicating copy to clipboard operation
laravel-eloquent-spatial copied to clipboard

Feature request: ST_Buffer support

Open aricooperdavis opened this issue 1 year ago • 1 comments

It would be brilliant if the API spatial scopes could be expanded to support ST_Buffer, e.g.


whereBuffer

Filters records within a buffer. Uses ST_Buffer.

parameter name type
$column Geometry \ string
$geometryOrColumn Geometry \ string
$value int \ float
Example
Place::create(['location' => new Point(1, 1.5)]);

$placesCountWithinBuffer = Place::query()
    ->whereBuffer('location', Polygon::fromJson('{"type":"Polygon","coordinates":[[[-1,-1],[1,-1],[1,1],[-1,1],[-1,-1]]]}'), 3)
    ->count();

echo $placesCountWithinBuffer; // 1

I will see if I can submit a PR, but with Christmas coming up it won't be for a little while!

aricooperdavis avatar Dec 21 '23 12:12 aricooperdavis

I'll be happy to accept a PR. Thanks!

MatanYadaev avatar Dec 22 '23 09:12 MatanYadaev