昆士兰丛林火灾警报feed的georss客户端库。
georss-qld-bushfire-alert-client的Python项目详细描述
python georss qld bushfire警报客户端
这个库提供了对Queensland Bushfire Alert Feed的方便访问。
安装
pip install georss-qld-bushfire-alert-client
用法
有关如何使用此库的示例,请参见下文。实例化后
feed类并提供所需的参数,您可以调用update
检索提要数据。返回值将是状态代码的元组,并且
以特定提要条目列表形式显示的实际数据。
状态代码
- update_ok:更新进行得很顺利,并检索到数据。库可能仍然返回空数据,例如,因为没有符合筛选条件的条目。
- update_ok_no_data:更新正常,但未检索到数据,例如,服务器指示自上次请求以来没有更新。
- update_error:更新过程中出错
支持的筛选器
Filter | Description | |
---|---|---|
Radius | ^{ | Radius in kilometers around the home coordinates in which events from the feed are included. |
Categories | ^{ | Array of category names. Only events with a category matching any of these are included. |
示例
fromgeorss_qld_bushfire_alert_clientimportQldBushfireAlertFeed# Home Coordinates: Latitude: -27.5, Longitude: 153.0# Filter radius: 50 km# Filter categories: 'Advice'feed=QldBushfireAlertFeed((-27.5,153.0),filter_radius=50,filter_categories=['Advice'])status,entries=feed.update()
馈送条目属性
每个feed条目都填充了以下属性- 乔治斯订阅源中的可用性:
Name | Description |
---|---|
geometry | All geometry details of this entry. |
coordinates | Best coordinates (latitude, longitude) of this entry. |
external_id | External id of this entry. |
title | Title of this entry with textual description of location. |
category | Category of this entry. |
attribution | Attribution from feed. |
distance_to_home | Distance in km of this entry to the home coordinates. |
description | Full content of this entry. |
published | Published date of this entry. |
updated | Updated date of this entry. |
status | Status of alert, e.g. "Patrolled", "Going", "Contained" |
饲料管理器
feed管理器通过通知 feed的使用者关于新的feed条目、更新和删除的条目 与上次源更新相比。
- 如果当前的feed更新是第一个,那么所有feed条目都将是 报告为新的。提要管理器将跟踪所有提要条目' 已成功处理的外部ID。
- 如果当前的feed更新不是第一次更新,那么feed管理器将
生产三套:
- 不在上一个提要更新中但在 当前源更新将报告为新的。
- 在上一个提要更新中仍在 当前源更新将报告为待更新。
- 在上一个提要更新中但不在 当前源更新将被报告为已删除。
- 如果当前更新失败,则前一个更新中处理的所有feed条目 将报告要删除源更新。
从feed成功更新后,feed管理器将提供两个 不同日期:
last_update
将是 喂。如果此库的用户希望 以不同的方式处理源更新中的间歇性错误。last_timestamp
将是从feed数据中提取的最新时间戳。 这要求底层的feed数据实际上包含一个合适的 日期。如果此库的用户希望 如果feed条目没有实际更新,则处理方式会有所不同。