/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testMultiPoint() { bool bAnswer = true; com.esri.core.geometry.MultiPoint multiPoint1 = new com.esri.core.geometry.MultiPoint (); multiPoint1.add(-97.06138, 32.837); multiPoint1.add(-97.06133, 32.836); multiPoint1.add(-97.06124, 32.834); multiPoint1.add(-97.06127, 32.832); { string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWGS84 , multiPoint1); org.codehaus.jackson.JsonParser mPointWgs84Parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry mPointWgs84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(mPointWgs84Parser); NUnit.Framework.Assert.IsTrue(multiPoint1.getPointCount() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPointCount()); NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(0).getX() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(0).getX()); NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(0).getY() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(0).getY()); int lastIndex = multiPoint1.getPointCount() - 1; NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(lastIndex).getX() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(lastIndex).getX()); NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(lastIndex).getY() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(lastIndex).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == mPointWgs84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(mPointWgs84MP, 4326, 0)) { bAnswer = false; } } { com.esri.core.geometry.MultiPoint p = new com.esri.core.geometry.MultiPoint(); 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,\"points\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); p.add(10.0, 20.0, 30.0); p.add(20.0, 40.0, 60.0); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"points\":[[10,20,30,null],[20,40,60,null]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { string points = "{\"hasM\" : false, \"hasZ\" : true, \"uncle remus\" : null, \"points\" : [ [0,0,1], [0.0,10.0,1], [10.0,10.0,1], [10.0,0.0,1, 6666] ],\"spatialReference\" : {\"wkid\" : 4326}}"; com.esri.core.geometry.MapGeometry mp = com.esri.core.geometry.GeometryEngine.jsonToGeometry (factory.createJsonParser(points)); com.esri.core.geometry.MultiPoint multipoint = (com.esri.core.geometry.MultiPoint )mp.getGeometry(); NUnit.Framework.Assert.IsTrue(multipoint.getPointCount() == 4); com.esri.core.geometry.Point2D point2d; point2d = multipoint.getXY(0); NUnit.Framework.Assert.IsTrue(point2d.x == 0.0 && point2d.y == 0.0); point2d = multipoint.getXY(1); NUnit.Framework.Assert.IsTrue(point2d.x == 0.0 && point2d.y == 10.0); point2d = multipoint.getXY(2); NUnit.Framework.Assert.IsTrue(point2d.x == 10.0 && point2d.y == 10.0); point2d = multipoint.getXY(3); NUnit.Framework.Assert.IsTrue(point2d.x == 10.0 && point2d.y == 0.0); NUnit.Framework.Assert.IsTrue(multipoint.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(!multipoint.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); double z = multipoint.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0); NUnit.Framework.Assert.IsTrue(z == 1); com.esri.core.geometry.SpatialReference spatial_reference = mp.getSpatialReference (); NUnit.Framework.Assert.IsTrue(spatial_reference.getID() == 4326); } return(bAnswer); }
public virtual void testMultiPoint() { com.esri.core.geometry.MultiPoint mp = new com.esri.core.geometry.MultiPoint(); mp.add(new com.esri.core.geometry.Point(100, 200)); mp.add(new com.esri.core.geometry.Point(101, 201)); mp.add(new com.esri.core.geometry.Point(102, 202)); NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); mp.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); NUnit.Framework.Assert.IsTrue(double.IsNaN(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0))); NUnit.Framework.Assert.IsTrue(double.IsNaN(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0))); NUnit.Framework.Assert.IsTrue(double.IsNaN(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0))); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 1); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 2); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 3); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0) == 1); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0) == 2); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0) == 3); NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); mp.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); NUnit.Framework.Assert.IsTrue(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0) == 0); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 1, 0) == 0); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 2, 0) == 0); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 11); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0, 21); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0, 31); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0) == 1); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0) == 2); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0) == 3); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0) == 11); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 1, 0) == 21); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 2, 0) == 31); NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .ID)); mp.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID); NUnit.Framework.Assert.IsTrue(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .ID)); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 0, 0) == 0); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 1, 0) == 0); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 2, 0) == 0); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 0, -11); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 1, 0, -21); mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 2, 0, -31); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0) == 1); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0) == 2); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0) == 3); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0) == 11); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 1, 0) == 21); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 2, 0) == 31); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 0, 0) == -11); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 1, 0) == -21); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 2, 0) == -31); mp.dropAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0) == 11); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 1, 0) == 21); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 2, 0) == 31); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 0, 0) == -11); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 1, 0) == -21); NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 2, 0) == -31); com.esri.core.geometry.MultiPoint mp1 = new com.esri.core.geometry.MultiPoint(); mp.copyTo(mp1); NUnit.Framework.Assert.IsFalse(mp1.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0) == 11); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 1, 0) == 21); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 2, 0) == 31); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 0, 0) == -11); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 1, 0) == -21); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 2, 0) == -31); mp1.dropAllAttributes(); mp1.mergeVertexDescription(mp.getDescription()); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0) == 0); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 1, 0) == 0); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 2, 0) == 0); NUnit.Framework.Assert.IsTrue(double.IsNaN(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0))); NUnit.Framework.Assert.IsTrue(double.IsNaN(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0))); NUnit.Framework.Assert.IsTrue(double.IsNaN(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0))); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 0, 0) == 0); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 1, 0) == 0); NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .ID, 2, 0) == 0); }