Dropped support for GEOS 3.1

This commit is contained in:
Claude Paroz 2014-03-27 22:53:04 +01:00
parent c6ffa4cab6
commit c5d1df70a4
8 changed files with 31 additions and 79 deletions

View File

@ -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):
@ -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):
@ -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):

View File

@ -1,29 +1,16 @@
"""
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
free = GEOSFunc('GEOSFree')
free.argtypes = [c_void_p]
free.restype = None
### ctypes error checking routines ###

View File

@ -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
@ -51,14 +53,10 @@ 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)
geos_project = topology(GEOSFunc('GEOSProject'), GEOM_PTR,
restype=c_double, errcheck=check_minus_one)
geos_interpolate = topology(GEOSFunc('GEOSInterpolate'), c_double)
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'])
geos_project_normalized = topology(GEOSFunc('GEOSProjectNormalized'),
GEOM_PTR, restype=c_double, errcheck=check_minus_one)
geos_interpolate_normalized = topology(GEOSFunc('GEOSInterpolateNormalized'), c_double)

View File

@ -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
@ -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)
@ -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)
@ -1007,15 +988,12 @@ 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)
self.assertEqual(geom.srid, tmpg.srid)
def test_prepared(self):
"Testing PreparedGeometry support."
@ -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"

View File

@ -101,16 +101,13 @@ 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
# Now setting the output dimensions to be 3
wkb_w.outdim = 3
self.assertEqual(hex3d, wkb_w.write_hex(g))
self.assertEqual(wkb3d, wkb_w.write(g))
self.assertEqual(hex3d, wkb_w.write_hex(g))
self.assertEqual(wkb3d, wkb_w.write(g))
# Telling the WKBWriter to include the srid in the representation.
wkb_w.srid = True
self.assertEqual(hex3d_srid, wkb_w.write_hex(g))
self.assertEqual(wkb3d_srid, wkb_w.write(g))
# Telling the WKBWriter to include the srid in the representation.
wkb_w.srid = True
self.assertEqual(hex3d_srid, wkb_w.write_hex(g))
self.assertEqual(wkb3d_srid, wkb_w.write(g))

View File

@ -336,8 +336,7 @@ class DistanceTest(TestCase):
# Reference queries:
# SELECT ST_Area(poly) FROM distapp_southtexaszipcode;
area_sq_m = [5437908.90234375, 10183031.4389648, 11254471.0073242, 9881708.91772461]
# Tolerance has to be lower for Oracle and differences
# with GEOS 3.0.0RC4
# Tolerance has to be lower for Oracle
tol = 2
for i, z in enumerate(SouthTexasZipcode.objects.area()):
self.assertAlmostEqual(area_sq_m[i], z.area.sq_m, tol)

View File

@ -10,7 +10,7 @@ geospatial libraries:
======================== ==================================== ================================ ==========================
Program Description Required Supported Versions
======================== ==================================== ================================ ==========================
:ref:`GEOS <ref-geos>` Geometry Engine Open Source Yes 3.4, 3.3, 3.2, 3.1
:ref:`GEOS <ref-geos>` Geometry Engine Open Source Yes 3.4, 3.3, 3.2
`PROJ.4`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 4.8, 4.7, 4.6, 4.5, 4.4
:ref:`GDAL <ref-gdal>` Geospatial Data Abstraction Library No (but, required for SQLite) 1.9, 1.8, 1.7, 1.6
:ref:`GeoIP <ref-geoip>` IP-based geolocation library No 1.4
@ -23,7 +23,6 @@ totally fine with GeoDjango. Your mileage may vary.
..
Libs release dates:
GEOS 3.1.0 2009-03-11
GEOS 3.2.0 2009-12-14
GEOS 3.3.0 2011-05-30
GEOS 3.4.0 2013-08-11

View File

@ -175,6 +175,8 @@ Miscellaneous
* ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
* ``django.contrib.gis`` dropped support for GEOS 3.1.
.. _deprecated-features-1.8:
Features deprecated in 1.8