public DataBounds calculateProjectedImageBounds(Projection p){
  DataBounds db=null;
  if (sourceImageBounds != null) {
    int pw=p.getWidth();
    int ph=p.getHeight();
    Point2D min=sourceImageBounds.getMin();
    Point2D max=sourceImageBounds.getMax();
    double x1=Math.floor(min.getX());
    double y1=Math.floor(min.getY());
    double x2=Math.ceil(max.getX());
    double y2=Math.ceil(max.getY());
    double width=sourceImageBounds.getWidth();
    double height=sourceImageBounds.getHeight();
    LatLonPoint tmpG=new LatLonPoint.Double();
    Point2D tmpP=new Point2D.Double();
    db=new DataBounds();
    db.setHardLimits(new DataBounds(0,0,pw,ph));
    db.add(p.forward(geoTrans.inverse(x1,y1,tmpG),tmpP));
    db.add(p.forward(geoTrans.inverse(x1,y2,tmpG),tmpP));
    db.add(p.forward(geoTrans.inverse(x2,y1,tmpG),tmpP));
    db.add(p.forward(geoTrans.inverse(x2,y2,tmpG),tmpP));
    double numSplits=4;
    double xSpacer=width / numSplits;
    double ySpacer=height / numSplits;
    for (int i=1; i < numSplits; i++) {
      db.add(p.forward(geoTrans.inverse(Math.ceil(x1 + xSpacer * i),y1,tmpG),tmpP));
      db.add(p.forward(geoTrans.inverse(x1,Math.ceil(y1 + ySpacer * i),tmpG),tmpP));
      db.add(p.forward(geoTrans.inverse(Math.ceil(x1 + xSpacer * i),y2,tmpG),tmpP));
      db.add(p.forward(geoTrans.inverse(x2,Math.ceil(y1 + ySpacer * i),tmpG),tmpP));
    }
    if (db.getWidth() <= 0 || db.getHeight() <= 0) {
      logger.fine("dimensions of data bounds bad, returning null " + db);
      return null;
    }
  }
  return db;
}

public DataBounds calculateProjectedImageBounds ( Projection p ) { DataBounds db = null ; if ( sourceImageBounds != null ) { int pw = p . getWidth ( ) ; int ph = p . getHeight ( ) ; Point2D min = sourceImageBounds . getMin ( ) ; Point2D max = sourceImageBounds . getMax ( ) ; double x1 = Math . floor ( min . getX ( ) ) ; double y1 = Math . floor ( min . getY ( ) ) ; double x2 = Math . ceil ( max . getX ( ) ) ; double y2 = Math . ceil ( max . getY ( ) ) ; double width = sourceImageBounds . getWidth ( ) ; double height = sourceImageBounds . getHeight ( ) ; LatLonPoint tmpG = new LatLonPoint . Double ( ) ; Point2D tmpP = new Point2D . Double ( ) ; db = new DataBounds ( ) ; db . setHardLimits ( new DataBounds ( 0 , 0 , pw , ph ) ) ; db . add ( p . forward ( geoTrans . inverse ( x1 , y1 , tmpG ) , tmpP ) ) ; db . add ( p . forward ( geoTrans . inverse ( x1 , y2 , tmpG ) , tmpP ) ) ; db . add ( p . forward ( geoTrans . inverse ( x2 , y1 , tmpG ) , tmpP ) ) ; db . add ( p . forward ( geoTrans . inverse ( x2 , y2 , tmpG ) , tmpP ) ) ; double numSplits = 4 ; double xSpacer = width / numSplits ; double ySpacer = height / numSplits ; for ( int i = 1 ; i < numSplits ; i ++ ) { db . add ( p . forward ( geoTrans . inverse ( Math . ceil ( x1 + xSpacer * i ) , y1 , tmpG ) , tmpP ) ) ; db . add ( p . forward ( geoTrans . inverse ( x1 , Math . ceil ( y1 + ySpacer * i ) , tmpG ) , tmpP ) ) ; db . add ( p . forward ( geoTrans . inverse ( Math . ceil ( x1 + xSpacer * i ) , y2 , tmpG ) , tmpP ) ) ; db . add ( p . forward ( geoTrans . inverse ( x2 , Math . ceil ( y1 + ySpacer * i ) , tmpG ) , tmpP ) ) ; } if ( db . getWidth ( ) <= 0 || db . getHeight ( ) <= 0 ) { logger . fine ( "dimensions of data bounds bad, returning null " + db ) ; return null ; } } return db ; }
returns the image bounds of the image as it would be warped to the provided projection .
