/// <summary>
 /// Computes the noding for a collection of <see cref="ISegmentString" />s.
 /// Some Noders may add all these nodes to the input <see cref="ISegmentString" />s;
 /// others may only add some or none at all.
 /// </summary>
 /// <param name="inputSegmentStrings"></param>
 public void ComputeNodes(IList <ISegmentString> inputSegmentStrings)
 {
     _nodedSegStrings = inputSegmentStrings;
     _noder           = new MCIndexNoder();
     _pointSnapper    = new MCIndexPointSnapper(_noder.Index);
     SnapRound(inputSegmentStrings, _li);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Computes all interior intersections in the collection of <see cref="ISegmentString" />s,
 /// and returns their <see cref="Coordinate" />s.
 /// Does NOT node the segStrings.
 /// </summary>
 /// <param name="segStrings"></param>
 /// <param name="li"></param>
 /// <returns>A list of <see cref="Coordinate" />s for the intersections.</returns>
 private static IList<Coordinate> FindInteriorIntersections(IList<ISegmentString> segStrings, LineIntersector li)
 {
     InteriorIntersectionFinderAdder intFinderAdder = new InteriorIntersectionFinderAdder(li);
     SinglePassNoder noder = new MCIndexNoder(intFinderAdder);
     noder.ComputeNodes(segStrings);
     return intFinderAdder.InteriorIntersections;
 }
 /// <summary>
 /// Computes the noding for a collection of <see cref="ISegmentString" />s.
 /// Some Noders may add all these nodes to the input <see cref="ISegmentString" />s;
 /// others may only add some or none at all.
 /// </summary>
 /// <param name="inputSegmentStrings"></param>
 public void ComputeNodes(IList<ISegmentString> inputSegmentStrings)
 {
     _nodedSegStrings = inputSegmentStrings;
     _noder = new MCIndexNoder();
     _pointSnapper = new MCIndexPointSnapper(_noder.Index);
     SnapRound(inputSegmentStrings, _li);
 }
        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));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Computes the noding for a collection of <see cref="SegmentString" />s.
 /// Some Noders may add all these nodes to the input <see cref="SegmentString" />s;
 /// others may only add some or none at all.
 /// </summary>
 /// <param name="inputSegmentStrings"></param>
 public void ComputeNodes(IList inputSegmentStrings)
 {
     this.nodedSegStrings = inputSegmentStrings;
     noder = new MCIndexNoder();
     pointSnapper = new MCIndexPointSnapper(noder.MonotoneChains, noder.Index);
     SnapRound(inputSegmentStrings, li);            
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Computes the noding for a collection of <see cref="SegmentString" />s.
 /// Some Noders may add all these nodes to the input <see cref="SegmentString" />s;
 /// others may only add some or none at all.
 /// </summary>
 /// <param name="inputSegmentStrings"></param>
 public void ComputeNodes(IList inputSegmentStrings)
 {
     this.nodedSegStrings = inputSegmentStrings;
     noder        = new MCIndexNoder();
     pointSnapper = new MCIndexPointSnapper(noder.MonotoneChains, noder.Index);
     SnapRound(inputSegmentStrings, li);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Computes all interior intersections in the collection of <see cref="SegmentString" />s,
        /// and returns their <see cref="Coordinate" />s.
        /// Does NOT node the segStrings.
        /// </summary>
        /// <param name="segStrings"></param>
        /// <param name="li"></param>
        /// <returns>A list of <see cref="Coordinate" />s for the intersections.</returns>
        private IList FindInteriorIntersections(IList segStrings, LineIntersector li)
        {
            IntersectionFinderAdder intFinderAdder = new IntersectionFinderAdder(li);
            SinglePassNoder         noder          = new MCIndexNoder(intFinderAdder);

            noder.ComputeNodes(segStrings);
            return(intFinderAdder.InteriorIntersections);
        }
        /// <summary>
        /// Computes all interior intersections in the collection of <see cref="ISegmentString" />s,
        /// and returns their <see cref="Coordinate" />s.
        /// Does NOT node the segStrings.
        /// </summary>
        /// <param name="segStrings"></param>
        /// <param name="li"></param>
        /// <returns>A list of <see cref="Coordinate" />s for the intersections.</returns>
        private static IList <Coordinate> FindInteriorIntersections(IList <ISegmentString> segStrings, LineIntersector li)
        {
            InteriorIntersectionFinderAdder intFinderAdder = new InteriorIntersectionFinderAdder(li);
            SinglePassNoder noder = new MCIndexNoder(intFinderAdder);

            noder.ComputeNodes(segStrings);
            return(intFinderAdder.InteriorIntersections);
        }
Ejemplo n.º 9
0
        public static int InteriorIntersectionCount(Geometry geom)
        {
            var    intCounter = NodingIntersectionFinder.CreateIntersectionCounter(new RobustLineIntersector());
            INoder noder      = new MCIndexNoder(intCounter);

            noder.ComputeNodes(SegmentStringUtil.ExtractNodedSegmentStrings(geom));
            return(intCounter.Count);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Computes all interior intersections in the collection of <see cref="ISegmentString" />s,
        /// and returns their <see cref="Coordinate" />s.
        /// <para/>
        /// Also adds the intersection nodes to the segments.
        /// </summary>
        /// <param name="segStrings"></param>
        /// <returns>A list of <see cref="Coordinate" />s for the intersections.</returns>
        private IList <Coordinate> FindInteriorIntersections(IList <ISegmentString> segStrings)
        {
            var intAdder = new SnapRoundingIntersectionAdder(_pm);
            var noder    = new MCIndexNoder();

            noder.SegmentIntersector = intAdder;
            noder.ComputeNodes(segStrings);
            return(intAdder.Intersections);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Detects interior intersections in the collection of {@link SegmentString}s,
 /// and adds nodes for them to the segment strings.
 /// Also creates HotPixel nodes for the intersection points.
 /// </summary>
 /// <param name="segStrings">The input NodedSegmentStrings</param>
 private void AddIntersectionPixels(IList<ISegmentString> segStrings)
 {
     var intAdder = new SnapRoundingIntersectionAdder(_pm);
     var noder = new MCIndexNoder(intAdder);
     //noder.SegmentIntersector = intAdder;
     noder.ComputeNodes(segStrings);
     var intPts = intAdder.Intersections;
     _pixelIndex.AddNodes(intPts);
 }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
0
        public void ComputeNodes(IList inputSegmentStrings)
        {
            this.nodedSegStrings = inputSegmentStrings;
            noder        = new MCIndexNoder();
            pointSnapper = new MCIndexPointSnapper(
                noder.MonotoneChains, noder.Index);

            SnapRound(inputSegmentStrings, li);

            // testing purposes only - remove in final version
            //checkCorrectness(inputSegmentStrings);
        }
Ejemplo n.º 14
0
        /// <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());
        }
        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));
        }
