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