cdm/src/main/java/ucar/unidata/geoloc/projection/LatLonProjection.java
public ProjectionRect[] latLonToProjRect(double lat0, double lon0, double lat1, double lon1) {

    double height = Math.abs(lat1 - lat0);
    lat0 = Math.min(lat1, lat0);
    double width = lon1 - lon0;
    if (width < 1.0e-8) {
      width = 360.0;  // assume its the whole thing
    }
    lon0 = LatLonPointImpl.lonNormal(lon0, centerLon);
    lon1 = LatLonPointImpl.lonNormal(lon1, centerLon);

    ProjectionRect[] rects = new ProjectionRect[] {new ProjectionRect(), new ProjectionRect()};
    if (width >= 360.0) {
      rects[0].setRect(centerLon - 180.0, lat0, 360.0, height);
      rects[1] = null;
    } else if (lon0 < lon1) {
      rects[0].setRect(lon0, lat0, width, height);
      rects[1] = null;
    } else {
      double y = centerLon + 180 - lon0;
      rects[0].setRect(lon0, lat0, y, height);
      rects[1].setRect(lon1 - width + y, lat0, width - y, height);
    }
    return rects;
  }
public ProjectionRect[] latLonToProjRect(double lat0, double lon0, double lat1, double lon1) {

    double height = Math.abs(lat1 - lat0);
    lat0 = Math.min(lat1, lat0);
    double width = lon1 - lon0;
    if (width < 1.0e-8) {
      width = 360.0;  // assume its the whole thing
    }
    lon0 = LatLonPointImpl.lonNormal(lon0, centerLon);
    lon1 = LatLonPointImpl.lonNormal(lon1, centerLon);

    ProjectionRect[] rects = new ProjectionRect[] {new ProjectionRect(), new ProjectionRect()};
    if (width >= 360.0) {
      rects[0].setRect(centerLon - 180.0, lat0, 360.0, height);
      rects[1] = null;
    } else if (lon0 < lon1) {
      rects[0].setRect(lon0, lat0, width, height);
      rects[1] = null;
    } else {
      double y = centerLon + 180 - lon0;
      rects[0].setRect(lon0, lat0, y, height);
      rects[1].setRect(lon1 - width + y, lat0, width - y, height);
    }
    return rects;
  }
public ProjectionRect [ ] latLonToProjRect ( double lat0 , double lon0 , double lat1 , double lon1 ) { double height = Math . abs ( lat1 - lat0 ) ; lat0 = Math . min ( lat1 , lat0 ) ; double width = lon1 - lon0 ; if ( width < 1.0e-8 ) { width = 360.0 ; // assume its the whole thing
 } lon0 = LatLonPointImpl . lonNormal ( lon0 , centerLon ) ; lon1 = LatLonPointImpl . lonNormal ( lon1 , centerLon ) ; ProjectionRect [ ] rects = new ProjectionRect [ ] { new ProjectionRect ( ) , new ProjectionRect ( ) } ; if ( width >= 360.0 ) { rects [ 0 ] . setRect ( centerLon - 180.0 , lat0 , 360.0 , height ) ; rects [ 1 ] = null ; } else if ( lon0 < lon1 ) { rects [ 0 ] . setRect ( lon0 , lat0 , width , height ) ; rects [ 1 ] = null ; } else { double y = centerLon + 180 - lon0 ; rects [ 0 ] . setRect ( lon0 , lat0 , y , height ) ; rects [ 1 ] . setRect ( lon1 - width + y , lat0 , width - y , height ) ; } return rects ; }
Create a latlon rectangle and split it into the equivalent
ProjectionRect using this LatLonProjection. The latlon rect is
constructed from 2 lat/lon points. The lon values are considered
coords in the latlonProjection, and so do not have to be +/- 180.

@param lat0 lat of point 1
@param lon0 lon of point 1
@param lat1 lat of point 1
@param lon1 lon of point 1
@return 1 or 2 ProjectionRect. If it doesnt cross the seam,
the second rectangle is null.
Create a latlon rectangle and split it into the equivalent ProjectionRect using this LatLonProjection . The latlon rect is constructed from 2 lat / lon points . The lon values are considered coords in the latlonProjection and so do not have to be + / - 180 .