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);
        }
        // Tests if Ring1 is inside Ring2.
        // We assume here that the Polygon is Weak Simple. That is if one point of
        // Ring1 is found to be inside of Ring2, then
        // we assume that all of Ring1 is inside Ring2.
        internal static bool _isRingInRing2D(com.epl.geometry.MultiPath polygon, int iRing1, int iRing2, double tolerance, com.epl.geometry.QuadTree quadTree)
        {
            com.epl.geometry.MultiPathImpl       polygonImpl = (com.epl.geometry.MultiPathImpl)polygon._getImpl();
            com.epl.geometry.SegmentIteratorImpl segIter     = polygonImpl.QuerySegmentIterator();
            segIter.ResetToPath(iRing1);
            if (!segIter.NextPath() || !segIter.HasNextSegment())
            {
                throw new com.epl.geometry.GeometryException("corrupted geometry");
            }
            int res = 2;

            while (res == 2 && segIter.HasNextSegment())
            {
                com.epl.geometry.Segment segment = segIter.NextSegment();
                com.epl.geometry.Point2D point   = segment.GetCoord2D(0.5);
                res = com.epl.geometry.PointInPolygonHelper.IsPointInRing(polygonImpl, iRing2, point, tolerance, quadTree);
            }
            if (res == 2)
            {
                throw com.epl.geometry.GeometryException.GeometryInternalError();
            }
            if (res == 1)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 /// <summary>Creates a polygon.</summary>
 public Polygon()
 {
     // TODO:remove as we use
     // writeReplace and
     // GeometrySerializer
     m_impl = new com.epl.geometry.MultiPathImpl(true);
 }
        private static int _isPointInPolygonInternalWithQuadTree(com.epl.geometry.Polygon inputPolygon, com.epl.geometry.QuadTreeImpl quadTree, com.epl.geometry.Point2D inputPoint, double tolerance)
        {
            com.epl.geometry.Envelope2D envPoly = new com.epl.geometry.Envelope2D();
            inputPolygon.QueryLooseEnvelope(envPoly);
            envPoly.Inflate(tolerance, tolerance);
            bool bAltenate = inputPolygon.GetFillRule() == com.epl.geometry.Polygon.FillRule.enumFillRuleOddEven;

            com.epl.geometry.PointInPolygonHelper helper   = new com.epl.geometry.PointInPolygonHelper(bAltenate, inputPoint, tolerance);
            com.epl.geometry.MultiPathImpl        mpImpl   = (com.epl.geometry.MultiPathImpl)inputPolygon._getImpl();
            com.epl.geometry.SegmentIteratorImpl  iter     = mpImpl.QuerySegmentIterator();
            com.epl.geometry.Envelope2D           queryEnv = new com.epl.geometry.Envelope2D();
            queryEnv.SetCoords(envPoly);
            queryEnv.xmax = inputPoint.x + tolerance;
            // no need to query segments to
            // the right of the point.
            // Only segments to the left
            // matter.
            queryEnv.ymin = inputPoint.y - tolerance;
            queryEnv.ymax = inputPoint.y + tolerance;
            com.epl.geometry.QuadTreeImpl.QuadTreeIteratorImpl qiter = quadTree.GetIterator(queryEnv, tolerance);
            for (int qhandle = qiter.Next(); qhandle != -1; qhandle = qiter.Next())
            {
                iter.ResetToVertex(quadTree.GetElement(qhandle));
                if (iter.HasNextSegment())
                {
                    com.epl.geometry.Segment segment = iter.NextSegment();
                    if (helper.ProcessSegment(segment))
                    {
                        return(-1);
                    }
                }
            }
            // point on boundary
            return(helper.Result());
        }
Ejemplo n.º 5
0
 /// <exception cref="java.io.ObjectStreamException"/>
 public virtual void SetGeometryByValue(com.epl.geometry.Geometry geometry)
 {
     try
     {
         esriShape    = com.epl.geometry.GeometryEngine.GeometryToEsriShape(geometry);
         geometryType = geometry.GetType().Value();
         if (com.epl.geometry.Geometry.IsMultiVertex(geometryType))
         {
             com.epl.geometry.MultiVertexGeometryImpl mvImpl = (com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl();
             tolerance  = mvImpl.m_simpleTolerance;
             simpleFlag = mvImpl.GetIsSimple(0);
             if (!geometry.IsEmpty() && com.epl.geometry.Geometry.IsMultiPath(geometryType))
             {
                 com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)geometry._getImpl();
                 ogcFlags = new bool[mpImpl.GetPathCount()];
                 com.epl.geometry.AttributeStreamOfInt8 pathFlags = mpImpl.GetPathFlagsStreamRef();
                 for (int i = 0, n = mpImpl.GetPathCount(); i < n; i++)
                 {
                     ogcFlags[i] = (pathFlags.Read(i) & unchecked ((byte)com.epl.geometry.PathFlags.enumOGCStartPolygon)) != 0;
                 }
             }
         }
     }
     catch (System.Exception)
     {
         throw new System.IO.InvalidDataException("Cannot serialize this geometry");
     }
 }
        private static int QuickTest2DPolylinePoint(com.epl.geometry.Polyline geomA, com.epl.geometry.Point2D ptB, double tolerance, int testType)
        {
            int mask = com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches | com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains | com.epl.geometry.OperatorInternalRelationUtils.Relation.Within | com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint | com.epl.geometry.OperatorInternalRelationUtils.Relation
                       .Intersects;

            if ((testType & mask) == 0)
            {
                return(com.epl.geometry.OperatorInternalRelationUtils.Relation.NoThisRelation);
            }
            int res = QuickTest2DMVPointRasterOnly(geomA, ptB, tolerance);

            if (res > 0)
            {
                return(res);
            }
            // Go through the segments:
            double toleranceSqr = tolerance * tolerance;

            com.epl.geometry.MultiPathImpl       mpImpl = (com.epl.geometry.MultiPathImpl)geomA._getImpl();
            com.epl.geometry.SegmentIteratorImpl iter   = mpImpl.QuerySegmentIterator();
            while (iter.NextPath())
            {
                int pathIndex = iter.GetPathIndex();
                if (!geomA.IsClosedPath(pathIndex))
                {
                    int pathSize  = geomA.GetPathSize(pathIndex);
                    int pathStart = geomA.GetPathStart(pathIndex);
                    if (pathSize == 0)
                    {
                        continue;
                    }
                    if (com.epl.geometry.Point2D.SqrDistance(geomA.GetXY(pathStart), ptB) <= toleranceSqr || (pathSize > 1 && com.epl.geometry.Point2D.SqrDistance(geomA.GetXY(pathStart + pathSize - 1), ptB) <= toleranceSqr))
                    {
                        return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches);
                    }
                }
                if (testType != com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches)
                {
                    while (iter.HasNextSegment())
                    {
                        com.epl.geometry.Segment segment = iter.NextSegment();
                        double t = segment.GetClosestCoordinate(ptB, false);
                        com.epl.geometry.Point2D pt = segment.GetCoord2D(t);
                        if (com.epl.geometry.Point2D.SqrDistance(pt, ptB) <= toleranceSqr)
                        {
                            if ((testType & com.epl.geometry.OperatorInternalRelationUtils.Relation.IntersectsOrDisjoint) != 0)
                            {
                                return(com.epl.geometry.OperatorInternalRelationUtils.Relation.Intersects);
                            }
                            return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
                        }
                    }
                }
            }
            return((testType & com.epl.geometry.OperatorInternalRelationUtils.Relation.IntersectsOrDisjoint) != 0 ? com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint : com.epl.geometry.OperatorInternalRelationUtils.Relation.NoThisRelation);
        }
