Gnomonic projection. This class, unlike MapAround.CoordinateSystems.Transformations.Gnomonic, is designed for internal use.
Esempio n. 1
0
        private static GeoPoint unprojectPoint(PointD point, GnomonicProjection projection)
        {
            double lat, lon;

            projection.Unproject(point.X, point.Y, out lat, out lon);
            return(new GeoPoint(lon, lat));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
 private static PointD projectPoint(GeoPoint point, GnomonicProjection projection)
 {
     PointD p = point.ToPlanarPoint(false);
     double x, y;
     projection.Project(p.Y, p.X, out x, out y);
     p.X = x;
     p.Y = y;
     return p;
 }
Esempio n. 4
0
        private static PointD projectPoint(GeoPoint point, GnomonicProjection projection)
        {
            PointD p = point.ToPlanarPoint(false);
            double x, y;

            projection.Project(p.Y, p.X, out x, out y);
            p.X = x;
            p.Y = y;
            return(p);
        }
Esempio n. 5
0
        private static GeoMultiPoint unprojectMultiPoint(MultiPoint multiPoint, GnomonicProjection projection)
        {
            GeoMultiPoint geoMultiPoint = new GeoMultiPoint();

            foreach (ICoordinate p in multiPoint.Points)
            {
                geoMultiPoint.Points.Add(unprojectPoint(new PointD(p), projection));
            }

            return(geoMultiPoint);
        }
Esempio n. 6
0
        private static MultiPoint projectMultiPoint(GeoMultiPoint multiPoint, GnomonicProjection projection)
        {
            MultiPoint mp = multiPoint.ToPlanarMultiPoint(false);
            for (int i = 0; i < mp.Points.Count; i++)
            {
                double x, y;
                projection.Project(mp.Points[i].Y, mp.Points[i].X, out x, out y);
                mp.Points[i] = PlanimetryEnvironment.NewCoordinate(x, y);
            }

            return mp;
        }
Esempio n. 7
0
        private static MultiPoint projectMultiPoint(GeoMultiPoint multiPoint, GnomonicProjection projection)
        {
            MultiPoint mp = multiPoint.ToPlanarMultiPoint(false);

            for (int i = 0; i < mp.Points.Count; i++)
            {
                double x, y;
                projection.Project(mp.Points[i].Y, mp.Points[i].X, out x, out y);
                mp.Points[i] = PlanimetryEnvironment.NewCoordinate(x, y);
            }

            return(mp);
        }
Esempio n. 8
0
        private static Polyline projectPolyline(GeoPolyline polyline, GnomonicProjection projection)
        {
            Polyline p = polyline.ToPlanarPolyline(false);
            foreach (LinePath path in p.Paths)
            {
                for (int i = 0; i < path.Vertices.Count; i++)
                {
                    double x, y;
                    projection.Project(path.Vertices[i].Y, path.Vertices[i].X, out x, out y);
                    path.Vertices[i] = PlanimetryEnvironment.NewCoordinate(x, y);
                }
            }

            return p;
        }
        private ICollection <IGeography> calculateOverlay(IGeography geometry1, IGeography geometry2, OverlayType operation, bool p)
        {
            GeographyCollection egc = new GeographyCollection();

            egc.Add(geometry1);
            egc.Add(geometry2);

            GnomonicProjection projection = GeometrySpreader.GetProjection(egc);
            GeometryCollection gc         = GeometrySpreader.GetGeometries(egc, projection);

            OverlayCalculator       oc           = new OverlayCalculator();
            ICollection <IGeometry> planarResult = oc.CalculateOverlay(gc[0], gc[1], operation);

            egc = GeometrySpreader.GetGeographies(planarResult, projection);
            return(egc);
        }
Esempio n. 10
0
        private static Polyline projectPolyline(GeoPolyline polyline, GnomonicProjection projection)
        {
            Polyline p = polyline.ToPlanarPolyline(false);

            foreach (LinePath path in p.Paths)
            {
                for (int i = 0; i < path.Vertices.Count; i++)
                {
                    double x, y;
                    projection.Project(path.Vertices[i].Y, path.Vertices[i].X, out x, out y);
                    path.Vertices[i] = PlanimetryEnvironment.NewCoordinate(x, y);
                }
            }

            return(p);
        }
Esempio n. 11
0
        private static Polygon projectPolygon(GeoPolygon polygon, GnomonicProjection projection)
        {
            Polygon p = polygon.ToPlanarPolygon(false);

            foreach (Contour contour in p.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    double x, y;
                    projection.Project(contour.Vertices[i].Y, contour.Vertices[i].X, out x, out y);
                    contour.Vertices[i] = PlanimetryEnvironment.NewCoordinate(x, y);
                }
            }

            return(p);
        }
