Skip to content

Commit

Permalink
Added setters for camera parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Archdoog committed Apr 2, 2024
1 parent cc5fac1 commit c85e904
Showing 1 changed file with 57 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,86 +1,84 @@
import Foundation

extension MapViewCamera {

public extension MapViewCamera {
// MARK: Zoom

/// Set a new zoom for the current camera state.
///
/// - Parameter newZoom: The new zoom value.
public mutating func setZoom(_ newZoom: Double) {
switch self.state {
case .centered(let onCoordinate, _, let pitch, let direction):
self.state = .centered(onCoordinate: onCoordinate,
zoom: newZoom,
pitch: pitch,
direction: direction)
case .trackingUserLocation(_, let pitch, let direction):
self.state = .trackingUserLocation(zoom: newZoom, pitch: pitch, direction: direction)
case .trackingUserLocationWithHeading(_, let pitch):
self.state = .trackingUserLocationWithHeading(zoom: newZoom, pitch: pitch)
case .trackingUserLocationWithCourse(_, let pitch):
self.state = .trackingUserLocationWithCourse(zoom: newZoom, pitch: pitch)
case .rect(let boundingBox, let edgePadding):
mutating func setZoom(_ newZoom: Double) {
switch state {
case let .centered(onCoordinate, _, pitch, direction):
state = .centered(onCoordinate: onCoordinate,
zoom: newZoom,
pitch: pitch,
direction: direction)
case let .trackingUserLocation(_, pitch, direction):
state = .trackingUserLocation(zoom: newZoom, pitch: pitch, direction: direction)
case let .trackingUserLocationWithHeading(_, pitch):
state = .trackingUserLocationWithHeading(zoom: newZoom, pitch: pitch)
case let .trackingUserLocationWithCourse(_, pitch):
state = .trackingUserLocationWithCourse(zoom: newZoom, pitch: pitch)
case let .rect(boundingBox, edgePadding):

Check warning on line 22 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'boundingBox' was never used; consider replacing with '_' or removing it

Check warning on line 22 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'edgePadding' was never used; consider replacing with '_' or removing it
return
case .showcase(let shapeCollection):
case let .showcase(shapeCollection):

Check warning on line 24 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'shapeCollection' was never used; consider replacing with '_' or removing it
return
}
self.lastReasonForChange = .programmatic

lastReasonForChange = .programmatic
}

/// Increment the zoom of the current camera state.
///
/// - Parameter newZoom: The value to increment the zoom by. Negative decrements the value.
public mutating func incrementZoom(by increment: Double) {
switch self.state {
case .centered(let onCoordinate, let zoom, let pitch, let direction):
self.state = .centered(onCoordinate: onCoordinate,
zoom: zoom + increment,
pitch: pitch,
direction: direction)
case .trackingUserLocation(let zoom, let pitch, let direction):
self.state = .trackingUserLocation(zoom: zoom + increment, pitch: pitch, direction: direction)
case .trackingUserLocationWithHeading(let zoom, let pitch):
self.state = .trackingUserLocationWithHeading(zoom: zoom + increment, pitch: pitch)
case .trackingUserLocationWithCourse(let zoom, let pitch):
self.state = .trackingUserLocationWithCourse(zoom: zoom + increment, pitch: pitch)
case .rect(let boundingBox, let edgePadding):
mutating func incrementZoom(by increment: Double) {
switch state {
case let .centered(onCoordinate, zoom, pitch, direction):
state = .centered(onCoordinate: onCoordinate,
zoom: zoom + increment,
pitch: pitch,
direction: direction)
case let .trackingUserLocation(zoom, pitch, direction):
state = .trackingUserLocation(zoom: zoom + increment, pitch: pitch, direction: direction)
case let .trackingUserLocationWithHeading(zoom, pitch):
state = .trackingUserLocationWithHeading(zoom: zoom + increment, pitch: pitch)
case let .trackingUserLocationWithCourse(zoom, pitch):
state = .trackingUserLocationWithCourse(zoom: zoom + increment, pitch: pitch)
case let .rect(boundingBox, edgePadding):

Check warning on line 47 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'boundingBox' was never used; consider replacing with '_' or removing it

Check warning on line 47 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'edgePadding' was never used; consider replacing with '_' or removing it
return
case .showcase(let shapeCollection):
case let .showcase(shapeCollection):

Check warning on line 49 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'shapeCollection' was never used; consider replacing with '_' or removing it
return
}
self.lastReasonForChange = .programmatic

lastReasonForChange = .programmatic
}

// MARK: Pitch

/// Set a new pitch for the current camera state.
///
/// - Parameter newPitch: The new pitch value.
public mutating func setPitch(_ newPitch: CameraPitch) {
switch self.state {
case .centered(let onCoordinate, let zoom, let pitch, let direction):
self.state = .centered(onCoordinate: onCoordinate,
zoom: zoom,
pitch: newPitch,
direction: direction)
case .trackingUserLocation(let zoom, _, let direction):
self.state = .trackingUserLocation(zoom: zoom, pitch: newPitch, direction: direction)
case .trackingUserLocationWithHeading(let zoom, _):
self.state = .trackingUserLocationWithHeading(zoom: zoom, pitch: newPitch)
case .trackingUserLocationWithCourse(let zoom, _):
self.state = .trackingUserLocationWithCourse(zoom: zoom, pitch: newPitch)
case .rect(let boundingBox, let edgePadding):
mutating func setPitch(_ newPitch: CameraPitch) {
switch state {
case let .centered(onCoordinate, zoom, pitch, direction):

Check warning on line 63 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'pitch' was never used; consider replacing with '_' or removing it
state = .centered(onCoordinate: onCoordinate,
zoom: zoom,
pitch: newPitch,
direction: direction)
case let .trackingUserLocation(zoom, _, direction):
state = .trackingUserLocation(zoom: zoom, pitch: newPitch, direction: direction)
case let .trackingUserLocationWithHeading(zoom, _):
state = .trackingUserLocationWithHeading(zoom: zoom, pitch: newPitch)
case let .trackingUserLocationWithCourse(zoom, _):
state = .trackingUserLocationWithCourse(zoom: zoom, pitch: newPitch)
case let .rect(boundingBox, edgePadding):

Check warning on line 74 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'boundingBox' was never used; consider replacing with '_' or removing it

Check warning on line 74 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'edgePadding' was never used; consider replacing with '_' or removing it
return
case .showcase(let shapeCollection):
case let .showcase(shapeCollection):

Check warning on line 76 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift

View workflow job for this annotation

GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)

immutable value 'shapeCollection' was never used; consider replacing with '_' or removing it
return
}
self.lastReasonForChange = .programmatic

lastReasonForChange = .programmatic
}

// TODO: Add direction set

}

0 comments on commit c85e904

Please sign in to comment.