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)); }
/// <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; } }
public GeoPoint(Coordinate coordinate, ProjNet.CoordinateSystems.CoordinateSystem sourceProjection) { this.RhinoPoint = new Point3d(coordinate.X, coordinate.Y, coordinate.Z); this.GeoCoordinate = coordinate; this.CoordinateReferenceSystem = sourceProjection; }
public GeoPoint(Point3d point, ProjNet.CoordinateSystems.CoordinateSystem sourceProjection) { this.RhinoPoint = point; this.CoordinateReferenceSystem = sourceProjection; this.GeoCoordinate = new Coordinate(point.X, point.Y, point.Z); }