Code

Ticket #11433: 3dhack2.diff

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

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

Line 
1Index: django/contrib/gis/db/backend/postgis/adaptor.py
2===================================================================
3--- django/contrib/gis/db/backend/postgis/adaptor.py    (revision 11265)
4+++ django/contrib/gis/db/backend/postgis/adaptor.py    (working copy)
5@@ -6,12 +6,20 @@
6 from psycopg2 import Binary
7 from psycopg2.extensions import ISQLQuote
8 
9+from django.contrib.gis.geos import WKBWriter
10+
11+wkb_3d = WKBWriter()
12+wkb_3d.outdim = 3
13+
14 class PostGISAdaptor(object):
15     def __init__(self, geom):
16         "Initializes on the geometry."
17         # Getting the WKB (in string form, to allow easy pickling of
18         # the adaptor) and the SRID from the geometry.
19-        self.wkb = str(geom.wkb)
20+        if geom.hasz:
21+          self.wkb = str(wkb_3d.write(geom))
22+        else:
23+          self.wkb = str(geom.wkb)
24         self.srid = geom.srid
25 
26     def __conform__(self, proto):