protected void ExecuteTests(IVerticalCoordinateSystem source, IVerticalCoordinateSystem target, bool inverse) { CoordinateTransformationFactory ctf = new CoordinateTransformationFactory(); ICoordinateTransformation coordinateTransformation = ctf.CreateFromCoordinateSystems(source, target); if( inverse ) ExecuteTests(coordinateTransformation.MathTransform.Inverse); else ExecuteTests(coordinateTransformation.MathTransform); }
public void CoordinateTransformationTransformsQueryHavingDifferentSpatialReferenceAsTransformationTarget() { MockRepository repository = new MockRepository(); FeatureProviderBase provider = repository.CreateMock<FeatureProviderBase>(); BufferedCoordinateFactory coordFactory = new BufferedCoordinateFactory(); BufferedCoordinateSequenceFactory coordSeqFactory = new BufferedCoordinateSequenceFactory(coordFactory); IGeometryFactory<BufferedCoordinate> geoFactory = new GeometryFactory<BufferedCoordinate>(coordSeqFactory); IMatrixFactory<DoubleComponent> matrixFactory = new LinearFactory<DoubleComponent>(); ICoordinateTransformationFactory transformFactory = new CoordinateTransformationFactory<BufferedCoordinate>(coordFactory, geoFactory, matrixFactory); SetupResult.For(provider.CoordinateTransformation).Return(transformFactory); }
public void TestNad83ToWGS84() { var src = CoordinateSystemFactory.CreateFromWkt(wkt2236); var tgt = CoordinateSystemFactory.CreateFromWkt(wkt8307);//CoordinateSystems.GeographicCoordinateSystem.WGS84;; ProjNet.CoordinateSystems.Projections.ProjectionsRegistry.Register("SPCS83 Florida East zone (US Survey feet) (EPSG OP 15318)", ReflectType("ProjNet.CoordinateSystems.Projections.TransverseMercator")); ICoordinateTransformation transform = null; Assert.DoesNotThrow(() => transform = CoordinateTransformationFactory.CreateFromCoordinateSystems(src, tgt)); Assert.IsNotNull(transform); }
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); }
public void TestAlbersProjection() { ICoordinateSystemFactory cFac = new CoordinateSystemFactory(); ILinearUnit usSurveyFoot = cFac.CreateLinearUnit(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere( 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot, "Clarke 1866"); IHorizontalDatum datum = cFac.CreateHorizontalDatum( DatumType.HorizontalGeocentric, ellipsoid, null, "Clarke 1866"); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem( "Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory() .CreateFromCoordinateSystems(gcs, coordsys); IPoint pGeo = new Point(-75, 35); IPoint pUtm = trans.MathTransform.Transform(pGeo); IPoint pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); IPoint expected = new IPoint(1885472.7, 1535925); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.05), String.Format("Albers forward transformation outside tolerance, Expected {0}, got {1}", expected, pUtm)); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestDiscussion352813() { var csSource = GeographicCoordinateSystem.WGS84; var csTarget = ProjectedCoordinateSystem.WebMercator; // CoordinateSystemFactory.CreateFromWkt( //"PROJCS[\"Popular Visualisation CRS / Mercator\"," + // "GEOGCS[\"Popular Visualisation CRS\"," + // "DATUM[\"Popular Visualisation Datum\"," + // "SPHEROID[\"Popular Visualisation Sphere\", 6378137, 298.257223563, " + // "AUTHORITY[\"EPSG\", \"7030\"]]," + // /*"TOWGS84[0, 0, 0, 0, 0, 0, 0], */"AUTHORITY[\"EPSG\", \"6055\"]], " + // "PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]]," + // "UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]]," + // "AXIS[\"E\", EAST]," + // "AXIS[\"N\", NORTH]," + // "AUTHORITY[\"EPSG\", \"4055\"]]," + // "PROJECTION[\"Mercator\"]," + // "PARAMETER[\"semi_major\", 6378137]," + // "PARAMETER[\"semi_minor\", 6378137]," + // "PARAMETER[\"scale_factor\", 1]," + // "PARAMETER[\"False_Easting\", 0]," + // "PARAMETER[\"False_Northing\", 0]," + // "PARAMETER[\"Central_Meridian\", 0]," + // "PARAMETER[\"Latitude_of_origin\", 0]," + // "UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]]," + // "AXIS[\"East\", EAST]," + //"AXIS[\"North\", NORTH]," + //"AUTHORITY[\"EPSG\", \"3857\"]]"); //"PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"],AXIS["X",EAST],AXIS["Y",NORTH]]" var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSource, csTarget); //var ct2 = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSource, csTarget2); Verbose = true; double[] pg1 = new[] { 23.57892d, 37.94712d }; //src DotSpatial.Projections double[] pExpected = new[] { 2624793.3678553337, 4571958.333297424 }; double[] pp = ct.MathTransform.Transform(pg1); Console.WriteLine(TransformationError("EPSG 4326 -> EPSG 3857", pExpected, pp)); Assert.IsTrue(ToleranceLessThan(pp, pExpected, 1e-9), TransformationError("EPSG 4326 -> EPSG 3857", pExpected, pp)); double[] pg2 = ct.MathTransform.Inverse().Transform(pp); Assert.IsTrue(ToleranceLessThan(pg1, pg2, 1e-13), TransformationError("EPSG 4326 -> EPSG 3857", pg1, pg2, true)); }
public GenericWktProjection(string wktConfig, string crsId) : this(crsId) { if (String.IsNullOrEmpty(wktConfig)) { throw new ArgumentNullException(nameof(wktConfig)); } ICoordinateSystem CoorSystem = CoordinateSystemWktReader.Parse(wktConfig, Encoding.UTF8) as ICoordinateSystem; IGeographicCoordinateSystem WGSSystem = GeographicCoordinateSystem.WGS84; CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); _trans = ctfac.CreateFromCoordinateSystems(WGSSystem, CoorSystem); _inversedTransform = ctfac.CreateFromCoordinateSystems(CoorSystem, WGSSystem).MathTransform; }
double calcpolygonarea(List <PointLatLng> polygon) { // should be a closed polygon // coords are in lat long // need utm to calc area if (polygon.Count == 0) { CustomMessageBox.Show("Please define a polygon!"); return(0); } // close the polygon if (polygon[0] != polygon[polygon.Count - 1]) { polygon.Add(polygon[0]); // make a full loop } CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); IGeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84; int utmzone = (int)((polygon[0].Lng - -186.0) / 6.0); IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(utmzone, polygon[0].Lat < 0 ? false : true); ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm); double prod1 = 0; double prod2 = 0; for (int a = 0; a < (polygon.Count - 1); a++) { double[] pll1 = { polygon[a].Lng, polygon[a].Lat }; double[] pll2 = { polygon[a + 1].Lng, polygon[a + 1].Lat }; double[] p1 = trans.MathTransform.Transform(pll1); double[] p2 = trans.MathTransform.Transform(pll2); prod1 += p1[0] * p2[1]; prod2 += p1[1] * p2[0]; } double answer = (prod1 - prod2) / 2; if (polygon[0] == polygon[polygon.Count - 1]) { polygon.RemoveAt(polygon.Count - 1); // unmake a full loop } return(Math.Abs(answer)); }
public void Filter(GeoAPI.Geometries.Coordinate coord) { ProjNet.CoordinateSystems.ICoordinateSystem equalArea = (ProjNet.CoordinateSystems.ICoordinateSystem)CoordinateSystemWktReader.Parse(ProjectionUtil.NORTH_AMERICAN_ALBERS_EQUAL_AREA_WKT); ProjNet.CoordinateSystems.IGeographicCoordinateSystem latlon = (ProjNet.CoordinateSystems.IGeographicCoordinateSystem)CoordinateSystemWktReader.Parse(ProjectionUtil.GCS_WGS84_WKT); ICoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); ICoordinateTransformation transformation = ctfac.CreateFromCoordinateSystems(equalArea, latlon); double[] newCoords = transformation.MathTransform.Transform(new double[] { coord.X, coord.Y }); coord.X = newCoords[0]; coord.Y = newCoords[1]; }
private static void ToLatLon(double utmX, double utmY, string utmZone, out double latitude, out double longitude) { ICoordinateSystem gcs_WGS84 = GeographicCoordinateSystem.WGS84; IProjectedCoordinateSystem pcs_UTM31N = ProjectedCoordinateSystem.WGS84_UTM(23, false); CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(pcs_UTM31N, gcs_WGS84); double[] fromPoint = new double[] { utmX, utmY }; double[] toPoint = trans.MathTransform.Transform(fromPoint); longitude = toPoint[0]; latitude = toPoint[1]; }
public void TestMichiganGeoRefToWebMercator() { var src = CoordinateSystemFactory.CreateFromWkt(wkt7151); var tgt = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator; ICoordinateTransformation transform = null; Assert.DoesNotThrow(() => transform = CoordinateTransformationFactory.CreateFromCoordinateSystems(src, tgt)); Assert.IsNotNull(transform); double[] ptSrc = new[] { 535247.9375, 324548.09375 }; double[] ptTgt = null; Assert.DoesNotThrow(() => ptTgt = transform.MathTransform.Transform(ptSrc)); Assert.IsNotNull(ptTgt); }
public void TestLambertConicConformal2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection <ProjectionParameter> parameters = new Collection <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(-96, 28.5); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(2963503.91, 254759.80); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format( "LambertConicConformal2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format( "LambertConicConformal2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestGridTransformationInverse_ProjCS_NTv2() { var ETRS89 = SRIDReader.GetCSbyID(25832); // ETRS89 (UTM Zone 32N) var GK = SRIDReader.GetCSbyID(31466); // DHDN (3-degree Gauss-Kruger zone 2) var ctf = new CoordinateTransformationFactory(); var ct = ctf.CreateFromCoordinateSystems(ETRS89, GK, Grid, true); double[] input = new[] { 399340.601863, 5928794.177992 }; double[] expected = new[] { 2598417.333192, 5930677.980308 }; double[] actual = ct.MathTransform.Transform(input); CollectionAssert.AreEqual(expected, actual); }
//获取shp投影方式 public ICoordinateTransformation getmapTransform(config.ProjPara proj) { CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); CoordinateSystemFactory cFac = new CoordinateSystemFactory(); ICoordinateTransformation transform = null; //等经纬,shp数据原始投影 var epsg4326 = cFac.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]"); //目标坐标系 var epsg3857 = cFac.CreateFromWkt(getSrcCoordinate(proj)); transform = ctFac.CreateFromCoordinateSystems(epsg4326, epsg3857); return(transform); }
static GeoUtils() { _utmZone = ConfigManager.ConfigFile.UtmZone; _utmNorth = ConfigManager.ConfigFile.IsUtmNorth; CoordinateTransformationFactory _ctf = new CoordinateTransformationFactory(); _transformationFromWGS84ToUTM = _ctf.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth)); _transformationFromWGS84ToMercator = _ctf.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, ProjectedCoordinateSystem.WebMercator); _transformationFromMercatorToWGS84 = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, GeographicCoordinateSystem.WGS84); _transformationFromUTMToUGS84 = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth), GeographicCoordinateSystem.WGS84); _transformationFromUTMToMercator = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth), ProjectedCoordinateSystem.WebMercator); _transformationFromMercatorToUTM = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth)); _utmOrigin = default(GeoPointUTM); }
public void TestGeocentric() { var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var gcenCs = CoordinateSystemFactory.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich); var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, gcenCs); var pExpected = new[] { 2 + 7.0 / 60 + 46.38 / 3600, 53 + 48.0 / 60 + 33.82 / 3600 }; // Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); var pExpected3D = new[] { pExpected[0], pExpected[1], 73.0 }; var p0 = new[] { 3771793.97, 140253.34, 5124304.35 }; var p1 = ct.MathTransform.Transform(pExpected3D); var p2 = ct.MathTransform.Inverse().Transform(p1); Assert.IsTrue(ToleranceLessThan(p1, p0, 0.01)); Assert.IsTrue(ToleranceLessThan(p2, pExpected, 0.00001)); }
void SetCoordinateTransformation() { // Source Coordinate System use by OSM var sourceCS = GeographicCoordinateSystem.WGS84; // Target Coordinate System used by LiDAR data (Berlin) // https://epsg.io/25833 var ETRS89_EPSG25833 = "PROJCS[\"ETRS89 / UTM zone 33N\", GEOGCS[\"ETRS89\", DATUM[\"European_Terrestrial_Reference_System_1989\", SPHEROID[\"GRS 1980\", 6378137, 298.257222101, AUTHORITY[\"EPSG\", \"7019\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\", \"6258\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4258\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 15], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH], AUTHORITY[\"EPSG\", \"25833\"]]"; var cf = new CoordinateSystemFactory(); var targetCS = cf.CreateFromWkt(ETRS89_EPSG25833); CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); CoordinateTransformation = ctfac.CreateFromCoordinateSystems(sourceCS, targetCS); }
public void TestGridTransformationInverse_GeogCS_NTv2() { var ETRS89 = SRIDReader.GetCSbyID(4326); // ETRS89_Lat-Lon var DHDN = SRIDReader.GetCSbyID(4314); // DE_DHDN_Lat-Lon var ctf = new CoordinateTransformationFactory(); var ct = ctf.CreateFromCoordinateSystems(ETRS89, DHDN, Grid, true); double[] input = new[] { 7.482506019176, 53.498461143331 }; double[] expected = new[] { 7.483333333333, 53.500000000000 }; double[] actual = ct.MathTransform.Transform(input); CollectionAssert.AreEqual(expected, actual); }
public void TestGridTransformation_Proj2GeogCS_NTv2() { var GK = SRIDReader.GetCSbyID(31466); // DHDN (3-degree Gauss-Kruger zone 2) var ETRS89 = SRIDReader.GetCSbyID(4326); // ETRS89_Lat-Lon var ctf = new CoordinateTransformationFactory(); var ct = ctf.CreateFromCoordinateSystems(GK, ETRS89, Grid, false); double[] input = new[] { 2598417.333192, 5930677.980308 }; double[] expected = new[] { 7.482506019176, 53.498461143331 }; double[] actual = ct.MathTransform.Transform(input); CollectionAssert.AreEqual(expected, actual); }
private static void ToUTM(double longitude, double latitude, out double x, out double y, out string zone) { ICoordinateSystem gcs_WGS84 = GeographicCoordinateSystem.WGS84; IProjectedCoordinateSystem pcs_UTM31N = ProjectedCoordinateSystem.WGS84_UTM(23, false); CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(gcs_WGS84, pcs_UTM31N); double[] fromPoint = new double[] { longitude, latitude }; double[] toPoint = trans.MathTransform.Transform(fromPoint); x = toPoint[0]; y = toPoint[1]; zone = "23S"; }
public void BL2XY(double iLongtitude, double iLatitude, out double iProjectedX, out double iProjectedY) { SharpMap.Geometries.Point ptInput = new SharpMap.Geometries.Point(iLongtitude, iLatitude); iProjectedX = -1; iProjectedY = -1; //if (Math.Abs(ptInput.X) > 360) // return null; int nCenterLongitude = ((int)(ptInput.X / 3)) * 3; CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory(); //创建椭球体 IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Xian 1980", 6378140, 298.257, SharpMap.CoordinateSystems.LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Xian_1980", DatumType.HD_Geocentric, ellipsoid, null); //创建地理坐标系 SharpMap.CoordinateSystems.IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem( "Xian 1980", SharpMap.CoordinateSystems.AngularUnit.Degrees, datum, SharpMap.CoordinateSystems.PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", nCenterLongitude)); parameters.Add(new ProjectionParameter("scale_factor", 1.0)); parameters.Add(new ProjectionParameter("false_easting", 500000)); parameters.Add(new ProjectionParameter("false_northing", 0.0)); //创建投影坐标系 SharpMap.CoordinateSystems.IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); SharpMap.CoordinateSystems.IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( "Xian_1980_3_Degree_GK_CM", gcs, projection, SharpMap.CoordinateSystems.LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); //创建坐标转换器 ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); //工作区坐标到投影坐标系的转换 SharpMap.Geometries.Point ptOutput = trans.MathTransform.Transform(ptInput); iProjectedX = ptOutput.X; iProjectedY = ptOutput.Y; }
public void TestUnitTransforms() { ICoordinateSystem nadUTM = SRIDReader.GetCSbyID(2868); //UTM Arizona Central State Plane using Feet as units ICoordinateSystem wgs84GCS = SRIDReader.GetCSbyID(4326); //GCS WGS84 ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(wgs84GCS, nadUTM); double[] p0 = new double[] { -111.89, 34.165 }; double[] expected = new double[] { 708066.190579, 1151426.44638 }; double[] p1 = trans.MathTransform.Transform(p0); double[] p2 = trans.MathTransform.Inverse().Transform(p1); Assert.IsTrue(ToleranceLessThan(p1, expected, 0.013), String.Format("Transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], p1[0], p1[1])); //WARNING: This accuracy is too poor! Assert.IsTrue(ToleranceLessThan(p0, p2, 0.0000001), String.Format("Transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", p0[0], p0[1], p2[0], p2[1])); }
// NOT USED private IList <double[]> TransformCords(IList <double[]> coordinates, bool reverse = true) { CoordinateTransformationFactory cFact = new CoordinateTransformationFactory(); ICoordinateTransformation cTrans = null; if (reverse) { cTrans = cFact.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, GeographicCoordinateSystem.WGS84); } else { cTrans = cFact.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, ProjectedCoordinateSystem.WebMercator); } return(cTrans.MathTransform.TransformList(coordinates)); }
private static void Initialize() { if (_fromCS == null) { if (_fromCS == null) { string utmWkt = @" PROJCS[""ETRS89 / UTM zone 32N"", GEOGCS[""ETRS89"", DATUM[""European_Terrestrial_Reference_System_1989"", SPHEROID[""GRS 1980"",6378137,298.257222101, AUTHORITY[""EPSG"",""7019""]], AUTHORITY[""EPSG"",""6258""]], PRIMEM[""Greenwich"",0, AUTHORITY[""EPSG"",""8901""]], UNIT[""degree"",0.01745329251994328, AUTHORITY[""EPSG"",""9122""]], AUTHORITY[""EPSG"",""4258""]], UNIT[""metre"",1, AUTHORITY[""EPSG"",""9001""]], PROJECTION[""Transverse_Mercator""], PARAMETER[""latitude_of_origin"",0], PARAMETER[""central_meridian"",9], PARAMETER[""scale_factor"",0.9996], PARAMETER[""false_easting"",500000], PARAMETER[""false_northing"",0], AUTHORITY[""EPSG"",""25832""], AXIS[""Easting"",EAST], AXIS[""Northing"",NORTH]]"; // WGS 84 string wgsWkt = @" GEOGCS[""GCS_WGS_1984"", DATUM[""D_WGS_1984"",SPHEROID[""WGS_1984"",6378137,298.257223563]], PRIMEM[""Greenwich"",0], UNIT[""Degree"",0.0174532925199433] ]"; // Initialize objects needed for coordinate transformation _fromCS = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wgsWkt) as IGeographicCoordinateSystem; _toCS = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(utmWkt) as IProjectedCoordinateSystem; _ctfac = new CoordinateTransformationFactory(); _trans = _ctfac.CreateFromCoordinateSystems(_fromCS, _toCS); } } }
private void TestLambertConicConformal_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-96, 28.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(2963503.91, 254759.80), pGeo2, "Lambert Conic Conformal 2SP test"); }
private void TestAlbers() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-75, 35); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(1885472.7, 1535925), pGeo2, "Albers Conical Equal Area test"); }
public static void Main() { //////Add this to class constructor NtsGeometryServices.Instance = new NtsGeometryServices( NetTopologySuite.Geometries.Implementation.CoordinateArraySequenceFactory.Instance, new NetTopologySuite.Geometries.PrecisionModel(1000d), 4326, // Note the following arguments are only valid for NTS v2.2 // Geometry overlay operation function set to use (Legacy or NG) NetTopologySuite.Geometries.GeometryOverlay.NG, // Coordinate equality comparer to use (CoordinateEqualityComparer or PerOrdinateEqualityComparer) new NetTopologySuite.Geometries.CoordinateEqualityComparer()); //Transform Projection //*****Add ProjNet to make transform //https://docs.microsoft.com/en-us/ef/core/modeling/spatial //2nd Way //Add WKT projection coordinate system const string outputWKT = @""; CoordinateSystemFactory csFact = new CoordinateSystemFactory(); var csWgs84Text = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84.WKT; var csWgs84 = csFact.CreateFromWkt(csWgs84Text); var outputProjection = csFact.CreateFromWkt(outputWKT); CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory(); ICoordinateTransformation trans = ctFact.CreateFromCoordinateSystems(csWgs84, outputProjection); var mt = trans.MathTransform; // Use the following website to look up the arguement below that should match outputProjection ESRG //http://epsg.io var gf = NtsGeometryServices.Instance.CreateGeometryFactory(XXXX); //////End of Class Constructor //IMPORTANT-ALL GEOMETRY POINTS MUST BE WRAPPED WITH mt.Transform() // Create a point at Aurich (lat=53.4837, long=7.5404) var pntAUR = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.5404, 53.4837))); // Create a point at Emden (lat=53.3646, long=7.1559) var pntLER = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.1559, 53.3646))); // Create a point at Leer (lat=53.2476, long=7.4550) var pntEMD = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.4550, 53.2476))); var distancepntAURpntLER = pntAUR.Distance(pntLER); Console.WriteLine($"{distancepntAURpntLER} miles"); }
private void Init() { CoordinateSystem wgs84CoordinateSystem = GeographicCoordinateSystem.WGS84; CoordinateSystem webMercatorCoordinateSystem = ProjectedCoordinateSystem.WebMercator; this.WGS84CoordinateSystem = wgs84CoordinateSystem; this.WebMercatorCoordinateSystem = webMercatorCoordinateSystem; this.WGS84GeometryFactory = new GeometryFactory(new PrecisionModel(), (int)wgs84CoordinateSystem.AuthorityCode); this.WebMercatorGeometryFactory = new GeometryFactory(new PrecisionModel(), (int)webMercatorCoordinateSystem.AuthorityCode); var trfWeb = new CoordinateTransformationFactory(); this.WGS84ToWebMercatorTransformer = trfWeb.CreateFromCoordinateSystems(wgs84CoordinateSystem, webMercatorCoordinateSystem).MathTransform; this.WebMercatorToWGS84Transformer = trfWeb.CreateFromCoordinateSystems(webMercatorCoordinateSystem, wgs84CoordinateSystem).MathTransform; }
public string getCoordinates(int X, int Y) { GeoAPI.Geometries.Coordinate p = _sharpMap.ImageToWorld(new PointF(X, Y)); PointF pUTM = new PointF(); IProjectedCoordinateSystem utmProj = Helpers.CoordinateSystem.CreateUtmProjection(34); IGeographicCoordinateSystem geoCS = utmProj.GeographicCoordinateSystem; CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ICoordinateTransformation transform = ctFac.CreateFromCoordinateSystems(geoCS, utmProj); double[] c = new double[2]; c[0] = p.X; c[1] = p.Y; c = transform.MathTransform.Transform(c); pUTM.X = (float)c[0]; pUTM.Y = (float)c[1]; return(pUTM.X + " : " + pUTM.Y); }
public void TestGitHubIssue53() { // arrange var csWgs84 = GeographicCoordinateSystem.WGS84; var csUtm35N = ProjectedCoordinateSystem.WGS84_UTM(35, true); var csTrans = CoordinateTransformationFactory.CreateFromCoordinateSystems(csWgs84, csUtm35N); var csTransBack = CoordinateTransformationFactory.CreateFromCoordinateSystems(csUtm35N, csWgs84); // act double[] point = { 42.5, 24.5 }; double[] r = csTrans.MathTransform.Transform(point); double[] rBack = csTransBack.MathTransform.Transform(r); // assert Assert.AreEqual(point[0], rBack[0], 1e-5); Assert.AreEqual(point[1], rBack[1], 1e-5); }
public static double MetersDistance(this Point pointA, Point pointB) { var transformationFactory = new CoordinateTransformationFactory(); var originCoordinateSystem = GeographicCoordinateSystem.WGS84; var targetCoordinateSystem = GeocentricCoordinateSystem.WGS84; var transform = transformationFactory.CreateFromCoordinateSystems( originCoordinateSystem, targetCoordinateSystem); var pointACoordinate = new GeoAPI.Geometries.Coordinate(pointA.X, pointA.Y); var pointBCoordinate = new GeoAPI.Geometries.Coordinate(pointB.X, pointB.Y); var newPointA = transform.MathTransform.Transform(pointACoordinate); var newPointB = transform.MathTransform.Transform(pointBCoordinate); return(newPointB.Distance(newPointA) * 1.11); }
private void TestMercator_1SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(120, -3); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(5009726.58, 569150.82), pGeo2, "Mercator_1SP test"); }
public void TestKrovak_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_center", 49.5)); parameters.Add(new ProjectionParameter("longitude_of_center", 42.5)); parameters.Add(new ProjectionParameter("azimuth", 30.28813972222222)); parameters.Add(new ProjectionParameter("pseudo_standard_parallel_1", 78.5)); parameters.Add(new ProjectionParameter("scale_factor", 0.9999)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Krovak", "Krovak", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("WGS 84", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); // test case 1 double[] pGeo = new double[] { 12, 48 }; double[] expected = new double[] { -953172.26, -1245573.32 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Krovak forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Krovak reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); // test case 2 pGeo = new double[] { 18, 49 }; expected = new double[] { -499258.06, -1192389.16 }; pUtm = trans.MathTransform.Transform(pGeo); pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Krovak forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Krovak reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); }
private void TestAlbers() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-75, 35); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(1885472.7, 1535925), pGeo2, "Albers Conical Equal Area test"); }
private void TestLambertConicConformal_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-96, 28.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(2963503.91, 254759.80), pGeo2, "Lambert Conic Conformal 2SP test"); }
public void TestCassiniSoldnerFactoryEPSG() { IProjectedCoordinateSystem pcs = CoordinateSystemAuthorityFactory.CreateProjectedCoordinateSystem(30200); IGeographicCoordinateSystem gcs = pcs.GeographicCoordinateSystem; CoordinateTransformationFactory ctf = new CoordinateTransformationFactory(); ICoordinateTransformation coordinateTransformation = ctf.CreateFromCoordinateSystems(gcs, pcs); IMathTransform d = coordinateTransformation.MathTransform; IMathTransform i = d.Inverse; TestDirectTransform(d, Sexa2DecimalDegrees(10, 0, 00.000, CardinalPoint.N), Sexa2DecimalDegrees(62, 00, 00.000, CardinalPoint.W), 66644.94, 82536.22, 1E-2); TestInverseTransform(i, Sexa2DecimalDegrees(10, 0, 00.000, CardinalPoint.N), Sexa2DecimalDegrees(62, 00, 00.000, CardinalPoint.W), 66644.94, 82536.22, 1E-2); }
protected void ExecuteTests(ICoordinateSystem source, ICoordinateSystem target, bool inverse, DelegateCoordinateOperation delegado) { CoordinateTransformationFactory ctf = new CoordinateTransformationFactory(); ICoordinateTransformation coordinateTransformation = ctf.CreateFromCoordinateSystems(source, target, delegado); IMathTransform d = coordinateTransformation.MathTransform; IMathTransform i = d.Inverse; if( inverse ) ExecuteTests(i, d); else ExecuteTests(d, i); }
private void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); IGeocentricCoordinateSystem geoccs = cFac.CreateGeocentricCoordinateSystem("WGS84 geocentric", gcs.HorizontalDatum, LinearUnit.Metre, PrimeMeridian.Greenwich); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, geoccs); var pGeo = new Coordinate(2.12955, 53.80939444, 73); var pGc = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pGc); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, geoccs, pGeo, pGc, new Coordinate(3771793.97, 140253.34, 5124304.35), pGeo2, "Geocentric test"); return; }
private void TestTransverseMercator() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 49)); parameters.Add(new ProjectionParameter("central_meridian", -2)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717)); parameters.Add(new ProjectionParameter("false_easting", 400000)); parameters.Add(new ProjectionParameter("false_northing", -100000)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(0.5, 50.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(577274.99, 69740.50), pGeo2, "Transverse Mercator test"); }
private void TestMercator_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 42)); parameters.Add(new ProjectionParameter("central_meridian", 51)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( "Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(53, 53); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(165704.29, 5171848.07), pGeo2, "Mercator_2SP test"); }
public void TestMercator_1SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(120, -3); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(5009726.58, 569150.82); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_1SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_1SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestDatumTransform() { ICoordinateSystemFactory cFac = new ICoordinateSystemFactory(); //Define datums IHorizontalDatum wgs72 = HorizontalDatum.WGS72; IHorizontalDatum ed50 = HorizontalDatum.ED50; //Define geographic coordinate systems IGeographicCoordinateSystem gcsWGS72 = cFac.CreateGeographicCoordinateSystem("WGS72 Geographic", AngularUnit.Degrees, wgs72, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); IGeographicCoordinateSystem gcsWGS84 = cFac.CreateGeographicCoordinateSystem("WGS84 Geographic", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); IGeographicCoordinateSystem gcsED50 = cFac.CreateGeographicCoordinateSystem("ED50 Geographic", AngularUnit.Degrees, ed50, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); //Define geocentric coordinate systems IGeocentricCoordinateSystem gcenCsWGS72 = cFac.CreateGeocentricCoordinateSystem("WGS72 Geocentric", wgs72, LinearUnit.Metre, PrimeMeridian.Greenwich); IGeocentricCoordinateSystem gcenCsWGS84 = cFac.CreateGeocentricCoordinateSystem("WGS84 Geocentric", HorizontalDatum.WGS84, LinearUnit.Metre, PrimeMeridian.Greenwich); IGeocentricCoordinateSystem gcenCsED50 = cFac.CreateGeocentricCoordinateSystem("ED50 Geocentric", ed50, LinearUnit.Metre, PrimeMeridian.Greenwich); //Define projections //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 9)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996)); parameters.Add(new ProjectionParameter("false_easting", 500000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem utmED50 = cFac.CreateProjectedCoordinateSystem("ED50 UTM Zone 32N", gcsED50, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); IProjectedCoordinateSystem utmWGS84 = cFac.CreateProjectedCoordinateSystem("WGS84 UTM Zone 32N", gcsWGS84, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); //Set TOWGS84 parameters wgs72.Wgs84Parameters = new Wgs84ConversionInfo(0, 0, 4.5, 0, 0, 0.554, 0.219); ed50.Wgs84Parameters = new Wgs84ConversionInfo(-81.0703, -89.3603, -115.7526, -0.48488, -0.02436, -0.41321, -0.540645); //Parameters for Denmark //Set up coordinate transformations ICoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ICoordinateTransformation ctForw = ctFac.CreateFromCoordinateSystems(gcsWGS72, gcenCsWGS72); //Geographic->Geocentric (WGS72) ICoordinateTransformation ctWGS84_Gcen2Geo = ctFac.CreateFromCoordinateSystems(gcenCsWGS84, gcsWGS84); //Geocentric->Geographic (WGS84) ICoordinateTransformation ctWGS84_Geo2UTM = ctFac.CreateFromCoordinateSystems(gcsWGS84, utmWGS84); //UTM ->Geographic (WGS84) ICoordinateTransformation ctED50_UTM2Geo = ctFac.CreateFromCoordinateSystems(utmED50, gcsED50); //UTM ->Geographic (ED50) ICoordinateTransformation ctED50_Geo2Gcen = ctFac.CreateFromCoordinateSystems(gcsED50, gcenCsED50); //Geographic->Geocentric (ED50) //Test datum-shift from WGS72 to WGS84 //Point3D pGeoCenWGS72 = ctForw.MathTransform.Transform(pLongLatWGS72) as Point3D; IPoint3D pGeoCenWGS72 = new IPoint3D(3657660.66, 255768.55, 5201382.11); ICoordinateTransformation geocen_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(gcenCsWGS72, gcenCsWGS84); IPoint3D pGeoCenWGS84 = geocen_ed50_2_Wgs84.MathTransform.Transform(pGeoCenWGS72) as IPoint3D; //Point3D pGeoCenWGS84 = wgs72.Wgs84Parameters.Apply(pGeoCenWGS72); Assert.IsTrue(toleranceLessThan(new IPoint3D(3657660.78, 255778.43, 5201387.75), pGeoCenWGS84, 0.01)); ICoordinateTransformation utm_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(utmED50, utmWGS84); IPoint pUTMED50 = new IPoint(600000, 6100000); IPoint pUTMWGS84 = utm_ed50_2_Wgs84.MathTransform.Transform(pUTMED50); Assert.IsTrue(toleranceLessThan(new IPoint(599928.6, 6099790.2), pUTMWGS84, 0.1)); //Perform reverse ICoordinateTransformation utm_Wgs84_2_Ed50 = ctFac.CreateFromCoordinateSystems(utmWGS84, utmED50); pUTMED50 = utm_Wgs84_2_Ed50.MathTransform.Transform(pUTMWGS84); Assert.IsTrue(toleranceLessThan(new IPoint(600000, 6100000), pUTMED50, 0.1)); //Assert.IsTrue(Math.Abs((pUTMWGS84 as Point3D).Z - 36.35) < 0.5); //Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); //ED50_to_WGS84_Denmark: datum.Wgs84Parameters = new Wgs84ConversionInfo(-89.5, -93.8, 127.6, 0, 0, 4.5, 1.2); }
public void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); IGeocentricCoordinateSystem gcenCs = cFac.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich); CoordinateTransformationFactory gtFac = new CoordinateTransformationFactory(); ICoordinateTransformation ct = gtFac.CreateFromCoordinateSystems(gcs, gcenCs); Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); Point3D pExpected3D = new Point3D(pExpected.X, pExpected.Y, 73.0); Point3D p0 = new Point3D(3771793.97, 140253.34, 5124304.35); Point3D p1 = ct.MathTransform.Transform(pExpected3D) as Point3D; Point3D p2 = ct.MathTransform.Inverse().Transform(p1) as Point3D; Assert.IsTrue(toleranceLessThan(p1, p0, 0.01)); Assert.IsTrue(toleranceLessThan(p2, pExpected, 0.00001)); }
public void TestLambertConicConformal2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(-96, 28.5); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(2963503.91, 254759.80); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format( "LambertConicConformal2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format( "LambertConicConformal2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestTransverseMercator_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 49)); parameters.Add(new ProjectionParameter("central_meridian", -2)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717)); parameters.Add(new ProjectionParameter("false_easting", 400000)); parameters.Add(new ProjectionParameter("false_northing", -100000)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(0.5, 50.5); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(577274.99, 69740.50); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format( "TransverseMercator forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format( "TransverseMercator reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
private void TestMercator_1SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(120, -3); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(5009726.58, 569150.82), pGeo2, "Mercator_1SP test"); }
public void TestMercator_2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 42)); parameters.Add(new ProjectionParameter("central_meridian", 51)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(53, 53); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(165704.29, 5171848.07); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }