Commit 5330cd50 authored by Claude Paroz's avatar Claude Paroz
Browse files

[py3] Fixed GEOS/GDAL tests

parent 8cdc8472
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ try:
    from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
    from django.contrib.gis.gdal.geometries import OGRGeometry
    HAS_GDAL = True
except:
except ImportError:
    HAS_GDAL = False

try:
+3 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ from django.contrib.gis.gdal.layer import Layer
# Getting the ctypes prototypes for the DataSource.
from django.contrib.gis.gdal.prototypes import ds as capi

from django.utils.encoding import force_bytes
from django.utils import six
from django.utils.six.moves import xrange

@@ -73,7 +74,7 @@ class DataSource(GDALBase):
            ds_driver = Driver.ptr_type()
            try:
                # OGROpen will auto-detect the data source type.
                ds = capi.open_ds(ds_input, self._write, byref(ds_driver))
                ds = capi.open_ds(force_bytes(ds_input), self._write, byref(ds_driver))
            except OGRException:
                # Making the error message more clear rather than something
                # like "Invalid pointer returned from OGROpen".
@@ -102,7 +103,7 @@ class DataSource(GDALBase):
    def __getitem__(self, index):
        "Allows use of the index [] operator to get a layer at the index."
        if isinstance(index, six.string_types):
            l = capi.get_layer_by_name(self.ptr, index)
            l = capi.get_layer_by_name(self.ptr, force_bytes(index))
            if not l: raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
        elif isinstance(index, int):
            if index < 0 or index >= self.layer_count:
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ from django.contrib.gis.gdal.error import OGRException
from django.contrib.gis.gdal.prototypes import ds as capi

from django.utils import six
from django.utils.encoding import force_bytes

# For more information, see the OGR C API source code:
#  http://www.gdal.org/ogr/ogr__api_8h.html
@@ -36,7 +37,7 @@ class Driver(GDALBase):
                name = dr_input

            # Attempting to get the OGR driver by the string name.
            dr = capi.get_driver_by_name(name)
            dr = capi.get_driver_by_name(force_bytes(name))
        elif isinstance(dr_input, int):
            self._register()
            dr = capi.get_driver(dr_input)
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class Envelope(object):
        elif len(args) == 4:
            # Individual parameters passed in.
            #  Thanks to ww for the help
            self._from_sequence(map(float, args))
            self._from_sequence([float(a) for a in args])
        else:
            raise OGRException('Incorrect number (%d) of arguments.' % len(args))

+4 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType
# ctypes function prototypes
from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api

from django.utils.encoding import force_bytes
from django.utils import six
from django.utils.six.moves import xrange

@@ -107,6 +108,7 @@ class Feature(GDALBase):

    def index(self, field_name):
        "Returns the index of the given field name."
        i = capi.get_field_index(self.ptr, field_name)
        if i < 0: raise OGRIndexError('invalid OFT field name given: "%s"' % field_name)
        i = capi.get_field_index(self.ptr, force_bytes(field_name))
        if i < 0:
            raise OGRIndexError('invalid OFT field name given: "%s"' % field_name)
        return i
Loading