用于geonet nz quakes feed的异步geojson客户端库。

aio-geojson-geonetnz-quakes的Python项目详细描述


python aio geojson geonetnz地震

Build StatusCoverage StatusPyPiVersion

此库可方便地异步访问 GeoNet NZ Quakes馈送。

安装

pip install aio-geojson-geonetnz-quakes

用法

有关如何使用此库的示例,请参见下文。在实例化 特定的类-feed或feed管理器-并提供所需的参数, 您可以调用update来检索提要数据。返回值 将是状态代码和实际数据的元组,形式为 特定于选定源的源条目。

状态代码

  • ok:更新进行得很顺利,数据被检索到。图书馆可能仍然 返回空数据,例如因为没有满足筛选条件的条目 标准。
  • ok_no_data:更新正常,但未检索到数据,例如 因为服务器指示自上次请求以来没有更新。
  • error:更新过程中出错

参数

ParameterDescription
^{}Coordinates (tuple of latitude/longitude)
^{}Request quakes that may have caused shaking greater than or equal to the MMI value in the New Zealand region. Allowable values are -1..8 inclusive. Default: -1 is used for quakes that are too small to calculate a stable MMI value for.

支持的筛选器

FilterDescription
Radius^{}Radius in kilometers around the home coordinates in which events from feed are included.
Minimum Magnitude^{}Minimum magnitude as float value. Only events with a magnitude equal or above this value are included.
Time^{}Time interval; only events with a reported origin time that falls within now and this past time interval are included.

示例

importasynciofromaiohttpimportClientSessionfromaio_geojson_geonetnz_quakesimportGeonetnzQuakesFeedasyncdefmain()->None:asyncwithClientSession()aswebsession:# Home Coordinates: Latitude: -41.2, Longitude: 174.7# MMI: 2# Filter radius: 200 km# Filter minimum magnitude: 2.5feed=GeonetnzQuakesFeed(websession,(-41.2,174.7),mmi=2,filter_radius=200,filter_minimum_magnitude=2.5)status,entries=awaitfeed.update()print(status)print(entries)asyncio.get_event_loop().run_until_complete(main())

馈送条目属性

每个提要条目都填充有以下属性:

NameDescriptionFeed attribute
geometryAll geometry details of this entry.^{}
coordinatesBest coordinates (latitude, longitude) of this entry.^{}
external_idThe unique public identifier for this quake.^{}
titleTitle of this entry.^{}
attributionAttribution of the feed.n/a
distance_to_homeDistance in km of this entry to the home coordinates.n/a
timeThe origin time of the quake.^{}
depthThe depth of the quake in km.^{}
magnitudeThe summary magnitude for the quake.^{}
localityDistance and direction to the nearest locality.^{}
mmiThe calculated MMI shaking at the closest locality in the New Zealand region.^{}
qualityThe quality of this information: best, good, caution, deleted.^{}

饲料管理器

feed管理器通过通知 feed的使用者关于新的feed条目、更新和删除的条目 与上次源更新相比。

  • 如果当前的feed更新是第一个,那么所有feed条目都将是 报告为新的。提要管理器将跟踪所有提要条目' 已成功处理的外部ID。
  • 如果当前的feed更新不是第一次更新,那么feed管理器将 生产三套:
    • 不在上一个提要更新中但在 当前源更新将报告为新的。
    • 在上一个提要更新中仍在 当前源更新将报告为待更新。
    • 在上一个提要更新中但不在 当前源更新将被报告为已删除。
  • 如果当前更新失败,则前一个更新中处理的所有feed条目 将报告要删除源更新。

从feed成功更新后,feed管理器提供了两个 不同日期:

  • last_update将是 饲料如果此库的用户希望 以不同的方式处理源更新中的间歇性错误。
  • last_timestamp(可选,取决于提要数据)将是最新的 从feed数据中提取的时间戳。 这要求底层的feed数据实际上包含一个合适的 日期。如果此库的用户希望 如果feed条目没有实际更新,则处理方式会有所不同。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java应用程序不是在Eclipse中运行,而是在命令行中运行   swing Java图形组件问题。似乎找不到错误   我需要键盘。close();让代码正常工作?   Springboot中的java HttpSession   抽象语法树我想添加一个语句。我试图解析它,java解析器异常被抛出。如何克服它?   java Hibernate:清理会话   具有不连续子集的java划分问题   java正则表达式查找最后一个冒号后的字符串   java从SpringShell执行OS命令   Java扫描器字符串输入   java字符串索引越界异常(charAt)   java执行器服务终止被卡住   Springockito没有继承java@ContextConfiguration   java如何为一个servlet映射多个url   java安卓获取命令的stderr   java生成类型。表:数据库中的大数字   安卓 Getter Setter返回NothingJava