地理 FeedLink to this heading

GeoDjango has its own Feed subclass that may embed location information in RSS/Atom feeds formatted according to either the Simple GeoRSS or W3C Geo standards. Because GeoDjango's syndication API is a superset of Django's, please consult Django's syndication documentation for details on general usage.

例如Link to this heading

API 参考Link to this heading

Feed 子类Link to this heading

class FeedLink to this definition

除了 django.contrib.syndication.views.Feed 基类提供的方法之外,GeoDjango 的 Feed 类还提供了以下覆盖方法。请注意,可以以多种方式进行这些覆盖操作:

Code
from django.contrib.gis.feeds import Feed


class MyFeed(Feed):
    # First, as a class attribute.
    geometry = ...
    item_geometry = ...

    # Also a function with no arguments
    def geometry(self): ...

    def item_geometry(self): ...

    # And as a function with a single argument
    def geometry(self, obj): ...

    def item_geometry(self, item): ...
geometry(obj)Link to this definition

使用 get_object() 返回的对象,并返回 feed 的几何形状。通常情况下,这是一个 GEOSGeometry 实例,或者可以是一个表示点或矩形框的元组。例如:

Code
class ZipcodeFeed(Feed):
    def geometry(self, obj):
        # Can also return: `obj.poly`, and `obj.poly.centroid`.
        return obj.poly.extent  # tuple like: (X0, Y0, X1, Y1).
item_geometry(item)Link to this definition

将此设置为返回 feed 中每个 item 的几何形状。这可以是一个 GEOSGeometry 实例,或者是表示点坐标或边界框的元组。例如:

Code
class ZipcodeFeed(Feed):
    def item_geometry(self, obj):
        # Returns the polygon.
        return obj.poly

SyndicationFeed 子类Link to this heading

以下是可用的 django.utils.feedgenerator.SyndicationFeed 子类:

class GeoRSSFeedLink to this definition
class GeoAtom1FeedLink to this definition
class W3CGeoFeedLink to this definition