cdm/src/main/java/ucar/unidata/geoloc/projection/proj4/LambertConformalConicEllipse.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) {
			if (n < 0.0) {
				rho = -rho;
				fromX = -fromX;
				fromY = -fromY;
			}
			if (isSpherical)
				toLat = 2.0 * Math.atan(Math.pow(c / rho, 1.0/n)) - MapMath.HALFPI;
			else
				toLat = MapMath.phi2(Math.pow(rho / c, 1.0/n), e);

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

		} else {
			toLon = 0.0;
			toLat = n > 0.0 ? MapMath.HALFPI : -MapMath.HALFPI;
		}

    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) {
			if (n < 0.0) {
				rho = -rho;
				fromX = -fromX;
				fromY = -fromY;
			}
			if (isSpherical)
				toLat = 2.0 * Math.atan(Math.pow(c / rho, 1.0/n)) - MapMath.HALFPI;
			else
				toLat = MapMath.phi2(Math.pow(rho / c, 1.0/n), e);

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

		} else {
			toLon = 0.0;
			toLat = n > 0.0 ? MapMath.HALFPI : -MapMath.HALFPI;
		}

    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;
double fromY = world.getY() - falseNorthing;
double rhop = rho;

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

double yd = (rhop - fromY);
double theta = Math.atan2(fromX, yd);
double r = Math.sqrt(fromX * fromX + yd * yd);
if (n < 0.0) {
r *= -1.0;
}

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

if (Math.abs(r) < TOLERANCE) {
toLat = ((n < 0.0)
? -90.0
: 90.0);
} else {
double rn = Math.pow(EARTH_RADIUS * F / r, 1 / n);
toLat = Math.toDegrees(2.0 * Math.atan(rn) - Math.PI / 2);
}

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



public Point2D.Double projectInverse(double x, double y, Point2D.Double out) {
x /= scaleFactor;
y /= scaleFactor;
double rho = MapMath.distance(x, y = rho0 - y);
if (rho != 0) {
if (n < 0.0) {
rho = -rho;
x = -x;
y = -y;
}
if (spherical)
out.y = 2.0 * Math.atan(Math.pow(c / rho, 1.0/n)) - MapMath.HALFPI;
else
out.y = MapMath.phi2(Math.pow(rho / c, 1.0/n), e);
out.x = Math.atan2(x, y) / n;
} else {
out.x = 0.0;
out.y = n > 0.0 ? MapMath.HALFPI : -MapMath.HALFPI;
}
return out;
}
}