Example #1
0
		internal virtual com.epl.geometry.Geometry Intersect(com.epl.geometry.Geometry input_geom)
		{
			com.epl.geometry.Geometry dst_geom = TryNativeImplementation_(input_geom);
			if (dst_geom != null)
			{
				return dst_geom;
			}
			com.epl.geometry.Envelope2D commonExtent = com.epl.geometry.InternalUtils.GetMergedExtent(m_geomIntersector, input_geom);
			// return Topological_operations::intersection(input_geom,
			// m_geomIntersector, m_spatial_reference, m_progress_tracker);
			// Preprocess geometries to be clipped to the extent of intersection to
			// get rid of extra segments.
			double t = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(m_spatial_reference, commonExtent, true);
			com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
			m_geomIntersector.QueryEnvelope2D(env);
			com.epl.geometry.Envelope2D env1 = new com.epl.geometry.Envelope2D();
			input_geom.QueryEnvelope2D(env1);
			env.Inflate(2.0 * t, 2.0 * t);
			env.Intersect(env1);
			System.Diagnostics.Debug.Assert((!env.IsEmpty()));
			env.Inflate(100 * t, 100 * t);
			double tol = 0;
			com.epl.geometry.Geometry clippedIntersector = com.epl.geometry.Clipper.Clip(m_geomIntersector, env, tol, 0.0);
			com.epl.geometry.Geometry clippedInputGeom = com.epl.geometry.Clipper.Clip(input_geom, env, tol, 0.0);
			// perform the clip
			return com.epl.geometry.TopologicalOperations.Intersection(clippedInputGeom, clippedIntersector, m_spatial_reference, m_progress_tracker);
		}
        public virtual void TestBufferEnvelope()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Envelope         inputGeom = new com.epl.geometry.Envelope(1, 0, 200, 400);
            com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
            com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
            com.epl.geometry.Geometry         result    = buffer.Execute(inputGeom, sr, 40.0, null);
            NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
            com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - (80 + 199)) < 0.001 && System.Math.Abs(env2D.GetHeight() - (80 + 400)) < 0.001);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 201.0 / 2) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 400 / 2.0) < 0.001);
            int pathCount = poly.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.GetPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 104.0) < 10);
            com.epl.geometry.NonSimpleResult nsr = new com.epl.geometry.NonSimpleResult();
            NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, true, nsr, null));
            {
                result = buffer.Execute(inputGeom, sr, -200.0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -200.0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -199 / 2.0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -50.0, null);
                poly   = (com.epl.geometry.Polygon)(result);
                result.QueryEnvelope2D(env2D);
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - (199 - 100)) < 0.001 && System.Math.Abs(env2D.GetHeight() - (400 - 100)) < 0.001);
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 201.0 / 2) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 400 / 2.0) < 0.001);
                pathCount = poly.GetPathCount();
                NUnit.Framework.Assert.IsTrue(pathCount == 1);
                pointCount = poly.GetPointCount();
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 4.0) < 10);
                NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
            }
        }
        public virtual void TestBufferMultiPoint()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
            com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
            com.epl.geometry.MultiPoint       inputGeom = new com.epl.geometry.MultiPoint();
            inputGeom.Add(12, 120);
            inputGeom.Add(20, 120);
            com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null);
            NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
            com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80 - 8) < 0.001 && System.Math.Abs(env2D.GetHeight() - 80) < 0.001);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 16) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 120) < 0.001);
            int pathCount = poly.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.GetPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 108.0) < 10);
            NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
            {
                result = buffer.Execute(inputGeom, sr, 0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -1, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
        }
Example #4
0
		internal virtual com.epl.geometry.GeometryCursor IntersectEx(com.epl.geometry.Geometry input_geom)
		{
			System.Diagnostics.Debug.Assert((m_dimensionMask != -1));
			com.epl.geometry.Geometry dst_geom = TryNativeImplementation_(input_geom);
			if (dst_geom != null)
			{
				com.epl.geometry.Geometry[] res_vec = new com.epl.geometry.Geometry[3];
				res_vec[dst_geom.GetDimension()] = dst_geom;
				return PrepareVector_(input_geom.GetDescription(), m_dimensionMask, res_vec);
			}
			com.epl.geometry.Envelope2D commonExtent = com.epl.geometry.InternalUtils.GetMergedExtent(m_geomIntersector, input_geom);
			double t = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(m_spatial_reference, commonExtent, true);
			// Preprocess geometries to be clipped to the extent of intersection to
			// get rid of extra segments.
			com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
			m_geomIntersector.QueryEnvelope2D(env);
			env.Inflate(2 * t, 2 * t);
			com.epl.geometry.Envelope2D env1 = new com.epl.geometry.Envelope2D();
			input_geom.QueryEnvelope2D(env1);
			env.Intersect(env1);
			System.Diagnostics.Debug.Assert((!env.IsEmpty()));
			env.Inflate(100 * t, 100 * t);
			double tol = 0;
			com.epl.geometry.Geometry clippedIntersector = com.epl.geometry.Clipper.Clip(m_geomIntersector, env, tol, 0.0);
			com.epl.geometry.Geometry clippedInputGeom = com.epl.geometry.Clipper.Clip(input_geom, env, tol, 0.0);
			// perform the clip
			com.epl.geometry.Geometry[] res_vec_1;
			res_vec_1 = com.epl.geometry.TopologicalOperations.IntersectionEx(clippedInputGeom, clippedIntersector, m_spatial_reference, m_progress_tracker);
			return PrepareVector_(input_geom.GetDescription(), m_dimensionMask, res_vec_1);
		}
        internal static com.epl.geometry.Geometry PolylineMinusArea_(com.epl.geometry.Geometry geometry, com.epl.geometry.Geometry area, int area_type, com.epl.geometry.SpatialReference sr, com.epl.geometry.ProgressTracker progress_tracker)
        {
            // construct the complement of the Polygon (or Envelope)
            com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
            geometry.QueryEnvelope(envelope);
            com.epl.geometry.Envelope2D env_2D = new com.epl.geometry.Envelope2D();
            area.QueryEnvelope2D(env_2D);
            envelope.Merge(env_2D);
            double dw = 0.1 * envelope.GetWidth();
            double dh = 0.1 * envelope.GetHeight();

            envelope.Inflate(dw, dh);
            com.epl.geometry.Polygon complement = new com.epl.geometry.Polygon();
            complement.AddEnvelope(envelope, false);
            com.epl.geometry.MultiPathImpl complementImpl = (com.epl.geometry.MultiPathImpl)(complement._getImpl());
            if (area_type == com.epl.geometry.Geometry.GeometryType.Polygon)
            {
                com.epl.geometry.MultiPathImpl polygonImpl = (com.epl.geometry.MultiPathImpl)(area._getImpl());
                complementImpl.Add(polygonImpl, true);
            }
            else
            {
                complementImpl.AddEnvelope((com.epl.geometry.Envelope)(area), true);
            }
            com.epl.geometry.OperatorFactoryLocal projEnv = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorIntersection operatorIntersection = (com.epl.geometry.OperatorIntersection)projEnv.GetOperator(com.epl.geometry.Operator.Type.Intersection);
            com.epl.geometry.Geometry             difference           = operatorIntersection.Execute(geometry, complement, sr, progress_tracker);
            return(difference);
        }
Example #6
0
 internal virtual double Calculate(com.epl.geometry.Geometry geometryA, com.epl.geometry.Geometry geometryB)
 {
     /* const */
     /* const */
     if (geometryA.IsEmpty() || geometryB.IsEmpty())
     {
         return(com.epl.geometry.NumberUtils.TheNaN);
     }
     geometryA.QueryEnvelope2D(this.m_env2DgeometryA);
     geometryB.QueryEnvelope2D(this.m_env2DgeometryB);
     return(this.ExecuteBruteForce_(geometryA, geometryB));
 }
        internal static com.epl.geometry.Geometry SymmetricDifference(com.epl.geometry.Geometry geometry_a, com.epl.geometry.Geometry geometry_b, com.epl.geometry.SpatialReference spatial_reference, com.epl.geometry.ProgressTracker progress_tracker)
        {
            int dim_a = geometry_a.GetDimension();
            int dim_b = geometry_b.GetDimension();

            if (geometry_a.IsEmpty() && geometry_b.IsEmpty())
            {
                return(dim_a > dim_b ? geometry_a : geometry_b);
            }
            if (geometry_a.IsEmpty())
            {
                return(geometry_b);
            }
            if (geometry_b.IsEmpty())
            {
                return(geometry_a);
            }
            com.epl.geometry.Envelope2D env_a      = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D env_b      = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D env_merged = new com.epl.geometry.Envelope2D();
            geometry_a.QueryEnvelope2D(env_a);
            geometry_b.QueryEnvelope2D(env_b);
            env_merged.SetCoords(env_a);
            env_merged.Merge(env_b);
            double tolerance = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(spatial_reference, env_merged, false);
            int    type_a    = geometry_a.GetType().Value();
            int    type_b    = geometry_b.GetType().Value();

            if (type_a == com.epl.geometry.Geometry.GeometryType.Point && type_b == com.epl.geometry.Geometry.GeometryType.Point)
            {
                return(PointSymDiffPoint_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.Point)(geometry_b), tolerance, progress_tracker));
            }
            if (type_a != type_b)
            {
                if (dim_a > 0 || dim_b > 0)
                {
                    return(dim_a > dim_b ? geometry_a : geometry_b);
                }
                // Multi_point/Point case
                if (type_a == com.epl.geometry.Geometry.GeometryType.MultiPoint)
                {
                    return(MultiPointSymDiffPoint_((com.epl.geometry.MultiPoint)(geometry_a), (com.epl.geometry.Point)(geometry_b), tolerance, progress_tracker));
                }
                return(MultiPointSymDiffPoint_((com.epl.geometry.MultiPoint)(geometry_b), (com.epl.geometry.Point)(geometry_a), tolerance, progress_tracker));
            }
            return(com.epl.geometry.TopologicalOperations.SymmetricDifference(geometry_a, geometry_b, spatial_reference, progress_tracker));
        }
 internal static double CalculateToleranceFromGeometry(com.epl.geometry.SpatialReference sr, com.epl.geometry.Geometry geometry, bool bConservative)
 {
     com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
     geometry.QueryEnvelope2D(env2D);
     return(CalculateToleranceFromGeometry(sr, env2D, bConservative));
 }
 public virtual void TestBufferPolygon()
 {
     com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
     com.epl.geometry.Polygon          inputGeom = new com.epl.geometry.Polygon();
     com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
     com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
     inputGeom.StartPath(0, 0);
     inputGeom.LineTo(50, 50);
     inputGeom.LineTo(50, 0);
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         NUnit.Framework.Assert.IsTrue(result == inputGeom);
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 10, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 20 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 20 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 104.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         sr        = com.epl.geometry.SpatialReference.Create(4326);
         inputGeom = new com.epl.geometry.Polygon();
         inputGeom.StartPath(0, 0);
         inputGeom.LineTo(50, 50);
         inputGeom.LineTo(50, 0);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, -10, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 15.85) < 0.1 && System.Math.Abs(env2D.GetHeight() - 15.85) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 32.07) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 17.93) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(pointCount == 3);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         sr        = com.epl.geometry.SpatialReference.Create(4326);
         inputGeom = new com.epl.geometry.Polygon();
         inputGeom.StartPath(0, 0);
         inputGeom.LineTo(0, 50);
         inputGeom.LineTo(50, 50);
         inputGeom.LineTo(50, 0);
         inputGeom.StartPath(10, 10);
         inputGeom.LineTo(40, 10);
         inputGeom.LineTo(40, 40);
         inputGeom.LineTo(10, 40);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, -2, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() + 4 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() + 4 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 2);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 108) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
 }
 public virtual void TestBufferPolyline()
 {
     com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
     com.epl.geometry.Polyline         inputGeom = new com.epl.geometry.Polyline();
     com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
     com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
     inputGeom.StartPath(0, 0);
     inputGeom.LineTo(50, 50);
     inputGeom.LineTo(50, 0);
     inputGeom.LineTo(0, 50);
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         NUnit.Framework.Assert.IsTrue(result.IsEmpty());
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, -1, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         NUnit.Framework.Assert.IsTrue(result.IsEmpty());
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 80 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 171.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 4.0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 8 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 8 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 2);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 186.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         inputGeom = new com.epl.geometry.Polyline();
         inputGeom.StartPath(0, 0);
         inputGeom.LineTo(50, 50);
         inputGeom.StartPath(50, 0);
         inputGeom.LineTo(0, 50);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 4.0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 8 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 8 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 208.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         inputGeom = new com.epl.geometry.Polyline();
         inputGeom.StartPath(1.762614, 0.607368);
         inputGeom.LineTo(1.762414, 0.606655);
         inputGeom.LineTo(1.763006, 0.607034);
         inputGeom.LineTo(1.762548, 0.607135);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0.005, null);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
 }
