示例#1
0
  /**
   * Override because of the AATSR attachment flag treating. Valis dsds might have zero MDSR's
   * attached because the attachment_flag is rised for the whole (subset) product.
   *
   * @param datasetType the desired dataset type
   * @return all valis dsds conforming to the dataset type
   */
  @Override
  public DSD[] getValidDSDs(char datasetType) {
    ArrayList<DSD> dsdList = new ArrayList<DSD>();
    for (int i = 0; i < getNumDSDs(); i++) {
      final DSD dsd = getDSDAt(i);
      if (dsd.getDatasetType() == datasetType && !StringUtils.isNullOrEmpty(dsd.getDatasetName())) {
        dsdList.add(dsd);
      }
    }

    return dsdList.toArray(new DSD[dsdList.size()]);
  }
示例#2
0
 static int calculateSceneRasterHeight(DSD dsdGeoLocationAds, int numMDSR) {
   final int linesFromADS =
       (dsdGeoLocationAds.getNumRecords() - 1)
           * EnvisatConstants.AATSR_LOC_TIE_POINT_SUBSAMPLING_Y;
   if (numMDSR > linesFromADS) {
     return numMDSR;
   }
   return linesFromADS;
 }
  public void execute() throws MojoExecutionException {

    // Get the System Classloader
    ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();

    // Get the URLs
    URL[] urls = ((URLClassLoader) sysClassLoader).getURLs();

    for (int i = 0; i < urls.length; i++) {
      System.out.println(urls[i].getFile());
    }

    File f = null;
    if (isMain) f = sourceDirectory;
    else f = testSourceDirectory;
    if (f == null || !f.exists()) {
      throw new MojoExecutionException("Source directory (" + f + ")could not be found");
    }

    String dsdPath = null;
    if (dsdPackage != null) {
      String lookupDir = f.getPath() + "/" + dsdPackage.replace('.', '/') + "/";
      dsdPath = dsdFileName(lookupDir, dsdFile);
      if (dsdPath == null) {
        if (dsdFile != null) {
          throw new MojoExecutionException(
              "Configured DSD file " + lookupDir + dsdFile + " could not be found.");
        } else {
          throw new MojoExecutionException(
              "DSD file could not be found on configured path "
                  + dsdPackage
                  + " in any of: \n"
                  + searchedLocations
                  + "Add an explicit dsdPackage and/or dsdFile parameter to your configuration.");
        }
      }
    } else {
      String groupDir = groupId.replace('.', '/');
      String sourceDir = f.getPath() + "/" + groupDir + "/";
      String foundDsdName = existingDsdFileName(sourceDir, dsdFile);
      if (foundDsdName == null) foundDsdName = existingDsdFileName(f + artifactId + "/", dsdFile);
      if (foundDsdName == null)
        throw new MojoExecutionException(
            "DSD file could not be found in any of: \n"
                + searchedLocations
                + "Add an explicit dsdPackage and/or dsdFile parameter to your configuration.");
      getLog().info("Found DSD at " + foundDsdName + ":");
      dsdPath = foundDsdName;
    }
    String modelDir = dsdPath.substring(0, dsdPath.lastIndexOf('/') + 1);
    String modelName =
        capitalised(dsdPath.substring(dsdPath.lastIndexOf('/') + 1, dsdPath.lastIndexOf('.')));
    String databaseTablesFileName = modelDir + "generated/" + modelName + "DatabaseBase.java";

    File databaseTablesFile = new File(databaseTablesFileName);
    long dsdTimestamp = new File(dsdPath).lastModified();
    long databaseTablesTimestamp = 1;
    if (databaseTablesFile.exists()) {
      databaseTablesTimestamp = databaseTablesFile.lastModified();
    }
    boolean doIt = true;
    if (checkUptodate) {
      getLog().info(" Checking " + databaseTablesFileName);
      if (dsdTimestamp < databaseTablesTimestamp) {
        getLog().info("Generated files are uptodate. No action required.");
        doIt = false;
      }
    } else getLog().info(" Not checking - doing regardless");
    if (doIt) {
      DSD dsd;
      try {
        dsd = new DSD(dsdPath);
        dsd.generateJava();
      } catch (Exception e) {
        throw new MojoExecutionException("Error processing DSD", e);
      }
    }
  }
