Program: 190857
Project: 190857
Buggy source:
/** 
 * Creates tile.
 * @param x    X coordinate of tile.
 * @param y    Y coordinate of tile.
 * @param zoom Zoom level.
 * @return image in Tile format
 */
public Tile getTile(int x,int y,int zoom){
  double tileWidth=WORLD_WIDTH / Math.pow(2,zoom);
  double padding=tileWidth * mRadius / TILE_DIM;
  double tileWidthPadded=tileWidth + 2 * padding;
  double bucketWidth=tileWidthPadded / (TILE_DIM + mRadius * 2);
  double minX=x * tileWidth - padding;
  double maxX=(x + 1) * tileWidth + padding + SIGMA;
  double minY=y * tileWidth - padding;
  double maxY=(y + 1) * tileWidth + padding + SIGMA;
  double xOffset=0;
  Collection<WeightedLatLng> wrappedPoints=new ArrayList<WeightedLatLng>();
  if (minX < 0) {
    Bounds overlapBounds=new Bounds(minX + WORLD_WIDTH,WORLD_WIDTH,minY,maxY);
    xOffset=-WORLD_WIDTH;
    wrappedPoints=mTree.search(overlapBounds);
  }
 else   if (maxX > WORLD_WIDTH) {
    Bounds overlapBounds=new Bounds(0,maxX - WORLD_WIDTH,minY,maxY);
    xOffset=WORLD_WIDTH;
    wrappedPoints=mTree.search(overlapBounds);
  }
  Bounds tileBounds=new Bounds(minX,maxX,minY,maxY);
  Bounds paddedBounds=new Bounds(mBounds.minX - padding,mBounds.maxX + padding,mBounds.minY - padding,mBounds.maxY + padding);
  if (!tileBounds.intersects(paddedBounds)) {
    return TileProvider.NO_TILE;
  }
  Collection<WeightedLatLng> points=mTree.search(tileBounds);
  if (points.isEmpty()) {
    return TileProvider.NO_TILE;
  }
  double[][] intensity=new double[TILE_DIM + mRadius * 2][TILE_DIM + mRadius * 2];
  for (  WeightedLatLng w : points) {
    Point p=w.getPoint();
    int bucketX=(int)((p.x - minX) / bucketWidth);
    int bucketY=(int)((p.y - minY) / bucketWidth);
    intensity[bucketX][bucketY]+=w.getIntensity();
  }
  for (  WeightedLatLng w : wrappedPoints) {
    Point p=w.getPoint();
    int bucketX=(int)((p.x + xOffset - minX) / bucketWidth);
    int bucketY=(int)((p.y - minY) / bucketWidth);
    intensity[bucketX][bucketY]+=w.getIntensity();
  }
  double[][] convolved=convolve(intensity,mKernel);
  Bitmap bitmap=colorize(convolved,mColorMap,mMaxIntensity[zoom]);
  return convertBitmap(bitmap);
}

Fixed version (ground truth):
/** 
 * Creates tile.
 * @param x    X coordinate of tile.
 * @param y    Y coordinate of tile.
 * @param zoom Zoom level.
 * @return image in Tile format
 */
public Tile getTile(int x,int y,int zoom){
  double tileWidth=WORLD_WIDTH / Math.pow(2,zoom);
  double padding=tileWidth * mRadius / TILE_DIM;
  double tileWidthPadded=tileWidth + 2 * padding;
  double bucketWidth=tileWidthPadded / (TILE_DIM + mRadius * 2);
  double minX=x * tileWidth - padding;
  double maxX=(x + 1) * tileWidth + padding;
  double minY=y * tileWidth - padding;
  double maxY=(y + 1) * tileWidth + padding;
  double xOffset=0;
  Collection<WeightedLatLng> wrappedPoints=new ArrayList<WeightedLatLng>();
  if (minX < 0) {
    Bounds overlapBounds=new Bounds(minX + WORLD_WIDTH,WORLD_WIDTH,minY,maxY);
    xOffset=-WORLD_WIDTH;
    wrappedPoints=mTree.search(overlapBounds);
  }
 else   if (maxX > WORLD_WIDTH) {
    Bounds overlapBounds=new Bounds(0,maxX - WORLD_WIDTH,minY,maxY);
    xOffset=WORLD_WIDTH;
    wrappedPoints=mTree.search(overlapBounds);
  }
  Bounds tileBounds=new Bounds(minX,maxX,minY,maxY);
  Bounds paddedBounds=new Bounds(mBounds.minX - padding,mBounds.maxX + padding,mBounds.minY - padding,mBounds.maxY + padding);
  if (!tileBounds.intersects(paddedBounds)) {
    return TileProvider.NO_TILE;
  }
  Collection<WeightedLatLng> points=mTree.search(tileBounds);
  if (points.isEmpty()) {
    return TileProvider.NO_TILE;
  }
  double[][] intensity=new double[TILE_DIM + mRadius * 2][TILE_DIM + mRadius * 2];
  for (  WeightedLatLng w : points) {
    Point p=w.getPoint();
    int bucketX=(int)((p.x - minX) / bucketWidth);
    int bucketY=(int)((p.y - minY) / bucketWidth);
    intensity[bucketX][bucketY]+=w.getIntensity();
  }
  for (  WeightedLatLng w : wrappedPoints) {
    Point p=w.getPoint();
    int bucketX=(int)((p.x + xOffset - minX) / bucketWidth);
    int bucketY=(int)((p.y - minY) / bucketWidth);
    intensity[bucketX][bucketY]+=w.getIntensity();
  }
  double[][] convolved=convolve(intensity,mKernel);
  Bitmap bitmap=colorize(convolved,mColorMap,mMaxIntensity[zoom]);
  return convertBitmap(bitmap);
}