#17884: Distance lookups using ST_Distance_Sphere fails with PostGis 1.5.3 ---------------------------------+-------------------------------------- Reporter: ogirardot@… | Owner: nobody Type: Bug | Status: new Component: GIS | Version: SVN Severity: Release blocker | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+--------------------------------------
Old 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) New 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 : {{{ #!python 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) -- Comment (by kmtracey): Fixed formatting, please use WikiFormatting and preview before submitting. I don't see evidence that this is something that is a regression in Django code and therefore should be a release blocker? -- Ticket URL: <https://code.djangoproject.com/ticket/17884#comment:2> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.