PageRenderTime 182ms CodeModel.GetById 81ms app.highlight 1ms RepoModel.GetById 99ms app.codeStats 0ms

/docs/ref/contrib/gis/feeds.txt

https://code.google.com/p/mango-py/
Plain Text | 95 lines | 64 code | 31 blank | 0 comment | 0 complexity | c94e7576d6beb92a21c98aacfdf606f8 MD5 | raw file
 1================
 2Geographic Feeds
 3================
 4
 5.. module:: django.contrib.gis.feeds
 6   :synopsis: GeoDjango's framework for generating spatial feeds.
 7
 8GeoDjango has its own :class:`Feed` subclass that may embed location information
 9in RSS/Atom feeds formatted according to either the `Simple GeoRSS`__ or
10`W3C Geo`_ standards.  Because GeoDjango's syndication API is a superset of
11Django's, please consult :doc:`Django's syndication documentation
12</ref/contrib/syndication>` for details on general usage.
13
14.. _W3C Geo: http://www.w3.org/2003/01/geo/
15
16__ http://georss.org/1.0#simple
17
18Example
19=======
20
21API Reference
22=============
23
24``Feed`` Subclass
25-----------------
26
27.. class:: Feed
28
29   In addition to methods provided by
30   the :class:`django.contrib.syndication.feeds.Feed`
31   base class, GeoDjango's ``Feed`` class provides
32   the following overrides.  Note that these overrides may be done in multiple ways::
33
34       from django.contrib.gis.feeds import Feed
35
36       class MyFeed(Feed):
37
38            # First, as a class attribute.
39            geometry = ...
40            item_geometry = ...
41
42            # Also a function with no arguments
43            def geometry(self):
44                ...
45
46            def item_geometry(self):
47                ...
48
49            # And as a function with a single argument
50            def geometry(self, obj):
51                ...
52
53            def item_geometry(self, item):
54                ...
55
56   .. method:: geometry(obj)
57
58   Takes the object returned by ``get_object()`` and returns the *feed's*
59   geometry.  Typically this is a ``GEOSGeometry`` instance, or can be a
60   tuple to represent a point or a box.  For example::
61
62       class ZipcodeFeed(Feed):
63
64           def geometry(self, obj):
65               # Can also return: `obj.poly`, and `obj.poly.centroid`.
66               return obj.poly.extent # tuple like: (X0, Y0, X1, Y1).
67
68   .. method:: item_geometry(item)
69
70   Set this to return the geometry for each *item* in the feed.  This
71   can be a ``GEOSGeometry`` instance, or a tuple that represents a
72   point coordinate or bounding box.  For example::
73
74       class ZipcodeFeed(Feed):
75
76           def item_geometry(self, obj):
77	       # Returns the polygon.
78               return obj.poly
79
80``SyndicationFeed`` Subclasses
81------------------------------
82
83The following :class:`django.utils.feedgenerator.SyndicationFeed` subclasses
84are available:
85
86.. class:: GeoRSSFeed
87
88.. class:: GeoAtom1Feed
89
90.. class:: W3CGeoFeed
91
92.. note::
93
94    `W3C Geo`_ formatted feeds only support
95    :class:`~django.contrib.gis.db.models.PointField` geometries.