Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions library/src/com/google/maps/android/SphericalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ private SphericalUtil() {}

/**
* The earth's radius, in meters.
* Mean radius as defined by IUGG.
*/
static final double EARTH_RADIUS = 6378137;
static final double EARTH_RADIUS = 6371009;

/**
* Returns the heading from one LatLng to another LatLng. Headings are
Expand Down Expand Up @@ -93,7 +94,8 @@ public static LatLng computeOffsetOrigin(LatLng to, double distance, double head
// There are two solutions for b. b = n2 * n4 +/- sqrt(), one solution results
// in the latitude outside the [-90, 90] range. We first try one solution and
// back off to the other if we are outside that range.
double discriminant = n2 * n2 * n1 * n1 + n1 * n1 * n1 * n1 - n1 * n1 * n4 * n4;
double n12 = n1 * n1;
double discriminant = n2 * n2 * n12 + n12 * n12 - n12 * n4 * n4;
if (discriminant < 0) {
// No real solution which would make sense in LatLng-space.
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ public void testComputeOffsetAndBackToOrigin() {
start = SphericalUtil.computeOffsetOrigin(new LatLng(90, 0),
Math.PI * EARTH_RADIUS / 4, 0);
expectLatLngApproxEquals(
new LatLng(90, 0),
SphericalUtil.computeOffset(start, Math.PI * EARTH_RADIUS / 4, 0));

new LatLng(90, 0),
SphericalUtil.computeOffset(start, Math.PI * EARTH_RADIUS / 4, 0));
}

public void testInterpolate() {
Expand Down