private void assertCreateRightGeneralFilterBand(Element xmlElement) {
    final Object object = _generalFilterBandPersistable.createObjectFromXml(xmlElement, _product);
    _product.addBand((Band) object);

    assertNotNull(object);
    assertTrue(object instanceof GeneralFilterBand);
    final GeneralFilterBand gfb = (GeneralFilterBand) object;
    assertEquals(1, _product.getBandIndex(gfb.getName()));
    assertEquals(-1, gfb.getSpectralBandIndex());
    assertEquals("filtered_coffee", gfb.getName());
    assertEquals("with milk & sugar", gfb.getDescription());
    assertEquals(_source.getGeophysicalDataType(), gfb.getDataType());
    assertEquals("l", gfb.getUnit());
    assertEquals(0.0, gfb.getSolarFlux(), EPS);
    assertEquals(0.0, gfb.getSpectralWavelength(), EPS);
    assertEquals(0.0, gfb.getSpectralBandwidth(), EPS);
    assertEquals(1.0, gfb.getScalingFactor(), EPS);
    assertEquals(0.0, gfb.getScalingOffset(), EPS);
    assertFalse(gfb.isLog10Scaled());
    assertEquals(gfb.getSource().getName(), _source.getName());
    assertEquals(5, gfb.getSubWindowSize());
    assertEquals(5, gfb.getSubWindowWidth());
    assertEquals(5, gfb.getSubWindowHeight());
    assertTrue(gfb.getOperator() instanceof GeneralFilterBand.Mean);
  }
Exemplo n.º 2
0
 protected void setSpectralBand(Product product) {
   int spectralBandIndex = 0;
   for (String name : product.getBandNames()) {
     Band band = product.getBandAt(product.getBandIndex(name));
     if (name.matches("\\w+_\\d{3,}")) {
       String[] parts = name.split("_");
       String wvlstr = parts[parts.length - 1].trim();
       // Some bands have the wvl portion in the middle...
       if (!wvlstr.matches("^\\d{3,}")) {
         wvlstr = parts[parts.length - 2].trim();
       }
       final float wavelength = Float.parseFloat(wvlstr);
       band.setSpectralWavelength(wavelength);
       band.setSpectralBandIndex(spectralBandIndex++);
     }
   }
 }