Example #11
0
		internal virtual com.epl.geometry.Geometry TryNativeImplementation_(com.epl.geometry.Geometry input_geom)
		{
			// A note on attributes:
			// 1. The geometry with lower dimension wins in regard to the
			// attributes.
			// 2. If the dimensions are the same, the input_geometry attributes win.
			// 3. The exception to the 2. is when the input is an Envelope, and the
			// intersector is a polygon, then the intersector wins.
			// A note on the tolerance:
			// This operator performs a simple intersection operation. Should it use
			// the tolerance?
			// Example: Point is intersected by the envelope.
			// If it is slightly outside of the envelope, should we still return it
			// if it is closer than the tolerance?
			// Should we do crack and cluster and snap the point coordinates to the
			// envelope boundary?
			//
			// Consider floating point arithmetics approach. When you compare
			// doubles, you should use an epsilon (equals means ::fabs(a - b) <
			// eps), however when you add/subtract, etc them, you do not use
			// epsilon.
			// Shouldn't we do same here? Relational operators use tolerance, but
			// the action operators don't.
			com.epl.geometry.Envelope2D mergedExtent = com.epl.geometry.InternalUtils.GetMergedExtent(input_geom, m_geomIntersector);
			double tolerance = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(m_spatial_reference, mergedExtent, false);
			int gtInput = input_geom.GetType().Value();
			bool bInputEmpty = input_geom.IsEmpty();
			bool bGeomIntersectorEmpty = m_geomIntersector.IsEmpty();
			bool bResultIsEmpty = bInputEmpty || bGeomIntersectorEmpty;
			if (!bResultIsEmpty)
			{
				// test envelopes
				com.epl.geometry.Envelope2D env2D1 = new com.epl.geometry.Envelope2D();
				input_geom.QueryEnvelope2D(env2D1);
				com.epl.geometry.Envelope2D env2D2 = new com.epl.geometry.Envelope2D();
				m_geomIntersector.QueryEnvelope2D(env2D2);
				env2D2.Inflate(2.0 * tolerance, 2.0 * tolerance);
				bResultIsEmpty = !env2D1.IsIntersecting(env2D2);
			}
			if (!bResultIsEmpty)
			{
				// try accelerated test
				int res = com.epl.geometry.OperatorInternalRelationUtils.QuickTest2D_Accelerated_DisjointOrContains(m_geomIntersector, input_geom, tolerance);
				if (res == com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
				{
					// disjoint
					bResultIsEmpty = true;
				}
				else
				{
					if ((res & com.epl.geometry.OperatorInternalRelationUtils.Relation.Within) != 0)
					{
						// intersector
						// is
						// within
						// the
						// input_geom
						// TODO:
						// assign
						// input_geom
						// attributes
						// first
						return m_geomIntersector;
					}
					else
					{
						if ((res & com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains) != 0)
						{
							// intersector
							// contains
							// input_geom
							return input_geom;
						}
					}
				}
			}
			if (bResultIsEmpty)
			{
				// When one geometry or both are empty, we need to
				// return an empty geometry.
				// Here we do that end also ensure the type is
				// correct.
				// That is the lower dimension need to be
				// returned. Also, for Point vs Multi_point, an
				// empty Point need to be returned.
				int dim1 = com.epl.geometry.Geometry.GetDimensionFromType(gtInput);
				int dim2 = com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType);
				if (dim1 < dim2)
				{
					return ReturnEmpty_(input_geom, bInputEmpty);
				}
				else
				{
					if (dim1 > dim2)
					{
						return ReturnEmptyIntersector_();
					}
					else
					{
						if (dim1 == 0)
						{
							if (gtInput == com.epl.geometry.Geometry.GeometryType.MultiPoint && m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Point)
							{
								// point
								// vs
								// Multi_point
								// need
								// special
								// treatment
								// to
								// ensure
								// Point
								// is
								// returned
								// always.
								return ReturnEmptyIntersector_();
							}
							else
							{
								// Both input and intersector have same gtype, or input is
								// Point.
								return ReturnEmpty_(input_geom, bInputEmpty);
							}
						}
						else
						{
							return ReturnEmpty_(input_geom, bInputEmpty);
						}
					}
				}
			}
			// Note: No empty geometries after this point!
			// Warning: Do not try clip for polylines and polygons.
			// Try clip of Envelope with Envelope.
			if ((m_dimensionMask == -1 || m_dimensionMask == (1 << 2)) && gtInput == com.epl.geometry.Geometry.GeometryType.Envelope && m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Envelope)
			{
				com.epl.geometry.Envelope env1 = (com.epl.geometry.Envelope)input_geom;
				com.epl.geometry.Envelope env2 = (com.epl.geometry.Envelope)m_geomIntersector;
				com.epl.geometry.Envelope2D env2D_1 = new com.epl.geometry.Envelope2D();
				env1.QueryEnvelope2D(env2D_1);
				com.epl.geometry.Envelope2D env2D_2 = new com.epl.geometry.Envelope2D();
				env2.QueryEnvelope2D(env2D_2);
				env2D_1.Intersect(env2D_2);
				com.epl.geometry.Envelope result_env = new com.epl.geometry.Envelope();
				env1.CopyTo(result_env);
				result_env.SetEnvelope2D(env2D_1);
				return result_env;
			}
			// Use clip for Point and Multi_point with Envelope
			if ((gtInput == com.epl.geometry.Geometry.GeometryType.Envelope && com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType) == 0) || (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Envelope && com.epl.geometry.Geometry.GetDimensionFromType(gtInput
				) == 0))
			{
				com.epl.geometry.Envelope env = gtInput == com.epl.geometry.Geometry.GeometryType.Envelope ? (com.epl.geometry.Envelope)input_geom : (com.epl.geometry.Envelope)m_geomIntersector;
				com.epl.geometry.Geometry other = gtInput == com.epl.geometry.Geometry.GeometryType.Envelope ? m_geomIntersector : input_geom;
				com.epl.geometry.Envelope2D env_2D = new com.epl.geometry.Envelope2D();
				env.QueryEnvelope2D(env_2D);
				return com.epl.geometry.Clipper.Clip(other, env_2D, tolerance, 0);
			}
			if ((com.epl.geometry.Geometry.GetDimensionFromType(gtInput) == 0 && com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType) > 0) || (com.epl.geometry.Geometry.GetDimensionFromType(gtInput) > 0 && com.epl.geometry.Geometry.GetDimensionFromType(m_geomIntersectorType
				) == 0))
			{
				// multipoint
				// intersection
				double tolerance1 = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(m_spatial_reference, input_geom, false);
				if (gtInput == com.epl.geometry.Geometry.GeometryType.MultiPoint)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.MultiPoint)input_geom, m_geomIntersector, tolerance1);
				}
				if (gtInput == com.epl.geometry.Geometry.GeometryType.Point)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.Point)input_geom, m_geomIntersector, tolerance1);
				}
				if (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.MultiPoint)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.MultiPoint)m_geomIntersector, input_geom, tolerance1);
				}
				if (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Point)
				{
					return com.epl.geometry.TopologicalOperations.Intersection((com.epl.geometry.Point)m_geomIntersector, input_geom, tolerance1);
				}
				throw com.epl.geometry.GeometryException.GeometryInternalError();
			}
			// Try Polyline vs Polygon
			if ((m_dimensionMask == -1 || m_dimensionMask == (1 << 1)) && (gtInput == com.epl.geometry.Geometry.GeometryType.Polyline) && (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Polygon))
			{
				return TryFastIntersectPolylinePolygon_((com.epl.geometry.Polyline)(input_geom), (com.epl.geometry.Polygon)(m_geomIntersector));
			}
			// Try Polygon vs Polyline
			if ((m_dimensionMask == -1 || m_dimensionMask == (1 << 1)) && (gtInput == com.epl.geometry.Geometry.GeometryType.Polygon) && (m_geomIntersectorType == com.epl.geometry.Geometry.GeometryType.Polyline))
			{
				return TryFastIntersectPolylinePolygon_((com.epl.geometry.Polyline)(m_geomIntersector), (com.epl.geometry.Polygon)(input_geom));
			}
			return null;
		}
