Django

Code

Changeset 6861

Show
Ignore:
Timestamp:
12/03/07 00:27:16 (7 months ago)
Author:
jbronn
Message:

gis: renamed GEOSGeometryIndexError to GEOSIndexError; added GEOS_LIBRARY_PATH settings option.

Files:

Legend:

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

    r6653 r6861  
    1010# GEOS-related dependencies. 
    1111from django.contrib.gis.geos.coordseq import GEOSCoordSeq 
    12 from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError 
     12from django.contrib.gis.geos.error import GEOSException 
    1313from django.contrib.gis.geos.libgeos import GEOM_PTR 
    1414 
     
    122122        return self.union(other) 
    123123 
    124     # g1 |= g2 
    125     def __ior__(self, other): 
    126         "Reassigns this Geometry to the union of this Geometry and the other." 
    127         return self.union(other) 
    128  
    129124    # g = g1 & g2 
    130125    def __and__(self, other): 
     
    132127        return self.intersection(other) 
    133128 
    134     # g1 &= g2 
    135     def __iand__(self, other): 
    136         "Reassigns this Geometry to the intersection of this Geometry and the other." 
    137         return self.intersection(other) 
    138  
    139129    # g = g1 - g2 
    140130    def __sub__(self, other): 
     
    142132        return self.difference(other) 
    143133 
    144     # g1 -= g2 
    145     def __isub__(self, other): 
    146         "Reassigns this Geometry to the difference of this Geometry and the other." 
    147         return self.difference(other) 
    148  
    149134    # g = g1 ^ g2 
    150135    def __xor__(self, other): 
    151136        "Return the symmetric difference of this Geometry and the other." 
    152         return self.sym_difference(other) 
    153  
    154     # g1 ^= g2 
    155     def __ixor__(self, other): 
    156         """ 
    157         Reassigns this Geometry to the symmetric difference of this Geometry  
    158         and the other. 
    159         """ 
    160137        return self.sym_difference(other) 
    161138 
  • django/branches/gis/django/contrib/gis/geos/collections.py

    r6653 r6861  
    66from types import TupleType, ListType 
    77from django.contrib.gis.geos.base import GEOSGeometry 
    8 from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError 
     8from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 
    99from django.contrib.gis.geos.geometries import Point, LineString, LinearRing, Polygon 
    1010from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR 
     
    8181        "Checks the given geometry index." 
    8282        if index < 0 or index >= self.num_geom: 
    83             raise GEOSGeometryIndexError('invalid GEOS Geometry index: %s' % str(index)) 
     83            raise GEOSIndexError('invalid GEOS Geometry index: %s' % str(index)) 
    8484 
    8585    @property 
  • django/branches/gis/django/contrib/gis/geos/coordseq.py

    r6653 r6861  
    66from ctypes import c_double, c_uint, byref 
    77from types import ListType, TupleType 
    8 from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError 
     8from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 
    99from django.contrib.gis.geos.libgeos import CS_PTR, HAS_NUMPY 
    1010from django.contrib.gis.geos.prototypes import cs_clone, cs_getdims, cs_getordinate, cs_getsize, cs_setordinate 
     
    7070        sz = self.size 
    7171        if (sz < 1) or (index < 0) or (index >= sz): 
    72             raise GEOSGeometryIndexError('invalid GEOS Geometry index: %s' % str(index)) 
     72            raise GEOSIndexError('invalid GEOS Geometry index: %s' % str(index)) 
    7373 
    7474    def _checkdim(self, dim): 
  • django/branches/gis/django/contrib/gis/geos/error.py

    r6653 r6861  
    88    pass 
    99 
    10 class GEOSGeometryIndexError(GEOSException, KeyError): 
     10class GEOSIndexError(GEOSException, KeyError): 
    1111    """ 
    1212    This exception is raised when an invalid index is encountered, and has 
  • django/branches/gis/django/contrib/gis/geos/geometries.py

    r6653 r6861  
    88from django.contrib.gis.geos.base import GEOSGeometry 
    99from django.contrib.gis.geos.coordseq import GEOSCoordSeq 
    10 from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError 
     10from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 
    1111from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR, HAS_NUMPY 
    1212from django.contrib.gis.geos.prototypes import * 
     
    329329        "Internal routine for checking the given ring index." 
    330330        if index < 0 or index >= len(self): 
    331             raise GEOSGeometryIndexError('invalid Polygon ring index: %s' % index) 
     331            raise GEOSIndexError('invalid Polygon ring index: %s' % index) 
    332332 
    333333    def get_interior_ring(self, ring_i): 
  • django/branches/gis/django/contrib/gis/geos/__init__.py

    r6653 r6861  
    3232from django.contrib.gis.geos.geometries import Point, LineString, LinearRing, Polygon, HAS_NUMPY 
    3333from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon 
    34 from django.contrib.gis.geos.error import GEOSException, GEOSGeometryIndexError 
     34from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 
    3535from django.contrib.gis.geos.libgeos import geos_version 
    3636 
  • django/branches/gis/django/contrib/gis/geos/libgeos.py

    r6653 r6861  
    1818    HAS_NUMPY = False 
    1919 
     20# Custom library path set? 
     21try: 
     22    from django.conf import settings 
     23    lib_name = settings.GEOS_LIBRARY_PATH 
     24except (AttributeError, EnvironmentError): 
     25    lib_name = None 
     26 
    2027# Setting the appropriate name for the GEOS-C library, depending on which 
    2128# OS and POSIX platform we're running. 
    22 if os.name == 'nt': 
     29if lib_name: 
     30    pass 
     31elif os.name == 'nt': 
    2332    # Windows NT library 
    2433    lib_name = 'libgeos_c-1.dll' 
  • django/branches/gis/django/contrib/gis/tests/test_geos.py

    r6653 r6861  
    22from ctypes import ArgumentError 
    33from django.contrib.gis.geos import \ 
    4     GEOSException, GEOSGeometryIndexError, \ 
     4    GEOSException, GEOSIndexError, \ 
    55    GEOSGeometry, Point, LineString, LinearRing, Polygon, \ 
    66    MultiPoint, MultiLineString, MultiPolygon, GeometryCollection, \ 
     
    145145            self.assertAlmostEqual(mp.centroid[1], mpnt.centroid.tuple[1], 9) 
    146146 
    147             self.assertRaises(GEOSGeometryIndexError, mpnt.__getitem__, len(mpnt)) 
     147            self.assertRaises(GEOSIndexError, mpnt.__getitem__, len(mpnt)) 
    148148            self.assertEqual(mp.centroid, mpnt.centroid.tuple) 
    149149            self.assertEqual(mp.points, tuple(m.tuple for m in mpnt)) 
     
    170170            self.assertEqual(True, ls == fromstr(l.wkt)) 
    171171            self.assertEqual(False, ls == prev) 
    172             self.assertRaises(GEOSGeometryIndexError, ls.__getitem__, len(ls)) 
     172            self.assertRaises(GEOSIndexError, ls.__getitem__, len(ls)) 
    173173            prev = ls 
    174174 
     
    200200                self.assertEqual(ls.empty, False) 
    201201 
    202             self.assertRaises(GEOSGeometryIndexError, ml.__getitem__, len(ml)) 
     202            self.assertRaises(GEOSIndexError, ml.__getitem__, len(ml)) 
    203203            self.assertEqual(ml.wkt, MultiLineString(*tuple(s.clone() for s in ml)).wkt) 
    204204            self.assertEqual(ml, MultiLineString(*tuple(LineString(s.tuple) for s in ml))) 
     
    253253 
    254254            # Testing __getitem__ and __setitem__ on invalid indices 
    255             self.assertRaises(GEOSGeometryIndexError, poly.__getitem__, len(poly)) 
    256             #self.assertRaises(GEOSGeometryIndexError, poly.__setitem__, len(poly), False) 
    257             self.assertRaises(GEOSGeometryIndexError, poly.__getitem__, -1) 
     255            self.assertRaises(GEOSIndexError, poly.__getitem__, len(poly)) 
     256            #self.assertRaises(GEOSIndexError, poly.__setitem__, len(poly), False) 
     257            self.assertRaises(GEOSIndexError, poly.__getitem__, -1) 
    258258 
    259259            # Testing __iter__  
     
    284284                self.assertEqual(mp.n_p, mpoly.num_coords) 
    285285                self.assertEqual(mp.num_geom, len(mpoly)) 
    286                 self.assertRaises(GEOSGeometryIndexError, mpoly.__getitem__, len(mpoly)) 
     286                self.assertRaises(GEOSIndexError, mpoly.__getitem__, len(mpoly)) 
    287287                for p in mpoly: 
    288288                    self.assertEqual(p.geom_type, 'Polygon') 
     
    619619            # Testing __getitem__ (doesn't work on Point or Polygon) 
    620620            if isinstance(g, Point): 
    621                 self.assertRaises(GEOSGeometryIndexError, g.get_x) 
     621                self.assertRaises(GEOSIndexError, g.get_x) 
    622622            elif isinstance(g, Polygon): 
    623623                lr = g.shell 
     
    625625                self.assertEqual(0, len(lr)) 
    626626                self.assertEqual(True, lr.empty) 
    627                 self.assertRaises(GEOSGeometryIndexError, lr.__getitem__, 0) 
     627                self.assertRaises(GEOSIndexError, lr.__getitem__, 0) 
    628628            else: 
    629                 self.assertRaises(GEOSGeometryIndexError, g.__getitem__, 0) 
     629                self.assertRaises(GEOSIndexError, g.__getitem__, 0) 
    630630 
    631631    def test21_test_gdal(self):