gpt4 book ai didi

ios - 国家气象局 (NOAA) REST API 为预报参数返回 nil

转载 作者:可可西里 更新时间:2023-11-01 05:46:10 26 4
gpt4 key购买 nike

我正在使用 NWS REST API 作为我正在制作的应用程序的天气服务。最初我不太愿意使用 NWS,因为它的文档不好,但我无法抗拒,因为它是完全免费提供的。

现在我正在尝试使用它,但遇到了一些困难。请求多天时,最低温度连续几天显示为零。

(编辑:随着我对 API 的更多测试,我发现它并不总是最低温度为零。它可能是最高温度或降水量,它似乎完全是随机的。如果你想使用他们的网络界面测试调用,你可以在这里这样做:http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdBrowserByDay.htm

这里:http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXML.htm )

这是一个最低温度为空的请求示例:http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?listLatLon=40.863235,-73.714780&format=24%20hourly&numDays=7

令人惊讶的是,在他们的网站上,最低温度是可用的: http://forecast.weather.gov/MapClick.php?textField1=40.83&textField2=-73.70

您会在最低温度下看到大约 5 个(有时更少,不一致)空白字段,上面写着 <value xsi:nil="true"/>

如果有人能帮助我,我将不胜感激,使用 NWS API 有时会让人不知所措。

谢谢,

最佳答案

nil 值,根据我对文档的理解,herehere , 仅表示数据不可用。

在不对 NOAA 的数据架构做出假设的情况下,可以想象通过 API 提供的信息可能与其网站显示的不同。

Missing values are represented by an empty element and xsi:nil=”true” (R2.2.1).

返回的 Nil 值似乎涉及时间段。注意 time-layout 之间的区别1 中的 key (参见第 5.3.2 节)在这些请求中:

数据时间不同。

<layout-key> element

The key is derived using the following convention:

  1. “k” stands for key.
  2. “p24h” implies a data period length of 24 hours.
  3. “n7” means that the number of data times is 7.
  4. “1” is a sequential number used to keep the layout keys unique.

在这里,startDate是因素。将其关闭需要更多时间,并且可能会导致一些请求的数据尚未可用。

根据文档:

The beginning day for which you want NDFD data. If the string is empty, the start date is assumed to be the earliest available day in the database. This input is only needed if one wants to shorten the time window data is to be retrieved for (less than entire 7 days worth), e.g. if user wants data for days 2-5.

我没有遇到您提到的随机性。 NOAA's Yahoo! Groups forum 上的人或许可以告诉您更多信息。

关于ios - 国家气象局 (NOAA) REST API 为预报参数返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12873792/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com