geodjango有自己的 Feed
子类,可以将位置信息嵌入根据 `Simple GeoRSS`_ 或 W3C Geo 标准。因为geodjango的联合API是django的超集,请参考 Django's syndication documentation 有关一般用法的详细信息。
Feed
子类¶除了 django.contrib.syndication.views.Feed
基班,杰德扬戈 Feed
类提供以下重写。请注意,这些覆盖可以通过多种方式执行:
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): ...
获取返回的对象 get_object()
并返回 饲料 几何学。通常这是一个 GEOSGeometry
实例,或者可以是表示点或框的元组。例如::
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 在饲料中。这可以是 GEOSGeometry
实例或表示点坐标或边界框的元组。例如::
class ZipcodeFeed(Feed):
def item_geometry(self, obj):
# Returns the polygon.
return obj.poly
7月 22, 2024