Commit 9db58cb0 authored by Alex Kerney's avatar Alex Kerney

Removing geoa Geometry class and updating docs

parent 933ea265
......@@ -37,14 +37,10 @@ Creating simple model
---------------------
GeoAlchemy comes with a `Geometry`_ field that is carefully divorced from the
`Shapely`_ library. Flask-Admin takes the approach that if you're using spatial
objects in your database, and you want an admin interface to edit those objects,
you're probably already using Shapely, so we provide a Geometry field that is
integrated with Shapely objects. To make your admin interface works, be sure to
use this field rather that the one that ships with GeoAlchemy when defining your
models::
from flask.ext.admin.contrib.geoa.sqltypes import Geometry
`Shapely`_ library. Flask-Admin will use this field so that there are no changes necessary to other code. ``ModelView`` should be imported from ``geoa`` rather than the one imported from ``sqla``::
from geoalchemy2 import Geometry
from flask.ext.admin.contrib.geoa import ModelView
# .. flask initialization
db = SQLAlchemy(app)
......
from geoalchemy2 import Geometry as BaseGeometry
from geoalchemy2.shape import to_shape
class Geometry(BaseGeometry):
"""
PostGIS datatype that can convert directly to/from Shapely objects,
without worrying about WKTElements or WKBElements.
"""
def result_processor(self, dialect, coltype):
to_wkbelement = super(Geometry, self).result_processor(dialect, coltype)
def process(value):
if value:
return to_shape(to_wkbelement(value))
else:
return None
return process
def bind_processor(self, dialect):
from_wktelement = super(Geometry, self).bind_processor(dialect)
def process(value):
if value:
return from_wktelement(value.wkt)
else:
return None
return process
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