Example #12
0
        /// <summary>Performs the Distance operation on two geometries</summary>
        /// <returns>Returns a double.</returns>
        public override double Execute(com.epl.geometry.Geometry geom1, com.epl.geometry.Geometry geom2, com.epl.geometry.ProgressTracker progressTracker)
        {
            if (null == geom1 || null == geom2)
            {
                throw new System.ArgumentException();
            }
            com.epl.geometry.Geometry geometryA = geom1;
            com.epl.geometry.Geometry geometryB = geom2;
            if (geometryA.IsEmpty() || geometryB.IsEmpty())
            {
                return(com.epl.geometry.NumberUtils.TheNaN);
            }
            com.epl.geometry.Polygon    polygonA;
            com.epl.geometry.Polygon    polygonB;
            com.epl.geometry.MultiPoint multiPointA;
            com.epl.geometry.MultiPoint multiPointB;
            // if geometryA is an envelope use a polygon instead (if geom1 was
            // folded, then geometryA will already be a polygon)
            // if geometryA is a point use a multipoint instead
            com.epl.geometry.Geometry.Type gtA = geometryA.GetType();
            com.epl.geometry.Geometry.Type gtB = geometryB.GetType();
            if (gtA == com.epl.geometry.Geometry.Type.Point)
            {
                if (gtB == com.epl.geometry.Geometry.Type.Point)
                {
                    return(com.epl.geometry.Point2D.Distance(((com.epl.geometry.Point)geometryA).GetXY(), ((com.epl.geometry.Point)geometryB).GetXY()));
                }
                else
                {
                    if (gtB == com.epl.geometry.Geometry.Type.Envelope)
                    {
                        com.epl.geometry.Envelope2D envB = new com.epl.geometry.Envelope2D();
                        geometryB.QueryEnvelope2D(envB);
                        return(envB.Distance(((com.epl.geometry.Point)geometryA).GetXY()));
                    }
                }
                multiPointA = new com.epl.geometry.MultiPoint();
                multiPointA.Add((com.epl.geometry.Point)geometryA);
                geometryA = multiPointA;
            }
            else
            {
                if (gtA == com.epl.geometry.Geometry.Type.Envelope)
                {
                    if (gtB == com.epl.geometry.Geometry.Type.Envelope)
                    {
                        com.epl.geometry.Envelope2D envA = new com.epl.geometry.Envelope2D();
                        geometryA.QueryEnvelope2D(envA);
                        com.epl.geometry.Envelope2D envB = new com.epl.geometry.Envelope2D();
                        geometryB.QueryEnvelope2D(envB);
                        return(envB.Distance(envA));
                    }
                    polygonA = new com.epl.geometry.Polygon();
                    polygonA.AddEnvelope((com.epl.geometry.Envelope)geometryA, false);
                    geometryA = polygonA;
                }
            }
            // if geom_2 is an envelope use a polygon instead
            // if geom_2 is a point use a multipoint instead
            if (gtB == com.epl.geometry.Geometry.Type.Point)
            {
                multiPointB = new com.epl.geometry.MultiPoint();
                multiPointB.Add((com.epl.geometry.Point)geometryB);
                geometryB = multiPointB;
            }
            else
            {
                if (gtB == com.epl.geometry.Geometry.Type.Envelope)
                {
                    polygonB = new com.epl.geometry.Polygon();
                    polygonB.AddEnvelope((com.epl.geometry.Envelope)geometryB, false);
                    geometryB = polygonB;
                }
            }
            com.epl.geometry.OperatorDistanceLocal.DistanceCalculator distanceCalculator = new com.epl.geometry.OperatorDistanceLocal.DistanceCalculator(this, progressTracker);
            double distance = distanceCalculator.Calculate(geometryA, geometryB);

            return(distance);
        }
        internal static com.epl.geometry.Geometry Difference(com.epl.geometry.Geometry geometry_a, com.epl.geometry.Geometry geometry_b, com.epl.geometry.SpatialReference spatial_reference, com.epl.geometry.ProgressTracker progress_tracker)
        {
            if (geometry_a.IsEmpty() || geometry_b.IsEmpty())
            {
                return(geometry_a);
            }
            int dimension_a = geometry_a.GetDimension();
            int dimension_b = geometry_b.GetDimension();

            if (dimension_a > dimension_b)
            {
                return(geometry_a);
            }
            int type_a = geometry_a.GetType().Value();
            int type_b = geometry_b.GetType().Value();

            com.epl.geometry.Envelope2D env_a      = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D env_b      = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D env_merged = new com.epl.geometry.Envelope2D();
            geometry_a.QueryEnvelope2D(env_a);
            geometry_b.QueryEnvelope2D(env_b);
            env_merged.SetCoords(env_a);
            env_merged.Merge(env_b);
            double tolerance         = com.epl.geometry.InternalUtils.CalculateToleranceFromGeometry(spatial_reference, env_merged, false);
            double tolerance_cluster = tolerance * System.Math.Sqrt(2.0) * 1.00001;

            com.epl.geometry.Envelope2D env_a_inflated = new com.epl.geometry.Envelope2D();
            env_a_inflated.SetCoords(env_a);
            env_a_inflated.Inflate(tolerance_cluster, tolerance_cluster);
            // inflate
            // by
            // cluster
            // tolerance
            if (!env_a_inflated.IsIntersecting(env_b))
            {
                return(geometry_a);
            }
            if (dimension_a == 1 && dimension_b == 2)
            {
                return(PolylineMinusArea_(geometry_a, geometry_b, type_b, spatial_reference, progress_tracker));
            }
            if (type_a == com.epl.geometry.Geometry.GeometryType.Point)
            {
                com.epl.geometry.Geometry geometry_b_;
                if (com.epl.geometry.MultiPath.IsSegment(type_b))
                {
                    geometry_b_ = new com.epl.geometry.Polyline(geometry_b.GetDescription());
                    ((com.epl.geometry.Polyline)(geometry_b_)).AddSegment((com.epl.geometry.Segment)(geometry_b), true);
                }
                else
                {
                    geometry_b_ = geometry_b;
                }
                switch (type_b)
                {
                case com.epl.geometry.Geometry.GeometryType.Polygon:
                {
                    return(PointMinusPolygon_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.Polygon)(geometry_b_), tolerance, progress_tracker));
                }

                case com.epl.geometry.Geometry.GeometryType.Polyline:
                {
                    return(PointMinusPolyline_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.Polyline)(geometry_b_), tolerance, progress_tracker));
                }

                case com.epl.geometry.Geometry.GeometryType.MultiPoint:
                {
                    return(PointMinusMultiPoint_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.MultiPoint)(geometry_b_), tolerance, progress_tracker));
                }

                case com.epl.geometry.Geometry.GeometryType.Envelope:
                {
                    return(PointMinusEnvelope_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.Envelope)(geometry_b_), tolerance, progress_tracker));
                }

                case com.epl.geometry.Geometry.GeometryType.Point:
                {
                    return(PointMinusPoint_((com.epl.geometry.Point)(geometry_a), (com.epl.geometry.Point)(geometry_b_), tolerance, progress_tracker));
                }

                default:
                {
                    throw new System.ArgumentException();
                }
                }
            }
            else
            {
                if (type_a == com.epl.geometry.Geometry.GeometryType.MultiPoint)
                {
                    switch (type_b)
                    {
                    case com.epl.geometry.Geometry.GeometryType.Polygon:
                    {
                        return(MultiPointMinusPolygon_((com.epl.geometry.MultiPoint)(geometry_a), (com.epl.geometry.Polygon)(geometry_b), tolerance, progress_tracker));
                    }

                    case com.epl.geometry.Geometry.GeometryType.Envelope:
                    {
                        return(MultiPointMinusEnvelope_((com.epl.geometry.MultiPoint)(geometry_a), (com.epl.geometry.Envelope)(geometry_b), tolerance, progress_tracker));
                    }

                    case com.epl.geometry.Geometry.GeometryType.Point:
                    {
                        return(MultiPointMinusPoint_((com.epl.geometry.MultiPoint)(geometry_a), (com.epl.geometry.Point)(geometry_b), tolerance, progress_tracker));
                    }

                    default:
                    {
                        break;
                    }
                    }
                }
            }
            return(com.epl.geometry.TopologicalOperations.Difference(geometry_a, geometry_b, spatial_reference, progress_tracker));
        }
        public static int QuickTest2D_Accelerated_DisjointOrContains(com.epl.geometry.Geometry geomA, com.epl.geometry.Geometry geomB, double tolerance)
        {
            int gtA = geomA.GetType().Value();
            int gtB = geomB.GetType().Value();

            com.epl.geometry.GeometryAccelerators accel;
            bool endWhileStatement = false;

            do
            {
                if (com.epl.geometry.Geometry.IsMultiVertex(gtA))
                {
                    com.epl.geometry.MultiVertexGeometryImpl impl = (com.epl.geometry.MultiVertexGeometryImpl)geomA._getImpl();
                    accel = impl._getAccelerators();
                    if (accel != null)
                    {
                        com.epl.geometry.RasterizedGeometry2D rgeom = accel.GetRasterizedGeometry();
                        if (rgeom != null)
                        {
                            if (gtB == com.epl.geometry.Geometry.GeometryType.Point)
                            {
                                com.epl.geometry.Point2D ptB = ((com.epl.geometry.Point)geomB).GetXY();
                                com.epl.geometry.RasterizedGeometry2D.HitType hit = rgeom.QueryPointInGeometry(ptB.x, ptB.y);
                                if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Inside)
                                {
                                    return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
                                }
                                else
                                {
                                    if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                                    {
                                        return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
                                    }
                                }
                                break;
                            }
                            com.epl.geometry.Envelope2D envB = new com.epl.geometry.Envelope2D();
                            geomB.QueryEnvelope2D(envB);
                            com.epl.geometry.RasterizedGeometry2D.HitType hit_1 = rgeom.QueryEnvelopeInGeometry(envB);
                            if (hit_1 == com.epl.geometry.RasterizedGeometry2D.HitType.Inside)
                            {
                                return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
                            }
                            else
                            {
                                if (hit_1 == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                                {
                                    return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
                                }
                            }
                            break;
                        }
                    }
                }
            }while (endWhileStatement);
            accel = null;
            do
            {
                if (com.epl.geometry.Geometry.IsMultiVertex(gtB))
                {
                    com.epl.geometry.MultiVertexGeometryImpl impl = (com.epl.geometry.MultiVertexGeometryImpl)geomB._getImpl();
                    accel = impl._getAccelerators();
                    if (accel != null)
                    {
                        com.epl.geometry.RasterizedGeometry2D rgeom = accel.GetRasterizedGeometry();
                        if (rgeom != null)
                        {
                            if (gtA == com.epl.geometry.Geometry.GeometryType.Point)
                            {
                                com.epl.geometry.Point2D ptA = ((com.epl.geometry.Point)geomA).GetXY();
                                com.epl.geometry.RasterizedGeometry2D.HitType hit = rgeom.QueryPointInGeometry(ptA.x, ptA.y);
                                if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Inside)
                                {
                                    return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Within);
                                }
                                else
                                {
                                    if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                                    {
                                        return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
                                    }
                                }
                                break;
                            }
                            com.epl.geometry.Envelope2D envA = new com.epl.geometry.Envelope2D();
                            geomA.QueryEnvelope2D(envA);
                            com.epl.geometry.RasterizedGeometry2D.HitType hit_1 = rgeom.QueryEnvelopeInGeometry(envA);
                            if (hit_1 == com.epl.geometry.RasterizedGeometry2D.HitType.Inside)
                            {
                                return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Within);
                            }
                            else
                            {
                                if (hit_1 == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                                {
                                    return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
                                }
                            }
                            break;
                        }
                    }
                }
            }while (endWhileStatement);
            return(0);
        }