Ejemplo n.º 16
0
        private INoder CreateNoder(PrecisionModel precisionModel)
        {
            if (workingNoder != null)
                return workingNoder;
			
            // otherwise use a fast (but non-robust) noder
            MCIndexNoder noder       = new MCIndexNoder();
            LineIntersector li       = new RobustLineIntersector();
            li.PrecisionModel        = precisionModel;
            noder.SegmentIntersector = new IntersectionAdder(li);

            return noder;
        }
Ejemplo n.º 17
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));
        }
Ejemplo n.º 18
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.º 19
0
        private static INoder CreateFloatingPrecisionNoder(bool doValidation)
        {
            var mcNoder = new MCIndexNoder();
            var li      = new RobustLineIntersector();

            mcNoder.SegmentIntersector = new IntersectionAdder(li);

            INoder noder = mcNoder;

            if (doValidation)
            {
                noder = new ValidatingNoder(mcNoder);
            }
            return(noder);
        }
Ejemplo n.º 20
0
        private INoder GetNoder(IPrecisionModel precisionModel)
        {
            if (_workingNoder != null) return _workingNoder;

            // otherwise use a fast (but non-robust) noder
            var noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector { PrecisionModel = precisionModel}));
            
            //var li = new RobustLineIntersector();
            //li.PrecisionModel = precisionModel;
            //noder.SegmentIntersector = new IntersectionAdder(li);
            //    Noder noder = new IteratedNoder(precisionModel);
            return noder;
            //    Noder noder = new SimpleSnapRounder(precisionModel);
            //    Noder noder = new MCIndexSnapRounder(precisionModel);
            //    Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)),
            //                                  precisionModel.getScale());
        }
        /**
         * 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);
        }
        private static void ProcessNodes(Geometry geom, NodingIntersectionFinder intFinder)
        {
            var noder = new MCIndexNoder(intFinder);

            noder.ComputeNodes(SegmentStringUtil.ExtractNodedSegmentStrings(geom));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Computes all interior intersections in the collection of <see cref="SegmentString" />s,
 /// and returns their <see cref="Coordinate" />s.
 /// Does NOT node the segStrings.
 /// </summary>
 /// <param name="segStrings"></param>
 /// <param name="li"></param>
 /// <returns>A list of <see cref="Coordinate" />s for the intersections.</returns>
 private IList FindInteriorIntersections(IList segStrings, LineIntersector li)
 {
     IntersectionFinderAdder intFinderAdder = new IntersectionFinderAdder(li);
     SinglePassNoder noder = new MCIndexNoder(intFinderAdder);            
     noder.ComputeNodes(segStrings);
     return intFinderAdder.InteriorIntersections;
 }