cdm/src/main/java/ucar/unidata/geoloc/projection/FlatEarth.java
public LatLonPoint projToLatLon(ProjectionPoint world,
                                  LatLonPointImpl result) {
    double toLat, toLon;
    double x = world.getX();
    double y = world.getY();
    double cosl;
    int TOLERENCE = 1;
    double xp, yp;

    xp = cosRot * x + sinRot * y;
    yp = -sinRot * x + cosRot * y;

    toLat = Math.toDegrees(lat0) + Math.toDegrees(yp / radius);
    //double lat2;
    //lat2 = lat0 + Math.toDegrees(yp/radius);
    cosl = Math.cos(Math.toRadians(toLat));
    if (Math.abs(cosl) < TOLERANCE) {
      toLon = Math.toDegrees(lon0);
    } else {
      toLon = Math.toDegrees(lon0)
              + Math.toDegrees(xp / cosl / radius);
    }

    toLon = LatLonPointImpl.lonNormal(toLon);

    result.setLatitude(toLat);
    result.setLongitude(toLon);
    return result;
  }
public LatLonPoint projToLatLon(ProjectionPoint world,
                                  LatLonPointImpl result) {
    double toLat, toLon;
    double x = world.getX();
    double y = world.getY();
    double cosl;
    int TOLERENCE = 1;
    double xp, yp;

    xp = cosRot * x + sinRot * y;
    yp = -sinRot * x + cosRot * y;

    toLat = Math.toDegrees(lat0) + Math.toDegrees(yp / radius);
    //double lat2;
    //lat2 = lat0 + Math.toDegrees(yp/radius);
    cosl = Math.cos(Math.toRadians(toLat));
    if (Math.abs(cosl) < TOLERANCE) {
      toLon = Math.toDegrees(lon0);
    } else {
      toLon = Math.toDegrees(lon0)
              + Math.toDegrees(xp / cosl / radius);
    }

    toLon = LatLonPointImpl.lonNormal(toLon);

    result.setLatitude(toLat);
    result.setLongitude(toLon);
    return result;
  }
public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { double toLat , toLon ; double x = world . getX ( ) ; double y = world . getY ( ) ; double cosl ; int TOLERENCE = 1 ; double xp , yp ; xp = cosRot * x + sinRot * y ; yp = - sinRot * x + cosRot * y ; toLat = Math . toDegrees ( lat0 ) + Math . toDegrees ( yp / radius ) ; //double lat2; //lat2 = lat0 + Math.toDegrees(yp/radius); cosl = Math . cos ( Math . toRadians ( toLat ) ) ; if ( Math . abs ( cosl ) < TOLERANCE ) { toLon = Math . toDegrees ( lon0 ) ; } else { toLon = Math . toDegrees ( lon0 ) + Math . toDegrees ( xp / cosl / radius ) ; } toLon = LatLonPointImpl . lonNormal ( toLon ) ; result . setLatitude ( toLat ) ; result . setLongitude ( toLon ) ; 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
Convert projection coordinates to a LatLonPoint Note : a new object is not created on each call for the return value .