1. ================
    
  2. Geographic Feeds
    
  3. ================
    
  4. 
    
  5. .. module:: django.contrib.gis.feeds
    
  6.     :synopsis: GeoDjango's framework for generating spatial feeds.
    
  7. 
    
  8. GeoDjango has its own :class:`Feed` subclass that may embed location information
    
  9. in RSS/Atom feeds formatted according to either the `Simple GeoRSS`__ or
    
  10. `W3C Geo`_ standards.  Because GeoDjango's syndication API is a superset of
    
  11. Django's, please consult :doc:`Django's syndication documentation
    
  12. </ref/contrib/syndication>` for details on general usage.
    
  13. 
    
  14. .. _W3C Geo: https://www.w3.org/2003/01/geo/
    
  15. 
    
  16. __ https://georss.org
    
  17. 
    
  18. Example
    
  19. =======
    
  20. 
    
  21. API Reference
    
  22. =============
    
  23. 
    
  24. ``Feed`` Subclass
    
  25. -----------------
    
  26. 
    
  27. .. class:: Feed
    
  28. 
    
  29.     In addition to methods provided by the
    
  30.     :class:`django.contrib.syndication.views.Feed` base class, GeoDjango's
    
  31.     ``Feed`` class provides the following overrides. Note that these overrides
    
  32.     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 tuple
    
  60.     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 can be a
    
  71.     ``GEOSGeometry`` instance, or a tuple that represents a point coordinate or
    
  72.     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. 
    
  83. The following :class:`django.utils.feedgenerator.SyndicationFeed` subclasses
    
  84. are 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.