Opened 4 years ago

Closed 2 years 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

Description

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).

Thanks!

Luca

Attachments (2)

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

Download all attachments as: .zip

Change History (7)

comment:1 Changed 4 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:

Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/options.py" in wrapper
  307.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/sites.py" in inner
  197.             return view(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapper
  28.             return bound_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in bound_func
  24.                 return func(self, *args2, **kwargs2)
File "/usr/lib/python2.6/site-packages/django/db/transaction.py" in inner
  217.                 res = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/options.py" in change_view
  982.                 self.save_model(request, new_object, form, change=True)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/options.py" in save_model
  665.         obj.save()
File "/usr/lib/python2.6/site-packages/django/db/models/base.py" 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/base.py" in save_base
  526.                         rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in _update
  491.         return query.get_compiler(self.db).execute_sql(None)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  869.         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  735.         cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/util.py" in execute
  34.             return self.cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py" 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 3 years 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 3 years ago by claudep

Added 3d support to wkt property

comment:3 Changed 3 years 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 3 years ago by claudep

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

comment:4 Changed 3 years ago by fcurella

  • Cc flavio.curella@… added

comment:5 Changed 2 years 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).

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