Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit fc1dbe70fe69021a182cc6fb5a7db35eddf60529 1 parent d2ca3b8
@jbronn jbronn authored
View
7 django/contrib/gis/geos/base.py
@@ -12,7 +12,7 @@
# 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 @@ def __conform__(self, proto):
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
View
2  django/contrib/gis/geos/geometries.py
@@ -167,7 +167,7 @@ def __init__(self, *args, **kwargs):
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):
View
2  django/contrib/gis/geos/libgeos.py
@@ -21,10 +21,8 @@
# 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.
View
19 django/contrib/gis/tests/test_geos.py
@@ -594,6 +594,25 @@ def test16_mutable_geometries(self):
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))
Please sign in to comment.
Something went wrong with that request. Please try again.