/// <summary> /// Calculates the intersection of a polygon shape without relying on the NTS geometry. /// </summary> /// <param name="lineShape">LineShape used for calculation.</param> /// <param name="otherShape">Other shape of any feature type.</param> /// <returns>True, if the given shape ranges intersect.</returns> public static bool Intersects(ShapeRange lineShape, ShapeRange otherShape) { if (lineShape.FeatureType != FeatureType.Line) { throw new ArgumentException(string.Format(DataStrings.Shape_WrongFeatureType, "lineShape", "line", lineShape.FeatureType)); } // Implemented in PolygonShape if (otherShape.FeatureType == FeatureType.Polygon) { return(otherShape.Intersects(lineShape)); } // Test for point on a line if (otherShape.FeatureType == FeatureType.Point || otherShape.FeatureType == FeatureType.MultiPoint) { return(IntersectsVertex(lineShape, otherShape)); } // There is no other way for this polygon to intersect the other points if (otherShape.FeatureType == FeatureType.Point || otherShape.FeatureType == FeatureType.MultiPoint) { return(false); } // For lines and polygons, if any segment intersects any segment of this polygon shape, return true. // This is essentially looking for the rare case of crossing in and crossing out again with // no actual points inside this polygonShape. return(SegmentsIntersect(lineShape, otherShape)); }
/// <summary> /// Calculates the intersection of a polygon shape without relying on the NTS geometry /// </summary> /// <param name="lineShape"></param> /// <param name="otherShape"></param> /// <returns></returns> public static bool Intersects(ShapeRange lineShape, ShapeRange otherShape) { if (lineShape.FeatureType != FeatureType.Line) { throw new ArgumentException("The First parameter should be a point shape, but it was featuretype:" + lineShape.FeatureType); } // Implmented in PolygonShape if (otherShape.FeatureType == FeatureType.Polygon) { return otherShape.Intersects(lineShape); } // Test for point on a line if (otherShape.FeatureType == FeatureType.Point || otherShape.FeatureType == FeatureType.MultiPoint) { return IntersectsVertex(lineShape, otherShape); } // There is no other way for this polygon to intersect the other points if (otherShape.FeatureType == FeatureType.Point || otherShape.FeatureType == FeatureType.MultiPoint) return false; // For lines and polygons, if any segment intersects any segment of this polygon shape, return true. // This is essentially looking for the rare case of crossing in and crossing out again with // no actual points inside this polygonShape. return SegmentsIntersect(lineShape, otherShape); }
/// <summary> /// Calculates the intersection of a polygon shape without relying on the NTS geometry /// </summary> /// <param name="lineShape"></param> /// <param name="otherShape"></param> /// <returns></returns> public static bool Intersects(ShapeRange lineShape, ShapeRange otherShape) { if (lineShape.FeatureType != FeatureType.Line) { throw new ArgumentException("The First parameter should be a point shape, but it was featuretype:" + lineShape.FeatureType); } // Implmented in PolygonShape if (otherShape.FeatureType == FeatureType.Polygon) { return(otherShape.Intersects(lineShape)); } // Test for point on a line if (otherShape.FeatureType == FeatureType.Point || otherShape.FeatureType == FeatureType.MultiPoint) { return(IntersectsVertex(lineShape, otherShape)); } // There is no other way for this polygon to intersect the other points if (otherShape.FeatureType == FeatureType.Point || otherShape.FeatureType == FeatureType.MultiPoint) { return(false); } // For lines and polygons, if any segment intersects any segment of this polygon shape, return true. // This is essentially looking for the rare case of crossing in and crossing out again with // no actual points inside this polygonShape. return(SegmentsIntersect(lineShape, otherShape)); }
/// <summary> /// Calculates the intersection of a point shape without relying on the NTS geometry. /// </summary> /// <param name="pointShape">Point shape used for calculation.</param> /// <param name="otherShape">Other shape of any feature type.</param> /// <returns>True, if the given shape ranges intersect.</returns> public static bool Intersects(ShapeRange pointShape, ShapeRange otherShape) { if (pointShape.FeatureType != FeatureType.Point && pointShape.FeatureType != FeatureType.MultiPoint) { throw new ArgumentException(string.Format(DataStrings.Shape_WrongFeatureType, "pointShape", "point or multi point", pointShape.FeatureType)); } // Implemented in PolygonShape or line shape. Point shape is the simplest and just looks for overlapping coordinates. if (otherShape.FeatureType == FeatureType.Polygon || otherShape.FeatureType == FeatureType.Line) { return(otherShape.Intersects(pointShape)); } // For two point-type shapes, test if any vertex from one overlaps with any vertex of the other within Epsilon tollerance return(VerticesIntersect(pointShape, otherShape)); }
/// <summary> /// Calculates the intersection of a polygon shape without relying on the NTS geometry /// </summary> /// <param name="pointShape"></param> /// <param name="otherShape"></param> /// <returns></returns> public static bool Intersects(ShapeRange pointShape, ShapeRange otherShape) { if (pointShape.FeatureType != FeatureType.Point && pointShape.FeatureType != FeatureType.MultiPoint) { throw new ArgumentException("The First parameter should be a point shape, but it was featuretype:" + pointShape.FeatureType); } // Implmented in PolygonShape or line shape. Point shape is the simplest and just looks for overlapping coordinates. if (otherShape.FeatureType == FeatureType.Polygon || otherShape.FeatureType == FeatureType.Line) { return(otherShape.Intersects(pointShape)); } // For two point-type shapes, test if any vertex from one overlaps with any vertex of the other within Epsilon tollerance return(VerticesIntersect(pointShape, otherShape)); }
/// <summary> /// Calculates the intersection of a polygon shape without relying on the NTS geometry /// </summary> /// <param name="pointShape"></param> /// <param name="otherShape"></param> /// <returns></returns> public static bool Intersects(ShapeRange pointShape, ShapeRange otherShape) { if (pointShape.FeatureType != FeatureType.Point && pointShape.FeatureType != FeatureType.MultiPoint) { throw new ArgumentException("The First parameter should be a point shape, but it was featuretype:" + pointShape.FeatureType); } // Implmented in PolygonShape or line shape. Point shape is the simplest and just looks for overlapping coordinates. if (otherShape.FeatureType == FeatureType.Polygon || otherShape.FeatureType == FeatureType.Line) { return otherShape.Intersects(pointShape); } // For two point-type shapes, test if any vertex from one overlaps with any vertex of the other within Epsilon tollerance return VerticesIntersect(pointShape, otherShape); }