Пример #1
0
        /// <summary>
        /// Simplifies the specified line string.
        /// </summary>
        /// <param name="source">The coordinates of the line string.</param>
        /// <param name="delta">The tolerance.</param>
        /// <param name="precisionModel">The precision model.</param>
        /// <returns>The list of coordinates of the simplified line string.</returns>
        /// <exception cref="System.ArgumentNullException">The source is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">The delta is less than or equal to 0.</exception>
        public static IReadOnlyList <Coordinate> Simplify(IReadOnlyList <Coordinate> source, Double delta, PrecisionModel precisionModel)
        {
            DouglasPeuckerAlgorithm algorithm = new DouglasPeuckerAlgorithm(source, delta, precisionModel);

            algorithm.Compute();
            return(algorithm.Result);
        }
Пример #2
0
        /// <summary>
        /// Simplifies the specified line string.
        /// </summary>
        /// <param name="source">The line string.</param>
        /// <param name="delta">The tolerance.</param>
        /// <param name="precisionModel">The precision model.</param>
        /// <returns>The simplified line string.</returns>
        /// <exception cref="System.ArgumentNullException">The source is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">The delta is less than or equal to 0.</exception>
        public static IBasicLineString Simplify(IBasicLineString source, Double delta, PrecisionModel precisionModel)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            DouglasPeuckerAlgorithm algorithm = new DouglasPeuckerAlgorithm(source, delta, precisionModel);

            algorithm.Compute();
            return(new BasicProxyLineString(algorithm.Result));
        }
Пример #3
0
        /// <summary>
        /// Simplifies the specified polygon.
        /// </summary>
        /// <param name="source">The polygon.</param>
        /// <param name="delta">The tolerance.</param>
        /// <param name="precisionModel">The precision model.</param>
        /// <returns>The simplified polygon.</returns>
        /// <exception cref="System.ArgumentNullException">The source is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">The delta is less than or equal to 0.</exception>
        public static IBasicPolygon Simplify(IBasicPolygon source, Double delta, PrecisionModel precisionModel)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            DouglasPeuckerAlgorithm algorithm = new DouglasPeuckerAlgorithm(source.Shell, delta, precisionModel);

            algorithm.Compute();
            IReadOnlyList <Coordinate>         shell = algorithm.Result;
            List <IReadOnlyList <Coordinate> > holes = new List <IReadOnlyList <Coordinate> >(source.HoleCount);

            foreach (IReadOnlyList <Coordinate> hole in source.Holes)
            {
                algorithm = new DouglasPeuckerAlgorithm(hole, delta, precisionModel);
                algorithm.Compute();
                holes.Add(algorithm.Result);
            }

            return(new BasicProxyPolygon(shell, holes));
        }