Example #1
0
        private bool IsSimpleLinearGeometry(MultiLineString 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);
        }
        /// <summary>
        /// Check all nodes to see if their labels are consistent with
        /// area topology.
        /// </summary>
        /// <returns>
        /// <c>true</c> if this area has a consistent node labelling
        /// </returns>
        public bool IsNodeConsistentArea()
        {
            // To fully check validity, it is necessary to
            // compute ALL intersections, including self-intersections
            // Within a single edge.
            SegmentIntersector intersector =
                geomGraph.ComputeSelfNodes(li, true);

            if (intersector.HasProperIntersection())
            {
                invalidPoint = intersector.ProperIntersectionPoint;
                return(false);
            }

            nodeGraph.Build(geomGraph);

            return(IsNodeEdgeAreaLabelsConsistent());
        }
Example #3
0
        private void ComputeProperIntersectionIM(SegmentIntersector intersector,
                                                 IntersectionMatrix im)
        {
            // If a proper intersection is found, we can set a lower bound on the IM.
            int  dimA              = (int)arg[0].Geometry.Dimension;
            int  dimB              = (int)arg[1].Geometry.Dimension;
            bool hasProper         = intersector.HasProperIntersection();
            bool hasProperInterior = intersector.HasProperInteriorIntersection();

            // For Geometry's of dim 0 there can never be proper intersections.

            //If edge segments of Areas properly intersect, the areas
            // must properly overlap.
            if (dimA == 2 && dimB == 2)
            {
                if (hasProper)
                {
                    im.SetAtLeast("212101212");
                }
            }
            // If an line segment properly intersects an edge segment of an area,
            // it follows that the interior of the line intersects the Boundary of the area.
            // If the intersection is a proper interior intersection, then
            // there is an Interior-Interior intersection too.
            // Note that it does not follow that the Interior of the line
            // Intersects the exterior of the area, since there may be another
            // area component which Contains the rest of the line.
            else if (dimA == 2 && dimB == 1)
            {
                if (hasProper)
                {
                    im.SetAtLeast("FFF0FFFF2");
                }
                if (hasProperInterior)
                {
                    im.SetAtLeast("1FFFFF1FF");
                }
            }
            else if (dimA == 1 && dimB == 2)
            {
                if (hasProper)
                {
                    im.SetAtLeast("F0FFFFFF2");
                }
                if (hasProperInterior)
                {
                    im.SetAtLeast("1F1FFFFFF");
                }
            }
            // If edges of LineStrings properly intersect *in an interior point*, all
            // we can deduce is that
            // the interiors intersect.  (We can NOT deduce that the exteriors intersect,
            // since some other segments in the geometries might cover the points in the
            // neighbourhood of the intersection.)
            // It is important that the point be known to be an interior point of
            // both Geometries, since it is possible in a self-intersecting geometry to
            // have a proper intersection on one segment that is also a boundary
            // point of another segment.
            else if (dimA == 1 && dimB == 1)
            {
                if (hasProperInterior)
                {
                    im.SetAtLeast("0FFFFFFFF");
                }
            }
        }