Skip to main content

Django speaking WFS 2.0 (exposing GeoDjango model fields)

Project description

Documentation Travis PyPI MPL License Coverage

django-gisserver

Django speaking WFS 2.0 to expose geo data.

Features

  • WFS 2.0 Basic implementation.
  • GML 3.2 output.
  • Standard and spatial filtering (FES 2.0)
  • GeoJSON and CSV export formats.
  • Extensible view/operations.
  • Uses GeoDjango queries for filtering.
  • Streaming responses for large datasets.

Documentation

For more details, see: https://django-gisserver.readthedocs.io/

Quickstart

Install the module in your project:

pip install django-gisserver

Add it to the INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "gisserver",
]

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.geometries import CRS, WGS84
from gisserver.views import WFSView
from .models import Restaurant

RD_NEW = CRS.from_srid(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(),
            fields="__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 or &OUTPUTFORMAT=csv to the GetFeature request, the GeoJSON and CSV outputs are returned. The CSV output has an unlimited page size, as it's quite performant.

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-1.1.2.tar.gz (86.2 kB view details)

Uploaded Source

Built Distribution

django_gisserver-1.1.2-py2.py3-none-any.whl (103.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-gisserver-1.1.2.tar.gz
  • Upload date:
  • Size: 86.2 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-1.1.2.tar.gz
Algorithm Hash digest
SHA256 409935629b1a2420ae5db9db7363a4f257edf6f1a0d37c881bd0ea316b7b3f0f
MD5 38c105c5fb513b79edfc558b7c64e8c7
BLAKE2b-256 e23ee2fdf004cd09368066f86a38713a573690fc3b6356d934d35730c9dee8c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_gisserver-1.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 103.9 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-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ca507d1dbe1fad4177eb375681d9fd626bce0988a284295ccad62666b68f5ad
MD5 f31647697481f77983d569ebab54191b
BLAKE2b-256 3975d568493d5ef8d5a0e5df1f261e8347d573323c3f0b2ae0089e992f25d588

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