Ejemplo n.º 7
0
        internal static void TestPointsOnPolyline2D_(com.epl.geometry.Polyline poly, com.epl.geometry.Point2D[] input_points, int count, double tolerance, com.epl.geometry.PolygonUtils.PiPResult[] test_results)
        {
            com.epl.geometry.MultiPathImpl        mp_impl = (com.epl.geometry.MultiPathImpl)poly._getImpl();
            com.epl.geometry.GeometryAccelerators accel   = mp_impl._getAccelerators();
            com.epl.geometry.RasterizedGeometry2D rgeom   = null;
            if (accel != null)
            {
                rgeom = accel.GetRasterizedGeometry();
            }
            int pointsLeft = count;

            for (int i = 0; i < count; i++)
            {
                test_results[i] = com.epl.geometry.PolygonUtils.PiPResult.PiPInside;
                // set to impossible value
                if (rgeom != null)
                {
                    com.epl.geometry.Point2D input_point = input_points[i];
                    com.epl.geometry.RasterizedGeometry2D.HitType hit = rgeom.QueryPointInGeometry(input_point.x, input_point.y);
                    if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                    {
                        test_results[i] = com.epl.geometry.PolygonUtils.PiPResult.PiPOutside;
                        pointsLeft--;
                    }
                }
            }
            if (pointsLeft != 0)
            {
                com.epl.geometry.SegmentIteratorImpl iter = mp_impl.QuerySegmentIterator();
                while (iter.NextPath() && pointsLeft != 0)
                {
                    while (iter.HasNextSegment() && pointsLeft != 0)
                    {
                        com.epl.geometry.Segment segment = iter.NextSegment();
                        for (int i_1 = 0; i_1 < count && pointsLeft != 0; i_1++)
                        {
                            if (test_results[i_1] == com.epl.geometry.PolygonUtils.PiPResult.PiPInside)
                            {
                                if (segment.IsIntersecting(input_points[i_1], tolerance))
                                {
                                    test_results[i_1] = com.epl.geometry.PolygonUtils.PiPResult.PiPBoundary;
                                    pointsLeft--;
                                }
                            }
                        }
                    }
                }
            }
            for (int i_2 = 0; i_2 < count; i_2++)
            {
                if (test_results[i_2] == com.epl.geometry.PolygonUtils.PiPResult.PiPInside)
                {
                    test_results[i_2] = com.epl.geometry.PolygonUtils.PiPResult.PiPOutside;
                }
            }
        }
