#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 , 9 years ago
comment:2 by , 9 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 , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 9 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:7 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
So we don't need a separate field as described in #26750 then?