Program: 11485
Project: 11485
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[] tileOverlapPercentage,ProgressMonitor pm) throws Exception {
  try {
    final int xmin=x0;
    final int ymin=Math.max(y0 - (int)(tileSize * tileOverlapPercentage[1]),0);
    final int ymax=y0 + h + (int)(tileSize * Math.abs(tileOverlapPercentage[0]));
    final int xmax=x0 + w;
    final double[] latLonMinMax=new double[4];
    computeImageGeoBoundary(xmin,xmax,ymin,ymax,latLonMinMax);
    final double delta=(double)dem.getDescriptor().getDegreeRes() / (double)dem.getDescriptor().getPixelRes();
    final double extralat=2 * delta;
    final double extralon=2 * 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];
    final PositionData posData=new PositionData();
    boolean noValidSlavePixPos=true;
    for (int l=0; l < numLines; l++) {
      for (int p=0; p < numPixels; p++) {
        GeoPos gp=dem.getGeoPos(new PixelPos(lonMinIdx + p,latMaxIdx + l));
        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[][] 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,azArray,rgArray,tileWindow,rgAzRatio,1,1,invalidIndex,0);
    boolean allElementsAreNull=true;
    final PixelPos[][] slavePixelPos=new PixelPos[h][w];
    for (int yy=0; yy < h; yy++) {
      for (int xx=0; xx < w; xx++) {
        if (rgArray[yy][xx] == invalidIndex || azArray[yy][xx] == invalidIndex) {
          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[] tileOverlapPercentage,ProgressMonitor pm) throws Exception {
  try {
    final int xmin=x0;
    final int ymin=Math.max(y0 - (int)(tileSize * tileOverlapPercentage[1]),0);
    final int ymax=y0 + h + (int)(tileSize * Math.abs(tileOverlapPercentage[0]));
    final int xmax=x0 + w;
    final double[] latLonMinMax=new double[4];
    computeImageGeoBoundary(xmin,xmax,ymin,ymax,latLonMinMax);
    final double delta=(double)dem.getDescriptor().getDegreeRes() / (double)dem.getDescriptor().getPixelRes();
    final double extralat=2 * delta;
    final double extralon=2 * 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();
    boolean noValidSlavePixPos=true;
    for (int l=0; l < numLines; l++) {
      for (int p=0; p < numPixels; p++) {
        GeoPos gp=dem.getGeoPos(new PixelPos(lonMinIdx + p,latMaxIdx + l));
        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];
    for (int yy=0; yy < h; yy++) {
      for (int xx=0; xx < w; xx++) {
        final double alt=dem.getElevation(new GeoPos(latArray[yy][xx],lonArray[yy][xx]));
        if (rgArray[yy][xx] == invalidIndex || azArray[yy][xx] == invalidIndex || 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;
}