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); }
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); }
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 TestNAD() { var NAD27 = SRIDReader.GetCSbyID(4267); var NAD83 = SRIDReader.GetCSbyID(4269); // https://github.com/OSGeo/proj-datumgrid/tree/master/north-america var grid = GridFile.Open(@"ntv2_0.gsb"); var ct = TransformationFactory.CreateFromCoordinateSystems(NAD27, NAD83, grid, false); // http://www.apsalin.com/nad-conversion.aspx // https://www.ngs.noaa.gov/NCAT/ double[] input = new[] { -79.378243, 43.664087 }; double[] expected = new[] { -79.3780316, 43.6641356 }; var actual = ct.MathTransform.Transform(input); CollectionAssert.AreEqual(expected, actual); }
public void TestBeta2007() { var cs = new Dictionary <string, CoordinateSystem>(); cs.Add("DE_DHDN_Lat-Lon", SRIDReader.GetCSbyID(4314)); cs.Add("DE_DHDN_3GK2", SRIDReader.GetCSbyID(31466)); cs.Add("DE_DHDN_3GK3", SRIDReader.GetCSbyID(31467)); cs.Add("DE_DHDN_3GK4", SRIDReader.GetCSbyID(31468)); cs.Add("DE_DHDN_3GK5", SRIDReader.GetCSbyID(31469)); cs.Add("ETRS89_Lat-Lon", SRIDReader.GetCSbyID(4326)); cs.Add("ETRS89_UTM32", SRIDReader.GetCSbyID(25832)); cs.Add("ETRS89_UTM33", SRIDReader.GetCSbyID(25833)); CoordinateSystem source, target; int success = 0; foreach (var item in Data) { if (cs.TryGetValue(item.qname, out source) && cs.TryGetValue(item.zname, out target)) { var ct = TransformationFactory.CreateFromCoordinateSystems(source, target, Grid, false); double[] input = new[] { item.qx, item.qy }; double[] expected = new[] { item.zx, item.zy }; var actual = ct.MathTransform.Transform(input); if (Validate(expected, actual)) { success++; } } } Assert.AreEqual(success, Data.Count); }