public static void TestImportExportWktMultiPoint() { com.esri.core.geometry.OperatorImportFromWkt importerWKT = (com.esri.core.geometry.OperatorImportFromWkt)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ImportFromWkt); com.esri.core.geometry.OperatorExportToWkt exporterWKT = (com.esri.core.geometry.OperatorExportToWkt)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ExportToWkt); com.esri.core.geometry.MultiPoint multipoint; string wktString; com.esri.core.geometry.Envelope2D envelope = new com.esri.core.geometry.Envelope2D(); com.esri.core.geometry.WktParser wktParser = new com.esri.core.geometry.WktParser(); // Test Import from Multi_point wktString = " MultiPoint ZM empty"; multipoint = (com.esri.core.geometry.MultiPoint)(importerWKT.Execute(0, com.esri.core.geometry.Geometry.Type.Unknown, wktString, null)); NUnit.Framework.Assert.IsTrue(multipoint != null); NUnit.Framework.Assert.IsTrue(multipoint.IsEmpty()); 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)); wktString = exporterWKT.Execute(0, multipoint, null); NUnit.Framework.Assert.IsTrue(wktString.Equals("MULTIPOINT ZM EMPTY")); wktParser.ResetParser(wktString); while (wktParser.NextToken() != com.esri.core.geometry.WktParser.WktToken.not_available) { } wktString = exporterWKT.Execute(com.esri.core.geometry.WktExportFlags.wktExportPoint, multipoint, null); NUnit.Framework.Assert.IsTrue(wktString.Equals("POINT ZM EMPTY")); wktParser.ResetParser(wktString); while (wktParser.NextToken() != com.esri.core.geometry.WktParser.WktToken.not_available) { } multipoint = new com.esri.core.geometry.MultiPoint(); multipoint.Add(118.15114354234563, 33.82234433423462345); multipoint.Add(88, 88); wktString = exporterWKT.Execute(com.esri.core.geometry.WktExportFlags.wktExportPrecision10, multipoint, null); NUnit.Framework.Assert.IsTrue(wktString.Equals("MULTIPOINT ((118.1511435 33.82234433), (88 88))")); wktParser.ResetParser(wktString); while (wktParser.NextToken() != com.esri.core.geometry.WktParser.WktToken.not_available) { } multipoint = new com.esri.core.geometry.MultiPoint(); multipoint.Add(88, 2); multipoint.Add(88, 88); wktString = exporterWKT.Execute(0, multipoint, null); NUnit.Framework.Assert.IsTrue(wktString.Equals("MULTIPOINT ((88 2), (88 88))")); wktParser.ResetParser(wktString); while (wktParser.NextToken() != com.esri.core.geometry.WktParser.WktToken.not_available) { } wktString = "Multipoint zm (empty, empty, (10 88 88 33), (10 20 5 33), (20 20 5 33), (20 10 5 33), (12 12 3 33), empty, (10 10 1 33), (12 12 1 33), empty, (60 60 7 33), (60 90.1 7 33), (90 90 7 33), empty, (70 70 7 33), (70 80 7 33), (80 80 7 33), empty)"; multipoint = (com.esri.core.geometry.MultiPoint)(importerWKT.Execute(0, com.esri.core.geometry.Geometry.Type.Unknown, wktString, null)); NUnit.Framework.Assert.IsTrue(multipoint != null); multipoint.QueryEnvelope2D(envelope); // assertTrue(envelope.xmin == 10 && envelope.xmax == 90 && // envelope.ymin == 10 && Math.abs(envelope.ymax - 90.1) <= 0.001); NUnit.Framework.Assert.IsTrue(multipoint.GetPointCount() == 13); 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)); wktString = "Multipoint zm (10 88 88 33, 10 20 5 33, 20 20 5 33, 20 10 5 33, 12 12 3 33, 10 10 1 33, 12 12 1 33, 60 60 7 33, 60 90.1 7 33, 90 90 7 33, 70 70 7 33, 70 80 7 33, 80 80 7 33)"; multipoint = (com.esri.core.geometry.MultiPoint)(importerWKT.Execute(0, com.esri.core.geometry.Geometry.Type.Unknown, wktString, null)); NUnit.Framework.Assert.IsTrue(multipoint != null); // assertTrue(envelope.xmin == 10 && envelope.xmax == 90 && // envelope.ymin == 10 && ::fabs(envelope.ymax - 90.1) <= 0.001); NUnit.Framework.Assert.IsTrue(multipoint.GetPointCount() == 13); 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)); wktString = exporterWKT.Execute(com.esri.core.geometry.WktExportFlags.wktExportPrecision15, multipoint, null); NUnit.Framework.Assert.IsTrue(wktString.Equals("MULTIPOINT ZM ((10 88 88 33), (10 20 5 33), (20 20 5 33), (20 10 5 33), (12 12 3 33), (10 10 1 33), (12 12 1 33), (60 60 7 33), (60 90.1 7 33), (90 90 7 33), (70 70 7 33), (70 80 7 33), (80 80 7 33))")); wktParser.ResetParser(wktString); while (wktParser.NextToken() != com.esri.core.geometry.WktParser.WktToken.not_available) { } wktString = "Multipoint zm (empty, empty, (10 10 5 33))"; multipoint = (com.esri.core.geometry.MultiPoint)(importerWKT.Execute(0, com.esri.core.geometry.Geometry.Type.Unknown, wktString, null)); wktString = exporterWKT.Execute(com.esri.core.geometry.WktExportFlags.wktExportPoint, multipoint, null); NUnit.Framework.Assert.IsTrue(wktString.Equals("POINT ZM (10 10 5 33)")); wktParser.ResetParser(wktString); while (wktParser.NextToken() != com.esri.core.geometry.WktParser.WktToken.not_available) { } }
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); }