Loading django/contrib/gis/__init__.py +0 −8 Original line number Diff line number Diff line from django.utils import six if six.PY3: memoryview = memoryview else: memoryview = buffer default_app_config = 'django.contrib.gis.apps.GISConfig' django/contrib/gis/db/models/proxy.py +1 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ corresponding to geographic model fields. Thanks to Robert Coup for providing this functionality (see #4322). """ from django.contrib.gis import memoryview from django.utils import six Loading Loading @@ -57,7 +56,7 @@ class GeometryProxy(object): # Assigning the SRID to the geometry. if value.srid is None: value.srid = self._field.srid elif value is None or isinstance(value, six.string_types + (memoryview,)): elif value is None or isinstance(value, six.string_types + (six.memoryview,)): # Set with None, WKT, HEX, or WKB pass else: Loading django/contrib/gis/db/models/query.py +1 −2 Original line number Diff line number Diff line from django.db import connections from django.db.models.query import QuerySet, ValuesQuerySet, ValuesListQuerySet from django.contrib.gis import memoryview from django.contrib.gis.db.models import aggregates from django.contrib.gis.db.models.fields import get_srid_info, PointField, LineStringField from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery Loading Loading @@ -690,7 +689,7 @@ class GeoQuerySet(QuerySet): if not backend.geography: if not isinstance(geo_field, PointField): raise ValueError('Spherical distance calculation only supported on PointFields.') if not str(Geometry(memoryview(params[0].ewkb)).geom_type) == 'Point': if not str(Geometry(six.memoryview(params[0].ewkb)).geom_type) == 'Point': raise ValueError('Spherical distance calculation only supported with Point Geometry parameters') # The `function` procedure argument needs to be set differently for # geodetic distance calculations. Loading django/contrib/gis/gdal/geometries.py +3 −5 Original line number Diff line number Diff line Loading @@ -43,8 +43,6 @@ import sys from binascii import a2b_hex, b2a_hex from ctypes import byref, string_at, c_char_p, c_double, c_ubyte, c_void_p from django.contrib.gis import memoryview # Getting GDAL prerequisites from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope Loading Loading @@ -77,7 +75,7 @@ class OGRGeometry(GDALBase): # If HEX, unpack input to a binary buffer. if str_instance and hex_regex.match(geom_input): geom_input = memoryview(a2b_hex(geom_input.upper().encode())) geom_input = six.memoryview(a2b_hex(geom_input.upper().encode())) str_instance = False # Constructing the geometry, Loading @@ -102,7 +100,7 @@ class OGRGeometry(GDALBase): # (e.g., 'Point', 'POLYGON'). OGRGeomType(geom_input) g = capi.create_geom(OGRGeomType(geom_input).num) elif isinstance(geom_input, memoryview): elif isinstance(geom_input, six.memoryview): # WKB was passed in g = capi.from_wkb(bytes(geom_input), None, byref(c_void_p()), len(geom_input)) elif isinstance(geom_input, OGRGeomType): Loading Loading @@ -346,7 +344,7 @@ class OGRGeometry(GDALBase): buf = (c_ubyte * sz)() capi.to_wkb(self.ptr, byteorder, byref(buf)) # Returning a buffer of the string at the pointer. return memoryview(string_at(buf, sz)) return six.memoryview(string_at(buf, sz)) @property def wkt(self): Loading django/contrib/gis/geos/factory.py +1 −2 Original line number Diff line number Diff line from django.contrib.gis import memoryview from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex from django.utils import six Loading Loading @@ -27,7 +26,7 @@ def fromfile(file_h): else: return GEOSGeometry(buf) return GEOSGeometry(memoryview(buf)) return GEOSGeometry(six.memoryview(buf)) def fromstr(string, **kwargs): Loading Loading
django/contrib/gis/__init__.py +0 −8 Original line number Diff line number Diff line from django.utils import six if six.PY3: memoryview = memoryview else: memoryview = buffer default_app_config = 'django.contrib.gis.apps.GISConfig'
django/contrib/gis/db/models/proxy.py +1 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ corresponding to geographic model fields. Thanks to Robert Coup for providing this functionality (see #4322). """ from django.contrib.gis import memoryview from django.utils import six Loading Loading @@ -57,7 +56,7 @@ class GeometryProxy(object): # Assigning the SRID to the geometry. if value.srid is None: value.srid = self._field.srid elif value is None or isinstance(value, six.string_types + (memoryview,)): elif value is None or isinstance(value, six.string_types + (six.memoryview,)): # Set with None, WKT, HEX, or WKB pass else: Loading
django/contrib/gis/db/models/query.py +1 −2 Original line number Diff line number Diff line from django.db import connections from django.db.models.query import QuerySet, ValuesQuerySet, ValuesListQuerySet from django.contrib.gis import memoryview from django.contrib.gis.db.models import aggregates from django.contrib.gis.db.models.fields import get_srid_info, PointField, LineStringField from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery Loading Loading @@ -690,7 +689,7 @@ class GeoQuerySet(QuerySet): if not backend.geography: if not isinstance(geo_field, PointField): raise ValueError('Spherical distance calculation only supported on PointFields.') if not str(Geometry(memoryview(params[0].ewkb)).geom_type) == 'Point': if not str(Geometry(six.memoryview(params[0].ewkb)).geom_type) == 'Point': raise ValueError('Spherical distance calculation only supported with Point Geometry parameters') # The `function` procedure argument needs to be set differently for # geodetic distance calculations. Loading
django/contrib/gis/gdal/geometries.py +3 −5 Original line number Diff line number Diff line Loading @@ -43,8 +43,6 @@ import sys from binascii import a2b_hex, b2a_hex from ctypes import byref, string_at, c_char_p, c_double, c_ubyte, c_void_p from django.contrib.gis import memoryview # Getting GDAL prerequisites from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope Loading Loading @@ -77,7 +75,7 @@ class OGRGeometry(GDALBase): # If HEX, unpack input to a binary buffer. if str_instance and hex_regex.match(geom_input): geom_input = memoryview(a2b_hex(geom_input.upper().encode())) geom_input = six.memoryview(a2b_hex(geom_input.upper().encode())) str_instance = False # Constructing the geometry, Loading @@ -102,7 +100,7 @@ class OGRGeometry(GDALBase): # (e.g., 'Point', 'POLYGON'). OGRGeomType(geom_input) g = capi.create_geom(OGRGeomType(geom_input).num) elif isinstance(geom_input, memoryview): elif isinstance(geom_input, six.memoryview): # WKB was passed in g = capi.from_wkb(bytes(geom_input), None, byref(c_void_p()), len(geom_input)) elif isinstance(geom_input, OGRGeomType): Loading Loading @@ -346,7 +344,7 @@ class OGRGeometry(GDALBase): buf = (c_ubyte * sz)() capi.to_wkb(self.ptr, byteorder, byref(buf)) # Returning a buffer of the string at the pointer. return memoryview(string_at(buf, sz)) return six.memoryview(string_at(buf, sz)) @property def wkt(self): Loading
django/contrib/gis/geos/factory.py +1 −2 Original line number Diff line number Diff line from django.contrib.gis import memoryview from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex from django.utils import six Loading Loading @@ -27,7 +26,7 @@ def fromfile(file_h): else: return GEOSGeometry(buf) return GEOSGeometry(memoryview(buf)) return GEOSGeometry(six.memoryview(buf)) def fromstr(string, **kwargs): Loading