示例#4
0
  /**
   * This method is called after the main product header has been read in successfully.
   *
   * <p>
   *
   * <p>Sub-classes should set product specific parameters in the <code>parameters</code> argument.
   * The parameters can be referenced in DDDB in order to implement dynamic field length, such as
   * 'LINE_WIDTH'.
   *
   * <p>
   *
   * <p>When this method is called, the <code>getMPH()</code> method returns a non-null value.
   *
   * <p>
   *
   * <p>The default implementation is empty.
   *
   * @param parameters product specific parameters (possibly referenced within in the DDDB
   */
  @Override
  protected void postProcessSPH(Map parameters) throws IOException {
    DSD[] mdsDsds = getValidDSDs(EnvisatConstants.DS_TYPE_MEASUREMENT);
    int numMDSR;
    if (mdsDsds.length == 0) {
      // throw new ProductIOException("no valid measurements datasets found in this AATSR product");
      // /*I18N*/
      numMDSR = 0;
    } else {
      numMDSR = mdsDsds[0].getNumRecords();
    }
    DSD dsdGeoLocationAds = getDSD("GEOLOCATION_ADS");
    if (dsdGeoLocationAds == null) {
      throw new IllegalFileFormatException(
          "invalid product: missing DSD for dataset 'GEOLOCATION_ADS'"); /*I18N*/
    }
    DSD dsdNadirViewSolarAnglesAds = getDSD("NADIR_VIEW_SOLAR_ANGLES_ADS");
    if (dsdNadirViewSolarAnglesAds == null) {
      throw new IllegalFileFormatException(
          "invalid product: missing DSD for dataset 'NADIR_VIEW_SOLAR_ANGLES_ADS'"); /*I18N*/
    }

    _sceneRasterHeight = calculateSceneRasterHeight(dsdGeoLocationAds, numMDSR);
    int sceneRasterWidth = EnvisatConstants.AATSR_SCENE_RASTER_WIDTH;

    int locTiePointGridWidth = EnvisatConstants.AATSR_LOC_TIE_POINT_GRID_WIDTH;
    int locTiePointGridHeight = dsdGeoLocationAds.getNumRecords();
    _locTiePointGridOffsetX = EnvisatConstants.AATSR_LOC_TIE_POINT_OFFSET_X;
    _locTiePointGridOffsetY = EnvisatConstants.AATSR_TIE_POINT_OFFSET_Y;
    _locTiePointSubSamplingX = EnvisatConstants.AATSR_LOC_TIE_POINT_SUBSAMPLING_X;
    _locTiePointSubSamplingY = EnvisatConstants.AATSR_LOC_TIE_POINT_SUBSAMPLING_Y;

    _solTiePointGridWidth = EnvisatConstants.AATSR_SOL_TIE_POINT_GRID_WIDTH;
    int solTiePointGridHeight = dsdNadirViewSolarAnglesAds.getNumRecords();
    _solTiePointGridOffsetX = EnvisatConstants.AATSR_SOL_TIE_POINT_OFFSET_X;
    _solTiePointGridOffsetY = EnvisatConstants.AATSR_TIE_POINT_OFFSET_Y;
    _solTiePointSubSamplingX = EnvisatConstants.AATSR_SOL_TIE_POINT_SUBSAMPLING_X;
    _solTiePointSubSamplingY = EnvisatConstants.AATSR_SOL_TIE_POINT_SUBSAMPLING_Y;

    //        _locTiePointSubSamplingX = sceneRasterWidth / (locTiePointGridWidth - 1);
    //        _locTiePointSubSamplingY = sceneRasterHeight / (locTiePointGridHeight - 1);
    //        _solTiePointSubSamplingX = sceneRasterWidth / (_solTiePointGridWidth - 1);
    //        _solTiePointSubSamplingY = sceneRasterHeight / (solTiePointGridHeight - 1);

    // Note: the following parameters are NOT used in the DDDB anymore
    // They are provided here for debugging purposes only.
    //
    parameters.put("sceneRasterWidth", sceneRasterWidth);
    parameters.put("sceneRasterHeight", _sceneRasterHeight);
    parameters.put("locTiePointGridWidth", locTiePointGridWidth);
    parameters.put("locTiePointGridHeight", locTiePointGridHeight);
    parameters.put("locTiePointGridOffsetX", _locTiePointGridOffsetX);
    parameters.put("locTiePointGridOffsetY", _locTiePointGridOffsetY);
    parameters.put("locTiePointSubSamplingX", _locTiePointSubSamplingX);
    parameters.put("locTiePointSubSamplingY", _locTiePointSubSamplingY);
    parameters.put("solTiePointGridWidth", _solTiePointGridWidth);
    parameters.put("solTiePointGridHeight", solTiePointGridHeight);
    parameters.put("solTiePointGridOffsetX", _solTiePointGridOffsetX);
    parameters.put("solTiePointGridOffsetY", _solTiePointGridOffsetY);
    parameters.put("solTiePointSubSamplingX", _solTiePointSubSamplingX);
    parameters.put("solTiePointSubSamplingY", _solTiePointSubSamplingY);

    if (_sceneRasterHeight > numMDSR) {
      mdsMapIndex = new int[getSceneRasterHeight()];
      final RecordReader recordReader = getRecordReader("GEOLOCATION_ADS");
      final int records = recordReader.getNumRecords() - 1;
      int mdsIndex = 0;
      for (int geoADSIndex = 0; geoADSIndex < records; geoADSIndex++) {
        final Record record = recordReader.readRecord(geoADSIndex);
        final int attachFlag = record.getField("attach_flag").getElemInt(0);
        for (int line = 0; line < 32; line++) {
          final int i = geoADSIndex * 32 + line;
          if (attachFlag == 0) {
            mdsMapIndex[i] = mdsIndex;
            ++mdsIndex;
          } else {
            mdsMapIndex[i] = -1;
          }
        }
      }
    }
  }