Commit 90b3e771 authored by Alex Kerney's avatar Alex Kerney

Passing the srid into GeoJSONField

parent 01683b92
...@@ -37,7 +37,7 @@ class JSONField(TextAreaField): ...@@ -37,7 +37,7 @@ class JSONField(TextAreaField):
class GeoJSONField(JSONField): class GeoJSONField(JSONField):
widget = LeafletWidget() widget = LeafletWidget()
def __init__(self, label=None, validators=None, geometry_type="GEOMETRY", srid='-1', **kwargs): def __init__(self, label=None, validators=None, geometry_type="GEOMETRY", srid='-1', session=None, **kwargs):
super(GeoJSONField, self).__init__(label, validators, **kwargs) super(GeoJSONField, self).__init__(label, validators, **kwargs)
self.web_srid = 4326 self.web_srid = 4326
self.srid = srid self.srid = srid
...@@ -55,4 +55,4 @@ class GeoJSONField(JSONField): ...@@ -55,4 +55,4 @@ class GeoJSONField(JSONField):
super(GeoJSONField, self).process_formdata(valuelist) super(GeoJSONField, self).process_formdata(valuelist)
web_shape = self.session.scalar(func.ST_AsText(func.ST_Transform(func.ST_GeomFromText(shape(self.data).wkt, self.web_srid), self.srid))) web_shape = self.session.scalar(func.ST_AsText(func.ST_Transform(func.ST_GeomFromText(shape(self.data).wkt, self.web_srid), self.srid)))
if type(self.data): if type(self.data):
self.data = 'SRID='+str(self.srid)+';'+web_shape self.data = 'SRID='+str(self.srid)+';'+str(web_shape)
...@@ -7,5 +7,6 @@ class AdminModelConverter(SQLAAdminConverter): ...@@ -7,5 +7,6 @@ class AdminModelConverter(SQLAAdminConverter):
@converts('Geometry') @converts('Geometry')
def convert_geom(self, column, field_args, **extra): def convert_geom(self, column, field_args, **extra):
field_args['geometry_type'] = column.type.geometry_type field_args['geometry_type'] = column.type.geometry_type
field_args['srid'] = column.type.srid
field_args['session'] = self.session field_args['session'] = self.session
return GeoJSONField(**field_args) return GeoJSONField(**field_args)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment