The module adds spatial filters to the ORM in order to query DataObjects. Most of them test relationships and accept a geometry as a parameter, except ST_Distance which expects an array of geometry and distance and ST_GeometryType which expects a shape type:
All filters can also be inverted using the :not
modifier.
Filter geometries that contain the given geometry
$city = City::get()->filter('Name', 'Wellington')->first();
$country = Country::get()->filter('Area:ST_Contains', $city->Location);
Filter geometries that cross the given geometry
Filter geometries that are disjoint from the given geometry
Filter geometries that are within distance of the given geometry
$city = City::get()->filter('Name', 'Wellington')->first();
$distance = 100000; // metres
$degrees = $distance / 111195;
$cities = Cities::get()->filter('Location:ST_Distance', [$city->Location, $degrees]);
Note: important to note is that the distance is given in the projections unit. For SRID 4326 it is degrees. Others use metres or kilometres. You can check this on epsg.io for the projection you are using.
Filter geometries that are equal to the given geometry
Filter geometries by the given shape type
$points = Anything::get()->filter('Location:ST_GeometryType', 'Point');
Filter geometries that intersect with the given geometry
Filter geometries that overlap the given geometry
Filter geometries that touch the given geometry
Filter geometries that lie within the given geometry