Add support for GeoAlchemy2 Geometry fields to Flask Appbuilder
Project description
fab_addon_geoalchemy
Implementation of GeoAlchemy fields for Flask Appbuilder.
It automatically transforms POINT Geometry columns to widgets with a field for latitude and longitude and a leaflet map. The map has a pointer for the location, and there is two way binding where dragging the pointer changes the value in the input fields and vice-versa. Later on, support for line and polygon columns may be added as well (pull requests welcome).
Installation
Run pip install fab-addon-geoalchemy
.
Usage
You can find examples in the unittests in the tests folder. But in short, this is what you need to do:
Add the following to your config.py:
ADDON_MANAGERS = ['fab_addon_geoalchemy.manager.GeoAlchemyManager']
And then use this for your models and views:
from sqlalchemy import Column, String
from fab_addon_geoalchemy.views import GeoModelView
from fab_addon_geoalchemy.models import GeoSQLAInterface, Geometry
class Observation(Model):
id = Column(Integer, primary_key=True)
name = Column(String)
location = Column(Geometry(geometry_type='POINT', srid=4326))
def __repr__(self):
if self.name:
return self.name
else:
return 'Person Type %s' % self.id
class ObservationView(GeoModelView):
datamodel = GeoSQLAInterface(Observation)
add_columns = ['name', 'location']
This will automatically create the LatLonWidget in the form, and process the data to transform the latitude and longitude values into a point geometry in the database. The srid form the column is used by the field for the conversion of the text coordinates to the geometry. No validation is done if the entered coordinates are actually valid for the specified SRID.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fab_addon_geoalchemy-0.4.1.tar.gz
.
File metadata
- Download URL: fab_addon_geoalchemy-0.4.1.tar.gz
- Upload date:
- Size: 57.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e752c7db88222696b2189327b5883f6cac89e1cf8653a1f1c384a6df1c88032 |
|
MD5 | fe1ab32bc0fe2a2370857c608c122658 |
|
BLAKE2b-256 | b293f61fafedfb06fcd9e517c30ebd5397857307ae169a954f2e791ae6f5e0f8 |
File details
Details for the file fab_addon_geoalchemy-0.4.1-py3.5.egg
.
File metadata
- Download URL: fab_addon_geoalchemy-0.4.1-py3.5.egg
- Upload date:
- Size: 75.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36295aac23a0a00e0c3341f98dec3df6ac45846ad5914474220f875fde0a6fde |
|
MD5 | 70c94e200aa0b09364b87cb205bf781f |
|
BLAKE2b-256 | 9b5a9d4b0d9d4d4a7fb6e62daa44c3ddc542b32127846f3e6b8f2615710a2a9d |