Git Product home page Git Product logo

django-wms's Introduction

Django WMS Framework

The Django WMS Framework is a toolkit that makes it easy to build a Web Map Service (WMS) or a x-y-z Tile Map Service. Rendering of both vector and raster data formats are supported.

For complete documentation please go to http://django-wms.readthedocs.org

https://api.shippable.com/projects/5423d57480088cee586cd0c7/badge?branchName=master

Requirements

The processing of spatial data in django-wms relies on MapServer and its python bindings MapScript. Raster data integration depends on the django-raster package. The use of PostGIS as the database backend is required as well, for raster ntegration PostGIS >= 2.0 is required (see also django-raster package).

Installation

  1. Install package with pip install django-wms

  2. Add "wms" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'wms',
    )
    

Example

To create a mapping service, subclass the django-wms layer, map and view classes and connect them to an existing model in django that has a spatial field (such as Point, Polygon or MultiPolygon). An example wms_config.py module could be specified as follows

### wms_config.py

# Load django-wms classes
from wms import maps, layers, views

# Load model with spatial field (Point, Polygon or MultiPolygon)
from myapp.models import MySpatialModel


# Subclass the WmsVectorLayer class and point it to a spatial model.
# Use WmsRasterLayer for rasters
class MyWmsLayer(layers.WmsVectorLayer):
    model = MySpatialModel

# Subclass the WmsMap class and add the layer to it
class MyWmsMap(maps.WmsMap):
    layer_classes = [ MyWmsLayer ]

# Subclass the WmsView to create a view for the map
class MyWmsView(views.WmsView):
    map_class = MyWmsMap

With the WmsView subclass in place, the only thing left to do to create a functional map service is to hook the view into a url. An example url configuration urls.py could be

### urls.py

# Import the wms view
from myproject.wms_config import MyWmsView

# Add url patterns to setup map services from the view
urlpatterns = patterns('',

    # This creates a WMS endpoint
    url(r'^wms/$', MyWmsView.as_view(), name='wms'),

    # This creates a TMS endpoint
    url(r'^tile/(?P<layers>[^/]+)/(?P<z>[0-9]+)/(?P<x>[0-9]+)/(?P<y>[0-9]+)(?P<format>\.jpg|\.png)$',
        MyWmsView.as_view(), name='tms'),
)

The django-wms package will automatically detect the first spatial field it can find in MySpatialModel and create a WMS endpoint from the class based view. If the three arguments x, y and z are found in the urlpattern, the view functions as TMS endpoint.

django-wms's People

Contributors

yellowcap avatar

Watchers

Jude Mwenda avatar James Cloos avatar

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.