Beispiel #1
0
        public static Point GetInteriorPoint(Geometry geom)
        {
            var factory = geom.Factory;

            if (geom.IsEmpty)
            {
                return(CreatePointEmpty(factory));
            }

            Coordinate interiorPt = null;

            switch (geom.Dimension)
            {
            case Dimension.Point:
                interiorPt = InteriorPointPoint.GetInteriorPoint(geom);
                break;

            case Dimension.Curve:
                interiorPt = InteriorPointLine.GetInteriorPoint(geom);
                break;

            default:
                interiorPt = InteriorPointArea.GetInteriorPoint(geom);
                break;
            }

            return(CreatePointPrecise(factory, interiorPt));
        }
        /// <summary>
        /// Compute a location of an interior point in a <see cref="Geometry"/>.
        /// <para/>
        /// Handles all geometry types.
        /// </summary>
        /// <remarks>
        /// This function is called <c>GetInteriorPoint</c> in JTS.
        /// It has been renamed to <c>GetInteriorCoord</c> to prevent a breaking change.</remarks>
        /// <param name="geom">A geometry in which to find an interior point</param>
        /// <returns>the location of an interior point, or <c>null</c> if the input is empty
        /// </returns>
        public static Coordinate GetInteriorCoord(Geometry geom)
        {
            if (geom.IsEmpty)
            {
                return(null);
            }

            Coordinate interiorPt;

            switch (geom.Dimension)
            {
            case Dimension.Point:
                interiorPt = InteriorPointPoint.GetInteriorPoint(geom);
                break;

            case Dimension.Curve:
                interiorPt = InteriorPointLine.GetInteriorPoint(geom);
                break;

            default:
                interiorPt = InteriorPointArea.GetInteriorPoint(geom);
                break;
            }

            return(interiorPt);
        }
Beispiel #3
0
        /// <summary>
        /// Computes an interior point for the
        /// polygonal components of a Geometry.
        /// </summary>
        /// <param name="geom">The geometry to compute.</param>
        /// <returns>
        /// The computed interior point,
        /// or <see langword="null"/> if the geometry has no polygonal components.
        /// </returns>
        public static Coordinate GetInteriorPoint(Geometry geom)
        {
            var intPt = new InteriorPointArea(geom);

            return(intPt.InteriorPoint);
        }