@@ -40,7 +40,7 @@ public func minimumBBox(for coords: [Coordinate2D]) -> BoundingBox2D? {
40
40
}
41
41
42
42
/// Returns the [bounding box](https://en.wikipedia.org/wiki/Minimum_bounding_box) enclosing the points.
43
- public func bbox( for coords: [ Coordinate2D ] ) -> BoundingBox2D ? {
43
+ public func bbox< C : Collection > ( for coords: C ) -> BoundingBox2D ? where C . Element == Coordinate2D {
44
44
guard let ( south, north) = coords. map ( \. latitude) . minAndMax ( ) ,
45
45
let ( west, east) = coords. map ( \. longitude) . minAndMax ( )
46
46
else { return nil }
@@ -51,9 +51,17 @@ public func bbox(for coords: [Coordinate2D]) -> BoundingBox2D? {
51
51
)
52
52
}
53
53
54
- /// Returns the [bounding box](https://en.wikipedia.org/wiki/Minimum_bounding_box) enclosing all elements.
55
- public func bbox< C: Collection & Boundable > ( for boundables: C ) -> C . BoundingBox ? {
56
- return boundables. bbox
54
+ /// Returns the [bounding box](https://en.wikipedia.org/wiki/Minimum_bounding_box) enclosing the points.
55
+ public func bbox< C: Collection > ( for coords: C ) -> BoundingBox3D ? where C. Element == Coordinate3D {
56
+ guard let ( south, north) = coords. map ( \. latitude) . minAndMax ( ) ,
57
+ let ( west, east) = coords. map ( \. longitude) . minAndMax ( ) ,
58
+ let ( low, high) = coords. map ( \. altitude) . minAndMax ( )
59
+ else { return nil }
60
+
61
+ return BoundingBox3D (
62
+ southWestLow: Coordinate3D ( latitude: south, longitude: west, altitude: low) ,
63
+ northEastHigh: Coordinate3D ( latitude: north, longitude: east, altitude: high)
64
+ )
57
65
}
58
66
59
67
/// Returns the [bounding box](https://en.wikipedia.org/wiki/Minimum_bounding_box) enclosing all elements.
0 commit comments