Base interface for all coordinate systems.

A coordinate system is a mathematical space, where the elements of the space are called positions. Each position is described by a list of numbers. The length of the list corresponds to the dimension of the coordinate system. So in a 2D coordinate system each position is described by a list containing 2 numbers.

However, in a coordinate system, not all lists of numbers correspond to a position - some lists may be outside the domain of the coordinate system. For example, in a 2D Lat/Lon coordinate system, the list (91,91) does not correspond to a position.

Some coordinate systems also have a mapping from the mathematical space into locations in the real world. So in a Lat/Lon coordinate system, the mathematical position (lat, long) corresponds to a location on the surface of the Earth. This mapping from the mathematical space into real-world locations is called a Datum.

Inheritance: Info, ICoordinateSystem
        internal static CoordinateSystemBase Create(ProjNet.CoordinateSystems.CoordinateSystem coordSys)
        {
            CoordinateSystemBase csb = null;

            try
            {
                //This fails because the XY-M projection is not supported
                csb = new ActualCoordinateSystem(coordSys);
            }
            catch { }

            if (csb == null && coordSys != null)
            {
                IUnit unit = coordSys.GetUnits(0);
                var   au   = unit as AngularUnit;
                var   lu   = unit as LinearUnit;
                if (au != null)
                {
                    double radians = au.RadiansPerUnit;
                    csb = new DegreeBasedCoordinateSystem();
                }
                else if (lu != null)
                {
                    csb = new MeterBasedCoordinateSystem(lu.MetersPerUnit, lu.MetersPerUnit);
                }
            }

            if (csb == null)
            {
                csb = new MeterBasedCoordinateSystem();
            }

            return(csb);
        }
        /// <summary>
        /// Reprojects a Placeful Polygon to a NetTopologySuite Polygon in a target Coordinate System
        /// </summary>
        public NetTopologySuite.Geometries.Polygon Reproject(ProjNet.CoordinateSystems.CoordinateSystem targetProjection)
        {
            CoordinateSystemFactory coordSystem = new CoordinateSystemFactory();
            var transform = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            var reproject = transform.CreateFromCoordinateSystems(this.CoordinateReferenceSystem, targetProjection);

            var reprojectedCoords = reproject.MathTransform.TransformList(this.GetCoordinates());
            var reprojectedRing   = new LinearRing(reprojectedCoords.ToArray());

            return(new NetTopologySuite.Geometries.Polygon(reprojectedRing));
        }
Exemple #3
0
        /// <summary>
        /// Reprojects a GeoPoint to a NetTopologySuite Point in a target Coordinate System
        /// </summary>
        public NetTopologySuite.Geometries.Point Reproject(ProjNet.CoordinateSystems.CoordinateSystem targetProjection)
        {
            CoordinateSystemFactory coordSystem = new CoordinateSystemFactory();
            var transform = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            var reproject = transform.CreateFromCoordinateSystems(this.CoordinateReferenceSystem, targetProjection);

            var reprojectedPoint = reproject.MathTransform.Transform(new double[2] {
                this.GeoCoordinate.X, this.GeoCoordinate.Y
            });
            var reprojectedCoord = new GeoAPI.Geometries.Coordinate(reprojectedPoint[0], reprojectedPoint[1]);

            return(new NetTopologySuite.Geometries.Point(reprojectedCoord));
        }
AUTHORITY[""EPSG"",""3785""]]"; //NOXLATE

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultSimpleTransform"/> class.
        /// </summary>
        /// <param name="sourceCsWkt">The source cs WKT.</param>
        /// <param name="targetCsWkt">The target cs WKT.</param>
        internal DefaultSimpleTransform(string sourceCsWkt, string targetCsWkt)
        {
            //Check for and replace the WGS84.PseudoMercator WKT
            string srcWkt = sourceCsWkt == CSMAP_WGS84_PSEUDO_MERCATOR ? POPULAR_VISUALISATION_CRS : sourceCsWkt;
            string dstWkt = targetCsWkt == CSMAP_WGS84_PSEUDO_MERCATOR ? POPULAR_VISUALISATION_CRS : targetCsWkt;
            var    fact   = new CoordinateSystemFactory();

            _source = fact.CreateFromWkt(srcWkt);
            _target = fact.CreateFromWkt(dstWkt);
            var tfact = new CoordinateTransformationFactory();

            _trans = tfact.CreateFromCoordinateSystems(_source, _target);
        }
        // GeoLinestring Constructor
        public GeoPolyline(Polyline polyline, ProjNet.CoordinateSystems.CoordinateSystem sourceProjection)
        {
            if (polyline.IsValid)
            {
                this.RhinoPolyline             = polyline;
                this.GeoLinestring             = this.ToGeoLinestring();
                this.CoordinateReferenceSystem = sourceProjection;
            }

            else
            {
                throw new ArgumentException("Polyline is not valid", "RhinoPolyline");
            }
        }
        // Polygon Constructor
        public GeoPolylineCollection(IEnumerable <GeoPolyline> geoPolylines)
        {
            GeoPolylines = geoPolylines.ToArray();

            var projections = geoPolylines.Select(geoPolyline => geoPolyline.CoordinateReferenceSystem);

            if (projections.Any(projection => projection != projections.First())) // Check to see if any of the CRS's for input geoms are not the same
            {
                throw new Exception("Error: Coordinate Reference Systems for input polygons are not the same");
            }
            else
            {
                this.CoordinateReferenceSystem = geoPolylines.First().CoordinateReferenceSystem;
            }
        }
Exemple #7
0
 public GeoPoint(Coordinate coordinate, ProjNet.CoordinateSystems.CoordinateSystem sourceProjection)
 {
     this.RhinoPoint                = new Point3d(coordinate.X, coordinate.Y, coordinate.Z);
     this.GeoCoordinate             = coordinate;
     this.CoordinateReferenceSystem = sourceProjection;
 }
Exemple #8
0
 public GeoPoint(Point3d point, ProjNet.CoordinateSystems.CoordinateSystem sourceProjection)
 {
     this.RhinoPoint = point;
     this.CoordinateReferenceSystem = sourceProjection;
     this.GeoCoordinate             = new Coordinate(point.X, point.Y, point.Z);
 }