Exemplo n.º 1
0
        public void CreateAndDestroyContextEPSG()
        {
            using (var pc = new ProjContext())
            {
                GC.KeepAlive(pc.Clone());

                // Needs proj.db

                using (var crs = CoordinateReferenceSystem.Create("EPSG:25832", pc))
                {
                    Assert.AreEqual("ETRS89 / UTM zone 32N", crs.Name);

                    Assert.IsNotNull(crs.Identifiers);
                    Assert.AreEqual(1, crs.Identifiers.Count);
                    Assert.AreEqual("EPSG", crs.Identifiers[0].Authority);
                    Assert.AreEqual("25832", crs.Identifiers[0].Name);
                    Assert.AreEqual("+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs +type=crs", crs.AsProjString());

                    using (var t = ProjObject.Create(crs.AsProjString()))
                    {
                        Assert.IsTrue(t is CoordinateReferenceSystem);

                        Assert.IsNull(t.Identifiers);

                        Assert.AreEqual(crs.AsProjString(), t.AsProjString());
                    }

                    using (var t = ProjObject.Create(crs.AsWellKnownText()))
                    {
                        Assert.IsTrue(t is CoordinateReferenceSystem);

                        Assert.IsNotNull(t.Identifiers);
                        Assert.AreEqual("EPSG", t.Identifiers[0].Authority);
                        Assert.AreEqual("25832", t.Identifiers[0].Name);
                        Assert.AreEqual("+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs +type=crs", t.AsProjString());
                        Assert.AreEqual(crs.AsProjString(), t.AsProjString());

                        Assert.IsTrue(t.IsEquivalentTo(crs));
                    }
                    using (var t = ProjObject.Create(crs.AsProjJson()))
                    {
                        Assert.IsTrue(t is CoordinateReferenceSystem);

                        Assert.IsNotNull(t.Identifiers);
                        Assert.AreEqual("EPSG", t.Identifiers[0].Authority);
                        Assert.AreEqual("25832", t.Identifiers[0].Name);
                        Assert.AreEqual("+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs +type=crs", t.AsProjString());
                        Assert.AreEqual(crs.AsProjString(), t.AsProjString());
                        Assert.IsTrue(t.IsEquivalentTo(crs));
                    }
                }
            }
        }