@Override
  protected double getValue(final int x, final int y, final Coordinate crd)
      throws GeoGridException {
    final double wspHeight = crd.z;
    if (Double.isNaN(wspHeight)) return Double.NaN;

    // possible that waterdepth input grid contains water depth less than zero!
    if (wspHeight <= 0.0) return Double.NaN;

    if (m_polygonCollection.size() == 0) return Double.NaN;

    final double cx = crd.x;
    final double cy = crd.y;

    try {
      final GM_Position position =
          m_geoTransformer.transform(GeometryFactory.createGM_Position(cx, cy), getSourceCRS());

      final double damageValue = calculateDamageValue(position, wspHeight);

      final Coordinate resultCrd = new Coordinate(position.getX(), position.getY(), damageValue);

      if (Doubles.isFinite(damageValue))
        m_statistics.addSpecificDamage(m_returnPeriod, resultCrd, m_cellSize);

      return damageValue;
    } catch (final Exception e) {
      e.printStackTrace();
      throw new GeoGridException(e.getLocalizedMessage(), e);
    }
  }
Exemplo n.º 2
0
 public Map<String, Map<GM_Position, Double>> readMatResultsFile(final String pStrFilter) {
   MatFileReader lMatFileReader = null;
   final MatFileFilter lMatFilter = new MatFileFilter();
   Map<String, Map<GM_Position, Double>> lRes = null;
   try {
     if (pStrFilter != null) {
       lMatFilter.addArrayName(STR_XP_NAME);
       lMatFilter.addArrayName(STR_YP_NAME);
       lMatFilter.addArrayName(pStrFilter);
     }
     if (m_strResultsFile == null) {
       lMatFileReader = new MatFileReader(FileUtils.toFile(m_resultsFile.getURL()), lMatFilter);
     } else {
       lMatFileReader = new MatFileReader(m_strResultsFile, lMatFilter);
     }
   } catch (final Exception e) {
     // throw new MatlabIOException( "Cannot open or read SWAN result matlab file." );
   }
   if (lMatFileReader != null) {
     try {
       final GM_Position lShiftPosition =
           SWANDataConverterHelper.readCoordinateShiftValues(m_resultsFile);
       m_doubleShiftX = lShiftPosition.getX();
       m_doubleShiftY = lShiftPosition.getY();
       final Map<String, MLArray> lMapData = lMatFileReader.getContent();
       // printDebugParsedSWANRawData( lMatFileReader, null );
       lRes = getValuesFormatedNameDatePosition(lMapData);
       // printDebugResultData( lRes, null );
     } catch (final Exception e) {
       e.printStackTrace();
     }
   }
   return lRes;
 }