/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testPolyline() { bool bAnswer = true; com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.startPath(-97.06138, 32.837); polyline.lineTo(-97.06133, 32.836); polyline.lineTo(-97.06124, 32.834); polyline.lineTo(-97.06127, 32.832); polyline.startPath(-97.06326, 32.759); polyline.lineTo(-97.06298, 32.755); { org.codehaus.jackson.JsonParser polylinePathsWgs84Parser = factory.createJsonParser (com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWGS84, polyline )); com.esri.core.geometry.MapGeometry mPolylineWGS84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(polylinePathsWgs84Parser); NUnit.Framework.Assert.IsTrue(polyline.getPointCount() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPointCount()); NUnit.Framework.Assert.IsTrue(polyline.getPoint(0).getX() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(0).getX()); NUnit.Framework.Assert.IsTrue(polyline.getPoint(0).getY() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(0).getY()); NUnit.Framework.Assert.IsTrue(polyline.getPathCount() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPathCount()); NUnit.Framework.Assert.IsTrue(polyline.getSegmentCount() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getSegmentCount()); NUnit.Framework.Assert.IsTrue(polyline.getSegmentCount(0) == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getSegmentCount(0)); NUnit.Framework.Assert.IsTrue(polyline.getSegmentCount(1) == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getSegmentCount(1)); int lastIndex = polyline.getPointCount() - 1; NUnit.Framework.Assert.IsTrue(polyline.getPoint(lastIndex).getX() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(lastIndex).getX()); NUnit.Framework.Assert.IsTrue(polyline.getPoint(lastIndex).getY() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(lastIndex).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == mPolylineWGS84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(mPolylineWGS84MP, 4326, 0)) { bAnswer = false; } } { com.esri.core.geometry.Polyline p = new com.esri.core.geometry.Polyline(); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"paths\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); p.startPath(0, 0); p.lineTo(0, 1); p.startPath(2, 2); p.lineTo(3, 3); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 5); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"paths\":[[[0,0,3,null],[0,1,0,5]],[[2,2,0,null],[3,3,0,null]]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { string paths = "{\"hasZ\" : true, \"paths\" : [ [ [0.0, 0.0,3], [0, 10.0,3], [10.0, 10.0,3, 6666], [10.0, 0.0,3, 6666] ], [ [1.0, 1,3], [1.0, 9.0,3], [9.0, 9.0,3], [1.0, 9.0,3] ] ], \"spatialReference\" : {\"wkid\" : 4326}, \"hasM\" : false}"; com.esri.core.geometry.MapGeometry mapGeometry = com.esri.core.geometry.GeometryEngine .jsonToGeometry(factory.createJsonParser(paths)); com.esri.core.geometry.Polyline p = (com.esri.core.geometry.Polyline)mapGeometry. getGeometry(); NUnit.Framework.Assert.IsTrue(p.getPathCount() == 2); int count = p.getPathCount(); NUnit.Framework.Assert.IsTrue(p.getPointCount() == 8); NUnit.Framework.Assert.IsTrue(p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(!p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); double z = p.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0); NUnit.Framework.Assert.IsTrue(z == 3); double length = p.calculateLength2D(); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 54.0) <= 0.001); com.esri.core.geometry.SpatialReference spatial_reference = mapGeometry.getSpatialReference (); NUnit.Framework.Assert.IsTrue(spatial_reference.getID() == 4326); } return(bAnswer); }