コード例 #1
0
		public virtual void TestMultipoint()
		{
			com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon();
			com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(855277, 3892059, 855277 + 100, 3892059 + 100);
			poly1.AddEnvelope(env1, false);
			com.esri.core.geometry.MultiPoint multiPoint = new com.esri.core.geometry.MultiPoint();
			multiPoint.Add(855277 + 10, 3892059 + 10);
			multiPoint.Add(855277, 3892059);
			multiPoint.Add(855277 + 100, 3892059 + 100);
			multiPoint.Add(855277 + 100, 3892059 + 101);
			multiPoint.Add(855277 + 101, 3892059 + 100);
			multiPoint.Add(855277 + 101, 3892059 + 101);
			com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection);
			com.esri.core.geometry.MultiPoint mpResult = (com.esri.core.geometry.MultiPoint)operatorIntersection.Execute(poly1, multiPoint, inputSR, null);
			NUnit.Framework.Assert.IsTrue(mpResult.GetPointCount() == 3);
			NUnit.Framework.Assert.IsTrue(mpResult.GetPoint(0).GetX() == 855277 + 10 && mpResult.GetPoint(0).GetY() == 3892059 + 10);
			NUnit.Framework.Assert.IsTrue(mpResult.GetPoint(1).GetX() == 855277 && mpResult.GetPoint(1).GetY() == 3892059);
			NUnit.Framework.Assert.IsTrue(mpResult.GetPoint(2).GetX() == 855277 + 100 && mpResult.GetPoint(2).GetY() == 3892059 + 100);
			// Test intersection of Polygon with Envelope (calls Clip)
			com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
			poly.StartPath(0, 0);
			poly.LineTo(10, 10);
			poly.LineTo(20, 0);
			env1.SetXMin(0);
			env1.SetXMax(20);
			env1.SetYMin(5);
			env1.SetYMax(15);
			com.esri.core.geometry.Envelope envelope1 = env1;
			com.esri.core.geometry.Polygon clippedPoly = (com.esri.core.geometry.Polygon)operatorIntersection.Execute(poly, envelope1, inputSR, null);
			double area = clippedPoly.CalculateArea2D();
			NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 25) < 0.00001);
			// Geometry res = GeometryEngine.difference(poly, envelope1, inputSR);
			com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(855277 + 1, 3892059 + 1, 855277 + 30, 3892059 + 20);
			env2.SetXMin(5);
			env2.SetXMax(10);
			env2.SetYMin(0);
			env2.SetYMax(20);
			com.esri.core.geometry.Envelope envelope2 = env2;
			com.esri.core.geometry.Envelope clippedEnvelope = (com.esri.core.geometry.Envelope)operatorIntersection.Execute(envelope1, envelope2, inputSR, null);
			area = clippedEnvelope.CalculateArea2D();
			NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 50) < 0.00001);
		}