如何计算openweathermap.org JSON中返回的摄氏温度?

hit*_*uct 38 javascript json units-of-measurement weather-api openweathermap

我正在使用openweathermap.org获取城市的天气.

jsonp调用正在运行,一切正常,但生成的对象包含未知单位的温度:

{
    //...
    "main": {
        "temp": 290.38, // What unit of measurement is this?
        "pressure": 1005,
        "humidity": 72,
        "temp_min": 289.25,
        "temp_max": 291.85
    },
    //...
}
Run Code Online (Sandbox Code Playgroud)

这是一个console.log完整对象的演示.

我不认为由此产生的温度是华氏温度,因为将290.38华氏温度转换为摄氏温度143.544.

有谁知道openweathermap返回的温度单位是​​多少?

T.J*_*der 108

它看起来像开尔文.将开尔文转换为摄氏温度很容易:只需减去273.15.

简短的一瞥,在API文档告诉我们,如果你添加&units=metric到你的要求,你会回来摄氏度.

  • @hitautodestruct:这是*me*,但是,那时,我不是科学家.:-) (4认同)
  • Kelvin(http://en.wikipedia.org/wiki/Kelvin)是"国际单位制"的温度单位.它是绝对的,基于物理学.零是"绝对零".对我而言,它看起来是一个非常自然的"默认"选择...... (4认同)
  • 我的英雄来了。边走边看他。甚至没有看到 &units 文档。 (2认同)

Sar*_*ara 5

开尔文换算华氏度为:

(( kelvinValue - 273.15) * 9/5) + 32
Run Code Online (Sandbox Code Playgroud)

我注意到并非所有 OpenWeatherApp 调用都会读取传入的单位参数。(此错误的示例: http://api.openweathermap.org/data/2.5/group?units=Imperial&id=5375480,4737316, 4164138,5099133,4666102,5391811,5809844,5016108,4400860,4957280&appid=XXXXXX ) 开尔文仍然返回。