Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculation based on altitude #12

Open
digitalummah opened this issue Jun 8, 2020 · 11 comments
Open

Calculation based on altitude #12

digitalummah opened this issue Jun 8, 2020 · 11 comments

Comments

@digitalummah
Copy link

Is altitude / elevation a parameter in calculating the prayer times?

@z3bi
Copy link
Contributor

z3bi commented Jun 8, 2020

This library does not use altitude for calculations. Altitude is tricky as it only has an effect when the altitude of the observer differs from the altitude of the horizon, for example being on mountain peak. But if the city you live in has a high altitude in all locations it has no effect.

Here is a good explanation of the apparent effects of altitude on sunrise https://astronomy.stackexchange.com/questions/24632/how-do-i-adjust-the-sunrise-equation-to-account-for-elevation

I think knowing the difference in altitude between the observer and the horizon is going to be extremely difficult for any application to know.

@digitalummah
Copy link
Author

This makes sense - thanks for the swift response!

@Abu-Abdullah
Copy link

Alsalam Alikom,

@z3bi , i beleive it might be good to have Altitude as an option to adjust the calculation. people who is in high rise towers differes in maghrib and fajr by 2 minites. for such reason, i knew that Awqaf in some cities start put their calculations to have Altitude of around 200 feets (not sure from sea level, elevation or from city land level). this result in maybe few seconds (or a minute) from the normal caluclation.

another point is the mountain as you mentioned. third one is when you are in airplane. it might be good option for those who enable your library in their phone app to get the altitude from their phone GPS.

@z3bi
Copy link
Contributor

z3bi commented Jun 28, 2020

@Abu-Abdullah My biggest concern with this is if developers always supply the altitude to the library regardless of the situation. This can cause a big issue in cities like Denver. Even though Denver is at an altitude of 5,000 ft, that altitude is consistent in the whole city so it doesn't affect sunrise/sunset times.

One feature the library needs is a function that recommends calculation parameters given a set of coordinates and city and country. Perhaps there's a good way for that function to identify true needs for altitude adjustment. I'm open to suggestions on how to make that clear in the design of the library's interface.

@Abu-Abdullah
Copy link

i would agree on your point but still this is a library not the final app, there is a responsbility on the developer to understand this feature and develop wht is suitable to make sure that this parameter is correct.

i beleive any suggestion will end up with the need to have internet connection to check the altitude of the city compared to the sea level. i have the following code to get the Altitude:

        // Only for US !!!!
	private double getAltitude(Double longitude, Double latitude)
	{
		double result = Double.NaN;
		final String url = "https://nationalmap.gov/epqs/"
				+ "pqs.php?x=" + longitude
				+ "&y=" + latitude
				+ "&units=Feet&output=xml";

		// Require API key and an account for google maps and 25000 hits limit per day
		String url_google = "https://maps.googleapis.com/maps/api/elevation/"
				+ "xml?locations=" + latitude
				+ "," + longitude
				+ "&sensor=true";

		try
		{
			final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
			final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
			final Document doc = docBuilder.parse(url);

			// normalize text representation
			doc.getDocumentElement().normalize();

			// The results are contained in a single <double> node
			final NodeList listOfDoubles = doc.getElementsByTagName("Elevation");

			if (listOfDoubles.getLength() > 0)
			{
				Node elevationNode = listOfDoubles.item(0);
				Element elevationElement = (Element) elevationNode;
				return Double.parseDouble(elevationElement.getFirstChild().getNodeValue());
			}
		}
		catch (IOException | SAXException | ParserConfigurationException e)
		{
			e.printStackTrace();
		}
		return result;
	}

@Abu-Abdullah
Copy link

this is really an issue in a city like dubai:
https://www.khaleejtimes.com/ramadan-2019/late-iftar-for-burj-khalifa-dubai-skyscraper-residents

@z3bi
Copy link
Contributor

z3bi commented Jun 28, 2020

I would probably not add an external API dependency. Perhaps in the example app we could show an external API being used to get the correct values.

@Abu-Abdullah
Copy link

ok, i meant we just need to understand how to use the api to take into account the altitude variable (not to include external API).

getting the altitude is the responsibility of the developer. even letting the end user himself adjust this value is one way of doing it (with good explanation).

getting an example is more than enough (with thanks)

i believe we need to understand what is the altitude that affects the calculation:

  • from sea level
  • horizon level from sea level
  • from horizon level

@z3bi
Copy link
Contributor

z3bi commented Jun 28, 2020

Yeah and in fact we can be more precise by adjusting sunrise and sunset differently by asking for:

  • altitude of the observer
  • altitude of the Eastern horizon
  • altitude of the Western horizon

This could provide additional accuracy for people living at the base of a mountain range.

@z3bi z3bi reopened this Jun 28, 2020
@z3bi
Copy link
Contributor

z3bi commented Jun 28, 2020

Re-opening this issue as we find a way to offer this functionality in a way that makes it clear how the feature is meant to work and what the limitations are.

@mubasherusman
Copy link

Has this feature been included in the library, or has any guide been added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@z3bi @Abu-Abdullah @mubasherusman @digitalummah and others