Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="geom"></param>
        /// <returns></returns>
        private 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;
        }
Ejemplo n.º 2
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(ICoordinate p, ICoordinate[] pt)
        {
            LineIntersector lineIntersector = new RobustLineIntersector();

            for (int i = 1; i < pt.Length; i++)
            {
                ICoordinate p0 = pt[i - 1];
                ICoordinate p1 = pt[i];
                lineIntersector.ComputeIntersection((Coordinate)p, (Coordinate)p0, (Coordinate)p1);
                if (lineIntersector.HasIntersection)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="precisionModel"></param>
        /// <returns></returns>
        private INoder GetNoder(IPrecisionModel precisionModel)
        {
            if (workingNoder != null) 
                return workingNoder;

            // otherwise use a fast (but non-robust) noder
            LineIntersector li = new RobustLineIntersector();
            li.PrecisionModel = precisionModel;
            MCIndexNoder noder = new MCIndexNoder(new IntersectionAdder(li));                     
            return noder;
        }
Ejemplo n.º 4
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(ICoordinate p, ICoordinate[] pt) 
 {
     LineIntersector lineIntersector = new RobustLineIntersector();
     for (int i = 1; i < pt.Length; i++) 
     {
         ICoordinate p0 = pt[i - 1];
         ICoordinate p1 = pt[i];
         lineIntersector.ComputeIntersection((Coordinate) p, (Coordinate) p0, (Coordinate) p1);
         if (lineIntersector.HasIntersection) 
             return true;                
     }
     return false;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks validity of a LinearRing.
        /// </summary>
        /// <param name="g"></param>
        private void CheckValid(ILinearRing g)
        {
            CheckInvalidCoordinates(g.Coordinates);
            if (validErr != null) return;
            CheckClosedRing(g);
            if (validErr != null) return;

            GeometryGraph graph = new GeometryGraph(0, g);
            CheckTooFewPoints(graph);
            if (validErr != null) return;
            LineIntersector li = new RobustLineIntersector();
            graph.ComputeSelfNodes(li, true);
            CheckNoSelfIntersectingRings(graph);
        }
Ejemplo n.º 6
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 ICoordinate Intersection(LineSegment line)
 {
     LineIntersector li = new RobustLineIntersector();
     li.ComputeIntersection(P0, P1, line.P0, line.P1);
     if (li.HasIntersection)
     return li.GetIntersection(0);
     return null;
 }