コード例 #1
0
ファイル: GCPManager.java プロジェクト: ama-jharrison/s1tbx
 public ProductNodeGroup<Placemark> getGcpGroup(final Band band) {
   ProductNodeGroup<Placemark> gcpGroup = bandGCPGroup.get(createKey(band));
   if (gcpGroup == null) {
     gcpGroup = new ProductNodeGroup<>(band.getProduct(), "ground_control_points", true);
     bandGCPGroup.put(createKey(band), gcpGroup);
   }
   return gcpGroup;
 }
コード例 #2
0
  private void addTiePointGrids(final Band band, final String imgXMLName, final String tpgPrefix) {

    // System.out.println("S1L1Dir.addTiePointGrids: band = " + band.getName() + " imgXMLName = " +
    // imgXMLName + " tpgPrefix = " + tpgPrefix);

    final Product product = band.getProduct();
    String pre = "";
    if (!tpgPrefix.isEmpty()) pre = tpgPrefix + '_';

    final TiePointGrid existingLatTPG = product.getTiePointGrid(pre + OperatorUtils.TPG_LATITUDE);
    final TiePointGrid existingLonTPG = product.getTiePointGrid(pre + OperatorUtils.TPG_LONGITUDE);
    if (existingLatTPG != null && existingLonTPG != null) {
      // System.out.println("for band = " + band.getName() + ", use existing TPG");
      // reuse geocoding
      final TiePointGeoCoding tpGeoCoding =
          new TiePointGeoCoding(existingLatTPG, existingLonTPG, Datum.WGS_84);
      band.setGeoCoding(tpGeoCoding);
      return;
    }
    // System.out.println("add new TPG for band = " + band.getName());
    final String annotation = FileUtils.exchangeExtension(imgXMLName, ".xml");
    final MetadataElement origProdRoot = AbstractMetadata.getOriginalProductMetadata(product);
    final MetadataElement annotationElem = origProdRoot.getElement("annotation");
    final MetadataElement imgElem = annotationElem.getElement(annotation);
    final MetadataElement productElem = imgElem.getElement("product");
    final MetadataElement geolocationGrid = productElem.getElement("geolocationGrid");
    final MetadataElement geolocationGridPointList =
        geolocationGrid.getElement("geolocationGridPointList");

    final MetadataElement[] geoGrid = geolocationGridPointList.getElements();

    // System.out.println("geoGrid.length = " + geoGrid.length);

    final double[] latList = new double[geoGrid.length];
    final double[] lngList = new double[geoGrid.length];
    final double[] incidenceAngleList = new double[geoGrid.length];
    final double[] elevAngleList = new double[geoGrid.length];
    final double[] rangeTimeList = new double[geoGrid.length];
    final int[] x = new int[geoGrid.length];
    final int[] y = new int[geoGrid.length];

    // Loop through the list of geolocation grid points, assuming that it represents a row-major
    // rectangular grid.
    int gridWidth = 0, gridHeight = 0;
    int i = 0;
    for (MetadataElement ggPoint : geoGrid) {
      latList[i] = ggPoint.getAttributeDouble("latitude", 0);
      lngList[i] = ggPoint.getAttributeDouble("longitude", 0);
      incidenceAngleList[i] = ggPoint.getAttributeDouble("incidenceAngle", 0);
      elevAngleList[i] = ggPoint.getAttributeDouble("elevationAngle", 0);
      rangeTimeList[i] =
          ggPoint.getAttributeDouble("slantRangeTime", 0) * Constants.oneBillion; // s to ns

      x[i] = (int) ggPoint.getAttributeDouble("pixel", 0);
      y[i] = (int) ggPoint.getAttributeDouble("line", 0);
      if (x[i] == 0) {
        // This means we are at the start of a new line
        if (gridWidth
            == 0) // Here we are implicitly assuming that the pixel horizontal spacing is assumed to
                  // be the same from line to line.
        gridWidth = i;
        ++gridHeight;
      }
      ++i;
    }

    // System.out.println("geoGrid w = " + gridWidth + "; h = " + gridHeight);

    final int newGridWidth = gridWidth;
    final int newGridHeight = gridHeight;
    final float[] newLatList = new float[newGridWidth * newGridHeight];
    final float[] newLonList = new float[newGridWidth * newGridHeight];
    final float[] newIncList = new float[newGridWidth * newGridHeight];
    final float[] newElevList = new float[newGridWidth * newGridHeight];
    final float[] newslrtList = new float[newGridWidth * newGridHeight];
    final int sceneRasterWidth = band.getSceneRasterWidth();
    final int sceneRasterHeight = band.getSceneRasterHeight();
    final double subSamplingX = (double) sceneRasterWidth / (newGridWidth - 1);
    final double subSamplingY = (double) sceneRasterHeight / (newGridHeight - 1);

    getListInEvenlySpacedGrid(
        sceneRasterWidth,
        sceneRasterHeight,
        gridWidth,
        gridHeight,
        x,
        y,
        latList,
        newGridWidth,
        newGridHeight,
        subSamplingX,
        subSamplingY,
        newLatList);

    getListInEvenlySpacedGrid(
        sceneRasterWidth,
        sceneRasterHeight,
        gridWidth,
        gridHeight,
        x,
        y,
        lngList,
        newGridWidth,
        newGridHeight,
        subSamplingX,
        subSamplingY,
        newLonList);

    getListInEvenlySpacedGrid(
        sceneRasterWidth,
        sceneRasterHeight,
        gridWidth,
        gridHeight,
        x,
        y,
        incidenceAngleList,
        newGridWidth,
        newGridHeight,
        subSamplingX,
        subSamplingY,
        newIncList);

    getListInEvenlySpacedGrid(
        sceneRasterWidth,
        sceneRasterHeight,
        gridWidth,
        gridHeight,
        x,
        y,
        elevAngleList,
        newGridWidth,
        newGridHeight,
        subSamplingX,
        subSamplingY,
        newElevList);

    getListInEvenlySpacedGrid(
        sceneRasterWidth,
        sceneRasterHeight,
        gridWidth,
        gridHeight,
        x,
        y,
        rangeTimeList,
        newGridWidth,
        newGridHeight,
        subSamplingX,
        subSamplingY,
        newslrtList);

    TiePointGrid latGrid = product.getTiePointGrid(pre + OperatorUtils.TPG_LATITUDE);
    if (latGrid == null) {
      latGrid =
          new TiePointGrid(
              pre + OperatorUtils.TPG_LATITUDE,
              newGridWidth,
              newGridHeight,
              0.5f,
              0.5f,
              subSamplingX,
              subSamplingY,
              newLatList);
      latGrid.setUnit(Unit.DEGREES);
      product.addTiePointGrid(latGrid);
    }

    TiePointGrid lonGrid = product.getTiePointGrid(pre + OperatorUtils.TPG_LONGITUDE);
    if (lonGrid == null) {
      lonGrid =
          new TiePointGrid(
              pre + OperatorUtils.TPG_LONGITUDE,
              newGridWidth,
              newGridHeight,
              0.5f,
              0.5f,
              subSamplingX,
              subSamplingY,
              newLonList,
              TiePointGrid.DISCONT_AT_180);
      lonGrid.setUnit(Unit.DEGREES);
      product.addTiePointGrid(lonGrid);
    }

    if (product.getTiePointGrid(pre + OperatorUtils.TPG_INCIDENT_ANGLE) == null) {
      final TiePointGrid incidentAngleGrid =
          new TiePointGrid(
              pre + OperatorUtils.TPG_INCIDENT_ANGLE,
              newGridWidth,
              newGridHeight,
              0.5f,
              0.5f,
              subSamplingX,
              subSamplingY,
              newIncList);
      incidentAngleGrid.setUnit(Unit.DEGREES);
      product.addTiePointGrid(incidentAngleGrid);
    }

    if (product.getTiePointGrid(pre + OperatorUtils.TPG_ELEVATION_ANGLE) == null) {
      final TiePointGrid elevAngleGrid =
          new TiePointGrid(
              pre + OperatorUtils.TPG_ELEVATION_ANGLE,
              newGridWidth,
              newGridHeight,
              0.5f,
              0.5f,
              subSamplingX,
              subSamplingY,
              newElevList);
      elevAngleGrid.setUnit(Unit.DEGREES);
      product.addTiePointGrid(elevAngleGrid);
    }

    if (product.getTiePointGrid(pre + OperatorUtils.TPG_SLANT_RANGE_TIME) == null) {
      final TiePointGrid slantRangeGrid =
          new TiePointGrid(
              pre + OperatorUtils.TPG_SLANT_RANGE_TIME,
              newGridWidth,
              newGridHeight,
              0.5f,
              0.5f,
              subSamplingX,
              subSamplingY,
              newslrtList);
      slantRangeGrid.setUnit(Unit.NANOSECONDS);
      product.addTiePointGrid(slantRangeGrid);
    }

    final TiePointGeoCoding tpGeoCoding = new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84);
    bandGeocodingMap.put(band, tpGeoCoding);
  }
コード例 #3
0
ファイル: GCPManager.java プロジェクト: ama-jharrison/s1tbx
 private String createKey(final Band band) {
   return band.getProduct().getName() + '_' + band.getName();
 }