code: public Coordinate ecefToWgs84( Coordinate ecef ) {
          // Radius computation
          double r = sqrt(pow(ecef.x, 2) + pow(ecef.y, 2) + pow(ecef.z, 2));
          // Geocentric longitude
          double lamGeoc = atan2(ecef.y, ecef.x);
          // Geocentric latitude
          double phiGeoc = atan(ecef.z / sqrt(pow(ecef.x, 2) + pow(ecef.y, 2)));
          // Computation of geodetic coordinates
          double psi = atan(tan(phiGeoc) / sqrt(1 - eccentricityP2));
          double phiGeod = atan((r * sin(phiGeoc) + eccentricityP2 * semiMajorAxis / sqrt(1 - eccentricityP2) * pow(sin(psi), 3))
                  / (r * cos(phiGeoc) - eccentricityP2 * semiMajorAxis * pow(cos(psi), 3)));
          double lamGeod = lamGeoc;
          double N = semiMajorAxis / sqrt(1 - eccentricityP2 * pow(sin(phiGeod), 2));
          double h = r * cos(phiGeoc) / cos(phiGeod) - N;
  
          double lon = toDegrees(lamGeod);
          double lat = toDegrees(phiGeod);
          return new Coordinate(lon, lat, h);
      }
docs: Converts a Earth-Centered Earth-Fixed (ECEF) coordinate to WGS84.
  
  @param ecef the ecef coordinate.
  @return the wgs84 coordinate.