cdm/src/main/java/ucar/unidata/geoloc/ProjectionImpl.java
public LatLonRect projToLatLonBB(ProjectionRect bb) {
    // look at all 4 corners of the bounding box
    LatLonPoint llpt = projToLatLon(bb.getLowerLeftPoint(), new LatLonPointImpl());
    LatLonPoint lrpt = projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl());
    LatLonPoint urpt = projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl());
    LatLonPoint ulpt = projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());

    // Check if grid contains poles.
    boolean includesNorthPole = false;
    /* int[] resultNP;
    findXYindexFromLatLon(90.0, 0, resultNP);
    if (resultNP[0] != -1 && resultNP[1] != -1)
      includesNorthPole = true;      */
    boolean includesSouthPole = false;
    /* int[] resultSP = new int[2];
    findXYindexFromLatLon(-90.0, 0, resultSP);
    if (resultSP[0] != -1 && resultSP[1] != -1)
      includesSouthPole = true; */

    LatLonRect llbb;

    if (includesNorthPole && !includesSouthPole) {
      llbb = new LatLonRect(llpt, new LatLonPointImpl(90.0, 0.0)); // ??? lon=???
      llbb.extend(lrpt);
      llbb.extend(urpt);
      llbb.extend(ulpt);
      // OR
      //llbb.extend( new LatLonRect( llpt, lrpt ));
      //llbb.extend( new LatLonRect( lrpt, urpt ) );
      //llbb.extend( new LatLonRect( urpt, ulpt ) );
      //llbb.extend( new LatLonRect( ulpt, llpt ) );
    } else if (includesSouthPole && !includesNorthPole) {
      llbb = new LatLonRect(llpt, new LatLonPointImpl(-90.0, -180.0)); // ??? lon=???
      llbb.extend(lrpt);
      llbb.extend(urpt);
      llbb.extend(ulpt);

    } else {
      double latMin = Math.min(llpt.getLatitude(), lrpt.getLatitude());
      double latMax = Math.max(ulpt.getLatitude(), urpt.getLatitude());

      // longitude is a bit tricky as usual
      double lonMin = getMinOrMaxLon(llpt.getLongitude(), ulpt.getLongitude(), true);
      double lonMax = getMinOrMaxLon(lrpt.getLongitude(), urpt.getLongitude(), false);

      LatLonPointImpl min = new LatLonPointImpl(latMin, lonMin);
      LatLonPointImpl max = new LatLonPointImpl(latMax, lonMax);
      llbb = new LatLonRect(min, max);
    }

    return llbb;
  }
public LatLonRect projToLatLonBB(ProjectionRect bb) {
    // look at all 4 corners of the bounding box
    LatLonPoint llpt = projToLatLon(bb.getLowerLeftPoint(), new LatLonPointImpl());
    LatLonPoint lrpt = projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl());
    LatLonPoint urpt = projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl());
    LatLonPoint ulpt = projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());

    // Check if grid contains poles.
    boolean includesNorthPole = false;
    /* int[] resultNP;
    findXYindexFromLatLon(90.0, 0, resultNP);
    if (resultNP[0] != -1 && resultNP[1] != -1)
      includesNorthPole = true;      */
    boolean includesSouthPole = false;
    /* int[] resultSP = new int[2];
    findXYindexFromLatLon(-90.0, 0, resultSP);
    if (resultSP[0] != -1 && resultSP[1] != -1)
      includesSouthPole = true; */

    LatLonRect llbb;

    if (includesNorthPole && !includesSouthPole) {
      llbb = new LatLonRect(llpt, new LatLonPointImpl(90.0, 0.0)); // ??? lon=???
      llbb.extend(lrpt);
      llbb.extend(urpt);
      llbb.extend(ulpt);
      // OR
      //llbb.extend( new LatLonRect( llpt, lrpt ));
      //llbb.extend( new LatLonRect( lrpt, urpt ) );
      //llbb.extend( new LatLonRect( urpt, ulpt ) );
      //llbb.extend( new LatLonRect( ulpt, llpt ) );
    } else if (includesSouthPole && !includesNorthPole) {
      llbb = new LatLonRect(llpt, new LatLonPointImpl(-90.0, -180.0)); // ??? lon=???
      llbb.extend(lrpt);
      llbb.extend(urpt);
      llbb.extend(ulpt);

    } else {
      double latMin = Math.min(llpt.getLatitude(), lrpt.getLatitude());
      double latMax = Math.max(ulpt.getLatitude(), urpt.getLatitude());

      // longitude is a bit tricky as usual
      double lonMin = getMinOrMaxLon(llpt.getLongitude(), ulpt.getLongitude(), true);
      double lonMax = getMinOrMaxLon(lrpt.getLongitude(), urpt.getLongitude(), false);

      LatLonPointImpl min = new LatLonPointImpl(latMin, lonMin);
      LatLonPointImpl max = new LatLonPointImpl(latMax, lonMax);
      llbb = new LatLonRect(min, max);
    }

    return llbb;
  }
