Version 12 (modified by Fran Boon, 11 years ago) ( diff )


GIS Storage

For portability, the default storage for Features is the normal database via Web2Py's DAL.

In order to support Lines & Polygons we store as WKT

An option should be provided to store in PostGIS, Spatialite or even GeoCouch instead, where available, as then can have spatial indexes for speed.

We can extend DAL for spatial support:

  • adding if deployment_settings.gis.spatialdb == True and deployment_settings.database.db_type == "postgres" to routines inside S3GIS' spaital functions to use optimsied routines where possible & falling back to the existing Shapely routines.

We could bypass DAL completely & use an ORM like GeoAlchemy:

response.custom_commit=lambda: do_commit()


Since we store features in Lat/Lon then we need to use the geography_columns, which stay updated automatically :)

geog GEOGRAPHY(Point)
geog GEOGRAPHY(Polygon)

ST_Distance(geography, geography) returns double
ST_DWithin(geography, geography, float8) returns boolean
ST_Area(geography) returns double
ST_Length(geography) returns double
ST_Covers(geography, geography) returns boolean
ST_CoveredBy(geography, geography) returns boolean
ST_Intersects(geography, geography) returns boolean

ST_Centroid(geometry) returns a point that is approximately on the center of mass of the input argument. This simple calculation is very fast, but sometimes not desirable, because the returned point is not necessarily in the feature itself. If the input feature has a convexity (imagine the letter ‘C’) the returned centroid might not be in the interior of the feature.
ST_PointOnSurface(geometry) returns a point that is guaranteed to be inside the input argument. It is substantially more computationally expensive than the centroid operation


Q: integrate FeatureServer?

Q: copy GeoDjango?

GIS BluePrints

Note: See TracWiki for help on using the wiki.