public static void Test2() { com.esri.core.geometry.MultiPoint multipoint = new com.esri.core.geometry.MultiPoint(); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { multipoint.Add(i, j); } } com.esri.core.geometry.Envelope2D extent = new com.esri.core.geometry.Envelope2D(); multipoint.QueryEnvelope2D(extent); com.esri.core.geometry.MultiPointImpl multipointImpl = (com.esri.core.geometry.MultiPointImpl)multipoint._getImpl(); com.esri.core.geometry.QuadTree quadtree = BuildQuadTree_(multipointImpl); com.esri.core.geometry.QuadTree.QuadTreeIterator qtIter = quadtree.GetIterator(); NUnit.Framework.Assert.IsTrue(qtIter.Next() == -1); int count = 0; qtIter.ResetIterator(extent, 0.0); while (qtIter.Next() != -1) { count++; } NUnit.Framework.Assert.IsTrue(count == 10000); }
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) { } }