### Question:
SphericalMercatorProjection { public static double[] ecefToGeodetic(double[] ecef) { double zp, w2, w, r2, r, s2, c2, s, c, ss, g, rg, rf, u, v, m, f, p, x, y, z; double[] geodetic = new double[3]; x = ecef[0]; y = ecef[1]; z = ecef[2]; zp = Math.abs(z); w2 = x * x + y * y; w = Math.sqrt(w2); r2 = w2 + z * z; r = Math.sqrt(r2); geodetic[1] = Math.atan2(y, x); s2 = z * z / r2; c2 = w2 / r2; u = A2 / r; v = A3 - A4 / r; if (c2 > 0.3) { s = (zp / r) * (1.0 + c2 * (A1 + u + s2 * v) / r); geodetic[0] = Math.asin(s); ss = s * s; c = Math.sqrt(1.0 - ss); } else { c = (w / r) * (1.0 - s2 * (A5 - u - c2 * v) / r); geodetic[0] = Math.acos(c); ss = 1.0 - c * c; s = Math.sqrt(ss); } g = 1.0 - E2 * ss; rg = EARTH_RADIUS / Math.sqrt(g); rf = A6 * rg; u = w - rg * c; v = zp - rf * s; f = c * u + s * v; m = c * v - s * u; p = m / (rf / g + f); geodetic[0] = geodetic[0] + p; geodetic[2] = f + m * p / 2.0; if (z < 0.0) { geodetic[0] *= -1.0; } return geodetic; }  static double yToLatitude(double y); static double xToLongitude(double x); static double latitudeToY(double latitude); static double longitudeToX(double longitude); static Location ecefToLocation(double[] ecef); static double[] ecefToGeodetic(double[] ecef); static double[] locationToEcef(Location location); static double[] geodeticToEcef(double[] geodetic); static final double EARTH_RADIUS; }### Answer:
@Test public void ecefToGeodetic_ecefArray_accurateGeodetic() { double[] expectedGeodetic = new double[]{ LocationTest.SOCCER_FIELD_CENTER.getLatitude(), LocationTest.SOCCER_FIELD_CENTER.getLongitude(), LocationTest.SOCCER_FIELD_CENTER.getAltitude() }; double[] ecefArray = new double[]{3786292.474596871, 890822.9600122868, 5037857.368752121}; double[] actualGeodetic = SphericalMercatorProjection.ecefToGeodetic(ecefArray); assertEquals(expectedGeodetic[0], Math.toDegrees(actualGeodetic[0]), 1); assertEquals(expectedGeodetic[1], Math.toDegrees(actualGeodetic[1]), 1); assertEquals(expectedGeodetic[2], Math.toDegrees(actualGeodetic[2]), 1); }