Ejemplo n.º 8
0
        // Mirrors wkt
        private static void ExportPolylineToGeoJson_(int export_flags, com.epl.geometry.Polyline polyline, com.epl.geometry.JsonWriter json_writer)
        {
            com.epl.geometry.MultiPathImpl polyline_impl = (com.epl.geometry.MultiPathImpl)polyline._getImpl();
            int point_count = polyline_impl.GetPointCount();
            int path_count  = polyline_impl.GetPathCount();

            if (point_count > 0 && path_count == 0)
            {
                throw new com.epl.geometry.GeometryException("corrupted geometry");
            }
            int  precision   = 17 - (31 & (export_flags >> 13));
            bool bFixedPoint = (com.epl.geometry.GeoJsonExportFlags.geoJsonExportPrecisionFixedPoint & export_flags) != 0;
            bool b_export_zs = polyline_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0;
            bool b_export_ms = polyline_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripMs) == 0;

            if (!b_export_zs && b_export_ms)
            {
                throw new System.ArgumentException("invalid argument");
            }
            com.epl.geometry.AttributeStreamOfDbl   position   = null;
            com.epl.geometry.AttributeStreamOfDbl   zs         = null;
            com.epl.geometry.AttributeStreamOfDbl   ms         = null;
            com.epl.geometry.AttributeStreamOfInt8  path_flags = null;
            com.epl.geometry.AttributeStreamOfInt32 paths      = null;
            if (point_count > 0)
            {
                position   = (com.epl.geometry.AttributeStreamOfDbl)polyline_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION);
                path_flags = polyline_impl.GetPathFlagsStreamRef();
                paths      = polyline_impl.GetPathStreamRef();
                if (b_export_zs)
                {
                    if (polyline_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z))
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)polyline_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                    }
                }
                if (b_export_ms)
                {
                    if (polyline_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M))
                    {
                        ms = (com.epl.geometry.AttributeStreamOfDbl)polyline_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                    }
                }
            }
            if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportPreferMultiGeometry) == 0 && path_count <= 1)
            {
                LineStringTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, json_writer);
            }
            else
            {
                MultiLineStringTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, path_count, json_writer);
            }
        }
        public static int IsPointInAnyOuterRing(com.epl.geometry.Polygon inputPolygon, com.epl.geometry.Point2D inputPoint, double tolerance)
        {
            com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
            inputPolygon.QueryLooseEnvelope(env);
            env.Inflate(tolerance, tolerance);
            if (!env.Contains(inputPoint))
            {
                return(0);
            }
            // Note:
            // Wolfgang had noted that this could be optimized if the exterior rings
            // have positive area:
            // Only test the positive rings and bail out immediately when in a
            // positive ring.
            // The worst case complexity is still O(n), but on average for polygons
            // with holes, that would be faster.
            // However, that method would not work if polygon is reversed, while the
            // one here works fine same as PointInPolygon.
            bool bAltenate = false;

            // use winding in this test
            com.epl.geometry.PointInPolygonHelper helper = new com.epl.geometry.PointInPolygonHelper(bAltenate, inputPoint, tolerance);
            com.epl.geometry.MultiPathImpl        mpImpl = (com.epl.geometry.MultiPathImpl)inputPolygon._getImpl();
            com.epl.geometry.SegmentIteratorImpl  iter   = mpImpl.QuerySegmentIterator();
            while (iter.NextPath())
            {
                double ringArea = mpImpl.CalculateRingArea2D(iter.GetPathIndex());
                bool   bIsHole  = ringArea < 0;
                if (!bIsHole)
                {
                    helper.m_windnum = 0;
                    while (iter.HasNextSegment())
                    {
                        com.epl.geometry.Segment segment = iter.NextSegment();
                        if (helper.ProcessSegment(segment))
                        {
                            return(-1);
                        }
                    }
                    // point on boundary
                    if (helper.m_windnum != 0)
                    {
                        return(1);
                    }
                }
            }
            return(helper.Result());
        }
