Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#11433 closed (fixed)

Complete support for 3D Geometries

Reported by: jbronn Owned by: jbronn
Component: GIS Version: dev
Severity: Keywords: gis 3d z
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

While GeoDjango has most the internal infrastructure to support 3D geometries, it does not completely work yet. Using the dim=3 on the model definition sets up the proper schema, but PostGISAdaptor only sends 2D data to the database no matter what.

Attachments (3)

3d_hack.diff (820 bytes ) - added by jbronn 15 years ago.
Hack that sends 3D geometry to the database.
3dhack2.diff (897 bytes ) - added by wibge 15 years ago.
Added a check if the geometry is 2 or 3d when converting it to wkb
3d_fix_v1.diff (9.9 KB ) - added by jbronn 15 years ago.
First draft of 3D fix. More tests are needed.

Download all attachments as: .zip

Change History (15)

by jbronn, 15 years ago

Attachment: 3d_hack.diff added

Hack that sends 3D geometry to the database.

comment:1 by jbronn, 15 years ago

Has patch: set
Needs documentation: set
Needs tests: set
Patch needs improvement: set

by wibge, 15 years ago

Attachment: 3dhack2.diff added

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

comment:2 by wibge, 15 years ago

I applied the patch, and then ran into problems since I have some objects that are 2d and some 3d. I was getting "psycopg2.IntegrityError: new row for relation "site_trip" violates check constraint "enforce_dims_extent"" when I tried to save 2d objects. I slightly changed the patch to check if it the geometry has a third dimension when it converts it to wkb.

comment:3 by christian@…, 15 years ago

I does not know if this belongs to my problem: I save in my model with

from django.contrib.gis.geos import Point
...
class Point(...):
    ....
    x = models.DecimalField(max_digits=12, decimal_places=5, blank=True, null=True)
    y = models.DecimalField(max_digits=12, decimal_places=5, blank=True, null=True)
    z = models.DecimalField(max_digits=12, decimal_places=5, blank=True, null=True)
    xyz = models.PointField(default="SRID=4326;POINT(8.2122802734375 50.0042724609375 260.00)", blank=True)
    ....

def save():
    self.xyz = Point(x=float(self.x), y=float(self.y), z=float(self.z), srid=self.xyz.srid)
    ...

But when I go into the django shell, I get for

>>> p = Point.objects.get(pk=1)
>>> p.xyz.z
>>> p.xyz.hasz
False

comment:4 by Christian Karrié, 15 years ago

The patch seems not to work for me, I still get False for p.xyz.hasz, what am I doing wrong?

(Btw, my Model class name is SinglePoint, not Point. Point is the class name of the geos Point)

comment:5 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

by jbronn, 15 years ago

Attachment: 3d_fix_v1.diff added

First draft of 3D fix. More tests are needed.

comment:6 by jbronn, 15 years ago

(In [11628]) The OGRGeometry.coord_dim property may now be set; implemented a work-around for an OGR bug that changed geometries to 3D after transformation. Refs #11433.

comment:7 by jbronn, 15 years ago

(In [11629]) [1.1.X] The OGRGeometry.coord_dim property may now be set; implemented a work-around for an OGR bug that changed geometries to 3D after transformation. Refs #11433.

Backport of r11628 from trunk.

comment:8 by jbronn, 15 years ago

Status: newassigned

(In [11728]) Added ewkb and hexewkb properties to GEOSGeometry. Refs #11433, #12010.

comment:9 by jbronn, 15 years ago

(In [11739]) OGRGeomType now recognizes 2.5D types, and removes need for unnecessary workaround in Layer.geom_type; corrected geometry type in test VRT file. Refs #11433.

comment:10 by jbronn, 15 years ago

Resolution: fixed
Status: assignedclosed

(In [11742]) Fixed #11433 -- 3D geometry fields are now supported with PostGIS; EWKB is now used by PostGISAdaptor.

comment:11 by jbronn, 15 years ago

(In [12877]) [1.1.X] OGRGeomType now recognizes 2.5D types, and removes need for unnecessary workaround in Layer.geom_type; corrected geometry type in test VRT file. Refs #11433.

Backport of r11739 from trunk.

comment:12 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top