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); }
/// <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); }
/// <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); }
// 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> /// 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> /// 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); }
/// <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> /// 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; }
/// <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; }
///<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; }