Commit 32d0730b authored by Justin Bronn's avatar Justin Bronn
Browse files

Fixed #11433 -- 3D geometry fields are now supported with PostGIS; EWKB is now...

Fixed #11433 -- 3D geometry fields are now supported with PostGIS; EWKB is now used by `PostGISAdaptor`.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@11742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 6c61ca3d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -18,18 +18,21 @@ SpatialBackend = BaseSpatialBackend(name='postgis', postgis=True,
                                    distance_spheroid=DISTANCE_SPHEROID,
                                    envelope=ENVELOPE,
                                    extent=EXTENT,
                                    extent3d=EXTENT3D,
                                    gis_terms=POSTGIS_TERMS,
                                    geojson=ASGEOJSON,
                                    gml=ASGML,
                                    intersection=INTERSECTION,
                                    kml=ASKML,
                                    length=LENGTH,
                                    length3d=LENGTH3D,
                                    length_spheroid=LENGTH_SPHEROID,
                                    make_line=MAKE_LINE,
                                    mem_size=MEM_SIZE,
                                    num_geom=NUM_GEOM,
                                    num_points=NUM_POINTS,
                                    perimeter=PERIMETER,
                                    perimeter3d=PERIMETER3D,
                                    point_on_surface=POINT_ON_SURFACE,
                                    scale=SCALE,
                                    select=GEOM_SELECT,
+3 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
"""

from django.contrib.gis.db.backend.postgis.query import GEOM_FROM_WKB
from django.contrib.gis.db.backend.postgis.query import GEOM_FROM_EWKB
from psycopg2 import Binary
from psycopg2.extensions import ISQLQuote

@@ -11,7 +11,7 @@ class PostGISAdaptor(object):
        "Initializes on the geometry."
        # Getting the WKB (in string form, to allow easy pickling of
        # the adaptor) and the SRID from the geometry.
        self.wkb = str(geom.wkb)
        self.ewkb = str(geom.ewkb)
        self.srid = geom.srid

    def __conform__(self, proto):
@@ -30,7 +30,7 @@ class PostGISAdaptor(object):
    def getquoted(self):
        "Returns a properly quoted string for use in PostgreSQL/PostGIS."
        # Want to use WKB, so wrap with psycopg2 Binary() to quote properly.
        return "%s(E%s, %s)" % (GEOM_FROM_WKB, Binary(self.wkb), self.srid or -1)
        return "%s(E%s)" % (GEOM_FROM_EWKB, Binary(self.ewkb))

    def prepare_database_save(self, unused):
        return self
+5 −1
Original line number Diff line number Diff line
@@ -63,17 +63,21 @@ if MAJOR_VERSION >= 1:
    DISTANCE_SPHERE = get_func('distance_sphere')
    DISTANCE_SPHEROID = get_func('distance_spheroid')
    ENVELOPE = get_func('Envelope')
    EXTENT = get_func('extent')
    EXTENT = get_func('Extent')
    EXTENT3D = get_func('Extent3D')
    GEOM_FROM_TEXT = get_func('GeomFromText')
    GEOM_FROM_EWKB = get_func('GeomFromEWKB')
    GEOM_FROM_WKB = get_func('GeomFromWKB')
    INTERSECTION = get_func('Intersection')
    LENGTH = get_func('Length')
    LENGTH3D = get_func('Length3D')
    LENGTH_SPHEROID = get_func('length_spheroid')
    MAKE_LINE = get_func('MakeLine')
    MEM_SIZE = get_func('mem_size')
    NUM_GEOM = get_func('NumGeometries')
    NUM_POINTS = get_func('npoints')
    PERIMETER = get_func('Perimeter')
    PERIMETER3D = get_func('Perimeter3D')
    POINT_ON_SURFACE = get_func('PointOnSurface')
    SCALE = get_func('Scale')
    SNAP_TO_GRID = get_func('SnapToGrid')
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ class Collect(GeoAggregate):
class Extent(GeoAggregate):
    name = 'Extent'

class Extent3D(GeoAggregate):
    name = 'Extent3D'

class MakeLine(GeoAggregate):
    name = 'MakeLine'

+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ class GeoManager(Manager):
    def extent(self, *args, **kwargs):
        return self.get_query_set().extent(*args, **kwargs)

    def extent3d(self, *args, **kwargs):
        return self.get_query_set().extent3d(*args, **kwargs)

    def geojson(self, *args, **kwargs):
        return self.get_query_set().geojson(*args, **kwargs)

Loading