Django

Code

Changeset 5832

Show
Ignore:
Timestamp:
08/08/07 22:07:02 (1 year ago)
Author:
jbronn
Message:

gis: geos: fixed 3d linestring constructor bug, and added tests; GEOM_FUNC_PREFIX no longer needed, since ST_Transform used.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/geos/base.py

    r5805 r5832  
    1313import re 
    1414from warnings import warn 
    15 from django.contrib.gis.geos.libgeos import lgeos, GEOSPointer, HAS_NUMPY, ISQLQuote, GEOM_FUNC_PREFIX 
     15from django.contrib.gis.geos.libgeos import lgeos, GEOSPointer, HAS_NUMPY, ISQLQuote 
    1616from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError 
    1717from django.contrib.gis.geos.coordseq import GEOSCoordSeq, create_cs 
     
    205205    def getquoted(self): 
    206206        "Returns a properly quoted string for use in PostgresSQL/PostGIS." 
    207         # GeomFromText() is ST_GeomFromText() in PostGIS >= 1.2.2 to correspond 
    208         #  to SQL/MM ISO standard. 
    209         return "%sGeomFromText('%s', %s)" % (GEOM_FUNC_PREFIX, self.wkt, self.srid or -1) 
     207        # Using ST_GeomFromText(), corresponds to SQL/MM ISO standard. 
     208        return "ST_GeomFromText('%s', %s)" % (self.wkt, self.srid or -1) 
    210209     
    211210    #### Coordinate Sequence Routines #### 
  • django/branches/gis/django/contrib/gis/geos/geometries.py

    r5805 r5832  
    168168 
    169169        # Creating the coordinate sequence 
    170         cs = GEOSCoordSeq(GEOSPointer(0, create_cs(c_uint(ncoords), c_uint(ndim)))
     170        cs = GEOSCoordSeq(GEOSPointer(0, create_cs(c_uint(ncoords), c_uint(ndim))), z=bool(ndim==3)
    171171 
    172172        # Setting each point in the coordinate sequence 
  • django/branches/gis/django/contrib/gis/geos/libgeos.py

    r5786 r5832  
    2222try: 
    2323    from psycopg2.extensions import ISQLQuote 
    24     from django.contrib.gis.db.backend.postgis import GEOM_FUNC_PREFIX 
    2524except (ImportError, EnvironmentError): 
    2625    ISQLQuote = None 
    27     GEOM_FUNC_PREFIX = None 
    2826 
    2927# Setting the appropriate name for the GEOS-C library, depending on which 
  • django/branches/gis/django/contrib/gis/tests/test_geos.py

    r5805 r5832  
    595595            del mpoly 
    596596 
     597     
     598    def test17_threed(self): 
     599        "Testing three-dimensional geometries." 
     600         
     601        # Testing a 3D Point 
     602        pnt = Point(2, 3, 8) 
     603        self.assertEqual((2.,3.,8.), pnt.coords) 
     604        self.assertRaises(TypeError, pnt.set_coords, (1.,2.)) 
     605        pnt.coords = (1.,2.,3.) 
     606        self.assertEqual((1.,2.,3.), pnt.coords) 
     607 
     608        # Testing a 3D LineString 
     609        ls = LineString((2., 3., 8.), (50., 250., -117.)) 
     610        self.assertEqual(((2.,3.,8.), (50.,250.,-117.)), ls.tuple) 
     611        self.assertRaises(TypeError, ls.__setitem__, 0, (1.,2.)) 
     612        ls[0] = (1.,2.,3.) 
     613        self.assertEqual((1.,2.,3.), ls[0]) 
     614             
     615 
    597616def suite(): 
    598617    s = unittest.TestSuite()