[Changeset] r11731 - in django/trunk/django/contrib/gis/geos: . tests

View: New views
1 Messages — Rating Filter:   Alert me  

[Changeset] r11731 - in django/trunk/django/contrib/gis/geos: . tests

by Django-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message


Author: jbronn
Date: 2009-11-10 11:28:20 -0600 (Tue, 10 Nov 2009)
New Revision: 11731

Modified:
   django/trunk/django/contrib/gis/geos/geometry.py
   django/trunk/django/contrib/gis/geos/tests/test_geos.py
Log:
Now raise an exception when trying to export 3D (HEX)EWKB when using GEOS 3.0 due to bug in that underlying library version.


Modified: django/trunk/django/contrib/gis/geos/geometry.py
===================================================================
--- django/trunk/django/contrib/gis/geos/geometry.py 2009-11-10 15:21:12 UTC (rev 11730)
+++ django/trunk/django/contrib/gis/geos/geometry.py 2009-11-10 17:28:20 UTC (rev 11731)
@@ -389,6 +389,9 @@
         geometry.
         """
         if self.hasz:
+            if not GEOS_PREPARE:
+                # See: http://trac.osgeo.org/geos/ticket/216
+                raise GEOSException('Upgrade GEOS to 3.1 to get valid 3D HEXEWKB.')              
             return ewkb_w3d.write_hex(self)
         else:
             return ewkb_w.write_hex(self)
@@ -422,6 +425,9 @@
         and Z values that are a part of this geometry.
         """
         if self.hasz:
+            if not GEOS_PREPARE:
+                # See: http://trac.osgeo.org/geos/ticket/216
+                raise GEOSException('Upgrade GEOS to 3.1 to get valid 3D EWKB.')
             return ewkb_w3d.write(self)
         else:
             return ewkb_w.write(self)

Modified: django/trunk/django/contrib/gis/geos/tests/test_geos.py
===================================================================
--- django/trunk/django/contrib/gis/geos/tests/test_geos.py 2009-11-10 15:21:12 UTC (rev 11730)
+++ django/trunk/django/contrib/gis/geos/tests/test_geos.py 2009-11-10 17:28:20 UTC (rev 11731)
@@ -84,16 +84,34 @@
 
         # HEXEWKB should be appropriate for its dimension -- have to use an
         # a WKBWriter w/dimension set accordingly, else GEOS will insert
-        # garbage into 3D coordinate if there is none.
+        # garbage into 3D coordinate if there is none.  Also, GEOS has a
+        # a bug in versions prior to 3.1 that puts the X coordinate in
+        # place of Z; an exception should be raised on those versions.
         self.assertEqual(hexewkb_2d, pnt_2d.hexewkb)
-        self.assertEqual(hexewkb_3d, pnt_3d.hexewkb)
+        if GEOS_PREPARE:
+            self.assertEqual(hexewkb_3d, pnt_3d.hexewkb)
+            self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz)
+        else:
+            try:
+                hexewkb = pnt_3d.hexewkb
+            except GEOSException:
+                pass
+            else:
+                self.fail('Should have raised GEOSException.')
 
         # Same for EWKB.
         self.assertEqual(buffer(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
-        self.assertEqual(buffer(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
+        if GEOS_PREPARE:
+            self.assertEqual(buffer(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
+        else:
+            try:
+                ewkb = pnt_3d.ewkb
+            except GEOSException:
+                pass
+            else:
+                self.fail('Should have raised GEOSException')
         
         # Redundant sanity check.
-        self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz)
         self.assertEqual(4326, GEOSGeometry(hexewkb_2d).srid)
 
     def test01c_kml(self):


--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---