django - GeoDjango: transform SRID in DRF Serializer -
i writing api using osm db, regular db, drf3 , django-rest-framework-gis.
the osm db using srid 900913, api output coordinates according srid 4326. achievable using transform(srid=4326)
on geoquerysets, unfortunately not option in case (explained why further down).
of understand, should able specify srid in field definition of model so:
class polygon(models.model): osm_id = models.autofield(primary_key=true) name = models.charfield(null=true) way = models.polygonfield(null=true, srid=4326) admin_level = models.charfield(default='2', null=true) objects = models.geomanager() class meta: db_table = 'osm_poly_lu'
but api keeps returning polygons coordinates in 900913 format.
do understand correctly; should able set srid on polygon field 4326 django automatically convert dbs 900913? if so, guess must missing something; ideas of may wrong? feel true newbie in area - appreciated.
the reason why can not use transform()
on querysets:
what doing querying member table, , member model regular model. have relation osm polygon table (field called osm_id_origin) , geodjango model. when serialize member drf3 serializer, have nested serializer in member serializer serializes osm_id_origin field in member model geojson. nested serializer using creating geojson subclass of django-rest-framework-gis serializer geofeaturemodelserializer
. since query member model, regular queryset, can not run transform(srid=4326)
on it.
Comments
Post a Comment