summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2007-08-09 03:07:02 +0000
committerJustin Bronn <jbronn@gmail.com>2007-08-09 03:07:02 +0000
commitfc1dbe70fe69021a182cc6fb5a7db35eddf60529 (patch)
tree4169541c5d83fec7a3591f1ddc34b98401315861
parentd2ca3b8b8fef57d9bfada833548578b852c5efb2 (diff)
gis: geos: fixed 3d linestring constructor bug, and added tests; GEOM_FUNC_PREFIX no longer needed, since ST_Transform used.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@5832 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/gis/geos/base.py7
-rw-r--r--django/contrib/gis/geos/geometries.py2
-rw-r--r--django/contrib/gis/geos/libgeos.py2
-rw-r--r--django/contrib/gis/tests/test_geos.py19
4 files changed, 23 insertions, 7 deletions
diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py
index fc159ffafd..77f6e810f6 100644
--- a/django/contrib/gis/geos/base.py
+++ b/django/contrib/gis/geos/base.py
@@ -12,7 +12,7 @@ from types import StringType, UnicodeType, IntType, FloatType
# Python and GEOS-related dependencies.
import re
from warnings import warn
-from django.contrib.gis.geos.libgeos import lgeos, GEOSPointer, HAS_NUMPY, ISQLQuote, GEOM_FUNC_PREFIX
+from django.contrib.gis.geos.libgeos import lgeos, GEOSPointer, HAS_NUMPY, ISQLQuote
from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError
from django.contrib.gis.geos.coordseq import GEOSCoordSeq, create_cs
if HAS_NUMPY: from numpy import ndarray, array
@@ -204,9 +204,8 @@ class GEOSGeometry(object):
def getquoted(self):
"Returns a properly quoted string for use in PostgresSQL/PostGIS."
- # GeomFromText() is ST_GeomFromText() in PostGIS >= 1.2.2 to correspond
- # to SQL/MM ISO standard.
- return "%sGeomFromText('%s', %s)" % (GEOM_FUNC_PREFIX, self.wkt, self.srid or -1)
+ # Using ST_GeomFromText(), corresponds to SQL/MM ISO standard.
+ return "ST_GeomFromText('%s', %s)" % (self.wkt, self.srid or -1)
#### Coordinate Sequence Routines ####
@property
diff --git a/django/contrib/gis/geos/geometries.py b/django/contrib/gis/geos/geometries.py
index 70dbfbf9f8..2a5b5df600 100644
--- a/django/contrib/gis/geos/geometries.py
+++ b/django/contrib/gis/geos/geometries.py
@@ -167,7 +167,7 @@ class LineString(GEOSGeometry):
raise TypeError, 'Invalid initialization input for LineStrings.'
# Creating the coordinate sequence
- cs = GEOSCoordSeq(GEOSPointer(0, create_cs(c_uint(ncoords), c_uint(ndim))))
+ cs = GEOSCoordSeq(GEOSPointer(0, create_cs(c_uint(ncoords), c_uint(ndim))), z=bool(ndim==3))
# Setting each point in the coordinate sequence
for i in xrange(ncoords):
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index f505522095..1a373e8682 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -21,10 +21,8 @@ except ImportError:
# Are psycopg2 and GeoDjango models being used?
try:
from psycopg2.extensions import ISQLQuote
- from django.contrib.gis.db.backend.postgis import GEOM_FUNC_PREFIX
except (ImportError, EnvironmentError):
ISQLQuote = None
- GEOM_FUNC_PREFIX = None
# Setting the appropriate name for the GEOS-C library, depending on which
# OS and POSIX platform we're running.
diff --git a/django/contrib/gis/tests/test_geos.py b/django/contrib/gis/tests/test_geos.py
index ad6043cd3e..185820d535 100644
--- a/django/contrib/gis/tests/test_geos.py
+++ b/django/contrib/gis/tests/test_geos.py
@@ -594,6 +594,25 @@ class GEOSTest(unittest.TestCase):
self.assertNotEqual(poly, mpoly[i])
del mpoly
+
+ def test17_threed(self):
+ "Testing three-dimensional geometries."
+
+ # Testing a 3D Point
+ pnt = Point(2, 3, 8)
+ self.assertEqual((2.,3.,8.), pnt.coords)
+ self.assertRaises(TypeError, pnt.set_coords, (1.,2.))
+ pnt.coords = (1.,2.,3.)
+ self.assertEqual((1.,2.,3.), pnt.coords)
+
+ # Testing a 3D LineString
+ ls = LineString((2., 3., 8.), (50., 250., -117.))
+ self.assertEqual(((2.,3.,8.), (50.,250.,-117.)), ls.tuple)
+ self.assertRaises(TypeError, ls.__setitem__, 0, (1.,2.))
+ ls[0] = (1.,2.,3.)
+ self.assertEqual((1.,2.,3.), ls[0])
+
+
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(GEOSTest))