Calculation of sunrise time does not match Google result

I'm not sure if this is really related to Android, but since I'm going to use it for an Android application, I put Android too.

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

I tried to follow, but everything gives a slightly different sunrise time, where I provide it (from Bangalore, India), and when I search google with the keyword Bangalore Sunrise , Google gives a different result in a card that looks more accurate:

Everyone gives different results, and yet Google looks more neat.

Does anyone know about the API or is it better computed? Or the algorithm / web service that Google uses for its maps?

Any help is greatly appreciated.

+6
source share
3 answers

Indian Standard Time is UTC + 05: 30, which is probably why you see a difference of 30 minutes.

The algorithm can calculate sunrise times in UTC, but it will not be able to convert UTC to local time, which requires complicated knowledge of the time zone. The algorithm probably does something very simplified, like

 localTime = utcTime + 1_hour * longitude / 15_degree 

which is 5 hours for the city of Banglor.

You must use UTC time and then convert it to local time using the date date API.

+2
source

A quick search will lead me to this api

http://www.earthtools.org/webservices.htm#sun

0
source

I did not study all the links that you gave, but most likely the differences are related to various assumptions and definitions. In particular, the following factors tend to vary from algorithm to algorithm:

  • Atmospheric refraction is on or off (i.e., “true” or “apparent” altitude)
  • The "top" or "center" of the sun horizon

There are, of course, other factors, and the problem is becoming more and more uncertain as latitude extends farther from the equator. But only these factors can explain the minutes of the difference.

0
source

All Articles