Ejemplo n.º 10
0
        /// <summary>Tests if Point is inside the Polygon's ring.</summary>
        /// <remarks>
        /// Tests if Point is inside the Polygon's ring. Returns PiPOutside if not in
        /// ring, PiPInside if in the ring, PiPBoundary is if on the border. It tests
        /// border only if the tolerance is greater than 0, otherwise PiPBoundary cannot be
        /// returned. Note: If the tolerance is not 0, the test is more expensive
        /// because it calculates closest distance from a point to each segment.
        /// O(n) complexity, where n is the number of ring segments.
        /// </remarks>
        public static com.epl.geometry.PolygonUtils.PiPResult IsPointInRing2D(com.epl.geometry.Polygon polygon, int iRing, com.epl.geometry.Point2D inputPoint, double tolerance)
        {
            com.epl.geometry.MultiPathImpl polygonImpl = (com.epl.geometry.MultiPathImpl)polygon._getImpl();
            int res = com.epl.geometry.PointInPolygonHelper.IsPointInRing(polygonImpl, iRing, inputPoint, tolerance, null);

            if (res == 0)
            {
                return(com.epl.geometry.PolygonUtils.PiPResult.PiPOutside);
            }
            if (res == 1)
            {
                return(com.epl.geometry.PolygonUtils.PiPResult.PiPInside);
            }
            // return PiPResult.PiPBoundary;
            return(com.epl.geometry.PolygonUtils.PiPResult.PiPInside);
        }
Ejemplo n.º 11
0
 public SegmentIteratorImpl(com.epl.geometry.MultiPathImpl parent)
 {
     // Bezier m_bezier:
     // Arc m_arc;
     // parent of the iterator.
     // If true, the iterator circulates around
     // the current Path.
     m_currentSegmentIndex = -1;
     m_nextSegmentIndex    = 0;
     m_nextPathIndex       = 0;
     m_currentPathIndex    = -1;
     m_parent         = parent;
     m_segmentCount   = _getSegmentCount(m_nextPathIndex);
     m_bCirculator    = false;
     m_currentSegment = null;
     m_pathBegin      = -1;
     m_dummyPoint     = new com.epl.geometry.Point2D();
 }
