コード例 #1
0
ファイル: IsValidOp.cs プロジェクト: klosejay/Gisoft.Map
        /// <summary>
        /// Tests that each hole is inside the polygon shell.
        /// This routine assumes that the holes have previously been tested
        /// to ensure that all vertices lie on the shell or inside it.
        /// A simple test of a single point in the hole can be used,
        /// provide the point is chosen such that it does not lie on the
        /// boundary of the shell.
        /// </summary>
        /// <param name="p">The polygon to be tested for hole inclusion.</param>
        /// <param name="graph">A GeometryGraph incorporating the polygon.</param>
        private void CheckHolesInShell(IPolygon p, GeometryGraph graph)
        {
            var shell = p.Shell;

            //IPointInRing pir = new MCPointInRing(shell);
            var pir = new IndexedPointInAreaLocator(shell);

            for (int i = 0; i < p.NumInteriorRings; i++)
            {
                var hole   = p.Holes[i];
                var holePt = FindPointNotNode(hole.Coordinates, shell, graph);

                /*
                 * If no non-node hole vertex can be found, the hole must
                 * split the polygon into disconnected interiors.
                 * This will be caught by a subsequent check.
                 */
                if (holePt == null)
                {
                    return;
                }

                var outside = Location.Exterior == pir.Locate(holePt);
                if (outside)
                {
                    _validErr = new TopologyValidationError(TopologyValidationErrors.HoleOutsideShell, holePt);
                    return;
                }
            }
        }
コード例 #2
0
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, string wkt)
        {
            var geom   = _reader.Read(wkt);
            var loc    = new IndexedPointInAreaLocator(geom);
            var result = loc.Locate(pt);

            Assert.AreEqual(expectedLoc, result);
        }
コード例 #3
0
 public void RunIndexPointInAreaLocator()
 {
     for (int i = 0; i < NUM_ITER; i++)
     {
         var ipa = new IndexedPointInAreaLocator(sinePoly);
         foreach (var pt in testPoints)
         {
             ipa.Locate(pt.Coordinate);
         }
     }
 }
コード例 #4
0
        private void AddResultVertices(Geometry geom0, Geometry geom1)
        {
            /*
             * Compute rays originating at vertices inside the resultant
             * (i.e. A vertices inside B, and B vertices inside A)
             */
            var  locator = new IndexedPointInAreaLocator(geom1);
            var  seq     = GetVertices(geom0);
            bool isCW    = !Orientation.IsCCW(seq);

            for (int i = 0; i < seq.Count - 1; i++)
            {
                var vPrev = i == 0 ? seq.GetCoordinate(seq.Count - 2) : seq.GetCoordinate(i - 1);
                var v     = seq.GetCoordinate(i);
                var vNext = seq.GetCoordinate(i + 1);
                if (Location.Interior == locator.Locate(v))
                {
                    _area += EdgeRay.AreaTerm(v, vPrev, !isCW);
                    _area += EdgeRay.AreaTerm(v, vNext, isCW);
                }
            }
        }