Commit 7548aa8f authored by Alex Gaynor's avatar Alex Gaynor
Browse files

More attacking E302 violators

parent 65c4ac3b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ class SpatiaLiteRelate(SpatiaLiteFunctionParam):

# Valid distance types and substitutions
dtypes = (Decimal, Distance, float) + six.integer_types


def get_dist_ops(operator):
    "Returns operations for regular distances; spherical distances are not currently supported."
    return (SpatiaLiteDistance(operator),)
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
 OGR methods.
"""


#### OGR & SRS Exceptions ####
class GDALException(Exception):
    pass
+8 −0
Original line number Diff line number Diff line
@@ -522,6 +522,7 @@ class OGRGeometry(GDALBase):
        """
        return self._geomgen(capi.geom_union, other)


# The subclasses for OGR Geometry.
class Point(OGRGeometry):

@@ -550,6 +551,7 @@ class Point(OGRGeometry):
            return (self.x, self.y, self.z)
    coords = tuple


class LineString(OGRGeometry):

    def __getitem__(self, index):
@@ -605,10 +607,12 @@ class LineString(OGRGeometry):
        if self.coord_dim == 3:
            return self._listarr(capi.getz)


# LinearRings are used in Polygons.
class LinearRing(LineString):
    pass


class Polygon(OGRGeometry):

    def __len__(self):
@@ -654,6 +658,7 @@ class Polygon(OGRGeometry):
        capi.get_centroid(self.ptr, p.ptr)
        return p


# Geometry Collection base class.
class GeometryCollection(OGRGeometry):
    "The Geometry Collection class."
@@ -700,13 +705,16 @@ class GeometryCollection(OGRGeometry):
        return tuple(self[i].tuple for i in xrange(self.geom_count))
    coords = tuple


# Multiple Geometry types.
class MultiPoint(GeometryCollection):
    pass


class MultiLineString(GeometryCollection):
    pass


class MultiPolygon(GeometryCollection):
    pass

+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ from django.contrib.gis.gdal.error import OGRException

from django.utils import six

#### OGRGeomType ####

class OGRGeomType(object):
    "Encapulates OGR Geometry Types."

+8 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ if os.name == 'nt':
    from ctypes import WinDLL
    lwingdal = WinDLL(lib_path)


def std_call(func):
    """
    Returns the correct STDCALL function for certain OSR routines on Win32
@@ -72,15 +73,19 @@ _version_info = std_call('GDALVersionInfo')
_version_info.argtypes = [c_char_p]
_version_info.restype = c_char_p


def gdal_version():
    "Returns only the GDAL version number information."
    return _version_info(b'RELEASE_NAME')


def gdal_full_version():
    "Returns the full GDAL version information."
    return _version_info('')

version_regex = re.compile(r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+))?')


def gdal_version_info():
    ver = gdal_version().decode()
    m = version_regex.match(ver)
@@ -97,10 +102,13 @@ del _verinfo

# Set library error handling so as errors are logged
CPLErrorHandler = CFUNCTYPE(None, c_int, c_int, c_char_p)


def err_handler(error_class, error_number, message):
    logger.error('GDAL_ERROR %d: %s' % (error_number, message))
err_handler = CPLErrorHandler(err_handler)


def function(name, args, restype):
    func = std_call(name)
    func.argtypes = args
Loading