Open daredevil82 opened 8 years ago
I don't see the benefit of including such a feature in drf-gis right now, you should be able to extend drf-gis serializers and implement what you need. You might as well publish your solution somewhere so we can better understand the use case in more detail.
This would be awesome
I've been asked to create a Django app where users can manage their existing library of KML documents along with other GIS formats. Unfortunately, it seems that about half of the documents have 2D geometry while the rest are 3D. This causes issues when saving the geometry model because GeoDjango's
GeometryField
has a defaultdim
value of 2, which results in errors when uploading a 3D file.My conundrum is similar to the question here at GIS Stackexchange, just inverted. However, I would not want to not force a 2D transform, as the height values are a big part of the data.
A short term solution is to include two geometry fields within the model, one 2D and the other 3D. Depending on the dimension, the geometry will be saved to the appropriate field in the model. In order to use this within the serializer, a
GeometrySerializerMethodField
needs to be used, much likeIf
geo_field
were to accept a tuple as a value, then the above could be functionally identical toThis would also benefit devs who find themselves doing far too many joins that impact performance and use denormalization as a solution.