Skip to content

jeffersonheard/ga_ows

Repository files navigation

RENCI Geoanalytics - OGC WFS and WMS

Core to Geoanalytics are the Open Geographic Consortium's Open Web Services. ga_ows is a reusable GeoDjango webapp that provides you the ability to expose GeoDjango models and Python objects as geographic webservices.

A geographic webservice allows you to access data in your GeoDjango models by bounding box and other filters; these data can then be imported into other geographic databases, or perhaps more importantly as layers on a map. For layering WFS services, see the OpenLayers project .

How does it work? OWS is based on Django's class-based generic views. The following in your urls.py will create a WFS service for a the models in your app:

from ga_ows.views.wfs import WFS
from myapp import models as m

urlpatterns = patterns('',

# ...

    url(r'^wfs/?', WFS.as_view(
        models=[m.MyModel1, m.MyModel2], # everything but this is optional.
        title='My app\'s WFS',
        keywords=['some','keywords'],
        fees='one dollar',
        provider_name='RENCI',
        addr_street='100 Europa Dr. ste 529',
        addr_city='Chapel Hill',
        addr_admin_area='NC',
        addr_postcode='27515',
        addr_country='USA',
        addr_email='jeff@renci.org'
    )),

# ...

)

This will create a WFS endpoint at $django_server/$myapp_root/wfs that serves up features in GML and any of the formats that support the creation of single-file dataset in OGR_ (note that for now this means shapefiles are not supported for output since they require multiple files, although they will be in the near future).

WMS, which renders data to image before returning it to a client, is currently implemented but undocumented. WMS services will change shortly to match the source code model in the WFS implementation as it is much cleaner and easier to support the standard as written. If you are interested in using WMS and don't mind the instabilty of the API, read the documentation in the following modules:

  • ga_ows.rendering.palettes
  • ga_ows.rendering.styler
  • ga_ows.views.wms
  • ga_ows.views.wmsconfig - note in particular this module is likely to go away and change drastically.

Implemented features

Currently implemented in WFS are the following operations, as urlencoded HTTP GET and HTTP POST. XML and SOAP are not supported yet and not high on my priority list at the moment:

  • GetCapabilities
  • DescribeFeatureType [1]
  • GetFeature
  • ListStoredQueries
  • DescribeStoredQueries

Yet to be implemented features include:

  • Transaction
  • GetFeatureWithLock
  • LockFeature
  • GetPropertyValue
  • CreateStoredQuery
  • DropStoredQuery

If you require transactional features, right now `django-tastypie`_ may well cover your needs nicely. It creates RESTful APIs for models instead of using the standard WFS transaction support.

[1]DescribeFeatureType requires that you have your models' schema exposed through django-model-schemas_

Querying the data

The standard query language is not implemented. Instead, the Django QuerySet query language is supported, including geographic extensions through GeoDjango. In the query parameter, you pass a JSON document containing the query as sets of parameters and JSON serializable values (geometry should be WKT strings in the same SRS as the service's native SRS.). Thus the following filter is valid:

{
    "geom__crosses" : "LINESTRING(0 0, 10 10, 20 30)",
    "entry__gt" : "10/10/2010",
    "speed__gt" : 10
}

Not all Django model queries are supported yet. In particular, referencing model fields and queries that requiree Q() are not yet supported. These will be supported in future versions of ga_ows.

Common return formats

Although nothing is guaranteed, most implementations of OGR contain at least the GeoJSON and GML formats as well as a number of others, often including CSV. For a complete list of formats, check the GetCapabilities document.

Requirements

Because OWS does a lot of heavy lifting, there are a few requirements above and beyond basic GeoDjango:

WFS

  • GDAL
  • lxml
  • psycopg2 [2]
  • PostGIS or Spatialite backends (MySQL and Oracle are currently unsupported)
  • django-tastypie (if you want to support transactions)
  • django-model-schemas (for DescribeFeatureType)

WMS

  • as above, but also...
  • pycairo
  • shapely
  • numpy
  • scipy - (yes, really)
[2]note that Postgres 9.1 users will want to get the `patch for psycopg2 described here`_

Support

Please post issues at github's repository for ga_ows for support.

This file was modified by PyCharm 2.0.1 for binding GitHub repository

About

OGC Web Map Service and Web Feature Service for Django

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages