コード例 #1
0
        public Geometry GetResult()
        {
            // reduce precision of non-point input, if required
            _geomNonPoint    = PrepareNonPoint(_geomNonPointInput);
            _geomNonPointDim = _geomNonPoint.Dimension;
            _locator         = CreateLocator(_geomNonPoint);

            var coords = ExtractCoordinates(_geomPoint, _pm);

            switch (_opCode)
            {
            case OverlayNG.INTERSECTION:
                return(ComputeIntersection(coords));

            case OverlayNG.UNION:
            case OverlayNG.SYMDIFFERENCE:
                // UNION and SYMDIFFERENCE have same output
                return(ComputeUnion(coords));

            case OverlayNG.DIFFERENCE:
                return(ComputeDifference(coords));
            }
            Assert.ShouldNeverReachHere("Unknown overlay op code");
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Sets a polygonal mask.
        /// </summary>
        /// <exception cref="ArgumentException">if the mask is not polygonal</exception>
        public void SetExtent(IGeometry mask)
        {
            if (!(mask is IPolygonal))
                throw new ArgumentException("Only polygonal extents are supported");

            _maskPoly = mask;
            Extent = mask.EnvelopeInternal;
            _extentLocator = new IndexedPointInAreaLocator(mask);
        }
コード例 #3
0
        /// <summary>
        /// Sets a polygonal mask.
        /// </summary>
        /// <exception cref="ArgumentException">if the mask is not polygonal</exception>
        public void SetExtent(IGeometry mask)
        {
            if (!(mask is IPolygonal))
            {
                throw new ArgumentException("Only polygonal extents are supported");
            }

            _maskPoly      = mask;
            Extent         = mask.EnvelopeInternal;
            _extentLocator = new IndexedPointInAreaLocator(mask);
        }
コード例 #4
0
 // MD - experimental for now
 /// <summary>
 /// Determines the <see cref="Location"/> of the given <see cref="Coordinate"/> in this geometry.
 /// </summary>
 /// <param name="pt">The point to test</param>
 /// <returns>
 /// The location of the point in the geometry
 /// </returns>
 public Location Locate(Coordinate pt)
 {
     if (_parentGeom is IPolygonal && _parentGeom.NumGeometries > 50)
     {
         // lazily init point locator
         if (_areaPtLocator == null)
         {
             _areaPtLocator = new IndexedPointInAreaLocator(_parentGeom);
         }
         return(_areaPtLocator.Locate(pt));
     }
     return(_ptLocator.Locate(pt, _parentGeom));
 }
コード例 #5
0
 // MD - experimental for now
 ///<summary>
 /// Determines the <see cref="Location"/> of the given <see cref="Coordinate"/> in this geometry.
 ///</summary>
 /// <param name="pt">The point to test</param>
 /// <returns>
 /// The location of the point in the geometry
 /// </returns>
 public Location Locate(Coordinate pt)
 {
     if (_parentGeom is IPolygonal && _parentGeom.NumGeometries > 50)
     {
         // lazily init point locator
         if (_areaPtLocator == null)
         {
             _areaPtLocator = new NetTopologySuite.Algorithm.Locate.IndexedPointInAreaLocator(_parentGeom);
         }
         return _areaPtLocator.Locate(pt);
     }
     return _ptLocator.Locate(pt, _parentGeom);
 }
コード例 #6
0
        /// <summary> 
        /// Convenience method to test a point for intersection with a geometry
        /// <para/>
        /// The geometry is wrapped in a <see cref="IPointOnGeometryLocator"/> class.
        /// </summary>
        /// <param name="locator">The locator to use.</param>
        /// <param name="coordinate">The coordinate to test.</param>
        /// <returns><c>true</c> if the point is in the interior or boundary of the geometry.</returns>
        public static bool Intersects(IPointOnGeometryLocator locator, Coordinate coordinate)
        {
            if (locator == null)
                throw new ArgumentNullException("locator");
            if (coordinate == null)
                throw new ArgumentNullException("coordinate");

            switch (locator.Locate(coordinate))
            {
                case Location.Boundary:
                case Location.Interior:
                    return true;

                case Location.Exterior:
                    return false;

                default:
                    throw new InvalidOperationException("IPointOnGeometryLocator.Locate should never return anything other than Boundary, Interior, or Exterior.");
            }
        }
コード例 #7
0
        /// <summary>
        /// Run
        /// </summary>
        /// <returns> true if all point locations were computed correctly</returns>
        public Boolean Run()
        {
            var sw = new Stopwatch();

            sw.Start();
            // default is to use the simple, non-indexed tester
            if (_pia2 == null)
            {
                _pia2 = new SimplePointInAreaLocator(_area);
            }


            int ptGridWidth = (int)Math.Sqrt(_numPts);

            Envelope areaEnv = _area.EnvelopeInternal;
            double   xStep   = areaEnv.Width / (ptGridWidth - 1);
            double   yStep   = areaEnv.Height / (ptGridWidth - 1);

            for (int i = 0; i < ptGridWidth; i++)
            {
                for (int j = 0; j < ptGridWidth; j++)
                {
                    // compute test point
                    double x  = areaEnv.MinX + i * xStep;
                    double y  = areaEnv.MinY + j * yStep;
                    var    pt = new Coordinate(x, y);
                    _geomFactory.PrecisionModel.MakePrecise(pt);

                    Boolean isEqual = TestPointInArea(pt);
                    if (!isEqual)
                    {
                        return(false);
                    }
                }
            }
            sw.Stop();
            Console.WriteLine("Test completed in " + sw.ElapsedMilliseconds);
            PrintStats();
            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Convenience method to test a point for intersection with a geometry
        /// <para/>
        /// The geometry is wrapped in a <see cref="IPointOnGeometryLocator"/> class.
        /// </summary>
        /// <param name="locator">The locator to use.</param>
        /// <param name="coordinate">The coordinate to test.</param>
        /// <returns><c>true</c> if the point is in the interior or boundary of the geometry.</returns>
        public static bool Intersects(IPointOnGeometryLocator locator, Coordinate coordinate)
        {
            if (locator == null)
            {
                throw new ArgumentNullException("locator");
            }
            if (coordinate == null)
            {
                throw new ArgumentNullException("coordinate");
            }

            switch (locator.Locate(coordinate))
            {
            case Location.Boundary:
            case Location.Interior:
                return(true);

            case Location.Exterior:
                return(false);

            default:
                throw new InvalidOperationException("IPointOnGeometryLocator.Locate should never return anything other than Boundary, Interior, or Exterior.");
            }
        }
コード例 #9
0
        /// <summary>
        /// Run
        /// </summary>
        /// <returns> true if all point locations were computed correctly</returns>
        public Boolean Run()
        {
            var sw = new Stopwatch();
            sw.Start();
            // default is to use the simple, non-indexed tester
            if (_pia2 == null)
                _pia2 = new SimplePointInAreaLocator(_area);


            int ptGridWidth = (int)Math.Sqrt(_numPts);

            Envelope areaEnv = _area.EnvelopeInternal;
            double xStep = areaEnv.Width / (ptGridWidth - 1);
            double yStep = areaEnv.Height / (ptGridWidth - 1);

            for (int i = 0; i < ptGridWidth; i++)
            {
                for (int j = 0; j < ptGridWidth; j++)
                {

                    // compute test point
                    double x = areaEnv.MinX + i * xStep;
                    double y = areaEnv.MinY + j * yStep;
                    var pt = new Coordinate(x, y);
                    _geomFactory.PrecisionModel.MakePrecise(pt);

                    Boolean isEqual = TestPointInArea(pt);
                    if (!isEqual)
                        return false;
                }
            }
            sw.Stop();
            Console.WriteLine("Test completed in " + sw.ElapsedMilliseconds);
            PrintStats();
            return true;
        }
コード例 #10
0
 /// <summary>
 /// Creates an instance of this operation.
 /// </summary>
 /// <param name="prepPoly">the PreparedPolygon to evaluate</param>
 protected PreparedPolygonPredicate(PreparedPolygon prepPoly)
 {
     this.prepPoly       = prepPoly;
     _targetPointLocator = prepPoly.PointLocator;
 }
コード例 #11
0
 // MD - experimental for now
 ///<summary>
 /// Determines the <see cref="Location"/> of the given <see cref="Coordinate"/> in this geometry.
 ///</summary>
 /// <param name="pt">The point to test</param>
 /// <returns>
 /// The location of the point in the geometry
 /// </returns>
 public Location Locate(Coordinate pt)
 {
     if (_parentGeom is IPolygonal && _parentGeom.NumGeometries > 50)
     {
         // lazily init point locator
         if (_areaPtLocator == null)
         {
             _areaPtLocator = new NetTopologySuite.Algorithm.Locate.IndexedPointInAreaLocator(_parentGeom);
         }
         return _areaPtLocator.Locate(pt);
     }
     return _ptLocator.Locate(pt, _parentGeom);
 }
コード例 #12
0
 ///<summary>
 /// Creates an instance of this operation.
 ///</summary>
 /// <param name="prepPoly">the PreparedPolygon to evaluate</param>
 protected PreparedPolygonPredicate(PreparedPolygon prepPoly)
 {
     this.prepPoly = prepPoly;
     _targetPointLocator = prepPoly.PointLocator;
 }