日出时间计算不符合谷歌的结果不符合、日出、结果、时间

2023-09-11 23:03:44 作者:生物书毁了我的单纯i

我不知道它是否真的涉及到Android,但由于我要使用它的Andr​​oid应用程序,我标注的Andr​​oid了。

I am not sure if it really is related to Android, but since I am going to use it for an Android app, I am tagging Android too.

我想建立一些逻辑来计算日出时间,如果LAT-长给出。

I am trying to build some logic to calculate sunrise time if lat-long are given.

我试过以下,但一切都使我为它提供(,班加罗尔印度),以及位置的日出稍有不同的时候,我对谷歌搜索的关键字班加罗尔日出谷歌给出了不同的结果看起来更准确的卡:

I've tried following, but everything gives a slightly different time of the Sunrise of the location I provide it with (of Bangalore, India), and when I search for google with the keyword Bangalore Sunrise Google gives a different result in the card which looks more accurate:

在试图移植这款C code到Java:http://souptonuts.sourceforge.net/$c$c/sunrise.c.html 在使用这个公式维基百科尝试:http://en.wikipedia.org/wiki/Sunrise_equation 在使用这个库的尝试:https://github.com/mikereedell/sunrisesunsetlib-java 在使用本网站服务尝试:http://www.earthtools.org/webservices.htm#sun Tried porting this C code to Java : http://souptonuts.sourceforge.net/code/sunrise.c.html Tried using this formula from WikiPedia: http://en.wikipedia.org/wiki/Sunrise_equation Tried using this library : https://github.com/mikereedell/sunrisesunsetlib-java Tried using this Web Service : http://www.earthtools.org/webservices.htm#sun

都给予不同的结果,并且仍然谷歌的容貌更加都很精确。

All give different results, and still Google's looks to be more acccurate.

有谁知道这里的​​API或这更好的计算?或算法/ web服务,谷歌正在使用他们的卡?

Does anybody here know of an API or a better calculation for this? Or the algorithm/webservice that Google is using for their cards?

任何帮助是非常AP preciated。

Any help is much appreciated.

推荐答案

印度标准时间为UTC + 05:30,这可能是为什么你看到一个30分钟的差异

Indian standard time is UTC+05:30, that's probably why you are seeing a 30 min difference.

该算法可以计算日出UTC时间,但它不能与UTC转换为本地时间,这需要复杂的时区的知识。该算法大概做了非常简单的,像

The algorithm can calculate sunrise time in UTC, but it won't be able to convert UTC to local time, which requires complicated timezone knowledge. The algorithm probably does something very simplistic, like

localTime = utcTime + 1_hour * longitude / 15_degree

这是5小时城市班加罗尔的。

which is 5 hours for city of Banglore.

您应该采取的UTC时间,然后通过使用Java API的日期转换为本地时间。

You should take the UTC time, then convert it to local time by using Java date APIs.