Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Rotate camera in the shortest path. (#426)
Browse files Browse the repository at this point in the history
* Rotate camera in the shortest path.

* Revert "Rotate camera in the shortest path."

This reverts commit 0858d5b

* Fix puck rotate error.

* Remove useless codes.

* Update test cases
  • Loading branch information
Kevin Li committed Jul 1, 2020
1 parent af4c3f3 commit 4c12fb2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ void feedNewLocation(@NonNull @Size(min = 1) Location[] newLocations,
// replace the animation start with the camera's previous value
latLngValues[0] = previousCameraLatLng;
if (isGpsNorth) {
bearingValues = new Float[] {previousCameraBearing, 0f};
bearingValues = new Float[] {previousCameraBearing, shortestRotation(0f, previousCameraBearing)};
} else {
bearingValues[0] = previousCameraBearing;
bearingValues = getBearingValues(previousCameraBearing, newLocations);
}
updateCameraAnimators(latLngValues, bearingValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,35 @@ class LocationAnimatorCoordinatorTest {
}
}

@Test
fun feedNewLocation_animatorValue_bearing() {
val previous = Location("")
previous.latitude = 51.1
previous.longitude = 17.1
previous.bearing = 355f

val current = Location("")
current.latitude = 51.2
current.longitude = 17.2
current.bearing = 0f

locationAnimatorCoordinator.feedNewLocation(arrayOf(previous, current), cameraPosition, false, false)

verify {
animatorProvider.floatAnimator(
arrayOf(0f, -5f, 0f), any(), any()
)
}

locationAnimatorCoordinator.feedNewLocation(arrayOf(previous, current), cameraPosition, true, false)

verify {
animatorProvider.floatAnimator(
arrayOf(0f, 0f), any(), any()
)
}
}

@Test
fun feedNewLocation_animatorValue_multiplePoints_animationDuration() {
every { projection.getMetersPerPixelAtLatitude(any()) } answers { 10000.0 } // disable snap
Expand Down

0 comments on commit 4c12fb2

Please sign in to comment.