Skip to main content

Django speaking WFS 2.0 (exposing GeoDjango model fields)

Project description

Travis PyPI MPL License Coverage

django-gisserver

Django speaking WFS 2.0 to expose geo data.

Features

  • WFS 2.0 simple implementation.
  • GML 3.2 output.
  • Standard and spatial filtering (FES 2.0)
  • GeoJSON export support.
  • Extensible view/operations.
  • Uses GeoDjango queries for filtering.
  • Uses Django template engine for rendering XML (might become streaming lxml later).

Usage

Create a model that exposes a GeoDjango field:

from django.contrib.gis.db.models import PointField
from django.db import models


class Restaurant(models.Model):
    name = models.CharField(max_length=200)
    location = PointField(null=True)

    def __str__(self):
        return self.name

Write a view that exposes this model as a WFS feature:

from gisserver.features import FeatureType, ServiceDescription
from gisserver.types import CRS, WGS84
from gisserver.views import WFSView
from .models import Restaurant

RD_NEW = CRS.from_string("urn:ogc:def:crs:EPSG::28992")


class PlacesWFSView(WFSView):
    """An simple view that uses the WFSView against our test model."""

    xml_namespace = "http://example.org/gisserver"

    # The service metadata
    service_description = ServiceDescription(
        title="Places",
        abstract="Unittesting",
        keywords=["django-gisserver"],
        provider_name="Django",
        provider_site="https://www.example.com/",
        contact_person="django-gisserver",
    )

    # Each Django model is listed here as a feature.
    feature_types = [
        FeatureType(Restaurant.objects.all(), other_crs=[RD_NEW]),
    ]

Use that view in the URLConf:

from django.urls import path
from . import views

urlpatterns = [
    path("/wfs/places/", views.PlacesWFSView.as_view()),
]

You can now use http://localhost:8000/wfs/places/ in your GIS application. It will perform requests such as:

By adding &OUTPUTFORMAT=geojson to the GetFeature request, the GeoJSON output is returned.

Standards compliance

Currently, the following 3 methods are implemented:

  • GetCapabilities
  • DescribeFeatureType
  • GetFeature with filtering and pagination support.

This is sufficient to show results in QGis. The unit tests validate the output against WFS 2.0 XSD schema.

Some parts for conformance to the "WFS simple" level are not implemented yet:

  • GetPropertyValue
  • ListStoredQueries
  • DescribeStoredQueries
  • Certain parameters:
    • KVP filters: resourceID, propertyName, aliases.
    • Remote resolving: resolve, resolveDepth, resolveTimeout.
    • Output rewriting: namespaces.
    • Some GetCapabilities features: acceptFormats and sections.
    • Using GetFeature with only the StoredQuery action.
    • Temporal filtering (high on todo)

Low-prio items:

Anything outside WFS simple could be implemented, but is very low on the todo-list:

  • The methods for the WFS basic, transactional, locking and inheritance conformance classes.
  • HTTP POST requests.
  • SOAP requests.
  • Other protocols (WMS, WMTS, WCS)
  • Other output formats (shapefile, CSV, KML, GML 3.1) - but easy to add.

Development

When you follow the source of the WFSView, WFSMethod and Parameter classes, you'll find that it's written with extensibility in mind. Extra parameters and operations can easily be added there. You could even do that within your own projects and implementations.

The Makefile gives you all you need to start working on the project. Typing make gives an overview of all possible shortcut commands.

The WFS specification and examples be found at:

Some deeplinks:

Other links:

Why this code is shared

The "datapunt" team of the Municipality of Amsterdam develops software for the municipality. Much of this software is then published as Open Source so that other municipalities, organizations and citizens can use the software as a basis and inspiration to develop similar software themselves. The Municipality of Amsterdam considers it important that software developed with public money is also publicly available.

This package is initially developed by the City of Amsterdam, but the tools and concepts created in this project can be used in any city.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-gisserver-0.3.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

django_gisserver-0.3-py2.py3-none-any.whl (49.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-gisserver-0.3.tar.gz.

File metadata

  • Download URL: django-gisserver-0.3.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.10.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.17

File hashes

Hashes for django-gisserver-0.3.tar.gz
Algorithm Hash digest
SHA256 3e1986837c825162e947a7f815267bc6be71b1da7010eaf7e6285069b287fda0
MD5 051df1f88b3cc95ef0628d3273c87516
BLAKE2b-256 fda5df38188d76f2d6da9e452889d46638de108fb3229c01ffe9cd555f86e7ed

See more details on using hashes here.

File details

Details for the file django_gisserver-0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: django_gisserver-0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 49.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.10.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.17

File hashes

Hashes for django_gisserver-0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4a11e1c46bebbbe5a7a8a2332d2d9ee3f56f703cb37897941bcae7aaef036a23
MD5 0e272bf3e407a8b16b5b9ef5f629211e
BLAKE2b-256 2b450ea569a9489bacfe11bad46c245b84bdc9de40df1443a1999d2bd69e3eac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page