/// <exception cref="com.fasterxml.jackson.core.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool TestPolyline() { bool bAnswer = true; com.epl.geometry.Polyline polyline = new com.epl.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); { com.fasterxml.jackson.core.JsonParser polylinePathsWgs84Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, polyline)); com.epl.geometry.MapGeometry mPolylineWGS84MP = com.epl.geometry.GeometryEngine.JsonToGeometry(polylinePathsWgs84Parser); NUnit.Framework.Assert.IsTrue(polyline.GetPointCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPointCount()); NUnit.Framework.Assert.IsTrue(polyline.GetPoint(0).GetX() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(0).GetX()); NUnit.Framework.Assert.IsTrue(polyline.GetPoint(0).GetY() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(0).GetY()); NUnit.Framework.Assert.IsTrue(polyline.GetPathCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPathCount()); NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount()); NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount(0) == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount(0)); NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount(1) == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount(1)); int lastIndex = polyline.GetPointCount() - 1; NUnit.Framework.Assert.IsTrue(polyline.GetPoint(lastIndex).GetX() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(lastIndex).GetX()); NUnit.Framework.Assert.IsTrue(polyline.GetPoint(lastIndex).GetY() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(lastIndex).GetY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolylineWGS84MP.GetSpatialReference().GetID()); if (!CheckResultSpatialRef(mPolylineWGS84MP, 4326, 0)) { bAnswer = false; } } { com.epl.geometry.Polyline p = new com.epl.geometry.Polyline(); p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z); p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); string s = com.epl.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.epl.geometry.VertexDescription.Semantics.Z, 0, 0, 3); p.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 5); s = com.epl.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.epl.geometry.MapGeometry mapGeometry = com.epl.geometry.GeometryEngine.JsonToGeometry(factory.CreateParser(paths)); com.epl.geometry.Polyline p = (com.epl.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.epl.geometry.VertexDescription.Semantics.Z)); NUnit.Framework.Assert.IsTrue(!p.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M)); double z = p.GetAttributeAsDbl(com.epl.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.epl.geometry.SpatialReference spatial_reference = mapGeometry.GetSpatialReference(); NUnit.Framework.Assert.IsTrue(spatial_reference.GetID() == 4326); } return(bAnswer); }