/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testEnvelope() { bool bAnswer = true; com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope(); envelope.setCoords(-109.55, 25.76, -86.39, 49.94); { org.codehaus.jackson.JsonParser envelopeWGS84Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine .geometryToJson(spatialReferenceWGS84, envelope)); com.esri.core.geometry.MapGeometry envelopeWGS84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(envelopeWGS84Parser); NUnit.Framework.Assert.IsTrue(envelope.isEmpty() == envelopeWGS84MP.getGeometry() .isEmpty()); NUnit.Framework.Assert.IsTrue(envelope.getXMax() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getXMax()); NUnit.Framework.Assert.IsTrue(envelope.getYMax() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getYMax()); NUnit.Framework.Assert.IsTrue(envelope.getXMin() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getXMin()); NUnit.Framework.Assert.IsTrue(envelope.getYMin() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getYMin()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == envelopeWGS84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(envelopeWGS84MP, 4326, 0)) { bAnswer = false; } } { // export com.esri.core.geometry.Envelope e = new com.esri.core.geometry.Envelope(); e.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); e.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.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.esri.core.geometry.Envelope1D z = new com.esri.core.geometry.Envelope1D(); com.esri.core.geometry.Envelope1D m = new com.esri.core.geometry.Envelope1D(); z.setCoords(5, 7); m.setCoords(11, 13); e.setInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, z); e.setInterval(com.esri.core.geometry.VertexDescription.Semantics.M, 0, m); s = com.esri.core.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}}"; org.codehaus.jackson.JsonParser parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry map_env = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Envelope env = (com.esri.core.geometry.Envelope)map_env.getGeometry (); com.esri.core.geometry.Envelope1D z = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0); com.esri.core.geometry.Envelope1D m = env.queryInterval(com.esri.core.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}"; org.codehaus.jackson.JsonParser parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry map_env = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Envelope env = (com.esri.core.geometry.Envelope)map_env.getGeometry (); com.esri.core.geometry.Envelope2D e = new com.esri.core.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.esri.core.geometry.Envelope1D e1D; NUnit.Framework.Assert.IsTrue(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); e1D = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); NUnit.Framework.Assert.IsTrue(e1D.vmin == 33 && e1D.vmax == 53); NUnit.Framework.Assert.IsTrue(!env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); } return(bAnswer); }
public virtual void testEnvelope() { com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(); env.setCoords(100, 200, 250, 300); NUnit.Framework.Assert.IsFalse(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); env.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .M, 0).isEmpty()); env.setInterval(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 1, 2); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .M, 0).vmin == 1); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .M, 0).vmax == 2); NUnit.Framework.Assert.IsFalse(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); env.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); NUnit.Framework.Assert.IsTrue(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmin == 0); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmax == 0); env.setInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 3, 4); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmin == 3); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmax == 4); NUnit.Framework.Assert.IsFalse(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .ID)); env.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID); NUnit.Framework.Assert.IsTrue(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .ID)); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmin == 0); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmax == 0); env.setInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 5, 6); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmin == 5); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmax == 6); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmin == 3); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmax == 4); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .M, 0).vmin == 1); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .M, 0).vmax == 2); env.dropAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsFalse(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmin == 5); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmax == 6); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmin == 3); NUnit.Framework.Assert.IsTrue(env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmax == 4); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(); env.copyTo(env1); NUnit.Framework.Assert.IsFalse(env1.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); NUnit.Framework.Assert.IsTrue(env1.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmin == 5); NUnit.Framework.Assert.IsTrue(env1.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .ID, 0).vmax == 6); NUnit.Framework.Assert.IsTrue(env1.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmin == 3); NUnit.Framework.Assert.IsTrue(env1.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0).vmax == 4); }