#31162: GIS error logging when using WKT string as input to filter() query -----------------------------------------+------------------------ Reporter: Arno | Owner: nobody Type: Uncategorized | Status: new Component: GIS | Version: 2.2 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -----------------------------------------+------------------------ When executing a geometry lookup like `my_geo_model.objects.filter(my_geom__intersects=wkt_string)` (i.e. using a WKT string as value) django.contrib.gis emits the following errors:
{{{ 2020-01-13 10:16:07,145 - django.contrib.gis - ERROR - GDAL_ERROR 4: b'POLYGON ((1 1, 1 0, 0 0, 0 1, 1 1)): No such file or directory' 2020-01-13 10:16:08,403 - django.contrib.gis - ERROR - GDAL_ERROR 10: b"Pointer 'hObject' is NULL in 'GDALGetDescription'.\n" }}} The reason is that if passed a string, the string is first treated as a potential filename which GDAL tries to open and fails ("no such file"). Only then it is tried to open the string as WKT/GeoJSON etc. Older Django versions did not emit these errors. However, in commit 6f44f714c9 a check in django/contrib/gis/gdal/raster/source.py:69 whether the file exists was removed. Silencing all errors from django.contrib.gis is not really a feasable workaround, as it would mean silcencing interesting GIS errors too. According to https://docs.djangoproject.com/en/2.2/ref/contrib/gis/db-api /#geometry-lookups passing WKT strings is allowed, but there's no mention of being able to pass a filename as parameter. It's a bit unexpected that Django first tries to open a file before it checks whether the passed string is valid WKT/GeoJSON, and that using WKT results in error messages. Or am I misunderstanding the documentation and calling the API wrongly? Relevant parts of example source: {{{ models.py: class Area(models.Model): area = models.PolygonField() settings.py: LOGGING = { 'version': 1, 'handlers': { 'console': { 'level': 'INFO', 'class': 'logging.StreamHandler', }, }, 'root': { 'handlers': ['console'], 'level': 'INFO', } } main.py: from app.models import Area Area.objects.filter(area__intersects='POLYGON ((1 1, 1 0, 0 0, 0 1, 1 1))') }}} -- Ticket URL: <https://code.djangoproject.com/ticket/31162> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.618494632e9eed8f642e233b11000108%40djangoproject.com.