GeoLocation constructor with parameters for all required fields.
The location name for display use such as "Lakewood, NJ"
the latitude in a double format such as 40.095965 for Lakewood, NJ. Note: For latitudes south of the equator, a negative value should be used.
double the longitude in a double format such as -74.222130 for Lakewood, NJ. Note: For longitudes west of the Prime Meridian (Greenwich), a negative value should be used.
the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating sunrise and set.
the TimeZone for the location.
ProtectedelevationProtectedlatitudeProtectedlocationProtectedlongitudeProtectedtimeAdjust the date for antimeridian crossover. This is needed to deal with edge cases such as Samoa that use a different calendar date than expected based on their geographic location.
The actual Time Zone offset may deviate from the expected offset based on the longitude. Since the 'absolute time' calculations are always based on longitudinal offset from UTC for a given date, the date is presumed to only increase East of the Prime Meridian, and to only decrease West of it. For Time Zones that cross the antimeridian, the date will be artificially adjusted before calculation to conform with this presumption.
For example, Apia, Samoa with a longitude of -171.75 uses a local offset of +14:00. When calculating sunrise for 2018-02-03, the calculator should operate using 2018-02-02 since the expected zone is -11. After determining the UTC time, the local DST offset of UTC+14:00 should be applied to bring the date back to 2018-02-03.
the date, at the start of which (in this location's time zone) the offset is read
the number of days to adjust the date This will typically be 0 unless the date crosses the antimeridian
Method to get the elevation in Meters.
Returns the elevation in Meters.
Returns the latitude.
A method that will return the location's local mean time offset in milliseconds from local standard time. The globe is split into 360°, with 15° per hour of the day. For a local that is at a longitude that is evenly divisible by 15 (longitude % 15 == 0), at solar noon (with adjustment for the equation of time) the sun should be directly overhead, so a user who is 1° west of this will have noon at 4 minutes after standard time noon, and conversely, a user who is 1° east of the 15° longitude will have noon at 11:56 AM.
the instant at which to read the time zone offset (DST is taken into account)
the offset in milliseconds not accounting for Daylight saving time. A positive value will be returned East of the 15° timezone line, and a negative value West of it.
Returns the location name.
Returns the longitude.
Returns the timeZone.
Method to set the elevation in Meters above sea level.
The elevation to set in Meters. An Error will be thrown if the value is a negative.
The setter method for the display name.
Method to set the TimeZone.
The timeZone to set.
A class that contains location information such as latitude and longitude required for astronomical calculations. The elevation field may not be used by some calculation engines and would be ignored if set.
Author
© Eliyahu Hershfeld 2004 - 2016
Version
1.1