Skip to content

Commit

Permalink
renaming CameraPitch
Browse files Browse the repository at this point in the history
  • Loading branch information
hactar committed May 13, 2024
1 parent bec6c70 commit 420efc1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import MapLibre

/// The current pitch state for the MapViewCamera
public enum CameraPitch: Hashable, Sendable {
public enum CameraPitchRange: Hashable, Sendable {
/// The user is free to control pitch from it's default min to max.
case free

Expand Down
8 changes: 4 additions & 4 deletions Sources/MapLibreSwiftUI/Models/MapCamera/CameraState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ public enum CameraState: Hashable {
onCoordinate: CLLocationCoordinate2D,
zoom: Double,
pitch: Double,
pitchRange: CameraPitch,
pitchRange: CameraPitchRange,
direction: CLLocationDirection
)

/// Follow the user's location using the MapView's internal camera.
///
/// This feature uses the MLNMapView's userTrackingMode to .follow which automatically
/// follows the user from within the MLNMapView.
case trackingUserLocation(zoom: Double, pitch: Double, pitchRange: CameraPitch, direction: CLLocationDirection)
case trackingUserLocation(zoom: Double, pitch: Double, pitchRange: CameraPitchRange, direction: CLLocationDirection)

/// Follow the user's location using the MapView's internal camera with the user's heading.
///
/// This feature uses the MLNMapView's userTrackingMode to .followWithHeading which automatically
/// follows the user from within the MLNMapView.
case trackingUserLocationWithHeading(zoom: Double, pitch: Double, pitchRange: CameraPitch)
case trackingUserLocationWithHeading(zoom: Double, pitch: Double, pitchRange: CameraPitchRange)

/// Follow the user's location using the MapView's internal camera with the users' course
///
/// This feature uses the MLNMapView's userTrackingMode to .followWithCourse which automatically
/// follows the user from within the MLNMapView.
case trackingUserLocationWithCourse(zoom: Double, pitch: Double, pitchRange: CameraPitch)
case trackingUserLocationWithCourse(zoom: Double, pitch: Double, pitchRange: CameraPitchRange)

/// Centered on a bounding box/rectangle.
case rect(
Expand Down
10 changes: 5 additions & 5 deletions Sources/MapLibreSwiftUI/Models/MapCamera/MapViewCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct MapViewCamera: Hashable {
public static let coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0)
public static let zoom: Double = 10
public static let pitch: Double = 0
public static let pitchRange: CameraPitch = .free
public static let pitchRange: CameraPitchRange = .free
public static let direction: CLLocationDirection = 0
}

Expand Down Expand Up @@ -51,7 +51,7 @@ public struct MapViewCamera: Hashable {
public static func center(_ coordinate: CLLocationCoordinate2D,
zoom: Double,
pitch: Double = Defaults.pitch,
pitchRange: CameraPitch = Defaults.pitchRange,
pitchRange: CameraPitchRange = Defaults.pitchRange,
direction: CLLocationDirection = Defaults.direction,
reason: CameraChangeReason? = nil) -> MapViewCamera
{
Expand All @@ -70,7 +70,7 @@ public struct MapViewCamera: Hashable {
/// - Returns: The MapViewCamera representing the scenario
public static func trackUserLocation(zoom: Double = Defaults.zoom,
pitch: Double = Defaults.pitch,
pitchRange: CameraPitch = Defaults.pitchRange,
pitchRange: CameraPitchRange = Defaults.pitchRange,
direction: CLLocationDirection = Defaults.direction) -> MapViewCamera
{
// Coordinate is ignored when tracking user location. However, pitch and zoom are valid.
Expand All @@ -88,7 +88,7 @@ public struct MapViewCamera: Hashable {
/// - pitch: Set the camera pitch method.
/// - Returns: The MapViewCamera representing the scenario
public static func trackUserLocationWithHeading(zoom: Double = Defaults.zoom,
pitch: Double = Defaults.pitch, pitchRange: CameraPitch = Defaults.pitchRange) -> MapViewCamera
pitch: Double = Defaults.pitch, pitchRange: CameraPitchRange = Defaults.pitchRange) -> MapViewCamera
{
// Coordinate is ignored when tracking user location. However, pitch and zoom are valid.
MapViewCamera(state: .trackingUserLocationWithHeading(zoom: zoom, pitch: pitch, pitchRange: pitchRange),
Expand All @@ -105,7 +105,7 @@ public struct MapViewCamera: Hashable {
/// - pitch: Set the camera pitch method.
/// - Returns: The MapViewCamera representing the scenario
public static func trackUserLocationWithCourse(zoom: Double = Defaults.zoom,
pitch: Double = Defaults.pitch, pitchRange: CameraPitch = Defaults.pitchRange) -> MapViewCamera
pitch: Double = Defaults.pitch, pitchRange: CameraPitchRange = Defaults.pitchRange) -> MapViewCamera
{
// Coordinate is ignored when tracking user location. However, pitch and zoom are valid.
MapViewCamera(state: .trackingUserLocationWithCourse(zoom: zoom, pitch: pitch, pitchRange: pitchRange),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import XCTest

final class CameraPitchTests: XCTestCase {
func testFreePitch() {
let pitch: CameraPitch = .free
let pitch: CameraPitchRange = .free
XCTAssertEqual(pitch.rangeValue.lowerBound, 0)
XCTAssertEqual(pitch.rangeValue.upperBound, 60)
}

func testRangePitch() {
let pitch = CameraPitch.freeWithinRange(minimum: 9, maximum: 29)
let pitch = CameraPitchRange.freeWithinRange(minimum: 9, maximum: 29)
XCTAssertEqual(pitch.rangeValue.lowerBound, 9)
XCTAssertEqual(pitch.rangeValue.upperBound, 29)
}

func testFixedPitch() {
let pitch = CameraPitch.fixed(41)
let pitch = CameraPitchRange.fixed(41)
XCTAssertEqual(pitch.rangeValue.lowerBound, 41)
XCTAssertEqual(pitch.rangeValue.upperBound, 41)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ final class MapViewCameraTests: XCTestCase {
}

func testTrackingUserLocation() {
let pitch: CameraPitch = .freeWithinRange(minimum: 12, maximum: 34)
let pitch: CameraPitchRange = .freeWithinRange(minimum: 12, maximum: 34)
let camera = MapViewCamera.trackUserLocation(zoom: 10, pitchRange: pitch)

assertSnapshot(of: camera, as: .dump)
}

func testTrackUserLocationWithCourse() {
let pitchRange: CameraPitch = .freeWithinRange(minimum: 12, maximum: 34)
let pitchRange: CameraPitchRange = .freeWithinRange(minimum: 12, maximum: 34)
let camera = MapViewCamera.trackUserLocationWithCourse(zoom: 18, pitchRange: pitchRange)

assertSnapshot(of: camera, as: .dump)
Expand Down

0 comments on commit 420efc1

Please sign in to comment.