用于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找不到当前线程的会话   同步Java同步方法调用非同步方法   这段代码的java时间复杂度是如何列出一个集合的所有子集的?   java Jetty SslConnectionFactory nextProtocol   为什么在java集合中使用游标而不是for循环   java如何对长函数进行单元测试?   如何从java中的文本输入创建数组   java工具栏内容未显示,尽管出现了片段内容   java MediaPlayer无法处理本地文件   java在多次读取时,从TCP服务器读取的数据将挂起   java组织。springframework。数据领域无法将PageImpl强制转换为   java如何使用@WithMockUser并从属性文件中传递用户名和密码?   JavaSpringBootGradle插件2。x如何使用自定义启动器布局工厂   sockets Java客户端和服务器之间使用字符串等进行通信的“行业标准”方法是什么   java变量引用不存在的资源:${project\u loc:project\u name}   搜索如何返回LDAP Java中所有用户的特定属性?   JDK1.8.016x的java密钥斗篷代理问题   spring如何使用Java中的Exchange获取邮件   java Kotlin+Dagger 2:Dagger*文件不会生成   如何在传入的double上执行操作,然后在Java中返回