feeds.txt 2.5 KB

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