/// <summary>
        /// Tests whether all components of the test Geometry are contained in the target geometry.
        /// </summary>
        /// <remarks>Handles both linear and point components.</remarks>
        /// <param name="testGeom">A geometry to test</param>
        /// <returns>
        /// true if all components of the argument are contained in the target geometry
        /// </returns>
        protected bool IsAllTestComponentsInTarget(Geometry testGeom)
        {
            var coords = ComponentCoordinateExtracter.GetCoordinates(testGeom);

            foreach (var p in coords)
            {
                var loc = _targetPointLocator.Locate(p);
                if (loc == Location.Exterior)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #2
0
 protected bool IsInExtent(Coordinate p)
 {
     if (_extentLocator != null)
     {
         return(_extentLocator.Locate(p) != Location.Exterior);
     }
     return(Extent.Contains(p));
 }
Пример #3
0
        private bool HasLocation(bool isCovered, Coordinate coord)
        {
            bool isExterior = Location.Exterior == _locator.Locate(coord);

            if (isCovered)
            {
                return(!isExterior);
            }
            return(isExterior);
        }
 // 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));
 }
 // 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);
 }
        /// <summary>
        /// TestPointInArea
        /// </summary>
        /// <param name="p"></param>
        /// <returns>true if the point location is determined to be the same by both PIA locaters</returns>
        private Boolean TestPointInArea(Coordinate p)
        {
            //Console.WriteLine(WKTWriter.toPoint(p));

            Location loc1 = _pia1.Locate(p);
            Location loc2 = _pia2.Locate(p);

            _locationCount[(Int32)loc1]++;

            if ((loc1 == Location.Boundary || loc2 == Location.Boundary) &&
                IgnoreBoundaryResults)
            {
                return(true);
            }

            return(loc1 == loc2);
        }
        /// <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.");
            }
        }
        /// <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.");
            }
        }