Ticket #11433: 3dhack2.diff

File 3dhack2.diff, 897 bytes (added by wibge, 6 years ago)

Added a check if the geometry is 2 or 3d when converting it to wkb

  • django/contrib/gis/db/backend/postgis/adaptor.py

     
    66from psycopg2 import Binary
    77from psycopg2.extensions import ISQLQuote
    88
     9from django.contrib.gis.geos import WKBWriter
     10
     11wkb_3d = WKBWriter()
     12wkb_3d.outdim = 3
     13
    914class PostGISAdaptor(object):
    1015    def __init__(self, geom):
    1116        "Initializes on the geometry."
    1217        # Getting the WKB (in string form, to allow easy pickling of
    1318        # the adaptor) and the SRID from the geometry.
    14         self.wkb = str(geom.wkb)
     19        if geom.hasz:
     20          self.wkb = str(wkb_3d.write(geom))
     21        else:
     22          self.wkb = str(geom.wkb)
    1523        self.srid = geom.srid
    1624
    1725    def __conform__(self, proto):
Back to Top