用于GDACS提要的异步GeoRSS客户端库。
aio-georss-gdacs的Python项目详细描述
python aio georss gdacs
此库提供对Global Disaster Alert and Coordination System (GDACS)提要的方便异步访问。在
安装
pip install aio-georss-gdacs
使用
有关如何使用此库的示例,请参见下文。在实例化
特定的类-feed或feed manager-并提供所需的参数,
您可以调用update
来检索提要数据。返回值
将是状态代码的元组和实际数据的列表形式
特定于选定源的源条目。在
状态代码
- OK:更新进行得很好,数据被检索到。图书馆可能还会 返回空数据,例如,因为没有条目满足筛选条件 标准。在
- OK_NO_DATA:更新进行得很好,但是没有检索到任何数据 因为服务器指示自上次请求后没有更新。在
- ERROR:更新过程中出错
参数
Parameter | Description |
---|---|
^{ | Coordinates (tuple of latitude/longitude) |
支持的筛选器
^{tb2}$示例
importasynciofromaiohttpimportClientSessionfromaio_georss_gdacsimportGdacsFeedasyncdefmain()->None:asyncwithClientSession()aswebsession:# Home Coordinates: Latitude: -33.0, Longitude: 150.0# Filter radius: 500 kmfeed=GdacsFeed(websession,(-33.0,150.0),filter_radius=500)status,entries=awaitfeed.update()print(status)print(entries)asyncio.get_event_loop().run_until_complete(main())
源条目属性
每个提要条目都填充以下属性:
Name | Description | Feed attribute |
---|---|---|
geometries | All geometry details of this entry (except bounding boxes). | ^{ |
coordinates | Best coordinates (latitude, longitude) of this entry. | ^{ |
external_id | The unique public identifier for this incident. | ^{ |
title | Title of this entry. | ^{ |
attribution | Attribution of the feed. | n/a |
distance_to_home | Distance in km of this entry to the home coordinates. | n/a |
category | The alert level of the incident. | ^{ |
description | The description of the incident. | ^{ |
alert_level | Alert level ("Red", "Orange", "Green"). | ^{ |
country | Country where incident happened. | ^{ |
duration_in_week | Duration of the incident in full weeks. | ^{ |
event_id | Event ID (numerical). | ^{ |
event_name | Short event name. | ^{ |
event_type_short | Short event type ("DR, "EQ", "FL", "TC", "TS", "VO"). | ^{ |
event_type | Long event type ("Drought", "Earthquake", "Flood", "Tropical Cyclone", "Tsunami", "Volcano"). | ^{ |
from_date | Date and time this incident started. | ^{ |
icon_url | Icon URL. | ^{ |
is_current | Whether this incident is current. | ^{ |
population | Exposed population. | ^{ |
severity | Severity of the incident. | ^{ |
temporary | Whether this incident is temporary. | ^{ |
to_date | Date and time this incident ended. | ^{ |
version | Version of the incident in this feed. | ^{ |
vulnerability | Vulnerability score (textual or numerical). | ^{ |
订阅源管理器
Feed管理器通过通知 关于新的提要条目、更新和删除条目的提要的使用者 与上次更新源相比。在
- 如果当前提要更新是第一次更新,那么所有提要条目都将 报告为新的。feed manager将跟踪所有feed条目' 已成功处理的外部ID。在
- 如果当前提要更新不是第一次更新,那么提要管理器将
生产三套:
- 不在上一个源更新中但位于 当前源更新将报告为新的。在
- 在上一个源更新中,但仍在 当前订阅源更新将被报告为要更新。在
- 在上一个源更新中但不在 当前源更新将被报告删除。在
- 如果当前更新失败,则上一次更新中处理的所有提要条目 将报告要删除源更新。在
从提要成功更新后,提要管理器提供两个 不同日期:
last_update
将是提要上一次更新的时间戳 不管成功与否。在last_update_successful
将是上次成功更新的时间戳 从饲料。如果此库的用户需要,此日期可能有用 以不同的方式处理来自feed更新的间歇性错误。在last_timestamp
(可选,取决于提要数据)将是最新的 从提要数据中提取的时间戳。 这要求底层feed数据实际上包含一个合适的 日期。如果此库的用户希望,此日期可能有用 如果feed条目实际上没有被更新,则对它们进行不同的处理。在
- 项目
标签: