Code

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#11433 closed (fixed)

Complete support for 3D Geometries

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

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 5 years ago.
Hack that sends 3D geometry to the database.
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
3d_fix_v1.diff (9.9 KB) - added by jbronn 5 years ago.
First draft of 3D fix. More tests are needed.

Download all attachments as: .zip

Change History (15)

Changed 5 years ago by jbronn

Hack that sends 3D geometry to the database.

comment:1 Changed 5 years ago by jbronn

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

Changed 5 years ago by wibge

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

comment:2 Changed 5 years ago by wibge

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 Changed 5 years ago by christian@…

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 Changed 5 years ago by ckarrie

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 Changed 5 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by jbronn

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

comment:6 Changed 5 years ago by jbronn

(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 Changed 5 years ago by jbronn

(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 Changed 4 years ago by jbronn

  • Status changed from new to assigned

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

comment:9 Changed 4 years ago by jbronn

(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 Changed 4 years ago by jbronn

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:11 Changed 4 years ago by jbronn

(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 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.