/// <summary> /// Returns an instance of <see cref="IRectangle"/> representing the bounding box of the specified GeoJSON <paramref name="collection"/>. /// </summary> /// <param name="collection">The feature collection.</param> /// <returns>An instance of <see cref="IRectangle"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="collection"/> is <c>null</c>.</exception> /// <exception cref="InvalidOperationException"><paramref name="collection"/> is empty.</exception> public static IRectangle GetBoundingBox(GeoJsonFeatureCollection collection) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (collection.Features.Count == 0) { throw new InvalidOperationException(nameof(collection)); } List <IPoint> points = new List <IPoint>(); foreach (GeoJsonFeature feature in collection.Features) { IRectangle bbox = GetBoundingBox(feature); if (bbox != null) { points.Add(bbox.SouthWest); points.Add(bbox.NorthEast); } } return(points.Count == 0 ? null : MapsUtils.GetBoundingBox(points)); }
/// <inheritdoc /> public IRectangle GetBoundingBox() { if (_lineStrings.Count == 0) { throw new InvalidOperationException("This MultiLineString does not contain any LineString."); } return(MapsUtils.GetBoundingBox(_lineStrings.SelectMany(x => x.Points))); }
/// <summary> /// Returns the bounding box of the specified collection of <paramref name="polygons"/>. /// </summary> /// <param name="polygons">A collection of polygons.</param> /// <returns>An instance of <see cref="IRectangle"/> representing the bounding box.</returns> public static IRectangle GetBoundingBox(this IEnumerable <IPolygon> polygons) { if (polygons == null) { throw new ArgumentNullException(nameof(polygons)); } return(MapsUtils.GetBoundingBox(polygons.SelectMany(x => x.Outer))); }
/// <summary> /// Returns a new rectangle representing the bounding box of this multi polygon. /// </summary> /// <returns>An instance of <see cref="IRectangle"/>.</returns> public IRectangle GetBoundingBox() { return(MapsUtils.GetBoundingBox(Polygons.SelectMany(x => x.Outer))); }
/// <summary> /// Returns an instance of <see cref="IRectangle"/> representing the bounding box of the polygon. /// </summary> /// <returns>An instance of <see cref="IRectangle"/>.</returns> public IRectangle GetBoundingBox() { return(MapsUtils.GetBoundingBox(Outer)); }
/// <summary> /// Returns a new rectangle representing the bounding box of this line string. /// </summary> /// <returns>An instance of <see cref="IRectangle"/>.</returns> public IRectangle GetBoundingBox() { return(MapsUtils.GetBoundingBox(Points)); }