Skip to content

Commit 87867b2

Browse files
committed
Typos, added BoundingBox.expanded(byHorizontalDegrees:verticalDegrees:)
1 parent 51ec942 commit 87867b2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Sources/GISTools/GeoJson/BoundingBox.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,29 +184,39 @@ public struct BoundingBox:
184184
}
185185

186186
/// Returns a copy of the receiver expanded by `degrees`.
187-
@available(*, deprecated, renamed: "expanded(byDegrees:)", message: "Renamed to expaned(byDegrees:)")
187+
@available(*, deprecated, renamed: "expanded(byDegrees:)", message: "Renamed to expanded(byDegrees:)")
188188
public func expand(_ degrees: CLLocationDegrees) -> BoundingBox {
189189
expanded(byDegrees: degrees)
190190
}
191191

192192
/// Returns a copy of the receiver expanded by `degrees` horizontally and vertically.
193193
public func expanded(byDegrees degrees: CLLocationDegrees) -> BoundingBox {
194+
expanded(byHorizontalDegrees: degrees, verticalDegrees: degrees)
195+
}
196+
197+
/// Returns a copy of the receiver expanded by `dx` and `dy` horizontally and vertically.
198+
public func expanded(
199+
byHorizontalDegrees dx: CLLocationDegrees,
200+
verticalDegrees dy: CLLocationDegrees
201+
) -> BoundingBox {
194202
switch projection {
195203
case .epsg3857:
196-
return projected(to: .epsg4326).expanded(byDegrees: degrees).projected(to: .epsg3857)
204+
return projected(to: .epsg4326)
205+
.expanded(byHorizontalDegrees: dx, verticalDegrees: dy)
206+
.projected(to: .epsg3857)
197207

198208
case .epsg4326:
199209
return BoundingBox(
200-
southWest: Coordinate3D(latitude: southWest.latitude - degrees, longitude: southWest.longitude - degrees),
201-
northEast: Coordinate3D(latitude: northEast.latitude + degrees, longitude: northEast.longitude + degrees))
210+
southWest: Coordinate3D(latitude: southWest.latitude - dy, longitude: southWest.longitude - dx),
211+
northEast: Coordinate3D(latitude: northEast.latitude + dy, longitude: northEast.longitude + dx))
202212

203213
case .noSRID:
204214
return self // Don't know what to do -> ignore
205215
}
206216
}
207217

208218
/// Returns a copy of the receiver expanded by `distance` diagonally.
209-
@available(*, deprecated, renamed: "expanded(byDistance:)", message: "Renamed to expaned(byDistance:)")
219+
@available(*, deprecated, renamed: "expanded(byDistance:)", message: "Renamed to expanded(byDistance:)")
210220
public func expand(distance: CLLocationDistance) -> BoundingBox {
211221
expanded(byDistance: distance)
212222
}

0 commit comments

Comments
 (0)