public LatLonRect projToLatLonBB ( ProjectionRect bb ) { // look at all 4 corners of the bounding box
 LatLonPoint llpt = projToLatLon ( bb . getLowerLeftPoint ( ) , new LatLonPointImpl ( ) ) ; LatLonPoint lrpt = projToLatLon ( bb . getLowerRightPoint ( ) , new LatLonPointImpl ( ) ) ; LatLonPoint urpt = projToLatLon ( bb . getUpperRightPoint ( ) , new LatLonPointImpl ( ) ) ; LatLonPoint ulpt = projToLatLon ( bb . getUpperLeftPoint ( ) , new LatLonPointImpl ( ) ) ; // Check if grid contains poles.
 boolean includesNorthPole = false ; /* int[] resultNP;
    findXYindexFromLatLon(90.0, 0, resultNP);
    if (resultNP[0] != -1 && resultNP[1] != -1)
      includesNorthPole = true;      */ boolean includesSouthPole = false ; /* int[] resultSP = new int[2];
    findXYindexFromLatLon(-90.0, 0, resultSP);
    if (resultSP[0] != -1 && resultSP[1] != -1)
      includesSouthPole = true; */ LatLonRect llbb ; if ( includesNorthPole && ! includesSouthPole ) { llbb = new LatLonRect ( llpt , new LatLonPointImpl ( 90.0 , 0.0 ) ) ; // ??? lon=???
 llbb . extend ( lrpt ) ; llbb . extend ( urpt ) ; llbb . extend ( ulpt ) ; // OR
 //llbb.extend( new LatLonRect( llpt, lrpt ));
 //llbb.extend( new LatLonRect( lrpt, urpt ) );
 //llbb.extend( new LatLonRect( urpt, ulpt ) );
 //llbb.extend( new LatLonRect( ulpt, llpt ) );
 } else if ( includesSouthPole && ! includesNorthPole ) { llbb = new LatLonRect ( llpt , new LatLonPointImpl ( - 90.0 , - 180.0 ) ) ; // ??? lon=???
 llbb . extend ( lrpt ) ; llbb . extend ( urpt ) ; llbb . extend ( ulpt ) ; } else { double latMin = Math . min ( llpt . getLatitude ( ) , lrpt . getLatitude ( ) ) ; double latMax = Math . max ( ulpt . getLatitude ( ) , urpt . getLatitude ( ) ) ; // longitude is a bit tricky as usual
 double lonMin = getMinOrMaxLon ( llpt . getLongitude ( ) , ulpt . getLongitude ( ) , true ) ; double lonMax = getMinOrMaxLon ( lrpt . getLongitude ( ) , urpt . getLongitude ( ) , false ) ; LatLonPointImpl min = new LatLonPointImpl ( latMin , lonMin ) ; LatLonPointImpl max = new LatLonPointImpl ( latMax , lonMax ) ; llbb = new LatLonRect ( min , max ) ; } return llbb ; }
Compute lat/lon bounding box from projection bounding box by finding the minimum enclosing box.
@param bb projection bounding box
@return lat, lon bounding box.
Compute lat / lon bounding box from projection bounding box by finding the minimum enclosing box .