views:

87

answers:

1

Can someone please explain why the wkt (well-known text) of a point object in geodjango would be returning what seems to be different coordinates than the object was initialized with? I've got to imagine it's something I'm doing wrong, and not geos. The wkt should look like: "POINT (-122.432534 37.764021)" but instead it looks like: 'POINT (-122.4325340000000040 37.7640209999999996)'

Where is this rounding coming from? It's making it so that I can't do a query like Location.objects.get(pnt="POINT (-122.432534 37.764021)") because it thinks they are (ever so slightly) different points!

>>> from django.contrib.gis.geos import Point
>>> p = Point(-122.432534,37.764021)
>>> p
<Point object at 0x239c1e4>
>>> p.wkt
'POINT (-122.4325340000000040 37.7640209999999996)'
>>> p.x
-122.432534
>>> p.y
37.764021
A: 

This is very likely coming from __str__ or __repr__. Doing anything to those numbers (cross products, saving to the db) and getting the same precision back should confirm this.

Cheers

Arthur Debert