Loading django/contrib/gis/geos/geometry.py +0 −8 Original line number Diff line number Diff line Loading @@ -577,15 +577,11 @@ class GEOSGeometry(GEOSBase, ListMixin): def interpolate(self, distance): if not isinstance(self, (LineString, MultiLineString)): raise TypeError('interpolate only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_interpolate'): raise NotImplementedError('interpolate requires GEOS 3.2+') return self._topology(capi.geos_interpolate(self.ptr, distance)) def interpolate_normalized(self, distance): if not isinstance(self, (LineString, MultiLineString)): raise TypeError('interpolate only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_interpolate_normalized'): raise NotImplementedError('interpolate_normalized requires GEOS 3.2+') return self._topology(capi.geos_interpolate_normalized(self.ptr, distance)) def intersection(self, other): Loading @@ -602,8 +598,6 @@ class GEOSGeometry(GEOSBase, ListMixin): raise TypeError('locate_point argument must be a Point') if not isinstance(self, (LineString, MultiLineString)): raise TypeError('locate_point only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_project'): raise NotImplementedError('geos_project requires GEOS 3.2+') return capi.geos_project(self.ptr, point.ptr) def project_normalized(self, point): Loading @@ -611,8 +605,6 @@ class GEOSGeometry(GEOSBase, ListMixin): raise TypeError('locate_point argument must be a Point') if not isinstance(self, (LineString, MultiLineString)): raise TypeError('locate_point only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_project_normalized'): raise NotImplementedError('project_normalized requires GEOS 3.2+') return capi.geos_project_normalized(self.ptr, point.ptr) def relate(self, other): Loading django/contrib/gis/geos/prototypes/errcheck.py +5 −18 Original line number Diff line number Diff line """ Error checking functions for GEOS ctypes prototype functions. """ import os from ctypes import c_void_p, string_at, CDLL from ctypes import c_void_p, string_at from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.libgeos import GEOS_VERSION from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc # Getting the `free` routine used to free the memory allocated for # string pointers returned by GEOS. if GEOS_VERSION >= (3, 1, 1): # In versions 3.1.1 and above, `GEOSFree` was added to the C API # because `free` isn't always available on all platforms. free = GEOSFunc('GEOSFree') free.argtypes = [c_void_p] free.restype = None else: # Getting the `free` routine from the C library of the platform. if os.name == 'nt': # On NT, use the MS C library. libc = CDLL('msvcrt') else: # On POSIX platforms C library is obtained by passing None into `CDLL`. libc = CDLL(None) free = libc.free ### ctypes error checking routines ### Loading django/contrib/gis/geos/prototypes/topology.py +10 −12 Original line number Diff line number Diff line Loading @@ -6,10 +6,12 @@ __all__ = ['geos_boundary', 'geos_buffer', 'geos_cascaded_union', 'geos_centroid', 'geos_convexhull', 'geos_difference', 'geos_envelope', 'geos_intersection', 'geos_linemerge', 'geos_pointonsurface', 'geos_preservesimplify', 'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate'] 'geos_symdifference', 'geos_union', 'geos_relate', 'geos_project', 'geos_interpolate', 'geos_project_normalized', 'geos_interpolate_normalized'] from ctypes import c_double, c_int from django.contrib.gis.geos.libgeos import geos_version_info, GEOM_PTR from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_minus_one, check_string from django.contrib.gis.geos.prototypes.geom import geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc Loading Loading @@ -51,8 +53,6 @@ geos_relate.restype = geos_char_p geos_relate.errcheck = check_string # Linear referencing routines info = geos_version_info() if info['version'] >= '3.2.0': geos_project = topology(GEOSFunc('GEOSProject'), GEOM_PTR, restype=c_double, errcheck=check_minus_one) geos_interpolate = topology(GEOSFunc('GEOSInterpolate'), c_double) Loading @@ -60,5 +60,3 @@ if info['version'] >= '3.2.0': geos_project_normalized = topology(GEOSFunc('GEOSProjectNormalized'), GEOM_PTR, restype=c_double, errcheck=check_minus_one) geos_interpolate_normalized = topology(GEOSFunc('GEOSInterpolateNormalized'), c_double) __all__.extend(['geos_project', 'geos_interpolate', 'geos_project_normalized', 'geos_interpolate_normalized']) django/contrib/gis/geos/tests/test_geos.py +4 −26 Original line number Diff line number Diff line Loading @@ -29,18 +29,6 @@ if HAS_GEOS: @skipUnless(HAS_GEOS, "Geos is required.") class GEOSTest(unittest.TestCase, TestDataMixin): @property def null_srid(self): """ Returns the proper null SRID depending on the GEOS version. See the comments in `test_srid` for more details. """ info = geos_version_info() if info['version'] == '3.0.0' and info['release_candidate']: return -1 else: return None def test_base(self): "Tests out the GEOSBase class." # Testing out GEOSBase class, which provides a `ptr` property Loading Loading @@ -116,9 +104,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # HEXEWKB should be appropriate for its dimension -- have to use an # a WKBWriter w/dimension set accordingly, else GEOS will insert # garbage into 3D coordinate if there is none. Also, GEOS has a # a bug in versions prior to 3.1 that puts the X coordinate in # place of Z; an exception should be raised on those versions. # garbage into 3D coordinate if there is none. self.assertEqual(hexewkb_2d, pnt_2d.hexewkb) self.assertEqual(hexewkb_3d, pnt_3d.hexewkb) self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz) Loading Loading @@ -651,13 +637,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): p1 = fromstr(hex) self.assertEqual(4326, p1.srid) # In GEOS 3.0.0rc1-4 when the EWKB and/or HEXEWKB is exported, # the SRID information is lost and set to -1 -- this is not a # problem on the 3.0.0 version (another reason to upgrade). exp_srid = self.null_srid p2 = fromstr(p1.hex) self.assertEqual(exp_srid, p2.srid) self.assertIsNone(p2.srid) p3 = fromstr(p1.hex, srid=-1) # -1 is intended. self.assertEqual(-1, p3.srid) Loading Loading @@ -1007,14 +988,11 @@ class GEOSTest(unittest.TestCase, TestDataMixin): tgeoms.extend(get_geoms(self.geometries.polygons, 3084)) tgeoms.extend(get_geoms(self.geometries.multipolygons, 900913)) # The SRID won't be exported in GEOS 3.0 release candidates. no_srid = self.null_srid == -1 for geom in tgeoms: s1, s2 = cPickle.dumps(geom), pickle.dumps(geom) g1, g2 = cPickle.loads(s1), pickle.loads(s2) for tmpg in (g1, g2): self.assertEqual(geom, tmpg) if not no_srid: self.assertEqual(geom.srid, tmpg.srid) def test_prepared(self): Loading Loading @@ -1071,7 +1049,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertIsInstance(g.valid_reason, six.string_types) self.assertTrue(g.valid_reason.startswith("Too few points in geometry component")) @skipUnless(HAS_GEOS and geos_version_info()['version'] >= '3.2.0', "geos >= 3.2.0 is required") @skipUnless(HAS_GEOS, "Geos is required.") def test_linearref(self): "Testing linear referencing" Loading django/contrib/gis/geos/tests/test_io.py +10 −13 Original line number Diff line number Diff line Loading @@ -101,9 +101,6 @@ class GEOSIOTest(unittest.TestCase): # Equivalent of `wkb_w.outdim = bad_outdim` self.assertRaises(ValueError, wkb_w._set_outdim, bad_outdim) # These tests will fail on 3.0.0 because of a bug that was fixed in 3.1: # http://trac.osgeo.org/geos/ticket/216 if not geos_version_info()['version'].startswith('3.0.'): # Now setting the output dimensions to be 3 wkb_w.outdim = 3 Loading Loading
django/contrib/gis/geos/geometry.py +0 −8 Original line number Diff line number Diff line Loading @@ -577,15 +577,11 @@ class GEOSGeometry(GEOSBase, ListMixin): def interpolate(self, distance): if not isinstance(self, (LineString, MultiLineString)): raise TypeError('interpolate only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_interpolate'): raise NotImplementedError('interpolate requires GEOS 3.2+') return self._topology(capi.geos_interpolate(self.ptr, distance)) def interpolate_normalized(self, distance): if not isinstance(self, (LineString, MultiLineString)): raise TypeError('interpolate only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_interpolate_normalized'): raise NotImplementedError('interpolate_normalized requires GEOS 3.2+') return self._topology(capi.geos_interpolate_normalized(self.ptr, distance)) def intersection(self, other): Loading @@ -602,8 +598,6 @@ class GEOSGeometry(GEOSBase, ListMixin): raise TypeError('locate_point argument must be a Point') if not isinstance(self, (LineString, MultiLineString)): raise TypeError('locate_point only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_project'): raise NotImplementedError('geos_project requires GEOS 3.2+') return capi.geos_project(self.ptr, point.ptr) def project_normalized(self, point): Loading @@ -611,8 +605,6 @@ class GEOSGeometry(GEOSBase, ListMixin): raise TypeError('locate_point argument must be a Point') if not isinstance(self, (LineString, MultiLineString)): raise TypeError('locate_point only works on LineString and MultiLineString geometries') if not hasattr(capi, 'geos_project_normalized'): raise NotImplementedError('project_normalized requires GEOS 3.2+') return capi.geos_project_normalized(self.ptr, point.ptr) def relate(self, other): Loading
django/contrib/gis/geos/prototypes/errcheck.py +5 −18 Original line number Diff line number Diff line """ Error checking functions for GEOS ctypes prototype functions. """ import os from ctypes import c_void_p, string_at, CDLL from ctypes import c_void_p, string_at from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.libgeos import GEOS_VERSION from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc # Getting the `free` routine used to free the memory allocated for # string pointers returned by GEOS. if GEOS_VERSION >= (3, 1, 1): # In versions 3.1.1 and above, `GEOSFree` was added to the C API # because `free` isn't always available on all platforms. free = GEOSFunc('GEOSFree') free.argtypes = [c_void_p] free.restype = None else: # Getting the `free` routine from the C library of the platform. if os.name == 'nt': # On NT, use the MS C library. libc = CDLL('msvcrt') else: # On POSIX platforms C library is obtained by passing None into `CDLL`. libc = CDLL(None) free = libc.free ### ctypes error checking routines ### Loading
django/contrib/gis/geos/prototypes/topology.py +10 −12 Original line number Diff line number Diff line Loading @@ -6,10 +6,12 @@ __all__ = ['geos_boundary', 'geos_buffer', 'geos_cascaded_union', 'geos_centroid', 'geos_convexhull', 'geos_difference', 'geos_envelope', 'geos_intersection', 'geos_linemerge', 'geos_pointonsurface', 'geos_preservesimplify', 'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate'] 'geos_symdifference', 'geos_union', 'geos_relate', 'geos_project', 'geos_interpolate', 'geos_project_normalized', 'geos_interpolate_normalized'] from ctypes import c_double, c_int from django.contrib.gis.geos.libgeos import geos_version_info, GEOM_PTR from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_minus_one, check_string from django.contrib.gis.geos.prototypes.geom import geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc Loading Loading @@ -51,8 +53,6 @@ geos_relate.restype = geos_char_p geos_relate.errcheck = check_string # Linear referencing routines info = geos_version_info() if info['version'] >= '3.2.0': geos_project = topology(GEOSFunc('GEOSProject'), GEOM_PTR, restype=c_double, errcheck=check_minus_one) geos_interpolate = topology(GEOSFunc('GEOSInterpolate'), c_double) Loading @@ -60,5 +60,3 @@ if info['version'] >= '3.2.0': geos_project_normalized = topology(GEOSFunc('GEOSProjectNormalized'), GEOM_PTR, restype=c_double, errcheck=check_minus_one) geos_interpolate_normalized = topology(GEOSFunc('GEOSInterpolateNormalized'), c_double) __all__.extend(['geos_project', 'geos_interpolate', 'geos_project_normalized', 'geos_interpolate_normalized'])
django/contrib/gis/geos/tests/test_geos.py +4 −26 Original line number Diff line number Diff line Loading @@ -29,18 +29,6 @@ if HAS_GEOS: @skipUnless(HAS_GEOS, "Geos is required.") class GEOSTest(unittest.TestCase, TestDataMixin): @property def null_srid(self): """ Returns the proper null SRID depending on the GEOS version. See the comments in `test_srid` for more details. """ info = geos_version_info() if info['version'] == '3.0.0' and info['release_candidate']: return -1 else: return None def test_base(self): "Tests out the GEOSBase class." # Testing out GEOSBase class, which provides a `ptr` property Loading Loading @@ -116,9 +104,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # HEXEWKB should be appropriate for its dimension -- have to use an # a WKBWriter w/dimension set accordingly, else GEOS will insert # garbage into 3D coordinate if there is none. Also, GEOS has a # a bug in versions prior to 3.1 that puts the X coordinate in # place of Z; an exception should be raised on those versions. # garbage into 3D coordinate if there is none. self.assertEqual(hexewkb_2d, pnt_2d.hexewkb) self.assertEqual(hexewkb_3d, pnt_3d.hexewkb) self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz) Loading Loading @@ -651,13 +637,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): p1 = fromstr(hex) self.assertEqual(4326, p1.srid) # In GEOS 3.0.0rc1-4 when the EWKB and/or HEXEWKB is exported, # the SRID information is lost and set to -1 -- this is not a # problem on the 3.0.0 version (another reason to upgrade). exp_srid = self.null_srid p2 = fromstr(p1.hex) self.assertEqual(exp_srid, p2.srid) self.assertIsNone(p2.srid) p3 = fromstr(p1.hex, srid=-1) # -1 is intended. self.assertEqual(-1, p3.srid) Loading Loading @@ -1007,14 +988,11 @@ class GEOSTest(unittest.TestCase, TestDataMixin): tgeoms.extend(get_geoms(self.geometries.polygons, 3084)) tgeoms.extend(get_geoms(self.geometries.multipolygons, 900913)) # The SRID won't be exported in GEOS 3.0 release candidates. no_srid = self.null_srid == -1 for geom in tgeoms: s1, s2 = cPickle.dumps(geom), pickle.dumps(geom) g1, g2 = cPickle.loads(s1), pickle.loads(s2) for tmpg in (g1, g2): self.assertEqual(geom, tmpg) if not no_srid: self.assertEqual(geom.srid, tmpg.srid) def test_prepared(self): Loading Loading @@ -1071,7 +1049,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertIsInstance(g.valid_reason, six.string_types) self.assertTrue(g.valid_reason.startswith("Too few points in geometry component")) @skipUnless(HAS_GEOS and geos_version_info()['version'] >= '3.2.0', "geos >= 3.2.0 is required") @skipUnless(HAS_GEOS, "Geos is required.") def test_linearref(self): "Testing linear referencing" Loading
django/contrib/gis/geos/tests/test_io.py +10 −13 Original line number Diff line number Diff line Loading @@ -101,9 +101,6 @@ class GEOSIOTest(unittest.TestCase): # Equivalent of `wkb_w.outdim = bad_outdim` self.assertRaises(ValueError, wkb_w._set_outdim, bad_outdim) # These tests will fail on 3.0.0 because of a bug that was fixed in 3.1: # http://trac.osgeo.org/geos/ticket/216 if not geos_version_info()['version'].startswith('3.0.'): # Now setting the output dimensions to be 3 wkb_w.outdim = 3 Loading