public static boolean stitchImagePartitionsFromS3File()

in spark/common/src/main/java/org/apache/sedona/viz/core/ImageStitcher.java [145:225]


  public static boolean stitchImagePartitionsFromS3File(
      String regionName,
      String accessKey,
      String secretKey,
      String bucketName,
      String imageTilePath,
      int resolutionX,
      int resolutionY,
      int zoomLevel,
      int partitionOnX,
      int partitionOnY)
      throws Exception {
    logger.info("[Sedona-Viz][stitchImagePartitions][Start]");

    BufferedImage stitchedImage =
        BigBufferedImage.create(resolutionX, resolutionY, BufferedImage.TYPE_INT_ARGB);
    S3Operator s3Operator = new S3Operator(regionName, accessKey, secretKey);
    // Stitch all image partitions together
    for (int i = 0; i < partitionOnX * partitionOnY; i++) {
      BufferedImage imageTile = null;
      try {
        imageTile =
            s3Operator.getImage(
                bucketName,
                imageTilePath
                    + "-"
                    + RasterizationUtils.getImageTileName(zoomLevel, partitionOnX, partitionOnY, i)
                    + ".png");
      } catch (AmazonS3Exception e) {
        continue;
      }
      Tuple2<Integer, Integer> partitionCoordinate =
          RasterizationUtils.Decode1DTo2DId(partitionOnX, partitionOnY, i);
      int partitionMinX = partitionCoordinate._1 * Math.round(resolutionX / partitionOnX);
      int partitionMinY = partitionCoordinate._2 * Math.round(resolutionY / partitionOnY);
      // if(partitionMinX!=0){partitionMinX--;}
      // if(partitionMinY!=0){partitionMinY--;}
      int[] rgbArray =
          imageTile.getRGB(
              0, 0, imageTile.getWidth(), imageTile.getHeight(), null, 0, imageTile.getWidth());
      int partitionMaxX = partitionMinX + imageTile.getWidth();
      int partitionMaxY = partitionMinY + imageTile.getHeight();
      logger.debug(
          "[Sedona-Viz][stitchImagePartitions] stitching image tile..."
              + i
              + " ResolutionX "
              + resolutionX
              + " ResolutionY "
              + resolutionY);
      logger.debug(
          "[Sedona-Viz][stitchImagePartitions] stitching a image tile..."
              + i
              + " MinX "
              + partitionMinX
              + " MaxX "
              + partitionMaxX
              + " MinY "
              + partitionMinY
              + " MaxY "
              + partitionMaxY);
      stitchedImage.setRGB(
          partitionMinX,
          partitionMinY,
          imageTile.getWidth(),
          imageTile.getHeight(),
          rgbArray,
          0,
          imageTile.getWidth());
    }
    ImageGenerator imageGenerator = new ImageGenerator();
    imageGenerator.SaveRasterImageAsS3File(
        stitchedImage,
        regionName,
        accessKey,
        secretKey,
        bucketName,
        imageTilePath + "-" + zoomLevel + "-stitched",
        ImageType.PNG);
    logger.info("[Sedona-Viz][stitchImagePartitions][Stop]");
    return true;
  }