Ejemplo n.º 12
0
        public SegmentIteratorImpl(com.epl.geometry.MultiPathImpl parent, int pointIndex)
        {
            if (pointIndex < 0 || pointIndex >= parent.GetPointCount())
            {
                throw new System.IndexOutOfRangeException();
            }
            m_currentSegmentIndex = -1;
            int path = parent.GetPathIndexFromPointIndex(pointIndex);

            m_nextSegmentIndex = pointIndex - parent.GetPathStart(path);
            m_nextPathIndex    = path + 1;
            m_currentPathIndex = path;
            m_parent           = parent;
            m_segmentCount     = _getSegmentCount(m_currentPathIndex);
            m_bCirculator      = false;
            m_currentSegment   = null;
            m_pathBegin        = m_parent.GetPathStart(m_currentPathIndex);
            m_dummyPoint       = new com.epl.geometry.Point2D();
        }
 public static int IsPointInPolygon(com.epl.geometry.Polygon inputPolygon, com.epl.geometry.Point2D inputPoint, double tolerance)
 {
     if (inputPolygon.IsEmpty())
     {
         return(0);
     }
     com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
     inputPolygon.QueryLooseEnvelope(env);
     env.Inflate(tolerance, tolerance);
     if (!env.Contains(inputPoint))
     {
         return(0);
     }
     com.epl.geometry.MultiPathImpl        mpImpl = (com.epl.geometry.MultiPathImpl)inputPolygon._getImpl();
     com.epl.geometry.GeometryAccelerators accel  = mpImpl._getAccelerators();
     if (accel != null)
     {
         // geometry has spatial indices built. Try using them.
         com.epl.geometry.RasterizedGeometry2D rgeom = accel.GetRasterizedGeometry();
         if (rgeom != null)
         {
             com.epl.geometry.RasterizedGeometry2D.HitType hit = rgeom.QueryPointInGeometry(inputPoint.x, inputPoint.y);
             if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Inside)
             {
                 return(1);
             }
             else
             {
                 if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                 {
                     return(0);
                 }
             }
         }
         com.epl.geometry.QuadTreeImpl qtree = accel.GetQuadTree();
         if (qtree != null)
         {
             return(_isPointInPolygonInternalWithQuadTree(inputPolygon, qtree, inputPoint, tolerance));
         }
     }
     return(_isPointInPolygonInternal(inputPolygon, inputPoint, tolerance));
 }
Ejemplo n.º 14
0
        internal static com.epl.geometry.QuadTree BuildQuadTree_(com.epl.geometry.MultiPathImpl multipathImpl, bool bStoreDuplicates)
        {
            com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
            multipathImpl.QueryEnvelope2D(extent);
            com.epl.geometry.QuadTree quadTree = new com.epl.geometry.QuadTree(extent, 8, bStoreDuplicates);
            int hint_index = -1;

            com.epl.geometry.Envelope2D          boundingbox = new com.epl.geometry.Envelope2D();
            com.epl.geometry.SegmentIteratorImpl seg_iter    = multipathImpl.QuerySegmentIterator();
            while (seg_iter.NextPath())
            {
                while (seg_iter.HasNextSegment())
                {
                    com.epl.geometry.Segment segment = seg_iter.NextSegment();
                    int index = seg_iter.GetStartPointIndex();
                    segment.QueryEnvelope2D(boundingbox);
                    hint_index = quadTree.Insert(index, boundingbox, hint_index);
                }
            }
            return(quadTree);
        }
        private static int _isPointInPolygonInternal(com.epl.geometry.Polygon inputPolygon, com.epl.geometry.Point2D inputPoint, double tolerance)
        {
            bool bAltenate = inputPolygon.GetFillRule() == com.epl.geometry.Polygon.FillRule.enumFillRuleOddEven;

            com.epl.geometry.PointInPolygonHelper helper = new com.epl.geometry.PointInPolygonHelper(bAltenate, inputPoint, tolerance);
            com.epl.geometry.MultiPathImpl        mpImpl = (com.epl.geometry.MultiPathImpl)inputPolygon._getImpl();
            com.epl.geometry.SegmentIteratorImpl  iter   = mpImpl.QuerySegmentIterator();
            while (iter.NextPath())
            {
                while (iter.HasNextSegment())
                {
                    com.epl.geometry.Segment segment = iter.NextSegment();
                    if (helper.ProcessSegment(segment))
                    {
                        return(-1);
                    }
                }
            }
            // point on boundary
            return(helper.Result());
        }
