Giter Club home page Giter Club logo

django-wfs's Introduction

django-wfs

A WFS (web feature service) implementation as a Django application.

This implementation of WFS (currently) very loosely follows the 1.0.0 spec. It is currently only tested with a PostGIS backend.

What you can expect:

  • GetCapabilities
  • DescribeFeatureType
  • GetFeature
  • Django Queryset filtering

What is not here yet:

  • Transactional requests
  • Native WFS filtering (bbox and friends)

Requirements

  • Django
  • Django sites framework
  • PostgreSQL + PostGIS

Example app

An example application can be found in the "example" folder of this repository.

Installation

pip install django-wfs

Add these to your INSTALLED_APPS setting:

INSTALLED_APPS = (
    ...
    'django.contrib.gis',
    'django.contrib.sites',
    'wfs',
    ...
)

And define a SITE_ID if you haven't yet:

SITE_ID = 1

In your urls.py add (the actual regex can be anything, it doesn't have to be ^wfs/):

url(r'^wfs/', include('wfs.urls')),

Make sure you have a working PostGIS GeoDjango installation. Generally, if your database engine is 'django.contrib.gis.db.backends.postgis', stuff will probably not break too much.

WFS Service and Feature Types

In the admin you'll now have a WFS section with Services and Feature Types. These are the concepts present in the WFS spec but generally you can have multiple feature types in each service.

A Service is an endpoint like /wfs/1 (service with ID 1). It has the parameters defined in the spec:

  • Name
  • Title
  • Keywords
  • Abstract
  • Fees
  • Access constraints

After you create a Service in the Django Admin you can then associate a Feature Type to the created service. A Feature Type has the following parameters:

  • Service (foreign key)
  • Name (no spaces!!)
  • Title
  • Keywords
  • Abstract
  • SRS: Spatial Reference System used by the Feature Type. Defaults to WGS 84 (EPSG:4326)
  • Model (any model present in your Django project which contains a geo field)
  • Fields (after selecting a Model and pressing the "Save and continue editing" button and you'll see its fields. The ones you select will be exposed through the service)
  • Query (JSON representation of Django queryset filters. Example follows)

Query

The JSON representation of Django queryset filters allow you cut down results presented by a Feature Type. Some examples:

Only display entries from a model if they belong to the "vascop" user:

{"user__username":"vascop"}

Only display entries from a model if they belong to the "vascop" user and are published:

{"user__username":"vascop", "published": true}

Possible problems

If you have APPEND_SLASH = True (which is the Django default) and you're adding your WFS service to QGIS be sure to insert the connection with an appended slash, otherwise Django replies with a 301 code and QGIS won't display your layer.

Be sure to use Feature Type names which have no spaces or special characters. The title can have whatever you want.

Any other problem, submit an issue and I'll try to take a look at it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.