Incorrect serialization for 3d GEOSGeometry

34 views
Skip to first unread message

Craig de Stigter

unread,
May 15, 2012, 8:02:54 AM5/15/12
to django-d...@googlegroups.com
Hi folks


I discovered django.contrib.gis support for 3d geometries is pretty patchy. I realised that the database stuff only worked in postgis, etc, but it turns out even the serialisation methods on GEOSGeometry don't work properly.

Here's a small test script that demonstrates the problem: https://gist.github.com/2594905

And here's the output: https://gist.github.com/2594926

In summary, all these properties return 2d-only output for 3d geometries (the Z dimension gets stripped):
  • wkt
  • ewkt
  • hex
  • wkb
  • json
  • geojson
Yet these others produce correct 3d output:
  • ewkb
  • hexewkb
  • kml
Is there any reasoning behind this, or should I create a ticket and try to fix them?

I tried posting this to the geodjango list (here), but I'm not sure if anyone actually reads those posts, as I haven't got a response in 10 days.

Thanks
Craig de Stigter

Russell Keith-Magee

unread,
May 15, 2012, 7:10:20 PM5/15/12
to django-d...@googlegroups.com
On Tue, May 15, 2012 at 8:02 PM, Craig de Stigter <crai...@gmail.com> wrote:
> Hi folks
>
>
> I discovered django.contrib.gis support for 3d geometries is pretty
> patchy. I realised that the database stuff only worked in postgis, etc, but
> it turns out even the serialisation methods on GEOSGeometry don't work
> properly.
>
> Here's a small test script that demonstrates the
> problem: https://gist.github.com/2594905
>
> And here's the output: https://gist.github.com/2594926
>
> In summary, all these properties return 2d-only output for 3d geometries
> (the Z dimension gets stripped):
>
> wkt
> ewkt
> hex
> wkb
> json
> geojson
>
> Yet these others produce correct 3d output:
>
> ewkb
> hexewkb
> kml
>
> Is there any reasoning behind this, or should I create a ticket and try to
> fix them?

I'm afraid I'm not an expert on Django's GIS libraries, so I can't
speak with authority as to whether the stripping of the Z axis is
deliberate or accidental. It feels like something that is probably
accidental, but it *might* be deliberate.

If I were in your shoes, the first way I'd check would be to make the
change to the serializer for one of the fields, and see if that change
breaks Django's test suite (in particular, the GIS portions). In
theory, everything in Django should be tested, so there *should* be a
test covering serialisation of GIS.

Failing that, you'll need some expertise from someone that knows the
GIS code well.

Sorry I can't be much more help than that.

Yours,
Russ Magee %-)
Reply all
Reply to author
Forward
0 new messages