Program: 11480
Project: 11480
Buggy source:
private PixelPos[][] computeSlavePixPos(final int subSwathIndex,final int mBurstIndex,final int sBurstIndex,final int x0,final int y0,final int w,final int h,final double[] extendedAmount,ProgressMonitor pm) throws Exception {
  try {
    final int xmin=Math.max(x0 - (int)extendedAmount[3],0);
    final int ymin=Math.max(y0 - (int)extendedAmount[1],0);
    final int ymax=y0 + h + (int)Math.abs(extendedAmount[0]);
    final int xmax=x0 + w + (int)Math.abs(extendedAmount[2]);
    final double[] latLonMinMax=new double[4];
    computeImageGeoBoundary(subSwathIndex,mBurstIndex,xmin,xmax,ymin,ymax,latLonMinMax);
    final double delta=(double)dem.getDescriptor().getDegreeRes() / (double)dem.getDescriptor().getPixelRes();
    final double extralat=20 * delta;
    double extralon=20 * delta;
    if (avgSceneHeight >= 2000.0) {
      extralon=20 * delta + 4.0 / 25.0;
    }
    final double latMin=latLonMinMax[0] - extralat;
    final double latMax=latLonMinMax[1] + extralat;
    final double lonMin=latLonMinMax[2] - extralon;
    final double lonMax=latLonMinMax[3] + extralon;
    final PixelPos upperLeft=dem.getIndex(new GeoPos(latMax,lonMin));
    final PixelPos lowerRight=dem.getIndex(new GeoPos(latMin,lonMax));
    final int latMaxIdx=(int)Math.floor(upperLeft.getY());
    final int latMinIdx=(int)Math.ceil(lowerRight.getY());
    final int lonMinIdx=(int)Math.floor(upperLeft.getX());
    final int lonMaxIdx=(int)Math.ceil(lowerRight.getX());
    final int numLines=latMinIdx - latMaxIdx;
    final int numPixels=lonMaxIdx - lonMinIdx;
    double[][] masterAz=new double[numLines][numPixels];
    double[][] masterRg=new double[numLines][numPixels];
    double[][] slaveAz=new double[numLines][numPixels];
    double[][] slaveRg=new double[numLines][numPixels];
    double[][] lat=new double[numLines][numPixels];
    double[][] lon=new double[numLines][numPixels];
    final PositionData posData=new PositionData();
    final PixelPos pix=new PixelPos();
    boolean noValidSlavePixPos=true;
    for (int l=0; l < numLines; l++) {
      for (int p=0; p < numPixels; p++) {
        pix.setLocation(lonMinIdx + p,latMaxIdx + l);
        GeoPos gp=dem.getGeoPos(pix);
        lat[l][p]=gp.lat;
        lon[l][p]=gp.lon;
        final double alt=dem.getElevation(gp);
        if (alt != demNoDataValue) {
          GeoUtils.geo2xyzWGS84(gp.lat,gp.lon,alt,posData.earthPoint);
          if (getPosition(subSwathIndex,mBurstIndex,mSU,mOrbit,posData)) {
            masterAz[l][p]=posData.azimuthIndex;
            masterRg[l][p]=posData.rangeIndex;
            if (getPosition(subSwathIndex,sBurstIndex,sSU,sOrbit,posData)) {
              slaveAz[l][p]=posData.azimuthIndex;
              slaveRg[l][p]=posData.rangeIndex;
              noValidSlavePixPos=false;
              continue;
            }
          }
        }
        masterAz[l][p]=invalidIndex;
        masterRg[l][p]=invalidIndex;
      }
    }
    if (noValidSlavePixPos) {
      return null;
    }
    final org.jlinda.core.Window tileWindow=new org.jlinda.core.Window(y0,y0 + h - 1,x0,x0 + w - 1);
    final double rgAzRatio=mSU.rangeSpacing / mSU.azimuthSpacing;
    final double[][] latArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    final double[][] lonArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    final double[][] azArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    final double[][] rgArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    for (    double[] data : azArray) {
      Arrays.fill(data,invalidIndex);
    }
    for (    double[] data : rgArray) {
      Arrays.fill(data,invalidIndex);
    }
    TriangleUtils.gridDataLinear(masterAz,masterRg,slaveAz,slaveRg,lat,lon,azArray,rgArray,latArray,lonArray,tileWindow,rgAzRatio,1,1,invalidIndex,0);
    boolean allElementsAreNull=true;
    final PixelPos[][] slavePixelPos=new PixelPos[h][w];
    double alt=0;
    for (int yy=0; yy < h; yy++) {
      for (int xx=0; xx < w; xx++) {
        if (maskOutAreaWithoutElevation) {
          alt=dem.getElevation(new GeoPos(latArray[yy][xx],lonArray[yy][xx]));
        }
        if (rgArray[yy][xx] == invalidIndex || azArray[yy][xx] == invalidIndex || (maskOutAreaWithoutElevation && alt == demNoDataValue)) {
          slavePixelPos[yy][xx]=null;
        }
 else {
          slavePixelPos[yy][xx]=new PixelPos(rgArray[yy][xx],azArray[yy][xx]);
          allElementsAreNull=false;
        }
      }
    }
    if (allElementsAreNull) {
      return null;
    }
    return slavePixelPos;
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
private PixelPos[][] computeSlavePixPos(final int subSwathIndex,final int mBurstIndex,final int sBurstIndex,final int x0,final int y0,final int w,final int h,final double[] extendedAmount,ProgressMonitor pm) throws Exception {
  try {
    final int xmin=x0 - (int)extendedAmount[3];
    final int ymin=y0 - (int)extendedAmount[1];
    final int ymax=y0 + h + (int)Math.abs(extendedAmount[0]);
    final int xmax=x0 + w + (int)Math.abs(extendedAmount[2]);
    final double[] latLonMinMax=new double[4];
    computeImageGeoBoundary(subSwathIndex,mBurstIndex,xmin,xmax,ymin,ymax,latLonMinMax);
    final double delta=(double)dem.getDescriptor().getDegreeRes() / (double)dem.getDescriptor().getPixelRes();
    final double extralat=20 * delta;
    final double extralon=20 * delta;
    final double latMin=latLonMinMax[0] - extralat;
    final double latMax=latLonMinMax[1] + extralat;
    final double lonMin=latLonMinMax[2] - extralon;
    final double lonMax=latLonMinMax[3] + extralon;
    final PixelPos upperLeft=dem.getIndex(new GeoPos(latMax,lonMin));
    final PixelPos lowerRight=dem.getIndex(new GeoPos(latMin,lonMax));
    final int latMaxIdx=(int)Math.floor(upperLeft.getY());
    final int latMinIdx=(int)Math.ceil(lowerRight.getY());
    final int lonMinIdx=(int)Math.floor(upperLeft.getX());
    final int lonMaxIdx=(int)Math.ceil(lowerRight.getX());
    final int numLines=latMinIdx - latMaxIdx;
    final int numPixels=lonMaxIdx - lonMinIdx;
    double[][] masterAz=new double[numLines][numPixels];
    double[][] masterRg=new double[numLines][numPixels];
    double[][] slaveAz=new double[numLines][numPixels];
    double[][] slaveRg=new double[numLines][numPixels];
    double[][] lat=new double[numLines][numPixels];
    double[][] lon=new double[numLines][numPixels];
    final PositionData posData=new PositionData();
    final PixelPos pix=new PixelPos();
    boolean noValidSlavePixPos=true;
    for (int l=0; l < numLines; l++) {
      for (int p=0; p < numPixels; p++) {
        pix.setLocation(lonMinIdx + p,latMaxIdx + l);
        GeoPos gp=dem.getGeoPos(pix);
        lat[l][p]=gp.lat;
        lon[l][p]=gp.lon;
        final double alt=dem.getElevation(gp);
        if (alt != demNoDataValue) {
          GeoUtils.geo2xyzWGS84(gp.lat,gp.lon,alt,posData.earthPoint);
          if (getPosition(subSwathIndex,mBurstIndex,mSU,mOrbit,posData)) {
            masterAz[l][p]=posData.azimuthIndex;
            masterRg[l][p]=posData.rangeIndex;
            if (getPosition(subSwathIndex,sBurstIndex,sSU,sOrbit,posData)) {
              slaveAz[l][p]=posData.azimuthIndex;
              slaveRg[l][p]=posData.rangeIndex;
              noValidSlavePixPos=false;
              continue;
            }
          }
        }
        masterAz[l][p]=invalidIndex;
        masterRg[l][p]=invalidIndex;
      }
    }
    if (noValidSlavePixPos) {
      return null;
    }
    final org.jlinda.core.Window tileWindow=new org.jlinda.core.Window(y0,y0 + h - 1,x0,x0 + w - 1);
    final double rgAzRatio=mSU.rangeSpacing / mSU.azimuthSpacing;
    final double[][] latArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    final double[][] lonArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    final double[][] azArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    final double[][] rgArray=new double[(int)tileWindow.lines()][(int)tileWindow.pixels()];
    for (    double[] data : azArray) {
      Arrays.fill(data,invalidIndex);
    }
    for (    double[] data : rgArray) {
      Arrays.fill(data,invalidIndex);
    }
    TriangleUtils.gridDataLinear(masterAz,masterRg,slaveAz,slaveRg,lat,lon,azArray,rgArray,latArray,lonArray,tileWindow,rgAzRatio,1,1,invalidIndex,0);
    boolean allElementsAreNull=true;
    final PixelPos[][] slavePixelPos=new PixelPos[h][w];
    double alt=0;
    for (int yy=0; yy < h; yy++) {
      for (int xx=0; xx < w; xx++) {
        if (maskOutAreaWithoutElevation) {
          alt=dem.getElevation(new GeoPos(latArray[yy][xx],lonArray[yy][xx]));
        }
        if (rgArray[yy][xx] == invalidIndex || azArray[yy][xx] == invalidIndex || (maskOutAreaWithoutElevation && alt == demNoDataValue)) {
          slavePixelPos[yy][xx]=null;
        }
 else {
          slavePixelPos[yy][xx]=new PixelPos(rgArray[yy][xx],azArray[yy][xx]);
          allElementsAreNull=false;
        }
      }
    }
    if (allElementsAreNull) {
      return null;
    }
    return slavePixelPos;
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException("String_Node_Str",e);
  }
  return null;
}