Пример #1
0
        private static HashSet <Coordinate> ExtractCoordinates(Geometry geom)
        {
            // DEVIATION: UniqueCoordinateArrayFilter is expensive (until we port 5e01aea, anyway).
            // Nobody actually needs the original input to be Coordinate[], and the original array
            // could never be used as-is because we could never assume that it's unique.
            var filter = new CustomUniqueCoordinateFilter();

            geom?.Apply(filter);
            return(filter.Coordinates);
        }
Пример #2
0
        /// <summary>
        /// Computes the convex hull for the given sequence of <see cref="Geometry"/> instances.
        /// </summary>
        /// <param name="geoms">
        /// The <see cref="Geometry"/> instances whose convex hull to compute.
        /// </param>
        /// <returns>
        /// The convex hull of <paramref name="geoms"/>.
        /// </returns>
        public static Geometry Create(IEnumerable <Geometry> geoms)
        {
            GeometryFactory factory = null;
            var             filter  = new CustomUniqueCoordinateFilter();

            foreach (var geom in geoms ?? Enumerable.Empty <Geometry>())
            {
                if (geom is null)
                {
                    continue;
                }

                if (factory is null)
                {
                    factory = geom.Factory;
                }

                geom.Apply(filter);
            }

            return(new ConvexHull(filter.Coordinates, factory).GetConvexHull());
        }