Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amsterdam/django-gisserver
Django speaking WFS 2.0 to expose geo data
https://github.com/amsterdam/django-gisserver
django geodjango geojson gis-server gml ogc team-datadiensten wfs wfs-server
Last synced: 3 days ago
JSON representation
Django speaking WFS 2.0 to expose geo data
- Host: GitHub
- URL: https://github.com/amsterdam/django-gisserver
- Owner: Amsterdam
- License: mpl-2.0
- Created: 2020-02-12T13:04:37.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-11T12:54:26.000Z (29 days ago)
- Last Synced: 2024-12-29T19:35:45.795Z (10 days ago)
- Topics: django, geodjango, geojson, gis-server, gml, ogc, team-datadiensten, wfs, wfs-server
- Language: Python
- Homepage:
- Size: 899 KB
- Stars: 44
- Watchers: 18
- Forks: 10
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
[![Documentation](https://readthedocs.org/projects/django-gisserver/badge/?version=latest)](https://django-gisserver.readthedocs.io/en/latest/?badge=latest)
[![Actions](https://github.com/Amsterdam/django-gisserver/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/Amsterdam/django-gisserver/actions/workflows/tests.yaml)
[![PyPI](https://img.shields.io/pypi/v/django-gisserver.svg)](https://pypi.python.org/pypi/django-gisserver)
[![MPL License](https://img.shields.io/badge/license-MPL%202.0-blue.svg)](https://pypi.python.org/pypi/django-gisserver)
[![Coverage](https://img.shields.io/codecov/c/github/amsterdam/django-gisserver/main.svg)](https://codecov.io/github/amsterdam/django-gisserver?branch=main)# 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:
## Quickstart
Install the module in your project:
```bash
pip install django-gisserver
```Add it to the ``INSTALLED_APPS``:
```python
INSTALLED_APPS = [
...
"gisserver",
]
```Create a model that exposes a GeoDjango field:
```python
from django.contrib.gis.db.models import PointField
from django.db import modelsclass 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:
```python
from gisserver.features import FeatureType, ServiceDescription
from gisserver.geometries import CRS, WGS84
from gisserver.views import WFSView
from .models import RestaurantRD_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:
```python
from django.urls import path
from . import viewsurlpatterns = [
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.