Esempio n. 12
0
        private static Polygon getBoundsBuffer(GeoPolygon polygon, GnomonicProjection projection, double distance, int pointsPerCircle, bool allowParallels)
        {
            Polygon temp = new Polygon();

            List <Polygon>          partialBuffers      = new List <Polygon>();
            GeographyCollection     geographyCollection = new GeographyCollection();
            ICollection <IGeometry> unionResult         = null;

            int c = 0;

            foreach (GeoContour contour in polygon.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    GeoPoint p = contour.Vertices[i];

                    GeoPolygon tempPolygon = getPointBuffer(p, Math.Abs(distance), pointsPerCircle);
                    geographyCollection.Clear();
                    geographyCollection.Add(tempPolygon);

                    GeometryCollection gc = GeometrySpreader.GetGeometries(geographyCollection, projection);
                    if (gc[0] is Polygon)
                    {
                        unionResult = temp.Union((Polygon)gc[0]);
                    }
                    if (unionResult.Count > 0)
                    {
                        temp = (Polygon)((GeometryCollection)unionResult)[0];
                    }

                    c++;
                    if (c == 3)
                    {
                        partialBuffers.Add(temp);
                        temp = new Polygon();
                        c    = 0;
                    }
                }
            }

            if (temp.CoordinateCount > 0)
            {
                partialBuffers.Add(temp);
            }

            return(mergePartialBuffers(partialBuffers, allowParallels));
        }
Esempio n. 13
0
        private static GeoPolyline unprojectPolyline(Polyline polyline, GnomonicProjection projection)
        {
            GeoPolyline geoPolyline = new GeoPolyline();

            foreach (LinePath path in polyline.Paths)
            {
                GeoPath geoPath = new GeoPath();
                foreach (ICoordinate p in path.Vertices)
                {
                    geoPath.Vertices.Add(unprojectPoint(new PointD(p), projection));
                }

                geoPolyline.Paths.Add(geoPath);
            }

            return(geoPolyline);
        }
Esempio n. 14
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));
        }
Esempio n. 15
0
        private static GeoPolygon getPointBuffer(GeoPoint point, double angleDistance, int pointsPerCircle)
        {
            if (angleDistance < 0)
                return new GeoPolygon();

            GnomonicProjection projection = new GnomonicProjection(point.L, point.Phi);
            PointD planePoint = new PointD(0, 0);
            Polygon planePolygon = (Polygon)planePoint.Buffer(Math.Tan(angleDistance), pointsPerCircle, false);

            GeometryCollection geometryColllection = new GeometryCollection();
            geometryColllection.Add(planePolygon);
            GeographyCollection gc = GeometrySpreader.GetGeographies(geometryColllection, projection);

            if(gc[0] is GeoPolygon)
                return (GeoPolygon)gc[0];

            return new GeoPolygon();
        }
