Hello, was wondering if anyone might be able to help here.
I am using the InBBoxFilter provided by django-rest-framework-gis to filter a queryset of geometries in my ReadOnlyModelViewset (DRF):
from rest_framework import viewsets
from rest_framework_gis import filters
from sites_app.serializers import SiteSerializer
class SiteViewset(viewsets.ReadOnlyModelViewSet):
bbox_filter_field = "geom"
bbox_filter_include_overlapping = True
filter_backends = (filters.InBBoxFilter,)
serializer_class = SiteSerializer
When the query is made in the database, I get:
django.db.utils.OperationalError: (3033, 'Binary geometry function mbroverlaps given two geometries of different srids: 27700 and 0, which should have been identical.')
The SRID of the geometry column in the database is EPSG:27700, and the bounding box passed to the view also has EPSG:27700 coordinates - but it looks like the latter is being passed to the database without an SRID? Do I need to specify the SRID of the bounding box somewhere? I’ve tried to trace this through the source code but can’t see how to do this.
The database is MySQL. I was originally using PostgreSQL / PostGIS, and this code worked fine. Unfortunately, I’ve had to switch the database to MySQL, and that’s when the error started.
From the database logs, I can see that the query being run on the database is of the form
... WHERE MBROverlaps(`table`.`geom`, ST_GeomFromText('POLYGON ((<bbox coords>))'))
I.e. no SRID is passed to the database for the bounding box, which is presumably causing the problem because MySQL interprets that as being an SRID of 0.
Any help on this would be very much appreciated. Many thanks.