Пример #1
0
        } // End Operator !=

        public override bool Equals(object obj)
        {
            if (!object.ReferenceEquals(typeof(Wgs84Coordinates), obj.GetType()))
            {
                return(false);
            }

            Wgs84Coordinates wgsObj = (Wgs84Coordinates)obj;

            return(this == wgsObj);
        }
Пример #2
0
        public static bool IsClockwise(System.Collections.Generic.List <Wgs84Coordinates> poly)
        {
            decimal sum = 0;

            for (int i = 0; i < poly.Count - 1; i++)
            {
                Wgs84Coordinates cur = poly[i], next = poly[i + 1];
                sum += (next.Latitude - cur.Latitude) * (next.Longitude + cur.Longitude);
            } // Next i

            return(sum > 0);
        } // End Function isClockwise
Пример #3
0
        } // End Function FromWgs84

        public static Wgs84Coordinates ToWgs84(double x, double y) //, int z)
        {
            Wgs84Coordinates coord = new Wgs84Coordinates();

            // coord.ZoomLevel = z;

            // coord.Longitude = (decimal)(x / System.Math.Pow(2, z) * 360 - 180);
            coord.Longitude = (decimal)x * 360.0M - 180.0M;

            //double n = System.Math.PI - 2 * System.Math.PI * y / System.Math.Pow(2, z);
            double n = System.Math.PI - 2 * System.Math.PI * y;

            coord.Latitude = (decimal)(180.0 / System.Math.PI * System.Math.Atan(0.5 *
                                                                                 (System.Math.Exp(n) - System.Math.Exp(-n))
                                                                                 ))
            ;

            return(coord);
        } // End Function ToWgs84
Пример #4
0
        } // End Function ToWgs84

        public static GeoAPI.Geometries.Coordinate FromWgs84(this Wgs84Coordinates coords) //, int zoom)
        {
            return(FromWgs84(coords.Latitude, coords.Longitude)); //, int zoom)
        } // End Function FromWgs84