public static Geometry MCIndexNoding(Geometry geom)
        {
            INoder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector()));

            noder.ComputeNodes(SegmentStringUtil.ExtractNodedSegmentStrings(geom));
            return(SegmentStringUtil.ToGeometry(noder.GetNodedSubstrings(), geom.Factory));
        }
Пример #2
0
        public static IGeometry MCIndexNoding(Geometry geom)
        {
            IList <ISegmentString> segs = CreateNodedSegmentStrings(geom);
            INoder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector()));

            noder.ComputeNodes(segs);
            IList <ISegmentString> nodedSegStrings = noder.GetNodedSubstrings();

            return(FromSegmentStrings(nodedSegStrings));
        }
        public static Geometry MCIndexNodingWithPrecision(Geometry geom, double scaleFactor)
        {
            var fixedPM = new PrecisionModel(scaleFactor);

            LineIntersector li = new RobustLineIntersector();

            li.PrecisionModel = fixedPM;

            INoder noder = new MCIndexNoder(new IntersectionAdder(li));

            noder.ComputeNodes(SegmentStringUtil.ExtractNodedSegmentStrings(geom));
            return(SegmentStringUtil.ToGeometry(noder.GetNodedSubstrings(), geom.Factory));
        }
        /// <summary>
        /// Computes all interior intersections in the collection of <see cref="ISegmentString"/>s,
        /// and returns their <see cref="NodedSegmentString"/>s.
        /// <para/>
        /// Also adds the intersection nodes to the segments.
        /// </summary>
        /// <returns>A list of noded substrings</returns>
        private IList <ISegmentString> ComputeIntersections(IList <ISegmentString> inputSS)
        {
            var intAdder = new SnappingIntersectionAdder(_snapTolerance, snapIndex);

            /*
             * Use an overlap tolerance to ensure all
             * possible snapped intersections are found
             */
            var noder = new MCIndexNoder(intAdder, 2 * _snapTolerance);

            noder.ComputeNodes(inputSS);
            return(noder.GetNodedSubstrings());
        }
Пример #5
0
        public static IGeometry MCIndexNodingWithPrecision(Geometry geom, double scaleFactor)
        {
            List <ISegmentString> segs = CreateNodedSegmentStrings(geom);

            LineIntersector li = new RobustLineIntersector();

            li.PrecisionModel = new PrecisionModel(scaleFactor);
            INoder noder = new MCIndexNoder(new IntersectionAdder(li));

            noder.ComputeNodes(segs);
            IList <ISegmentString> nodedSegStrings = noder.GetNodedSubstrings();

            return(FromSegmentStrings(nodedSegStrings));
        }
        /**
         * Nodes a LineString and returns a List of Noded LineString's. Used to
         * repare auto-intersecting LineString and Polygons. This method cannot
         * process CoordinateSequence. The noding process is limited to 3d
         * geometries.<br/>
         * Preserves duplicate coordinates.
         *
         * @param coords coordinate array to be noded
         * @param gf geometryFactory to use
         * @return a list of noded LineStrings
         */
        private ISet <LineString> nodeLineString(Coordinate[] coords, GeometryFactory gf)
        {
            MCIndexNoder noder = new MCIndexNoder();

            noder.SegmentIntersector = new IntersectionAdder(new RobustLineIntersector());
            List <ISegmentString> list = new ();

            list.Add(new NodedSegmentString(coords, null));
            noder.ComputeNodes(list);
            List <LineString> lineStringList = new ();

            foreach (NetTopologySuite.Geometries.Geometry segmentString in noder.GetNodedSubstrings())
            {
                lineStringList.Add(gf.CreateLineString(
                                       segmentString.Coordinates
                                       ));
            }

            // WARNING : merger loose original linestrings
            // It is useful for LinearRings but should not be used for (Multi)LineStrings
            LineMerger merger = new LineMerger();

            merger.Add(lineStringList);
            lineStringList = (List <LineString>)merger.GetMergedLineStrings();

            // Remove duplicate linestrings preserving main orientation
            ISet <LineString> lineStringSet = new HashSet <LineString>();

            foreach (LineString line in lineStringList)
            {
                // TODO as equals makes a topological comparison, comparison with line.reverse maybe useless
                if (!lineStringSet.Contains(line) && !lineStringSet.Contains((LineString)line.Reverse()))
                {
                    lineStringSet.Add(line);
                }
            }
            return(lineStringSet);
        }