示例#1
0
        /// <summary>
        /// Test whether a point lies on the line segments defined by a
        /// list of coordinates.
        /// </summary>
        /// <param name="p"></param>
        /// <param name="pt"></param>
        /// <returns>
        /// <c>true</c> true if
        /// the point is a vertex of the line or lies in the interior of a line
        /// segment in the linestring.
        /// </returns>
        public static bool IsOnLine(Coordinate p, IList <Coordinate> pt)
        {
            LineIntersector lineIntersector = new RobustLineIntersector();

            for (int i = 1; i < pt.Count; i++)
            {
                Coordinate p0 = pt[i - 1];
                Coordinate p1 = pt[i];
                lineIntersector.ComputeIntersection(p, p0, p1);
                if (lineIntersector.HasIntersection)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="geom"></param>
 /// <returns></returns>
 private static bool IsSimpleLinearGeometry(IGeometry geom)
 {
     if (geom.IsEmpty)
         return true;
     GeometryGraph graph = new GeometryGraph(0, geom);
     LineIntersector li = new RobustLineIntersector();
     SegmentIntersector si = graph.ComputeSelfNodes(li, true);
     // if no self-intersection, must be simple
     if (!si.HasIntersection) return true;
     if (si.HasProperIntersection) return false;
     if (HasNonEndpointIntersection(graph)) return false;
     if (HasClosedEndpointIntersection(graph)) return false;
     return true;
 }
示例#3
0
 /// <summary>
 /// Computes an intersection point between two segments, if there is one.
 /// There may be 0, 1 or many intersection points between two segments.
 /// If there are 0, null is returned. If there is 1 or more, a single one
 /// is returned (chosen at the discretion of the algorithm).  If
 /// more information is required about the details of the intersection,
 /// the {RobustLineIntersector} class should be used.
 /// </summary>
 /// <param name="line"></param>
 /// <returns> An intersection point, or <c>null</c> if there is none.</returns>
 public virtual Coordinate Intersection(ILineSegmentBase line)
 {
     LineIntersector li = new RobustLineIntersector();
     li.ComputeIntersection(P0, P1, new Coordinate(line.P0), new Coordinate(line.P1));
     if (li.HasIntersection)
         return li.GetIntersection(0);
     return null;
 }
示例#4
0
 /// <summary>
 /// Checks validity of a LinearRing.
 /// </summary>
 /// <param name="g"></param>
 private void CheckValidRing(ILinearRing g)
 {
     CheckClosedRing(g);
     if (_validErr != null) return;
     GeometryGraph graph = new GeometryGraph(0, g);
     LineIntersector li = new RobustLineIntersector();
     graph.ComputeSelfNodes(li, true);
     CheckNoSelfIntersectingRings(graph);
 }
示例#5
0
 /// <summary>
 /// Test whether a point lies on the line segments defined by a
 /// list of coordinates.
 /// </summary>
 /// <param name="p"></param>
 /// <param name="pt"></param>
 /// <returns>
 /// <c>true</c> true if
 /// the point is a vertex of the line or lies in the interior of a line
 /// segment in the linestring.
 /// </returns>
 public static bool IsOnLine(Coordinate p, IList<Coordinate> pt)
 {
     LineIntersector lineIntersector = new RobustLineIntersector();
     for (int i = 1; i < pt.Count; i++)
     {
         Coordinate p0 = pt[i - 1];
         Coordinate p1 = pt[i];
         lineIntersector.ComputeIntersection(p, p0, p1);
         if (lineIntersector.HasIntersection)
             return true;
     }
     return false;
 }
示例#6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="precisionModel"></param>
 /// <returns></returns>
 private static INoder GetNoder(PrecisionModel precisionModel)
 {
     // otherwise use a fast (but non-robust) noder
     LineIntersector li = new RobustLineIntersector();
     li.PrecisionModel = precisionModel;
     McIndexNoder noder = new McIndexNoder(new IntersectionAdder(li));
     return noder;
 }