Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26775 closed Bug (fixed)

Geography PointField ignores dim=3

Reported by: François-Xavier Thomas Owned by: nobody
Component: GIS Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using the following model :

class TestModel(models.Model):
    position = models.PointField(geography=True, dim=3)
    position2 = models.PointField(dim=3)

...the position field seems to ignore the dim=3 argument and does not create a PostGIS PointZ geography type (3D) but a regular Point (2D) :

                                  Table "public.testapp_testmodel"
  Column   |         Type          |                           Modifiers                            
-----------+-----------------------+----------------------------------------------------------------
 id        | integer               | not null default nextval('testapp_testmodel_id_seq'::regclass)
 position  | geography(Point,4326) | not null
 position2 | geometry(PointZ,4326) | not null
Indexes:
    "testapp_testmodel_pkey" PRIMARY KEY, btree (id)
    "testapp_testmodel_position2_id" gist (position2 gist_geometry_ops_nd)
    "testapp_testmodel_position_id" gist ("position")

Tested under Django 1.9.5.

Change History (9)

comment:1 by Tim Graham, 8 years ago

So we don't need a separate field as described in #26750 then?

comment:2 by François-Xavier Thomas, 8 years ago

No, I don't think so. Since dim already works for geometries, it probably should for geographies as well.

For the time being I solved this by manually editing the field type in a migration operation :

migrations.RunSQL(
        "ALTER TABLE dataset_files ALTER COLUMN position TYPE "
        "geography(PointZ, 4326) USING ST_Force3D(position::geometry)::geography",
        "ALTER TABLE dataset_files ALTER COLUMN position TYPE "
        "geography(Point, 4326) USING ST_Force2D(position::geometry)::geography",
)

Django seems to think that this is fine and works perfectly well with 3D geographies afterwards.

comment:3 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Claude Paroz, 8 years ago

Has patch: set

comment:5 by Tim Graham, 8 years ago

Does introspection work? That seemed to be the concern of #26750 which I closed as a duplicate. I suppose we can reopen that as a separate issue if you prefer.

comment:6 by Claude Paroz, 8 years ago

Yes, I'd like to treat introspection separately.

comment:7 by Tim Graham, 8 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Claude Paroz <claude@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 8ba44ec:

Fixed #26775 -- Supported dim=3 geography fields

Thanks François-Xavier Thomas for the report.

comment:9 by Claude Paroz <claude@…>, 8 years ago

In 1b6de8fd:

[1.10.x] Fixed #26775 -- Supported dim=3 geography fields

Thanks François-Xavier Thomas for the report.
Backport of 8ba44ecda0 from master.

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