Esempio n. 16
0
        private static GeoPolygon unprojectPolygon(Polygon polygon, GnomonicProjection projection)
        {
            GeoPolygon geoPolygon = new GeoPolygon();

            foreach (Contour contour in polygon.Contours)
            {
                GeoContour geoContour = new GeoContour();
                geoContour.Layout = contour.Layout;
                foreach (ICoordinate p in contour.Vertices)
                {
                    geoContour.Vertices.Add(unprojectPoint(new PointD(p), projection));
                }

                geoPolygon.Contours.Add(geoContour);
            }

            return(geoPolygon);
        }
Esempio n. 17
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;
            }
        }
Esempio n. 18
0
        private static GeoPolygon getPointBuffer(GeoPoint point, double angleDistance, int pointsPerCircle)
        {
            if (angleDistance < 0)
            {
                return(new GeoPolygon());
            }

            GnomonicProjection projection   = new GnomonicProjection(point.L, point.Phi);
            PointD             planePoint   = new PointD(0, 0);
            Polygon            planePolygon = (Polygon)planePoint.Buffer(Math.Tan(angleDistance), pointsPerCircle, false);

            GeometryCollection geometryColllection = new GeometryCollection();

            geometryColllection.Add(planePolygon);
            GeographyCollection gc = GeometrySpreader.GetGeographies(geometryColllection, projection);

            if (gc[0] is GeoPolygon)
            {
                return((GeoPolygon)gc[0]);
            }

            return(new GeoPolygon());
        }
Esempio n. 19
0
        /// <summary>
        /// Computes a convex hull of the specified points.
        /// </summary>
        /// <param name="points">Enumerator of coordinates for which convex hull should be computed</param>
        /// <returns>A list containing a sequence of the convex hull points</returns>
        public static IList <GeoPoint> GetConvexHull(IEnumerable <GeoPoint> points)
        {
            GeographyCollection geographyCollection = new GeographyCollection();

            foreach (GeoPoint p in points)
            {
                geographyCollection.Add(p);
            }

            GnomonicProjection projection         = GeometrySpreader.GetProjection(geographyCollection);
            GeometryCollection geometryCollection = GeometrySpreader.GetGeometries(geographyCollection, projection);
            List <ICoordinate> list = new List <ICoordinate>();

            foreach (IGeometry g in geometryCollection)
            {
                list.Add(((PointD)g).Coordinate);
            }

            IList <ICoordinate> planarResult = PlanimetryAlgorithms.GetConvexHull(list);

            geometryCollection.Clear();
            foreach (ICoordinate p in planarResult)
            {
                geometryCollection.Add(new PointD(p));
            }

            geographyCollection = GeometrySpreader.GetGeographies(geometryCollection, projection);
            List <GeoPoint> result = new List <GeoPoint>();

            foreach (GeoPoint p in geographyCollection)
            {
                result.Add(p);
            }

            return(result);
        }
Esempio n. 20
0
        private static Polygon getBoundsBuffer(GeoPolygon polygon, GnomonicProjection projection, double distance, int pointsPerCircle, bool allowParallels)
        {
            Polygon temp = new Polygon();

            List<Polygon> partialBuffers = new List<Polygon>();
            GeographyCollection geographyCollection = new GeographyCollection();
            ICollection<IGeometry> unionResult = null;

            int c = 0;
            foreach (GeoContour contour in polygon.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    GeoPoint p = contour.Vertices[i];

                    GeoPolygon tempPolygon = getPointBuffer(p, Math.Abs(distance), pointsPerCircle);
                    geographyCollection.Clear();
                    geographyCollection.Add(tempPolygon);

                    GeometryCollection gc = GeometrySpreader.GetGeometries(geographyCollection, projection);
                    if(gc[0] is Polygon)
                        unionResult = temp.Union((Polygon)gc[0]);
                    if (unionResult.Count > 0)
                        temp = (Polygon)((GeometryCollection)unionResult)[0];

                    c++;
                    if (c == 3)
                    {
                        partialBuffers.Add(temp);
                        temp = new Polygon();
                        c = 0;
                    }
                }
            }

            if (temp.CoordinateCount > 0)
                partialBuffers.Add(temp);

            return mergePartialBuffers(partialBuffers, allowParallels);
        }
