Exemplo n.º 1
0
        /// <summary>
        /// Nodes the linework of a set of Geometrys using SnapRounding.
        /// </summary>
        /// <param name="geoms">A collection of Geometrys of any type</param>
        /// <returns>A list of LineStrings representing the noded linework of the input</returns>
        public IList <ILineString> Node(ICollection <IGeometry> geoms)
        {
            // get geometry factory
            foreach (var g in geoms)
            {
                _geomFact = g.Factory;
                break;
            }

            var segStrings = ToSegmentStrings(ExtractLines(geoms));
            //Noder sr = new SimpleSnapRounder(pm);
            INoder sr = new MCIndexSnapRounder(_pm);

            sr.ComputeNodes(segStrings);
            var nodedLines = sr.GetNodedSubstrings();

            //TODO: improve this to check for full snap-rounded correctness
            if (IsValidityChecked)
            {
                NodingValidator nv = new NodingValidator(nodedLines);
                nv.CheckValid();
            }

            return(ToLineStrings(nodedLines));
        }
        /// <summary> 
        /// Nodes the linework of a set of Geometrys using SnapRounding.
        /// </summary>
        /// <param name="geoms">A collection of geometries</param>
        /// <returns>A collection of LineString geometries representing the noded linework of the input</returns>
        public ICollection<IGeometry> Node(ICollection<IGeometry> geoms)
        {
            // get geometry factory
            _geomFact = FunctionsUtil.GetFactoryOrDefault(geoms);

            var segStrings = ExtractSegmentStrings(geoms);
            //Noder sr = new SimpleSnapRounder(pm);
            var sr = new MCIndexSnapRounder(_pm);
            sr.ComputeNodes(segStrings);

            var nodedLines = GetNodedLines(segStrings);
            return nodedLines;

        }
        public IGeometry Node(IGeometry geom)
        {

            var geomList = new List<IGeometry>();
            geomList.Add(geom);
            var segStrings = ExtractSegmentStrings(geomList);
            //Noder sr = new SimpleSnapRounder(pm);
            var sr = new MCIndexSnapRounder(_pm);
            sr.ComputeNodes(segStrings);


            var nodedPtsMap = GetNodedPtsMap(segStrings);
            var lineReplacer = new GeometryLineReplacer(nodedPtsMap);
            var geomEditor = new GeometryEditor();
            var snapped = geomEditor.Edit(geom, lineReplacer);
            return snapped;

        }
Exemplo n.º 4
0
        /// <summary>
        /// Nodes the linework of a set of Geometrys using SnapRounding.
        /// </summary>
        /// <param name="geoms">A collection of Geometrys of any type</param>
        /// <returns>A list of LineStrings representing the noded linework of the input</returns>
        public ReadOnlyCollection <LineString> Node(IEnumerable <Geometry> geoms)
        {
            // get geometry factory
            // DEVIATION: JTS uses an "ExtractLines" helper, but by inlining it,
            // we can make the parameter any ol' IEnumerable<Geometry> without
            // iterating over it multiple times.
            var  lines = new List <Geometry>();
            var  lce   = new LinearComponentExtracter(lines);
            bool first = true;

            foreach (var g in geoms)
            {
                if (first)
                {
                    _geomFact = g.Factory;
                    first     = false;
                }

                g.Apply(lce);
            }

            var segStrings = ToSegmentStrings(lines);
            //Noder sr = new SimpleSnapRounder(pm);
            var sr = new MCIndexSnapRounder(_pm);

            sr.ComputeNodes(segStrings);
            var nodedLines = sr.GetNodedSubstrings();

            //TODO: improve this to check for full snap-rounded correctness
            if (IsValidityChecked)
            {
                var nv = new NodingValidator(nodedLines);
                nv.CheckValid();
            }

            return(ToLineStrings(nodedLines));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Nodes the linework of a set of Geometrys using SnapRounding.
        /// </summary>
        /// <param name="geoms">A collection of Geometrys of any type</param>
        /// <returns>A list of LineStrings representing the noded linework of the input</returns>
        public IList<ILineString> Node(ICollection<IGeometry> geoms)
        {
            // get geometry factory
            foreach (var g in geoms)
            {
                _geomFact = g.Factory;
                break;
            }

            var segStrings = ToSegmentStrings(ExtractLines(geoms));
            //Noder sr = new SimpleSnapRounder(pm);
            INoder sr = new MCIndexSnapRounder(_pm);
            sr.ComputeNodes(segStrings);
            var nodedLines = sr.GetNodedSubstrings();

            //TODO: improve this to check for full snap-rounded correctness
            if (IsValidityChecked)
            {
                NodingValidator nv = new NodingValidator(nodedLines);
                nv.CheckValid();
            }

            return ToLineStrings(nodedLines);
        }
 private void snapRound(IList<ISegmentString> segStrings)
 {
     //Noder sr = new SimpleSnapRounder(pm);
     var sr = new MCIndexSnapRounder(_pm);
     sr.ComputeNodes(segStrings);
 }