public void TestCopenhagen() { var ctx = new ProjContext(); var src = CoordinateReferenceSystem.Create("EPSG:4326", ctx); var dst = CoordinateReferenceSystem.Create(/*"+proj=utm +zone=32 +datum=WGS84" or */ "EPSG:32632", ctx); Assert.AreEqual("WGS 84", src.Name); Assert.AreEqual("WGS 84 / UTM zone 32N", dst.Name); var t = CoordinateTransform.Create(src, dst, ctx); var t2 = CoordinateTransform.Create(src.WithAxisNormalized(), dst.WithAxisNormalized(), ctx); var p = t2.ApplyReversed(new double[] { 12, 55 }); Trace.WriteLine($"Easting: {p[0]}, Northing: {p[1]}"); var r = t2.ApplyReversed(p); Trace.WriteLine($"Longitude: {r[0]}, Latitude: {r[1]}"); var tt = CoordinateTransform.Create(src, src, null); Assert.AreEqual("Null geographic offset from WGS 84 to WGS 84", tt.Name); var ss = ctx.Create("+proj=utm +zone=32 +datum=WGS84 +ellps=clrk66"); }
public void CreateAndDestroyContext() { using (var pc = new ProjContext()) { using (var crs = pc.Create("+proj=merc +ellps=clrk66 +lat_ts=33")) { Assert.AreEqual("PROJ-based coordinate operation", crs.Name); if (crs is CoordinateTransform cob) { Assert.IsNull(crs.Identifiers); var src = cob.SourceCRS; var dst = cob.TargetCRS; Assert.IsNull(src); Assert.IsNull(dst); //Assert.AreEqual(1, crs.Identifiers.Count); } else { Assert.Fail(); } Assert.AreEqual(ProjType.OtherCoordinateTransform, crs.Type); string expected = @"{ ""$schema"": ""https://proj.org/schemas/v0.2/projjson.schema.json"", ""type"": ""Conversion"", ""name"": ""PROJ-based coordinate operation"", ""method"": { ""name"": ""PROJ-based operation method: +proj=merc +ellps=clrk66 +lat_ts=33"" } }".Replace("\r", ""); Assert.AreEqual(expected, crs.AsProjJson()); Assert.AreEqual("proj=merc ellps=clrk66 lat_ts=33", crs.Definition); Assert.AreEqual("+proj=merc +ellps=clrk66 +lat_ts=33", crs.AsProjString()); } using (var crs = pc.Create(new string[] { "proj=merc", "ellps=clrk66", "lat_ts=33" })) { Assert.AreEqual("PROJ-based coordinate operation", crs.Name); } } }