Changeset 6861
- Timestamp:
- 12/03/07 00:27:16 (7 months ago)
- Files:
-
- django/branches/gis/django/contrib/gis/geos/base.py (modified) (4 diffs)
- django/branches/gis/django/contrib/gis/geos/collections.py (modified) (2 diffs)
- django/branches/gis/django/contrib/gis/geos/coordseq.py (modified) (2 diffs)
- django/branches/gis/django/contrib/gis/geos/error.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/geos/geometries.py (modified) (2 diffs)
- django/branches/gis/django/contrib/gis/geos/__init__.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/geos/libgeos.py (modified) (1 diff)
- django/branches/gis/django/contrib/gis/tests/test_geos.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/geos/base.py
r6653 r6861 10 10 # GEOS-related dependencies. 11 11 from django.contrib.gis.geos.coordseq import GEOSCoordSeq 12 from django.contrib.gis.geos.error import GEOSException , GEOSGeometryIndexError12 from django.contrib.gis.geos.error import GEOSException 13 13 from django.contrib.gis.geos.libgeos import GEOM_PTR 14 14 … … 122 122 return self.union(other) 123 123 124 # g1 |= g2125 def __ior__(self, other):126 "Reassigns this Geometry to the union of this Geometry and the other."127 return self.union(other)128 129 124 # g = g1 & g2 130 125 def __and__(self, other): … … 132 127 return self.intersection(other) 133 128 134 # g1 &= g2135 def __iand__(self, other):136 "Reassigns this Geometry to the intersection of this Geometry and the other."137 return self.intersection(other)138 139 129 # g = g1 - g2 140 130 def __sub__(self, other): … … 142 132 return self.difference(other) 143 133 144 # g1 -= g2145 def __isub__(self, other):146 "Reassigns this Geometry to the difference of this Geometry and the other."147 return self.difference(other)148 149 134 # g = g1 ^ g2 150 135 def __xor__(self, other): 151 136 "Return the symmetric difference of this Geometry and the other." 152 return self.sym_difference(other)153 154 # g1 ^= g2155 def __ixor__(self, other):156 """157 Reassigns this Geometry to the symmetric difference of this Geometry158 and the other.159 """160 137 return self.sym_difference(other) 161 138 django/branches/gis/django/contrib/gis/geos/collections.py
r6653 r6861 6 6 from types import TupleType, ListType 7 7 from django.contrib.gis.geos.base import GEOSGeometry 8 from django.contrib.gis.geos.error import GEOSException, GEOS GeometryIndexError8 from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 9 9 from django.contrib.gis.geos.geometries import Point, LineString, LinearRing, Polygon 10 10 from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR … … 81 81 "Checks the given geometry index." 82 82 if index < 0 or index >= self.num_geom: 83 raise GEOS GeometryIndexError('invalid GEOS Geometry index: %s' % str(index))83 raise GEOSIndexError('invalid GEOS Geometry index: %s' % str(index)) 84 84 85 85 @property django/branches/gis/django/contrib/gis/geos/coordseq.py
r6653 r6861 6 6 from ctypes import c_double, c_uint, byref 7 7 from types import ListType, TupleType 8 from django.contrib.gis.geos.error import GEOSException, GEOS GeometryIndexError8 from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 9 9 from django.contrib.gis.geos.libgeos import CS_PTR, HAS_NUMPY 10 10 from django.contrib.gis.geos.prototypes import cs_clone, cs_getdims, cs_getordinate, cs_getsize, cs_setordinate … … 70 70 sz = self.size 71 71 if (sz < 1) or (index < 0) or (index >= sz): 72 raise GEOS GeometryIndexError('invalid GEOS Geometry index: %s' % str(index))72 raise GEOSIndexError('invalid GEOS Geometry index: %s' % str(index)) 73 73 74 74 def _checkdim(self, dim): django/branches/gis/django/contrib/gis/geos/error.py
r6653 r6861 8 8 pass 9 9 10 class GEOS GeometryIndexError(GEOSException, KeyError):10 class GEOSIndexError(GEOSException, KeyError): 11 11 """ 12 12 This exception is raised when an invalid index is encountered, and has django/branches/gis/django/contrib/gis/geos/geometries.py
r6653 r6861 8 8 from django.contrib.gis.geos.base import GEOSGeometry 9 9 from django.contrib.gis.geos.coordseq import GEOSCoordSeq 10 from django.contrib.gis.geos.error import GEOSException, GEOS GeometryIndexError10 from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 11 11 from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR, HAS_NUMPY 12 12 from django.contrib.gis.geos.prototypes import * … … 329 329 "Internal routine for checking the given ring index." 330 330 if index < 0 or index >= len(self): 331 raise GEOS GeometryIndexError('invalid Polygon ring index: %s' % index)331 raise GEOSIndexError('invalid Polygon ring index: %s' % index) 332 332 333 333 def get_interior_ring(self, ring_i): django/branches/gis/django/contrib/gis/geos/__init__.py
r6653 r6861 32 32 from django.contrib.gis.geos.geometries import Point, LineString, LinearRing, Polygon, HAS_NUMPY 33 33 from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon 34 from django.contrib.gis.geos.error import GEOSException, GEOS GeometryIndexError34 from django.contrib.gis.geos.error import GEOSException, GEOSIndexError 35 35 from django.contrib.gis.geos.libgeos import geos_version 36 36 django/branches/gis/django/contrib/gis/geos/libgeos.py
r6653 r6861 18 18 HAS_NUMPY = False 19 19 20 # Custom library path set? 21 try: 22 from django.conf import settings 23 lib_name = settings.GEOS_LIBRARY_PATH 24 except (AttributeError, EnvironmentError): 25 lib_name = None 26 20 27 # Setting the appropriate name for the GEOS-C library, depending on which 21 28 # OS and POSIX platform we're running. 22 if os.name == 'nt': 29 if lib_name: 30 pass 31 elif os.name == 'nt': 23 32 # Windows NT library 24 33 lib_name = 'libgeos_c-1.dll' django/branches/gis/django/contrib/gis/tests/test_geos.py
r6653 r6861 2 2 from ctypes import ArgumentError 3 3 from django.contrib.gis.geos import \ 4 GEOSException, GEOS GeometryIndexError, \4 GEOSException, GEOSIndexError, \ 5 5 GEOSGeometry, Point, LineString, LinearRing, Polygon, \ 6 6 MultiPoint, MultiLineString, MultiPolygon, GeometryCollection, \ … … 145 145 self.assertAlmostEqual(mp.centroid[1], mpnt.centroid.tuple[1], 9) 146 146 147 self.assertRaises(GEOS GeometryIndexError, mpnt.__getitem__, len(mpnt))147 self.assertRaises(GEOSIndexError, mpnt.__getitem__, len(mpnt)) 148 148 self.assertEqual(mp.centroid, mpnt.centroid.tuple) 149 149 self.assertEqual(mp.points, tuple(m.tuple for m in mpnt)) … … 170 170 self.assertEqual(True, ls == fromstr(l.wkt)) 171 171 self.assertEqual(False, ls == prev) 172 self.assertRaises(GEOS GeometryIndexError, ls.__getitem__, len(ls))172 self.assertRaises(GEOSIndexError, ls.__getitem__, len(ls)) 173 173 prev = ls 174 174 … … 200 200 self.assertEqual(ls.empty, False) 201 201 202 self.assertRaises(GEOS GeometryIndexError, ml.__getitem__, len(ml))202 self.assertRaises(GEOSIndexError, ml.__getitem__, len(ml)) 203 203 self.assertEqual(ml.wkt, MultiLineString(*tuple(s.clone() for s in ml)).wkt) 204 204 self.assertEqual(ml, MultiLineString(*tuple(LineString(s.tuple) for s in ml))) … … 253 253 254 254 # Testing __getitem__ and __setitem__ on invalid indices 255 self.assertRaises(GEOS GeometryIndexError, poly.__getitem__, len(poly))256 #self.assertRaises(GEOS GeometryIndexError, poly.__setitem__, len(poly), False)257 self.assertRaises(GEOS GeometryIndexError, 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) 258 258 259 259 # Testing __iter__ … … 284 284 self.assertEqual(mp.n_p, mpoly.num_coords) 285 285 self.assertEqual(mp.num_geom, len(mpoly)) 286 self.assertRaises(GEOS GeometryIndexError, mpoly.__getitem__, len(mpoly))286 self.assertRaises(GEOSIndexError, mpoly.__getitem__, len(mpoly)) 287 287 for p in mpoly: 288 288 self.assertEqual(p.geom_type, 'Polygon') … … 619 619 # Testing __getitem__ (doesn't work on Point or Polygon) 620 620 if isinstance(g, Point): 621 self.assertRaises(GEOS GeometryIndexError, g.get_x)621 self.assertRaises(GEOSIndexError, g.get_x) 622 622 elif isinstance(g, Polygon): 623 623 lr = g.shell … … 625 625 self.assertEqual(0, len(lr)) 626 626 self.assertEqual(True, lr.empty) 627 self.assertRaises(GEOS GeometryIndexError, lr.__getitem__, 0)627 self.assertRaises(GEOSIndexError, lr.__getitem__, 0) 628 628 else: 629 self.assertRaises(GEOS GeometryIndexError, g.__getitem__, 0)629 self.assertRaises(GEOSIndexError, g.__getitem__, 0) 630 630 631 631 def test21_test_gdal(self):
