Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Dropped support for GDAL < 1.5

GDAL 1.5 has been released in December 2007.
  • Loading branch information...
commit cdcdd131da950741fa74debc21bef8632fd3c684 1 parent 3434051
@claudep claudep authored
View
4 django/contrib/gis/gdal/__init__.py
@@ -37,12 +37,12 @@
try:
from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.datasource import DataSource
- from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, gdal_release_date, GEOJSON, GDAL_VERSION
+ from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, gdal_release_date, GDAL_VERSION
from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
from django.contrib.gis.gdal.geometries import OGRGeometry
HAS_GDAL = True
except:
- HAS_GDAL, GEOJSON = False, False
+ HAS_GDAL = False
try:
from django.contrib.gis.gdal.envelope import Envelope
View
20 django/contrib/gis/gdal/geometries.py
@@ -48,7 +48,7 @@
from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope
from django.contrib.gis.gdal.error import OGRException, OGRIndexError, SRSException
from django.contrib.gis.gdal.geomtype import OGRGeomType
-from django.contrib.gis.gdal.libgdal import GEOJSON, GDAL_VERSION
+from django.contrib.gis.gdal.libgdal import GDAL_VERSION
from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
# Getting the ctypes prototype functions that interface w/the GDAL C library.
@@ -97,10 +97,7 @@ def __init__(self, geom_input, srs=None):
else:
g = capi.from_wkt(byref(c_char_p(wkt_m.group('wkt'))), None, byref(c_void_p()))
elif json_m:
- if GEOJSON:
- g = capi.from_json(geom_input)
- else:
- raise NotImplementedError('GeoJSON input only supported on GDAL 1.5+.')
+ g = capi.from_json(geom_input)
else:
# Seeing if the input is a valid short-hand string
# (e.g., 'Point', 'POLYGON').
@@ -328,22 +325,15 @@ def hex(self):
@property
def json(self):
"""
- Returns the GeoJSON representation of this Geometry (requires
- GDAL 1.5+).
+ Returns the GeoJSON representation of this Geometry.
"""
- if GEOJSON:
- return capi.to_json(self.ptr)
- else:
- raise NotImplementedError('GeoJSON output only supported on GDAL 1.5+.')
+ return capi.to_json(self.ptr)
geojson = json
@property
def kml(self):
"Returns the KML representation of the Geometry."
- if GEOJSON:
- return capi.to_kml(self.ptr, None)
- else:
- raise NotImplementedError('KML output only supported on GDAL 1.5+.')
+ return capi.to_kml(self.ptr, None)
@property
def wkb_size(self):
View
9 django/contrib/gis/gdal/libgdal.py
@@ -19,7 +19,7 @@
elif os.name == 'posix':
# *NIX library names.
lib_names = ['gdal', 'GDAL', 'gdal1.9.0', 'gdal1.8.0', 'gdal1.7.0',
- 'gdal1.6.0', 'gdal1.5.0', 'gdal1.4.0']
+ 'gdal1.6.0', 'gdal1.5.0']
else:
raise OGRException('Unsupported OS "%s"' % os.name)
@@ -97,10 +97,3 @@ def gdal_version_info():
GDAL_SUBMINOR_VERSION = _verinfo['subminor'] and int(_verinfo['subminor'])
GDAL_VERSION = (GDAL_MAJOR_VERSION, GDAL_MINOR_VERSION, GDAL_SUBMINOR_VERSION)
del _verinfo
-
-# GeoJSON support is available only in GDAL 1.5+.
-if GDAL_VERSION >= (1, 5):
- GEOJSON = True
-else:
- GEOJSON = False
-
View
15 django/contrib/gis/gdal/prototypes/geom.py
@@ -1,6 +1,6 @@
from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER
from django.contrib.gis.gdal.envelope import OGREnvelope
-from django.contrib.gis.gdal.libgdal import lgdal, GEOJSON
+from django.contrib.gis.gdal.libgdal import lgdal
from django.contrib.gis.gdal.prototypes.errcheck import check_bool, check_envelope
from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
double_output, geom_output, int_output, srs_output, string_output, void_output)
@@ -25,15 +25,10 @@ def topology_func(f):
### OGR_G ctypes function prototypes ###
-# GeoJSON routines, if supported.
-if GEOJSON:
- from_json = geom_output(lgdal.OGR_G_CreateGeometryFromJson, [c_char_p])
- to_json = string_output(lgdal.OGR_G_ExportToJson, [c_void_p], str_result=True)
- to_kml = string_output(lgdal.OGR_G_ExportToKML, [c_void_p, c_char_p], str_result=True)
-else:
- from_json = False
- to_json = False
- to_kml = False
+# GeoJSON routines.
+from_json = geom_output(lgdal.OGR_G_CreateGeometryFromJson, [c_char_p])
+to_json = string_output(lgdal.OGR_G_ExportToJson, [c_void_p], str_result=True)
+to_kml = string_output(lgdal.OGR_G_ExportToKML, [c_void_p, c_char_p], str_result=True)
# GetX, GetY, GetZ all return doubles.
getx = pnt_func(lgdal.OGR_G_GetX)
View
5 django/contrib/gis/gdal/tests/test_geom.py
@@ -6,7 +6,6 @@
from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType, OGRException,
OGRIndexError, SpatialReference, CoordTransform, GDAL_VERSION)
-from django.contrib.gis.gdal.prototypes.geom import GEOJSON
from django.contrib.gis.geometry.test_data import TestDataMixin
from django.utils import unittest
@@ -108,7 +107,6 @@ def test01d_wkb(self):
def test01e_json(self):
"Testing GeoJSON input/output."
- if not GEOJSON: return
for g in self.geometries.json_geoms:
geom = OGRGeometry(g.wkt)
if not hasattr(g, 'not_equal'):
@@ -244,9 +242,6 @@ def test07b_closepolygons(self):
self.fail('Should have raised an OGRException!')
print("\nEND - expecting IllegalArgumentException; safe to ignore.\n")
- # Closing the rings -- doesn't work on GDAL versions 1.4.1 and below:
- # http://trac.osgeo.org/gdal/ticket/1673
- if GDAL_VERSION <= (1, 4, 1): return
poly.close_rings()
self.assertEqual(10, poly.point_count) # Two closing points should've been added
self.assertEqual(OGRGeometry('POINT(2.5 2.5)'), poly.centroid)
View
1  django/contrib/gis/geos/base.py
@@ -10,7 +10,6 @@
# A 'dummy' gdal module.
class GDALInfo(object):
HAS_GDAL = False
- GEOJSON = False
gdal = GDALInfo()
# NumPy supported?
View
9 django/contrib/gis/geos/geometry.py
@@ -65,7 +65,7 @@ def __init__(self, geo_input, srid=None):
elif hex_regex.match(geo_input):
# Handling HEXEWKB input.
g = wkb_r().read(geo_input)
- elif gdal.GEOJSON and json_regex.match(geo_input):
+ elif gdal.HAS_GDAL and json_regex.match(geo_input):
# Handling GeoJSON input.
g = wkb_r().read(gdal.OGRGeometry(geo_input).wkb)
else:
@@ -409,13 +409,12 @@ def hexewkb(self):
@property
def json(self):
"""
- Returns GeoJSON representation of this Geometry if GDAL 1.5+
- is installed.
+ Returns GeoJSON representation of this Geometry if GDAL is installed.
"""
- if gdal.GEOJSON:
+ if gdal.HAS_GDAL:
return self.ogr.json
else:
- raise GEOSException('GeoJSON output only supported on GDAL 1.5+.')
+ raise GEOSException('GeoJSON output only supported when GDAL is installed.')
geojson = json
@property
View
2  django/contrib/gis/geos/tests/test_geos.py
@@ -196,7 +196,7 @@ def test_ewkt(self):
self.assertEqual(srid, poly.shell.srid)
self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export
- @unittest.skipUnless(gdal.HAS_GDAL and gdal.GEOJSON, "gdal >= 1.5 is required")
+ @unittest.skipUnless(gdal.HAS_GDAL, "gdal is required")
def test_json(self):
"Testing GeoJSON input/output (via GDAL)."
for g in self.geometries.json_geoms:
View
1  django/contrib/gis/tests/test_geoforms.py
@@ -71,6 +71,7 @@ def test04_to_python(self):
for wkt in ('POINT(5 23)', 'MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 'LINESTRING(0 0, 1 1)'):
self.assertEqual(GEOSGeometry(wkt), fld.to_python(wkt))
# but raises a ValidationError for any other string
+ import pdb; pdb.set_trace()
@claudep Collaborator
claudep added a note

Sorry, will remove this one ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
for wkt in ('POINT(5)', 'MULTI POLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 'BLAH(0 0, 1 1)'):
self.assertRaises(forms.ValidationError, fld.to_python, wkt)
View
2  docs/ref/contrib/gis/gdal.txt
@@ -447,7 +447,7 @@ systems and coordinate transformation::
This object is a wrapper for the `OGR Geometry`__ class.
These objects are instantiated directly from the given ``geom_input``
- parameter, which may be a string containing WKT or HEX, a ``buffer``
+ parameter, which may be a string containing WKT, HEX, GeoJSON, a ``buffer``
containing WKB data, or an :class:`OGRGeomType` object. These objects
are also returned from the :class:`Feature.geom` attribute, when
reading vector data from :class:`Layer` (which is in turn a part of
View
8 docs/ref/contrib/gis/install.txt
@@ -81,7 +81,7 @@ Program Description Required
======================== ==================================== ================================ ==========================
:ref:`GEOS <ref-geos>` Geometry Engine Open Source Yes 3.3, 3.2, 3.1, 3.0
`PROJ.4`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 4.7, 4.6, 4.5, 4.4
-:ref:`GDAL <ref-gdal>` Geospatial Data Abstraction Library No (but, required for SQLite) 1.8, 1.7, 1.6, 1.5, 1.4
+:ref:`GDAL <ref-gdal>` Geospatial Data Abstraction Library No (but, required for SQLite) 1.9, 1.8, 1.7, 1.6, 1.5
:ref:`GeoIP <ref-geoip>` IP-based geolocation library No 1.4
`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 1.5, 1.4, 1.3
`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 3.0, 2.4, 2.3
@@ -270,9 +270,9 @@ supports :ref:`GDAL's vector data <ref-gdal>` capabilities [#]_.
First download the latest GDAL release version and untar the archive::
- $ wget http://download.osgeo.org/gdal/gdal-1.8.1.tar.gz
- $ tar xzf gdal-1.8.1.tar.gz
- $ cd gdal-1.8.1
+ $ wget http://download.osgeo.org/gdal/gdal-1.9.1.tar.gz
+ $ tar xzf gdal-1.9.1.tar.gz
+ $ cd gdal-1.9.1
Configure, make and install::
View
5 docs/releases/1.5.txt
@@ -177,6 +177,11 @@ autocommit behavior was never restored. This bug is now fixed in 1.5. While
this is only a bug fix, it is worth checking your applications behavior if
you are using PostgreSQL together with the autocommit option.
+Miscellaneous
+~~~~~~~~~~~~~
+
+* GeoDjango dropped support for GDAL < 1.5
+
Features deprecated in 1.5
==========================
Please sign in to comment.
Something went wrong with that request. Please try again.