Ejemplo n.º 16
0
        public static void Test1()
        {
            {
                com.epl.geometry.QuadTree quad_tree           = new com.epl.geometry.QuadTree(com.epl.geometry.Envelope2D.Construct(-10, -10, 10, 10), 8);
                com.epl.geometry.QuadTree.QuadTreeIterator qt = quad_tree.GetIterator(true);
                NUnit.Framework.Assert.IsTrue(qt.Next() == -1);
                qt.ResetIterator(com.epl.geometry.Envelope2D.Construct(0, 0, 0, 0), 0);
                NUnit.Framework.Assert.IsTrue(quad_tree.GetIntersectionCount(com.epl.geometry.Envelope2D.Construct(0, 0, 0, 0), 0, 10) == 0);
                NUnit.Framework.Assert.IsTrue(quad_tree.GetElementCount() == 0);
            }
            com.epl.geometry.Polyline polyline;
            polyline = MakePolyline();
            com.epl.geometry.MultiPathImpl             polylineImpl = (com.epl.geometry.MultiPathImpl)polyline._getImpl();
            com.epl.geometry.QuadTree                  quadtree     = BuildQuadTree_(polylineImpl, false);
            com.epl.geometry.Line                      queryline    = new com.epl.geometry.Line(34, 9, 66, 46);
            com.epl.geometry.QuadTree.QuadTreeIterator qtIter       = quadtree.GetIterator();
            NUnit.Framework.Assert.IsTrue(qtIter.Next() == -1);
            qtIter.ResetIterator(queryline, 0.0);
            int element_handle = qtIter.Next();

            while (element_handle > 0)
            {
                int index = quadtree.GetElement(element_handle);
                NUnit.Framework.Assert.IsTrue(index == 6 || index == 8 || index == 14);
                element_handle = qtIter.Next();
            }
            com.epl.geometry.Envelope2D envelope     = new com.epl.geometry.Envelope2D(34, 9, 66, 46);
            com.epl.geometry.Polygon    queryPolygon = new com.epl.geometry.Polygon();
            queryPolygon.AddEnvelope(envelope, true);
            qtIter.ResetIterator(queryline, 0.0);
            element_handle = qtIter.Next();
            while (element_handle > 0)
            {
                int index = quadtree.GetElement(element_handle);
                NUnit.Framework.Assert.IsTrue(index == 6 || index == 8 || index == 14);
                element_handle = qtIter.Next();
            }
        }
Ejemplo n.º 17
0
        public SegmentIteratorImpl(com.epl.geometry.MultiPathImpl parent, int pathIndex, int segmentIndex)
        {
            if (pathIndex < 0 || pathIndex >= parent.GetPathCount() || segmentIndex < 0)
            {
                throw new System.IndexOutOfRangeException();
            }
            int d = parent.IsClosedPath(pathIndex) ? 0 : 1;

            if (segmentIndex >= parent.GetPathSize(pathIndex) - d)
            {
                throw new System.IndexOutOfRangeException();
            }
            m_currentSegmentIndex = -1;
            m_nextSegmentIndex    = segmentIndex;
            m_currentPathIndex    = pathIndex;
            m_nextPathIndex       = m_nextSegmentIndex + 1;
            m_parent         = parent;
            m_segmentCount   = _getSegmentCount(m_nextPathIndex);
            m_bCirculator    = false;
            m_currentSegment = null;
            m_pathBegin      = m_parent.GetPathStart(m_currentPathIndex);
            m_dummyPoint     = new com.epl.geometry.Point2D();
        }
 internal static int IsPointInPolygon(com.epl.geometry.Polygon inputPolygon, double inputPointXVal, double inputPointYVal, double tolerance)
 {
     if (inputPolygon.IsEmpty())
     {
         return(0);
     }
     com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
     inputPolygon.QueryLooseEnvelope(env);
     env.Inflate(tolerance, tolerance);
     if (!env.Contains(inputPointXVal, inputPointYVal))
     {
         return(0);
     }
     com.epl.geometry.MultiPathImpl        mpImpl = (com.epl.geometry.MultiPathImpl)inputPolygon._getImpl();
     com.epl.geometry.GeometryAccelerators accel  = mpImpl._getAccelerators();
     if (accel != null)
     {
         com.epl.geometry.RasterizedGeometry2D rgeom = accel.GetRasterizedGeometry();
         if (rgeom != null)
         {
             com.epl.geometry.RasterizedGeometry2D.HitType hit = rgeom.QueryPointInGeometry(inputPointXVal, inputPointYVal);
             if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Inside)
             {
                 return(1);
             }
             else
             {
                 if (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside)
                 {
                     return(0);
                 }
             }
         }
     }
     return(_isPointInPolygonInternal(inputPolygon, new com.epl.geometry.Point2D(inputPointXVal, inputPointYVal), tolerance));
 }