from flask.ext.admin.model.form import converts
from flask.ext.admin.contrib.sqla.form import AdminModelConverter as SQLAAdminConverter
from .fields import GeoJSONField


class AdminModelConverter(SQLAAdminConverter):
    @converts('Geometry')
    def convert_geom(self, column, field_args, **extra):
        field_args['geometry_type'] = column.type.geometry_type
        field_args['srid'] = column.type.srid
        field_args['session'] = self.session
        return GeoJSONField(**field_args)

from flask.ext.admin.model.form import converts
from flask.ext.admin.contrib.sqla.form import AdminModelConverter as SQLAAdminConverter
from .fields import GeoJSONField


class AdminModelConverter(SQLAAdminConverter):
    @converts('Geography', 'Geometry')
    def convert_geom(self, column, field_args, **extra):
        field_args['geometry_type'] = column.type.geometry_type
        field_args['srid'] = column.type.srid
        field_args['session'] = self.session
        return GeoJSONField(**field_args)

Add Geography Type to GeoAlchemy Backend
Add Geography Type to GeoAlchemy Backend

The current GeoAlchemy backend only works with geometry columns, and ignores geography columns (which are also supported by geoalchemy).  This 1-word fix adds support for geography columns.
  from flask.ext.admin.model.form import converts
  from flask.ext.admin.contrib.sqla.form import AdminModelConverter as SQLAAdminConverter
  from .fields import GeoJSONField
  
  
  class AdminModelConverter(SQLAAdminConverter):
-     @converts('Geometry')
+     @converts('Geography', 'Geometry')
      def convert_geom(self, column, field_args, **extra):
          field_args['geometry_type'] = column.type.geometry_type
          field_args['srid'] = column.type.srid
          field_args['session'] = self.session
          return GeoJSONField(**field_args)
  
Add Geography Type to GeoAlchemy Backend
## Code Before:
from flask.ext.admin.model.form import converts
from flask.ext.admin.contrib.sqla.form import AdminModelConverter as SQLAAdminConverter
from .fields import GeoJSONField


class AdminModelConverter(SQLAAdminConverter):
    @converts('Geometry')
    def convert_geom(self, column, field_args, **extra):
        field_args['geometry_type'] = column.type.geometry_type
        field_args['srid'] = column.type.srid
        field_args['session'] = self.session
        return GeoJSONField(**field_args)

## Instruction:
Add Geography Type to GeoAlchemy Backend
## Code After:
from flask.ext.admin.model.form import converts
from flask.ext.admin.contrib.sqla.form import AdminModelConverter as SQLAAdminConverter
from .fields import GeoJSONField


class AdminModelConverter(SQLAAdminConverter):
    @converts('Geography', 'Geometry')
    def convert_geom(self, column, field_args, **extra):
        field_args['geometry_type'] = column.type.geometry_type
        field_args['srid'] = column.type.srid
        field_args['session'] = self.session
        return GeoJSONField(**field_args)
