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.
Feed¶Sebagai tambahan pada metode disediakan oleh kelas dasar django.contrib.syndication.views.Feed, kelas Feed GeoDjango menyediakan penimpaan berikut. Catat bahwa penimpaan ini mungkin dilakukan dalam banyak cara:
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): ...
Ambil obyek dikembalikan oleh get_object() dan mengembalikan geometri feed. Khususnya ini adalah instance GEOSGeometry, atau dapat berupa sebuah tuple untuk mewakili titik atau sebuah kotak. Sebagai contoh:
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).
Setel ini untuk mengembalikan geometri untuk setiap item dalam umpan. Ini dapat berupa instance GEOSGeometry, atau tuple yang mewakili titik kordinat atau kotak batasan. Sebagai contoh:
class ZipcodeFeed(Feed):
def item_geometry(self, obj):
# Returns the polygon.
return obj.poly
Des 03, 2025