Sunday, April 29, 2012

Re: Unable to get result using distance query

On 26-04-12 00:02, vishy wrote:
> I am using PointField to store longitude and latitude with SRID 4326.
> All my places are in USA. Now, given a reference point, I do
>
> lat = "41.881944"
> lng = "-87.627778"
>
> ref_pnt = fromstr("POINT(%s %s)" % (lng, lat))

You have probably mixed up latitude and longitude. First pass lat, then lng.

> DatabaseError: Coordinate values are out of range [-180 -90,
> 180 90] for GEOGRAHY type

Only thing that springs to mind is that web-mercator coordinates
(="google") don't work from latitude 85 upwards and -85 downwards (so,
on the two poles). And as you swapped lat/lon, the 87 value ends up as
latitude. Long shot...

Another wild guess: print the value of ref_pnt. So what comes out of
fromstr(). Is that really the correct value? Is there some
number-formatting mishap that treats points differently?

Wild guesses...



Reinout

--
Reinout van Rees http://reinout.vanrees.org/
reinout@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment