“Django/docs/3.0.x/ref/contrib/gis/feeds”的版本间差异
来自菜鸟教程
Django/docs/3.0.x/ref/contrib/gis/feeds
(autoload) |
小 (Page commit) |
||
第1行: | 第1行: | ||
+ | {{DISPLAYTITLE:地理信息源 — Django 文档}} | ||
<div id="module-django.contrib.gis.feeds" class="section"> | <div id="module-django.contrib.gis.feeds" class="section"> | ||
<span id="geographic-feeds"></span> | <span id="geographic-feeds"></span> | ||
− | = | + | = 地理提要 = |
− | GeoDjango | + | GeoDjango 有自己的 [[#django.contrib.gis.feeds.Feed|Feed]] 子类,可以将位置信息嵌入到根据 [http://georss.org/simple.html Simple GeoRSS] 或 [https://www.w3.org/2003/01/geo/ W3C Geo] 标准格式化的 RSS/Atom 提要中。 由于 GeoDjango 的联合 API 是 Django 的超集,请参阅 [[../../syndication|Django 的联合文档]] 了解一般用法的详细信息。 |
− | |||
− | [https://www.w3.org/2003/01/geo/ W3C Geo] | ||
− | Django | ||
<div id="example" class="section"> | <div id="example" class="section"> | ||
− | == | + | == 示例 == |
第17行: | 第15行: | ||
<div id="api-reference" class="section"> | <div id="api-reference" class="section"> | ||
− | == | + | == API 参考 == |
<div id="feed-subclass" class="section"> | <div id="feed-subclass" class="section"> | ||
− | === | + | === Feed 子类 === |
<dl> | <dl> | ||
− | <dt>''class'' < | + | <dt>''<span class="pre">class</span>'' <span class="sig-name descname"><span class="pre">Feed</span></span></dt> |
− | <dd><p> | + | <dd><p>除了 [[../../syndication#django.contrib.syndication.views|django.contrib.syndication.views.Feed]] 基类提供的方法之外,GeoDjango 的 <code>Feed</code> 类提供以下覆盖。 请注意,这些覆盖可以通过多种方式完成:</p> |
− | [[../../syndication#django.contrib.syndication.views| | ||
− | <code>Feed</code> | ||
− | |||
<div class="highlight-default notranslate"> | <div class="highlight-default notranslate"> | ||
<div class="highlight"> | <div class="highlight"> | ||
− | < | + | <syntaxhighlight lang="python">from django.contrib.gis.feeds import Feed |
class MyFeed(Feed): | class MyFeed(Feed): | ||
第53行: | 第48行: | ||
def item_geometry(self, item): | def item_geometry(self, item): | ||
− | ...</ | + | ...</syntaxhighlight> |
</div> | </div> | ||
第59行: | 第54行: | ||
</div> | </div> | ||
<dl> | <dl> | ||
− | <dt>< | + | <dt><span class="sig-name descname"><span class="pre">geometry</span></span><span class="sig-paren">(</span>''<span class="n"><span class="pre">obj</span></span>''<span class="sig-paren">)</span></dt> |
<dd></dd></dl> | <dd></dd></dl> | ||
− | <p> | + | <p>获取由 <code>get_object()</code> 返回的对象并返回 ''馈送的'' 几何体。 通常这是一个 <code>GEOSGeometry</code> 实例,或者可以是一个元组来表示一个点或一个框。 例如:</p> |
− | |||
− | |||
<div class="highlight-default notranslate"> | <div class="highlight-default notranslate"> | ||
<div class="highlight"> | <div class="highlight"> | ||
− | < | + | <syntaxhighlight lang="python">class ZipcodeFeed(Feed): |
def geometry(self, obj): | def geometry(self, obj): | ||
# Can also return: `obj.poly`, and `obj.poly.centroid`. | # Can also return: `obj.poly`, and `obj.poly.centroid`. | ||
− | return obj.poly.extent # tuple like: (X0, Y0, X1, Y1).</ | + | return obj.poly.extent # tuple like: (X0, Y0, X1, Y1).</syntaxhighlight> |
</div> | </div> | ||
第79行: | 第72行: | ||
</div> | </div> | ||
<dl> | <dl> | ||
− | <dt>< | + | <dt><span class="sig-name descname"><span class="pre">item_geometry</span></span><span class="sig-paren">(</span>''<span class="n"><span class="pre">item</span></span>''<span class="sig-paren">)</span></dt> |
<dd></dd></dl> | <dd></dd></dl> | ||
− | <p> | + | <p>设置此项以返回提要中每个 ''项目'' 的几何图形。 这可以是 <code>GEOSGeometry</code> 实例,也可以是表示点坐标或边界框的元组。 例如:</p> |
− | <code>GEOSGeometry</code> | ||
− | |||
<div class="highlight-default notranslate"> | <div class="highlight-default notranslate"> | ||
<div class="highlight"> | <div class="highlight"> | ||
− | < | + | <syntaxhighlight lang="python">class ZipcodeFeed(Feed): |
def item_geometry(self, obj): | def item_geometry(self, obj): | ||
# Returns the polygon. | # Returns the polygon. | ||
− | return obj.poly</ | + | return obj.poly</syntaxhighlight> |
</div> | </div> | ||
第103行: | 第94行: | ||
<div id="syndicationfeed-subclasses" class="section"> | <div id="syndicationfeed-subclasses" class="section"> | ||
− | === | + | === SyndicationFeed 子类 === |
− | + | 以下 [[../../../utils#django.utils.feedgenerator|django.utils.feedgenerator.SyndicationFeed]] 子类可用: | |
− | |||
− | ; ''class'' < | + | ; ''<span class="pre">class</span>'' <span class="sig-name descname"><span class="pre">GeoRSSFeed</span></span> |
: | : | ||
− | ; ''class'' < | + | ; ''<span class="pre">class</span>'' <span class="sig-name descname"><span class="pre">GeoAtom1Feed</span></span> |
: | : | ||
− | ; ''class'' < | + | ; ''<span class="pre">class</span>'' <span class="sig-name descname"><span class="pre">W3CGeoFeed</span></span> |
: | : | ||
<div class="admonition note"> | <div class="admonition note"> | ||
− | + | 笔记 | |
− | [https://www.w3.org/2003/01/geo/ W3C Geo] | + | [https://www.w3.org/2003/01/geo/ W3C Geo] 格式的提要仅支持 [[../model-api#django.contrib.gis.db.models|PointField]] 几何图形。 |
− | [[../model-api#django.contrib.gis.db.models| | ||
第132行: | 第121行: | ||
</div> | </div> | ||
+ | <div class="clearer"> | ||
− | [[Category:Django 3.0.x | + | |
+ | |||
+ | </div> | ||
+ | |||
+ | [[Category:Django 3.0.x 文档]] |
2021年10月31日 (日) 04:09的最新版本
地理提要
GeoDjango 有自己的 Feed 子类,可以将位置信息嵌入到根据 Simple GeoRSS 或 W3C Geo 标准格式化的 RSS/Atom 提要中。 由于 GeoDjango 的联合 API 是 Django 的超集,请参阅 Django 的联合文档 了解一般用法的详细信息。
示例
API 参考
Feed 子类
- class Feed
除了 django.contrib.syndication.views.Feed 基类提供的方法之外,GeoDjango 的
Feed
类提供以下覆盖。 请注意,这些覆盖可以通过多种方式完成:- geometry(obj)
获取由
get_object()
返回的对象并返回 馈送的 几何体。 通常这是一个GEOSGeometry
实例,或者可以是一个元组来表示一个点或一个框。 例如:- item_geometry(item)
设置此项以返回提要中每个 项目 的几何图形。 这可以是
GEOSGeometry
实例,也可以是表示点坐标或边界框的元组。 例如: