Opened 13 years ago

Last modified 12 years ago

#17884 closed Bug

Distance lookups using ST_Distance_Sphere fails with PostGis 1.5.3 — at Initial Version

Reported by: ogirardot@… Owned by: nobody
Component: GIS Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,
i've worked a lot to make this work, and i just can't figure it out right now, so i'm opening a ticket. This is related to #16778 and my point of view right now is that it's a problem about how the EWKB Binary object gets created.
My problem is that, i've CommentAddress objects with PointField (srid=4326) and an Address with a PointField (srid=4326 too), i do a simple distance lookup request :

CommentAddress.objects.distance(Address.objects.get(pk=1111).geopoint)

And it fails with :

File ".../django/db/backends/postgresql_psycopg2/base.py", line 53, in execute

return self.cursor.execute(query, args)

DatabaseError: geometry_distance_spheroid: Operation on two GEOMETRIES with different SRIDs

But both are the proper srids, the problem is that the query that gets created is :

select St_Distance_Sphere(geopoint, ST_GeomFromEWKB('\x01010000001f7932dea0670240486469f173704840'::bytea)) from frontend_commentaddress;

But when i do myself the ST_AsEWKB on the same precise object i get a very different EWKB and the query - works :

select St_Distance_Sphere(geopoint, ST_GeomFromEWKB('\001\001\000\000 \346\020\000\000\037y1\336\240g\002@Hdi\361spH@'::bytea)) from frontend_commentaddress;

I tried to use self._adapter.adapted (which looks really better with a H@ at the end) instead of self._adapter.getquoted() into the postgis adapter but it doesn't work as it's unicode translated into bytes... Anyway i'm missing something there and can't get it working.

This is a real blocker, and it seems that this is crashing my local runserver (no stacktrace no log, just crashed).
Thank you for your help.

Here are my versions and what i tried :
Python 2.7.1
Django 1.4 trunk (as of today)
"POSTGIS="1.5.3" GEOS="3.3.2-CAPI-1.7.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.3" USE_STATS (procs from 1.5 r5976 need upgrade)"
"PostgreSQL 9.1.3 on x86_64-apple-darwin10.8.0, compiled by i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664), 64-bit"
both installed with homebrew. (on mac os lion)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top