如何计算openweathermap.org JSON中返回的摄氏温度? [英] How do I calculate the temperature in celsius returned in openweathermap.org JSON?

查看:404
本文介绍了如何计算openweathermap.org JSON中返回的摄氏温度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm getting the weather for a city using openweathermap.org.

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

The jsonp call is working and everything is fine but the resulting object contains the temperature in an unknown unit:

{
    //...
    "main": {
        "temp": 290.38, // What unit of measurement is this?
        "pressure": 1005,
        "humidity": 72,
        "temp_min": 289.25,
        "temp_max": 291.85
    },
    //...
}

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

Here is a demo that console.log's the full object.

我不认为最终的温度是华氏温度,因为将290.38华氏温度转换为摄氏温度是143.544.

I don't think the resulting temperature is in fahrenheit because converting 290.38 fahrenheit to celsius is 143.544.

有人知道openweathermap返回的温度单位吗?

Does anyone know what temperature unit openweathermap is returning?

推荐答案

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

It looks like kelvin. Converting kelvin to celsius is easy: Just subtract 273.15.

最简短的浏览(位于 API文档)告诉我们,如果添加&units=metric根据您的要求,您将返回摄氏温度.

And the briefest glance at the API documentation tells us that if you add &units=metric to your request, you'll get back celsius.

这篇关于如何计算openweathermap.org JSON中返回的摄氏温度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