cdm/src/main/java/ucar/unidata/geoloc/projection/proj4/AlbersEqualAreaEllipse.java
public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) {
    double toLat, toLon;
    double fromX = (world.getX() - falseEasting) / totalScale;  // assumes cartesion coords in km
    double fromY = (world.getY() - falseNorthing) / totalScale;

    fromY = rho0 - fromY;
    double rho = MapMath.distance(fromX, fromY);

    if (rho == 0.0) {
      toLon = 0.0;
      toLat = n > 0.0 ? MapMath.HALFPI : -MapMath.HALFPI;

    } else {
      if (n < 0.0) {
        rho = -rho;
        fromX = -fromX;
        fromY = -fromY;
      }
      double lpphi = rho / dd;

      if (!earth.isSpherical()) {
        lpphi = (c - lpphi * lpphi) / n;
        if (Math.abs(ec - Math.abs(lpphi)) > TOL7) {
          if (Math.abs(lpphi) > 2.0)
            throw new IllegalArgumentException("AlbersEqualAreaEllipse x,y="+world);

          lpphi = phi1_(lpphi, e, one_es);
          if (lpphi == Double.MAX_VALUE)
            throw new RuntimeException("I");
        } else {
          lpphi = (lpphi < 0.) ? -MapMath.HALFPI : MapMath.HALFPI;
        }

      } else { // spherical case
        lpphi = (c - lpphi * lpphi) / n2;
        if (Math.abs(lpphi) <= 1.0) {
          lpphi = Math.asin(lpphi);
        } else {
          lpphi = (lpphi < 0.) ? -MapMath.HALFPI : MapMath.HALFPI;
        }
      }

      toLon = Math.atan2(fromX, fromY) / n;
      //coverity[swapped_arguments]
      toLat = lpphi;
    }

    result.setLatitude(Math.toDegrees(toLat));
    result.setLongitude(Math.toDegrees(toLon) + lon0deg);
    return result;
  }
public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) {
    double toLat, toLon;
    double fromX = (world.getX() - falseEasting) / totalScale;  // assumes cartesion coords in km
    double fromY = (world.getY() - falseNorthing) / totalScale;

    fromY = rho0 - fromY;
    double rho = MapMath.distance(fromX, fromY);

    if (rho == 0.0) {
      toLon = 0.0;
      toLat = n > 0.0 ? MapMath.HALFPI : -MapMath.HALFPI;

    } else {
      if (n < 0.0) {
        rho = -rho;
        fromX = -fromX;
        fromY = -fromY;
      }
      double lpphi = rho / dd;

      if (!earth.isSpherical()) {
        lpphi = (c - lpphi * lpphi) / n;
        if (Math.abs(ec - Math.abs(lpphi)) > TOL7) {
          if (Math.abs(lpphi) > 2.0)
            throw new IllegalArgumentException("AlbersEqualAreaEllipse x,y="+world);

          lpphi = phi1_(lpphi, e, one_es);
          if (lpphi == Double.MAX_VALUE)
            throw new RuntimeException("I");
        } else {
          lpphi = (lpphi < 0.) ? -MapMath.HALFPI : MapMath.HALFPI;
        }

      } else { // spherical case
        lpphi = (c - lpphi * lpphi) / n2;
        if (Math.abs(lpphi) <= 1.0) {
          lpphi = Math.asin(lpphi);
        } else {
          lpphi = (lpphi < 0.) ? -MapMath.HALFPI : MapMath.HALFPI;
        }
      }

      toLon = Math.atan2(fromX, fromY) / n;
      //coverity[swapped_arguments]
      toLat = lpphi;
    }

    result.setLatitude(Math.toDegrees(toLat));
    result.setLongitude(Math.toDegrees(toLon) + lon0deg);
    return result;
  }
Convert projection coordinates to a LatLonPoint
Note: a new object is not created on each call for the return value.

@param world  convert from these projection coordinates
@param result the object to write to
@return LatLonPoint convert to these lat/lon coordinates

public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) {
double toLat, toLon;
double fromX = world.getX() - falseEasting;
double fromY = world.getY() - falseNorthing;
double rrho0 = rho0;

if (n < 0) {
rrho0 *= -1.0;
fromX *= -1.0;
fromY *= -1.0;
}

double yd = rrho0 - fromY;
double rho = Math.sqrt(fromX * fromX + yd * yd);
double theta = Math.atan2(fromX, yd);
if (n < 0) {
rho *= -1.0;
}
toLat = Math.toDegrees(Math.asin((C - Math.pow((rho * n / EARTH_RADIUS), 2)) / (2 * n)));

toLon = Math.toDegrees(theta / n + lon0);

result.setLatitude(toLat);
result.setLongitude(toLon);
return result;
}


public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) {
double rho;
if ((rho = MapMath.distance(xyx, xyy = rho0 - xyy)) != 0) {
double lpphi, lplam;
if (n < 0.) {
rho = -rho;
xyx = -xyx;
xyy = -xyy;
}
lpphi =  rho / dd;
if (!spherical) {
lpphi = (c - lpphi * lpphi) / n;
if (Math.abs(ec - Math.abs(lpphi)) > TOL7) {
if ((lpphi = phi1_(lpphi, e, one_es)) == Double.MAX_VALUE)
throw new ProjectionException("I");
} else
lpphi = lpphi < 0. ? -MapMath.HALFPI : MapMath.HALFPI;
} else if (Math.abs(out.y = (c - lpphi * lpphi) / n2) <= 1.)
lpphi = Math.asin(lpphi);
else
lpphi = lpphi < 0. ? -MapMath.HALFPI : MapMath.HALFPI;
lplam = Math.atan2(xyx, xyy) / n;
out.x = lplam;
out.y = lpphi;
} else {
out.x = 0.;
out.y = n > 0. ? MapMath.HALFPI : - MapMath.HALFPI;
}
return out;
}