示例#1
0
 public virtual void TestEnvelope()
 {
     com.epl.geometry.Envelope env = new com.epl.geometry.Envelope();
     env.SetCoords(100, 200, 250, 300);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     env.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).IsEmpty());
     env.SetInterval(com.epl.geometry.VertexDescription.Semantics.M, 0, 1, 2);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmin == 1);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmax == 2);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     env.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
     NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 0);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 0);
     env.SetInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0, 3, 4);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
     env.AddAttribute(com.epl.geometry.VertexDescription.Semantics.ID);
     NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 0);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 0);
     env.SetInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0, 5, 6);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 5);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 6);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmin == 1);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmax == 2);
     env.DropAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 5);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 6);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
     com.epl.geometry.Envelope env1 = new com.epl.geometry.Envelope();
     env.CopyTo(env1);
     NUnit.Framework.Assert.IsFalse(env1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 5);
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 6);
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
 }
        /// <exception cref="com.fasterxml.jackson.core.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool TestEnvelope()
        {
            bool bAnswer = true;

            com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
            envelope.SetCoords(-109.55, 25.76, -86.39, 49.94);
            {
                com.fasterxml.jackson.core.JsonParser envelopeWGS84Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, envelope));
                com.epl.geometry.MapGeometry          envelopeWGS84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(envelopeWGS84Parser);
                NUnit.Framework.Assert.IsTrue(envelope.IsEmpty() == envelopeWGS84MP.GetGeometry().IsEmpty());
                NUnit.Framework.Assert.IsTrue(envelope.GetXMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMax());
                NUnit.Framework.Assert.IsTrue(envelope.GetYMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMax());
                NUnit.Framework.Assert.IsTrue(envelope.GetXMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMin());
                NUnit.Framework.Assert.IsTrue(envelope.GetYMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMin());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == envelopeWGS84MP.GetSpatialReference().GetID());
                if (!CheckResultSpatialRef(envelopeWGS84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                // export
                com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
                e.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                e.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                string s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, e);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":null,\"ymin\":null,\"xmax\":null,\"ymax\":null,\"zmin\":null,\"zmax\":null,\"mmin\":null,\"mmax\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
                e.SetCoords(0, 1, 2, 3);
                com.epl.geometry.Envelope1D z = new com.epl.geometry.Envelope1D();
                com.epl.geometry.Envelope1D m = new com.epl.geometry.Envelope1D();
                z.SetCoords(5, 7);
                m.SetCoords(11, 13);
                e.SetInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0, z);
                e.SetInterval(com.epl.geometry.VertexDescription.Semantics.M, 0, m);
                s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, e);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":0,\"ymin\":1,\"xmax\":2,\"ymax\":3,\"zmin\":5,\"zmax\":7,\"mmin\":11,\"mmax\":13,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
            }
            {
                // import
                string s = "{\"xmin\":0.0,\"ymin\":1.0,\"xmax\":2.0,\"ymax\":3.0,\"zmin\":5.0,\"zmax\":7.0,\"mmin\":11.0,\"mmax\":13.0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}";
                com.fasterxml.jackson.core.JsonParser parser  = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_env = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Envelope             env     = (com.epl.geometry.Envelope)map_env.GetGeometry();
                com.epl.geometry.Envelope1D           z       = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                com.epl.geometry.Envelope1D           m       = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0);
                NUnit.Framework.Assert.IsTrue(z.vmin == 5.0);
                NUnit.Framework.Assert.IsTrue(z.vmax == 7.0);
                NUnit.Framework.Assert.IsTrue(m.vmin == 11.0);
                NUnit.Framework.Assert.IsTrue(m.vmax == 13.0);
            }
            {
                string s = "{ \"zmin\" : 33, \"xmin\" : -109.55, \"zmax\" : 53, \"ymin\" : 25.76, \"xmax\" : -86.39, \"ymax\" : 49.94, \"mmax\" : 13}";
                com.fasterxml.jackson.core.JsonParser parser  = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_env = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Envelope             env     = (com.epl.geometry.Envelope)map_env.GetGeometry();
                com.epl.geometry.Envelope2D           e       = new com.epl.geometry.Envelope2D();
                env.QueryEnvelope2D(e);
                NUnit.Framework.Assert.IsTrue(e.xmin == -109.55 && e.ymin == 25.76 && e.xmax == -86.39 && e.ymax == 49.94);
                com.epl.geometry.Envelope1D e1D;
                NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
                e1D = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                NUnit.Framework.Assert.IsTrue(e1D.vmin == 33 && e1D.vmax == 53);
                NUnit.Framework.Assert.IsTrue(!env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
            }
            return(bAnswer);
        }