Esempio n. 21
0
 private static GeoPoint unprojectPoint(PointD point, GnomonicProjection projection)
 {
     double lat, lon;
     projection.Unproject(point.X, point.Y, out lat, out lon);
     return new GeoPoint(lon, lat);
 }
Esempio n. 22
0
        private static GeoMultiPoint unprojectMultiPoint(MultiPoint multiPoint, GnomonicProjection projection)
        {
            GeoMultiPoint geoMultiPoint = new GeoMultiPoint();
                foreach (ICoordinate p in multiPoint.Points)
                    geoMultiPoint.Points.Add(unprojectPoint(new PointD(p), projection));

            return geoMultiPoint;
        }
Esempio n. 23
0
        private static GeoPolyline unprojectPolyline(Polyline polyline, GnomonicProjection projection)
        {
            GeoPolyline geoPolyline = new GeoPolyline();
            foreach (LinePath path in polyline.Paths)
            {
                GeoPath geoPath = new GeoPath();
                foreach (ICoordinate p in path.Vertices)
                    geoPath.Vertices.Add(unprojectPoint(new PointD(p), projection));

                geoPolyline.Paths.Add(geoPath);
            }

            return geoPolyline;
        }
Esempio n. 24
0
        private static GeoPolygon unprojectPolygon(Polygon polygon, GnomonicProjection projection)
        {
            GeoPolygon geoPolygon = new GeoPolygon();
            foreach (Contour contour in polygon.Contours)
            {
                GeoContour geoContour = new GeoContour();
                geoContour.Layout = contour.Layout;
                foreach (ICoordinate p in contour.Vertices)
                    geoContour.Vertices.Add(unprojectPoint(new PointD(p), projection));

                geoPolygon.Contours.Add(geoContour);
            }

            return geoPolygon;
        }
Esempio n. 25
0
        /// <summary>
        /// Converts a collection of geometric shapes on the surface of the ellipsoid 
        /// to the collection of geometric figures in the plane according to the given gnomonic projection.
        /// </summary>
        /// <param name="collection">Collection of geometric shapes on the surface of the ellipsoid</param>
        /// <param name="projection">Projection</param>
        /// <returns>Collection of geometric figures in the plane</returns>
        public static GeometryCollection GetGeometries(GeographyCollection collection, GnomonicProjection projection)
        { 
            GeometryCollection result = new GeometryCollection();
            IGeometry geometry = null;
            foreach (IGeography geography in collection)
            {
                if (geography is GeoPoint)
                {
                    geometry = projectPoint((GeoPoint)geography, projection);
                }
                else if (geography is GeoPolyline)
                {
                    geometry = projectPolyline((GeoPolyline)geography, projection);
                }
                else if (geography is GeoPolygon)
                {
                    geometry = projectPolygon((GeoPolygon)geography, projection);
                }
                else if (geography is GeoMultiPoint)
                {
                    geometry = projectMultiPoint((GeoMultiPoint)geography, projection);
                }
                else
                    throw new NotImplementedException("Geometry \"" + geography.GetType().FullName + "\" is not supported.");

                result.Add(geometry);
            }

            return result;
        }
