Opened 3 years ago

Closed 16 months ago

#16594 closed Bug (fixed)

Missing altitude (z) on Point on admin interface for geodjango

Reported by: info@… Owned by: nobody
Component: GIS Version: 1.3
Severity: Normal Keywords:
Cc: flavio.curella@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I am using a model with a 3d Point field, although in the database I can see correctly the z component in the admin section for the Point field I see only the x,y component i.e. POINT(x_value y_value ) instead of POINT(x_value y_value z_value).



Attachments (2)

16594-1.diff (3.3 KB) - added by claudep 22 months ago.
Added 3d support to wkt property
16594-2.diff (7.5 KB) - added by claudep 21 months ago.
Updated now that geometries.json.gz test data is geometries.json

Download all attachments as: .zip

Change History (7)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I can reproduce this with PostgreSQL and PostGIS.

I wrote a model that contains this field: geom3 = django.contrib.gis.db.models.GeometryField(dim=3).

I can create an object with the value POINT(1 2 3) in the admin. When I edit this object again, the field contains POINT (1.0000000000000000 2.0000000000000000) — no 3.0000000000000000. If I try to save the object, I get this traceback:

File "/usr/lib/python2.6/site-packages/django/core/handlers/" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/" in wrapper
  307.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/" in inner
  197.             return view(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/" in _wrapper
  28.             return bound_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/" in bound_func
  24.                 return func(self, *args2, **kwargs2)
File "/usr/lib/python2.6/site-packages/django/db/" in inner
  217.                 res = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/" in change_view
  982.                 self.save_model(request, new_object, form, change=True)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/" in save_model
File "/usr/lib/python2.6/site-packages/django/db/models/" in save
  460.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/lib/python2.6/site-packages/django/db/models/" in save_base
  526.                         rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/usr/lib/python2.6/site-packages/django/db/models/" in _update
  491.         return query.get_compiler(self.db).execute_sql(None)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/" in execute_sql
  869.         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/" in execute_sql
  735.         cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/" in execute
  34.             return self.cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/" in execute
  44.             return self.cursor.execute(query, args)

Exception Type: IntegrityError at /admin/myapp/mymodel/1/
Exception Value: new row for relation "myapp_mymodel" violates check constraint "enforce_dims_geom3"

comment:2 Changed 22 months ago by DavidEklund

See also #18919.

The __str__() method applied to a point object returns a coordinate-tuple with the z-component dropped. This seems directly related to the issue at hand.

Changed 22 months ago by claudep

Added 3d support to wkt property

comment:3 Changed 22 months ago by claudep

  • Has patch set

I'd be interested to hear from tests with the attached patch. GEOS 3.3 is still required to have 3D WKTs.

Changed 21 months ago by claudep

Updated now that geometries.json.gz test data is geometries.json

comment:4 Changed 21 months ago by fcurella

  • Cc flavio.curella@… added

comment:5 Changed 16 months ago by Claude Paroz <claude@…>

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

In 5e80571bf92d93c177bea9e5ee7d89153ecadbad:

Fixed #16594 -- Added wkt 3D support for GEOS geometries

This requires GEOS >= 3.3.0 to function properly. On previous
versions, the Z dimension will simply not appear in the wkt.
Disabled OpenLayers editing for 3D geometries (unsupported).

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.