Exemple #1
0
        public static int GetTimezoneOffsetFromLocationAndDateInSeconds(long timestamp, int latitude, int longitude)
        {
            var           timezone = TimeZoneLookup.GetTimeZone(FixedPointCoordConversion.ToDouble(latitude), FixedPointCoordConversion.ToDouble(longitude));
            Instant       instant  = new Instant(timestamp * 1000);
            ZonedDateTime zdt      = instant.InZone(DateTimeZoneProviders.Tzdb[timezone.Result]);

            return(zdt.Offset.Milliseconds / 1000);
        }
Exemple #2
0
        /// <summary>
        /// Calculate the distance between two coords (expressed as fixed-point values)
        /// </summary>
        /// <param name="lat1"></param>
        /// <param name="lon1"></param>
        /// <param name="lat2"></param>
        /// <param name="lon2"></param>
        /// <returns>Distance in meters, expressed as a fixed-point value</returns>
        public static int Measure(int lat1, int lon1, int lat2, int lon2) //with fixed-point coversion
        {
            var floatingPointResult = Measure(
                FixedPointCoordConversion.ToDouble(lat1),
                FixedPointCoordConversion.ToDouble(lon1),
                FixedPointCoordConversion.ToDouble(lat2),
                FixedPointCoordConversion.ToDouble(lon2)
                );

            return(FixedPointCoordConversion.ToInt(floatingPointResult));
        }