Esempio n. 26
0
        /// <summary>
        /// Converts a collection of geometric shapes on the surface of the ellipsoid 
        /// to the collection of geometric figures in the plane in line with the given projection.
        /// </summary>
        /// <param name="geometries">Enumerator geometric shapes on the surface of the ellipsoid</param>
        /// <param name="projection">Projection</param>
        /// <returns>Collection of geometric figures in the plane</returns>
        public static GeographyCollection GetGeographies(IEnumerable<IGeometry> geometries, GnomonicProjection projection)
        {
            GeographyCollection result = new GeographyCollection();
            IGeography geometry = null;
            foreach (IGeometry g in geometries)
            {
                if (g is PointD)
                {
                    geometry = unprojectPoint((PointD)g, projection);
                }
                else if (g is Polyline)
                {
                    geometry = unprojectPolyline((Polyline)g, projection);
                }
                else if (g is Polygon)
                {
                    geometry = unprojectPolygon((Polygon)g, projection);
                }
                else if (g is MultiPoint)
                {
                    geometry = unprojectMultiPoint((MultiPoint)g, projection);
                }
                else
                    throw new NotImplementedException("Geometry \"" + g.GetType().FullName + "\" is not supported.");

                result.Add(geometry);
            }

            return result;
        }
Esempio n. 27
0
        private static Polygon projectPolygon(GeoPolygon polygon, GnomonicProjection projection)
        {
            Polygon p = polygon.ToPlanarPolygon(false);
            foreach (Contour contour in p.Contours)
            {
                for (int i = 0; i < contour.Vertices.Count; i++)
                {
                    double x, y;
                    projection.Project(contour.Vertices[i].Y, contour.Vertices[i].X, out x, out y);
                    contour.Vertices[i] = PlanimetryEnvironment.NewCoordinate(x, y);
                }
            }

            return p;
        }
Esempio n. 28
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;
        }
Esempio n. 29
0
        /// <summary>
        /// Converts a collection of geometric shapes on the surface of the ellipsoid
        /// to the collection of geometric figures in the plane in line with the given projection.
        /// </summary>
        /// <param name="geometries">Enumerator geometric shapes on the surface of the ellipsoid</param>
        /// <param name="projection">Projection</param>
        /// <returns>Collection of geometric figures in the plane</returns>
        public static GeographyCollection GetGeographies(IEnumerable <IGeometry> geometries, GnomonicProjection projection)
        {
            GeographyCollection result   = new GeographyCollection();
            IGeography          geometry = null;

            foreach (IGeometry g in geometries)
            {
                if (g is PointD)
                {
                    geometry = unprojectPoint((PointD)g, projection);
                }
                else if (g is Polyline)
                {
                    geometry = unprojectPolyline((Polyline)g, projection);
                }
                else if (g is Polygon)
                {
                    geometry = unprojectPolygon((Polygon)g, projection);
                }
                else if (g is MultiPoint)
                {
                    geometry = unprojectMultiPoint((MultiPoint)g, projection);
                }
                else
                {
                    throw new NotImplementedException("Geometry \"" + g.GetType().FullName + "\" is not supported.");
                }

                result.Add(geometry);
            }

            return(result);
        }
Esempio n. 30
0
        /// <summary>
        /// Converts a collection of geometric shapes on the surface of the ellipsoid
        /// to the collection of geometric figures in the plane according to the given gnomonic projection.
        /// </summary>
        /// <param name="collection">Collection of geometric shapes on the surface of the ellipsoid</param>
        /// <param name="projection">Projection</param>
        /// <returns>Collection of geometric figures in the plane</returns>
        public static GeometryCollection GetGeometries(GeographyCollection collection, GnomonicProjection projection)
        {
            GeometryCollection result   = new GeometryCollection();
            IGeometry          geometry = null;

            foreach (IGeography geography in collection)
            {
                if (geography is GeoPoint)
                {
                    geometry = projectPoint((GeoPoint)geography, projection);
                }
                else if (geography is GeoPolyline)
                {
                    geometry = projectPolyline((GeoPolyline)geography, projection);
                }
                else if (geography is GeoPolygon)
                {
                    geometry = projectPolygon((GeoPolygon)geography, projection);
                }
                else if (geography is GeoMultiPoint)
                {
                    geometry = projectMultiPoint((GeoMultiPoint)geography, projection);
                }
                else
                {
                    throw new NotImplementedException("Geometry \"" + geography.GetType().FullName + "\" is not supported.");
                }

                result.Add(geometry);
            }

            return(result);
        }