GetCenter() public static method

Calculates the longitude and latitude of the projection center for an array of points on the ellipsoid.
public static GetCenter ( IEnumerable points, double &centerLat, double &centerLon ) : void
points IEnumerable An array of points on the ellipsoid
centerLat double The output value of latitude
centerLon double The output value of the longitude
return void
示例#1
0
        /// <summary>
        /// Calculates the center of mass of points.
        /// Calculated as the point on the surface of the ellipsoid, which "points to"
        /// a vector, which is the sum of the vectors coming from the center of the
        /// ellipsoid to each of the points.
        /// </summary>
        /// <remarks>
        /// Masses of points are set equal.
        /// </remarks>
        public static GeoPoint GetPointsCentroid(IEnumerable <GeoPoint> points)
        {
            double latitude  = 0;
            double longitude = 0;

            GnomonicProjection.GetCenter(points, out latitude, out longitude);
            return(new GeoPoint(latitude, longitude));
        }
示例#2
0
        /// <summary>
        /// Calculates gnomonic projection for geometric shapes on the surface of the ellipsoid.
        /// </summary>
        /// <param name="collection">Collection of geometric shapes on the surface of the ellipsoid</param>
        /// <returns>Gnomonic projection</returns>
        public static GnomonicProjection GetProjection(GeographyCollection collection)
        {
            List <GeoPoint> points = new List <GeoPoint>();

            foreach (IGeography g in collection)
            {
                GeoPoint[] pts = g.ExtractPoints();
                foreach (GeoPoint p in pts)
                {
                    points.Add(p);
                }
            }
            double centerLat = 0;
            double centerLon = 0;

            GnomonicProjection.GetCenter(points, out centerLat, out centerLon);
            return(new GnomonicProjection(centerLon, centerLat));
        }
示例#3
0
        private static void projectGeography(IGeography geography, out GnomonicProjection projection, out IGeometry geometry)
        {
            GeographyCollection geographyCollection = new GeographyCollection();

            geographyCollection.Add(geography);

            double centerLatitude, centerLongitude;

            GnomonicProjection.GetCenter(geography.ExtractPoints(), out centerLatitude, out centerLongitude);
            projection = new GnomonicProjection(centerLongitude, centerLatitude);

            GeometryCollection geometryCollection = GeometrySpreader.GetGeometries(geographyCollection, projection);

            if (geometryCollection.Count > 0)
            {
                geometry = geometryCollection[0];
            }
            else
            {
                geometry = null;
            }
        }