Hi fellow Django developers

I have Lat/Lng points stored in my db:

class Airfield(models.Model):
    point = models.PointField(srid=4326)

I noticed when i query on my development server with postgresql i DONT
have to have the EXACT number of decimal places to find that point.
(what i want)
However on the production server if i ask for a point then i have to
give the exact same number with the same number of decimal places.
(undesired)

Production server is postgresql-8.3 where as my development server is
postgresql-8.4

Obviously the db backend is behaving differently.

8.4:
-32.6666666667 == -32.66666667
8.3:
-32.6666666667 !=  -32.66666667

How would i solve this issue with the geodjango/django ORM?
I dont want to have to change the db to 8 decimal places and try and
standardise things if possible.
I want to find matching points regardless of wether they are 8,9,10
decimal places.


Eg:

>>> Airfield.objects.get(airfield_name="Luskintyre")
<Airfield: -32.6666666667,151.416666667,ALA,Luskintyre,NSW...>

8.3:
>>> lat1 = -32.66666667
>>> long1 = 151.41666667
>>> destination = Point(lat1, long1)
>>> Airfield.objects.get(point=destination)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/db/models/manager.py",
line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 341, in get
    % self.model._meta.object_name)
DoesNotExist: Airfield matching query does not exist.

8.4:
>>> lat1 = -32.66666667
>>> long1 = 151.41666667
>>> destination = Point(lat1, long1)
>>> Airfield.objects.get(point=destination)
<Airfield: -32.6666666667,151.416666667,ALA,Luskintyre,NSW,...>

cheers

sam_W

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

Reply via email to