Exemplo n.º 1
0
 @Override
 protected void readBandRasterDataImpl(
     int sourceOffsetX,
     int sourceOffsetY,
     int sourceWidth,
     int sourceHeight,
     int sourceStepX,
     int sourceStepY,
     Band destBand,
     int destOffsetX,
     int destOffsetY,
     int destWidth,
     int destHeight,
     ProductData destBuffer,
     ProgressMonitor pm)
     throws IOException {
   pm.beginTask("Reading band data...", 3);
   NITFReaderWrapper reader = readerMap.get(destBand);
   try {
     reader.readBandData(
         sourceOffsetX,
         sourceOffsetY,
         sourceWidth,
         sourceHeight,
         sourceStepX,
         sourceStepY,
         destBuffer,
         pm);
   } finally {
     pm.done();
   }
 }
Exemplo n.º 2
0
  @Override
  protected Product readProductNodesImpl() throws IOException {
    productDirectory = RapidEyeReader.getInput(getInput());
    // String dirName =
    // productDirectory.getBasePath().substring(productDirectory.getBasePath().lastIndexOf(File.separator) + 1);
    String metadataFileName = productDirectory.findFirst(RapidEyeConstants.METADATA_FILE_SUFFIX);
    File metadataFile = productDirectory.getFile(metadataFileName);
    // First parse *_metadata.xml
    if (metadataFile.exists()) {
      logger.info("Reading product metadata");
      metadata = XmlMetadata.create(RapidEyeMetadata.class, metadataFile);
      if (metadata == null) {
        logger.warning(
            String.format("Error while reading metadata file %s", metadataFile.getName()));
      } else {
        metadata.setFileName(metadataFile.getName());
        String metadataProfile = metadata.getMetadataProfile();
        if (metadataProfile == null || !metadataProfile.startsWith(RapidEyeConstants.PROFILE_L1)) {
          IOException ex =
              new IOException(
                  "The selected product is not a RapidEye L1 product. Please use the appropriate filter");
          logger.log(Level.SEVERE, ex.getMessage(), ex);
          throw ex;
        }
      }
    } else {
      logger.info("No metadata file found");
    }
    // Second, parse other *.xml if exist
    parseAdditionalMetadataFiles();

    try {
      String[] nitfFiles = getRasterFileNames();
      for (int i = 0; i < nitfFiles.length; i++) {
        NITFReaderWrapper reader = new NITFReaderWrapper(productDirectory.getFile(nitfFiles[i]));
        if (product == null) {
          product =
              new Product(
                  metadata != null
                      ? metadata.getProductName()
                      : RapidEyeConstants.PRODUCT_GENERIC_NAME,
                  RapidEyeConstants.L1_FORMAT_NAMES[0],
                  metadata != null ? metadata.getRasterWidth() : reader.getWidth(),
                  metadata != null ? metadata.getRasterHeight() : reader.getHeight(),
                  this);
          if (metadata != null) {
            product.setProductType(metadata.getMetadataProfile());
            product.setStartTime(metadata.getProductStartTime());
            product.setEndTime(metadata.getProductEndTime());
            product.getMetadataRoot().addElement(metadata.getRootElement());
            NITFMetadata nitfMetadata = reader.getMetadata();
            if (nitfMetadata != null)
              product.getMetadataRoot().addElement(nitfMetadata.getMetadataRoot());
          }
          product.setPreferredTileSize(getPreferredTileSize());
        }
        addBandToProduct(product, reader, i);
      }
      if (product != null) {
        readMasks();
        initGeoCoding(product);
        product.setModified(false);
      }
    } catch (IIOException e) {
      logger.severe("Product is not a valid RapidEye L1 data product!");
    }
    product.setFileLocation(new File(productDirectory.getBasePath()));
    return product;
  }