static void parseVELFPVELOCFile(const QString&datFileName, Mesh* mesh) {
    // these files are optional, so if not present, reading is skipped
    int nnodes = mesh->nodes().size();
    QFileInfo fi(datFileName);
    QVector<float> maxVel(nnodes);

    {
        QString nodesFileName(fi.dir().filePath("VELFP.OUT"));
        QFile nodesFile(nodesFileName);
        if (!nodesFile.open(QIODevice::ReadOnly | QIODevice::Text)) return;
        QTextStream nodesStream(&nodesFile);
        int node_inx = 0;

        // VELFP.OUT - COORDINATES (NODE NUM, X, Y, MAX VEL) - Maximum floodplain flow velocity;
        while (!nodesStream.atEnd())
        {
            if (node_inx == nnodes) throw LoadStatus::Err_IncompatibleMesh;

            QString line = nodesStream.readLine();
            QStringList lineParts = line.split(" ", QString::SkipEmptyParts);
            if (lineParts.size() != 4) {
                throw LoadStatus::Err_UnknownFormat;
            }

            float val = getFloat(lineParts[3]);
            maxVel[node_inx] = val;

            node_inx++;
        }
    }

    {
        QString nodesFileName(fi.dir().filePath("VELOC.OUT"));
        QFile nodesFile(nodesFileName);
        if (!nodesFile.open(QIODevice::ReadOnly | QIODevice::Text)) return;
        QTextStream nodesStream(&nodesFile);
        int node_inx = 0;

        // VELOC.OUT - COORDINATES (NODE NUM, X, Y, MAX VEL)  - Maximum channel flow velocity
        while (!nodesStream.atEnd())
        {
            if (node_inx == nnodes) throw LoadStatus::Err_IncompatibleMesh;

            QString line = nodesStream.readLine();
            QStringList lineParts = line.split(" ", QString::SkipEmptyParts);
            if (lineParts.size() != 4) {
                throw LoadStatus::Err_UnknownFormat;
            }

            float val = getFloat(lineParts[3]);
            if (!is_nodata(val)) { // overwrite value from VELFP if it is not 0
                maxVel[node_inx] = val;
            }

            node_inx++;
        }
    }

    addStaticDataset(maxVel, "Velocity/Maximums", DataSet::Scalar, datFileName, mesh);
}
static float getFloat(const QString& val) {
    float valF = val.toFloat();
    if (is_nodata(valF, 0.0f)) {
        return -9999.0;
    } else {
        return valF;
    }
}
static void activateElements(NodeOutput* tos, const Mesh* mesh){
   // Activate only elements that do all node's outputs with some data
   char* active = tos->active.data();

   for (int idx=0; idx<mesh->elements().size(); ++idx)
   {
       Element elem = mesh->elements().at(idx);

       if (is_nodata(tos->values[elem.p(0)]) ||
           is_nodata(tos->values[elem.p(1)]) ||
           is_nodata(tos->values[elem.p(2)]) ||
           is_nodata(tos->values[elem.p(3)]))
       {
           active[idx] = 0; //NOT ACTIVE
       } else {
           active[idx] = 1; //ACTIVE
       }
   }
}
示例#4
0
static double getDouble( double val )
{
  if ( is_nodata( val ) )
  {
    return MDAL_NAN;
  }
  else
  {
    return val;
  }
}
示例#5
0
void 
weightWindow::compute(const dimension_type i, const dimension_type j,
		      const genericWindow<elevation_type>& elevwin, 
		      const direction_type dir,
		      const int trustdir) {
  
  elevation_type elev_crt, elev_neighb, e_diff;
  dimension_type i_neighb, j_neighb;
  
  /* initialize all weights to 0 */
  init();

  elev_crt = elevwin.get(); 
  assert(!is_nodata(elev_crt));
  
  /* map direction to neighbors */
  directionWindow dirwin(dir);  

  /* compute weights of the 8 neighbours  */
  int skipit = 0;
  for (short di = -1; di <= 1; di++) {
    for (short dj = -1; dj <= 1; dj++) {
      
      /* grid coordinates and elevation of neighbour */
      i_neighb = i + di; 
      j_neighb = j + dj;
      elev_neighb = elevwin.get(di, dj);
      e_diff = (elevation_type)(elev_crt - elev_neighb);

      skipit = ((di ==0) && (dj==0));
      skipit |= (elev_crt < elev_neighb);
      /* skipit |= (elev_neighb == edge_nodata); ?? */

      if (!trustdir) {
	dirwin.correctDirection(di,dj,skipit, i,j, elev_crt,dir,elev_neighb);
      }
      
      /* if direction points to it then compute its weight */
      if (dirwin.get(di,dj) == true) {
	computeWeight(di,dj, elev_crt, elev_neighb);
      }
    } /* for dj */
  } /* for di */
  normalize(); /* normalize the weights */
  
#ifdef CHECK_WEIGHTS 
  cout <<"weights: [";
  for (int l=0;l<9;l++) cout << form("%3.2f ",weight.get(l));
  cout <<"]\n";
#endif
};
示例#6
0
/* Find the dominant direction. Set corresponding weight to 1, and
   sets all other weights to 0. Set sumweight and sumcontour.*/
void 
weightWindow::makeD8(const dimension_type i, const dimension_type j,
		     const genericWindow<elevation_type>& elevwin, 
		     const direction_type dir,
		     const bool trustdir) {
  

  elevation_type elev_crt;
  short di,dj;
  elev_crt = elevwin.get(); 
  assert(!is_nodata(elev_crt));

  int maxi=0, maxj=0;
  double tanb, contour, maxtanb = -1, maxcontour = -1;
  /* map direction to neighbors */
  directionWindow dirwin(dir); 

  /* compute biggest angle to a neighbor */
  for (di=-1; di <=1; di++) {
    for (dj = -1; dj <= 1; dj++) {
      if (dirwin.get(di,dj)) {
	
	tanb = computeTanB(di,dj, elevwin);
	contour = computeContour(di, dj);
	
	if (tanb > maxtanb) {
	  maxtanb = tanb;
	  maxi = di;
	  maxj = dj;
	  maxcontour = contour;
	}
      }
    }
  }
  /* at this point maxi and maxj must be set */
  assert((maxi != 0 || maxj != 0) && maxtanb >= 0);
  
  /* set weights corresponding to this direction */
  init();   /* initialize all weights to 0 */
  int maxindex = 3* (maxi + 1) + maxj+1;
  weight.set(maxindex,1);   /* set maxweight to 1 */

  sumweight = 1;
  sumcontour = maxcontour;
}
示例#7
0
void MDAL::DriverFlo2D::parseDEPTHFile( const std::string &datFileName, const std::vector<double> &elevations )
{
  // this file is optional, so if not present, reading is skipped
  std::string depthFile( fileNameFromDir( datFileName, "DEPTH.OUT" ) );
  if ( !MDAL::fileExists( depthFile ) )
  {
    return; //optional file
  }

  std::ifstream depthStream( depthFile, std::ifstream::in );
  std::string line;

  size_t nVertices = mMesh->verticesCount();
  std::vector<double> maxDepth( nVertices );
  std::vector<double> maxWaterLevel( nVertices );

  size_t vertex_idx = 0;

  // DEPTH.OUT - COORDINATES (ELEM NUM, X, Y, MAX DEPTH)
  while ( std::getline( depthStream, line ) )
  {
    line = MDAL::rtrim( line );
    if ( vertex_idx == nVertices ) throw MDAL_Status::Err_IncompatibleMesh;

    std::vector<std::string> lineParts = MDAL::split( line, ' ' );
    if ( lineParts.size() != 4 )
    {
      throw MDAL_Status::Err_UnknownFormat;
    }

    double val = getDouble( lineParts[3] );
    maxDepth[vertex_idx] = val;

    //water level
    if ( !is_nodata( val ) ) val += elevations[vertex_idx];
    maxWaterLevel[vertex_idx] = val;


    vertex_idx++;
  }

  addStaticDataset( true, maxDepth, "Depth/Maximums", datFileName );
  addStaticDataset( true, maxWaterLevel, "Water Level/Maximums", datFileName );
}
static void parseDEPTHFile(const QString&datFileName, Mesh* mesh, const QVector<float>& elevations) {
    // this file is optional, so if not present, reading is skipped
    QFileInfo fi(datFileName);
    QString nodesFileName(fi.dir().filePath("DEPTH.OUT"));
    QFile nodesFile(nodesFileName);
    if (!nodesFile.open(QIODevice::ReadOnly | QIODevice::Text)) return;
    QTextStream nodesStream(&nodesFile);

    int nnodes = mesh->nodes().size();
    QVector<float> maxDepth(nnodes);
    QVector<float> maxWaterLevel(nnodes);

    int node_inx = 0;

    // DEPTH.OUT - COORDINATES (NODE NUM, X, Y, MAX DEPTH)
    while (!nodesStream.atEnd())
    {
        if (node_inx == nnodes) throw LoadStatus::Err_IncompatibleMesh;

        QString line = nodesStream.readLine();
        QStringList lineParts = line.split(" ", QString::SkipEmptyParts);
        if (lineParts.size() != 4) {
            throw LoadStatus::Err_UnknownFormat;
        }

        float val = getFloat(lineParts[3]);
        maxDepth[node_inx] = val;

        //water level
        if (!is_nodata(val)) val += elevations[node_inx];
        maxWaterLevel[node_inx] = val;


        node_inx++;
    }

    addStaticDataset(maxDepth, "Depth/Maximums", DataSet::Scalar, datFileName, mesh);
    addStaticDataset(maxWaterLevel, "Water Level/Maximums", DataSet::Scalar, datFileName, mesh);
}
示例#9
0
void
flow_waterWindower::processWindow(dimension_type i, dimension_type j, 
				  waterWindowBaseType *a,
				  waterWindowBaseType *b,
				  waterWindowBaseType *c) {
  
  elevation_type el1[3], el2[3], el3[3];
  toporank_type ac1[3], ac2[3], ac3[3];
  
  if (is_nodata(b[1].el)) {
    /*sweep_str does not include nodata */
    return;
  }
  /*#ifdef  COMPRESSED_WINDOWS
	sweepItem win = sweepItem(i, j, a, b, c);
	#else
  */
  for (int k=0; k<3; k++) {
    el1[k] = a[k].el;
    ac1[k] = -a[k].depth; /*WEIRD */
    el2[k] = b[k].el;
    ac2[k] = -b[k].depth; /*WEIRD*/
    el3[k] = c[k].el;
    ac3[k] = -c[k].depth; /*WEIRD*/
  }
  /*
	genericWindow<elevation_type> e_win(el);
	genericWindow<toporank_type> a_win(ac);
	sweepItem win = sweepItem(i, j, b[1].dir, e_win, a_win);
  */
  sweepItem win = sweepItem(i, j, b[1].dir, el1, el2, el3, ac1, ac2, ac3);
  /* #endif */
 
  AMI_err ae = sweep_str->write_item(win);
  assert(ae == AMI_ERROR_NO_ERROR);
}
示例#10
0
/*returns 1 if value is Nodata, 0 if it is not */
int is_nodata_grid(Grid * grid, float value)
{
    assert(grid);
	return is_nodata(grid->hd, value);
}
static void parseTIMDEPFile(const QString& datFileName, Mesh* mesh, const QVector<float>& elevations) {\
    // TIMDEP.OUT
    // this file is optional, so if not present, reading is skipped
    // time (separate line)
    // For every node:
    // FLO2D: node number (indexed from 1), depth, velocity, velocity x, velocity y
    // FLO2DPro: node number (indexed from 1), depth, velocity, velocity x, velocity y, water surface elevation
    QFileInfo fi(datFileName);
    QFile inFile(fi.dir().filePath("TIMDEP.OUT"));
    if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text)) return;
    QTextStream in(&inFile);

    int nnodes = mesh->nodes().size();
    int nelems = mesh->elements().size();
    int ntimes = 0;

    float time = 0.0;
    int node_inx = 0;

    DataSet* depthDs = new DataSet(datFileName);
    depthDs->setType(DataSet::Scalar);
    depthDs->setName("Depth");

    DataSet* waterLevelDs = new DataSet(datFileName);
    waterLevelDs->setType(DataSet::Scalar);
    waterLevelDs->setName("Water Level");

    DataSet* flowDs = new DataSet(datFileName);
    flowDs->setType(DataSet::Vector);
    flowDs->setName("Velocity");

    NodeOutput* flowOutput = 0;
    NodeOutput* depthOutput = 0;
    NodeOutput* waterLevelOutput = 0;


    while (!in.atEnd())
    {
        QString line = in.readLine();
        QStringList lineParts = line.split(" ", QString::SkipEmptyParts);
        if (lineParts.size() == 1) {
            time = line.toFloat();
            ntimes++;

            if (depthOutput) addOutput(depthDs, depthOutput, mesh);
            if (flowOutput) addOutput(flowDs, flowOutput, mesh);
            if (waterLevelOutput) addOutput(waterLevelDs, waterLevelOutput, mesh);

            depthOutput = new NodeOutput;
            flowOutput = new NodeOutput;
            waterLevelOutput = new NodeOutput;

            depthOutput->init(nnodes, nelems, false); //scalar
            flowOutput->init(nnodes, nelems, true); //vector
            waterLevelOutput->init(nnodes, nelems, false); //scalar

            depthOutput->time = time;
            flowOutput->time = time;
            waterLevelOutput->time = time;

            node_inx = 0;

        } else if ((lineParts.size() == 5) || (lineParts.size() == 6)) {
            // new node for time
            if (!depthOutput || !flowOutput || !waterLevelOutput) throw LoadStatus::Err_UnknownFormat;
            if (node_inx == nnodes) throw LoadStatus::Err_IncompatibleMesh;

            flowOutput->values[node_inx] = getFloat(lineParts[2]);
            flowOutput->valuesV[node_inx].x = getFloat(lineParts[3]);
            flowOutput->valuesV[node_inx].y = getFloat(lineParts[4]);

            float depth = getFloat(lineParts[1]);
            depthOutput->values[node_inx] = depth;

            if (!is_nodata(depth)) depth += elevations[node_inx];
            waterLevelOutput->values[node_inx] = depth;

            node_inx ++;

        } else {
            throw LoadStatus::Err_UnknownFormat;
        }
    }

    if (depthOutput) addOutput(depthDs, depthOutput, mesh);
    if (flowOutput) addOutput(flowDs, flowOutput, mesh);
    if (waterLevelOutput) addOutput(waterLevelDs, waterLevelOutput, mesh);

    depthDs->setIsTimeVarying(ntimes>1);
    flowDs->setIsTimeVarying(ntimes>1);
    waterLevelDs->setIsTimeVarying(ntimes>1);

    depthDs->updateZRange();
    flowDs->updateZRange();
    waterLevelDs->updateZRange();

    mesh->addDataSet(depthDs);
    mesh->addDataSet(flowDs);
    mesh->addDataSet(waterLevelDs);
}
示例#12
0
static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GRIDINFO **tables, struct CTABLE *ct) {
    int  itable = 0;
    double value = HUGE_VAL;
    double grid_x, grid_y;
    long   grid_ix, grid_iy;
    long   grid_ix2, grid_iy2;
    float  *cvs;
    /* do not deal with NaN coordinates */
    /* cppcheck-suppress duplicateExpression */
    if( isnan(input.phi) || isnan(input.lam) )
        itable = *gridlist_count_p;

    /* keep trying till we find a table that works */
    for ( ; itable < *gridlist_count_p; itable++ )
    {
        PJ_GRIDINFO *gi = tables[itable];

        ct = gi->ct;

        /* skip tables that don't match our point at all.  */
        if( ct->ll.phi > input.phi || ct->ll.lam > input.lam
            || ct->ll.phi + (ct->lim.phi-1) * ct->del.phi < input.phi
            || ct->ll.lam + (ct->lim.lam-1) * ct->del.lam < input.lam )
            continue;

        /* If we have child nodes, check to see if any of them apply. */
        while( gi->child != NULL )
        {
            PJ_GRIDINFO *child;

            for( child = gi->child; child != NULL; child = child->next )
            {
                struct CTABLE *ct1 = child->ct;

                if( ct1->ll.phi > input.phi || ct1->ll.lam > input.lam
                  || ct1->ll.phi+(ct1->lim.phi-1)*ct1->del.phi < input.phi
                  || ct1->ll.lam+(ct1->lim.lam-1)*ct1->del.lam < input.lam)
                    continue;

                break;
            }

            /* we didn't find a more refined child node to use, so go with current grid */
            if( child == NULL )
            {
                break;
            }

            /* Otherwise let's try for childrens children .. */
            gi = child;
            ct = child->ct;
        }

        /* load the grid shift info if we don't have it. */
        if( ct->cvs == NULL && !pj_gridinfo_load( pj_get_ctx(defn), gi ) )
        {
            pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID );
            return PJD_ERR_FAILED_TO_LOAD_GRID;
        }


        /* Interpolation a location within the grid */
        grid_x = (input.lam - ct->ll.lam) / ct->del.lam;
        grid_y = (input.phi - ct->ll.phi) / ct->del.phi;
        grid_ix = lround(floor(grid_x));
        grid_iy = lround(floor(grid_y));
        grid_x -= grid_ix;
        grid_y -= grid_iy;

        grid_ix2 = grid_ix + 1;
        if( grid_ix2 >= ct->lim.lam )
            grid_ix2 = ct->lim.lam - 1;
        grid_iy2 = grid_iy + 1;
        if( grid_iy2 >= ct->lim.phi )
            grid_iy2 = ct->lim.phi - 1;

        cvs = (float *) ct->cvs;
        {
            float value_a = cvs[grid_ix + grid_iy * ct->lim.lam];
            float value_b = cvs[grid_ix2 + grid_iy * ct->lim.lam];
            float value_c = cvs[grid_ix + grid_iy2 * ct->lim.lam];
            float value_d = cvs[grid_ix2 + grid_iy2 * ct->lim.lam];
            double total_weight = 0.0;
            int n_weights = 0;
            value = 0.0f;
            if( !is_nodata(value_a) )
            {
                double weight = (1.0-grid_x) * (1.0-grid_y);
                value += value_a * weight;
                total_weight += weight;
                n_weights ++;
            }
            if( !is_nodata(value_b) )
            {
                double weight = (grid_x) * (1.0-grid_y);
                value += value_b * weight;
                total_weight += weight;
                n_weights ++;
            }
            if( !is_nodata(value_c) )
            {
                double weight = (1.0-grid_x) * (grid_y);
                value += value_c * weight;
                total_weight += weight;
                n_weights ++;
            }
            if( !is_nodata(value_d) )
            {
                double weight = (grid_x) * (grid_y);
                value += value_d * weight;
                total_weight += weight;
                n_weights ++;
            }
            if( n_weights == 0 )
                value = HUGE_VAL;
            else if( n_weights != 4 )
                value /= total_weight;
        }

    }

    return value;
}
示例#13
0
void MDAL::DriverFlo2D::parseVELFPVELOCFile( const std::string &datFileName )
{
  // these files are optional, so if not present, reading is skipped
  size_t nVertices = mMesh->verticesCount();
  std::vector<double> maxVel( nVertices );

  {
    std::string velocityFile( fileNameFromDir( datFileName, "VELFP.OUT" ) );
    if ( !MDAL::fileExists( velocityFile ) )
    {
      return; //optional file
    }

    std::ifstream velocityStream( velocityFile, std::ifstream::in );
    std::string line;

    size_t vertex_idx = 0;

    // VELFP.OUT - COORDINATES (ELEM NUM, X, Y, MAX VEL) - Maximum floodplain flow velocity;
    while ( std::getline( velocityStream, line ) )
    {
      if ( vertex_idx == nVertices ) throw MDAL_Status::Err_IncompatibleMesh;

      line = MDAL::rtrim( line );
      std::vector<std::string> lineParts = MDAL::split( line, ' ' );
      if ( lineParts.size() != 4 )
      {
        throw MDAL_Status::Err_UnknownFormat;
      }

      double val = getDouble( lineParts[3] );
      maxVel[vertex_idx] = val;

      vertex_idx++;
    }
  }

  {
    std::string velocityFile( fileNameFromDir( datFileName, "VELOC.OUT" ) );
    if ( !MDAL::fileExists( velocityFile ) )
    {
      return; //optional file
    }

    std::ifstream velocityStream( velocityFile, std::ifstream::in );
    std::string line;

    size_t vertex_idx = 0;

    // VELOC.OUT - COORDINATES (ELEM NUM, X, Y, MAX VEL)  - Maximum channel flow velocity
    while ( std::getline( velocityStream, line ) )
    {
      if ( vertex_idx == nVertices ) throw MDAL_Status::Err_IncompatibleMesh;

      line = MDAL::rtrim( line );
      std::vector<std::string> lineParts = MDAL::split( line, ' ' );
      if ( lineParts.size() != 4 )
      {
        throw MDAL_Status::Err_UnknownFormat;
      }

      double val = getDouble( lineParts[3] );
      if ( !is_nodata( val ) ) // overwrite value from VELFP if it is not 0
      {
        maxVel[vertex_idx] = val;
      }

      vertex_idx++;
    }
  }

  addStaticDataset( true, maxVel, "Velocity/Maximums", datFileName );
}
示例#14
0
void MDAL::DriverFlo2D::parseTIMDEPFile( const std::string &datFileName, const std::vector<double> &elevations )
{
  // TIMDEP.OUT
  // this file is optional, so if not present, reading is skipped
  // time (separate line)
  // For every Vertex:
  // FLO2D: ELEM NUMber (indexed from 1), depth, velocity, velocity x, velocity y
  // FLO2DPro: ELEM NUMber (indexed from 1), depth, velocity, velocity x, velocity y, water surface elevation
  std::string inFile( fileNameFromDir( datFileName, "TIMDEP.OUT" ) );
  if ( !MDAL::fileExists( inFile ) )
  {
    return;
  }

  std::ifstream inStream( inFile, std::ifstream::in );
  std::string line;

  size_t nVertexs = mMesh->verticesCount();
  size_t ntimes = 0;

  double time = 0.0;
  size_t face_idx = 0;

  std::shared_ptr<DatasetGroup> depthDsGroup = std::make_shared< DatasetGroup >(
        name(),
        mMesh.get(),
        datFileName,
        "Depth"
      );
  depthDsGroup->setIsOnVertices( false );
  depthDsGroup->setIsScalar( true );


  std::shared_ptr<DatasetGroup> waterLevelDsGroup = std::make_shared< DatasetGroup >(
        name(),
        mMesh.get(),
        datFileName,
        "Water Level"
      );
  waterLevelDsGroup->setIsOnVertices( false );
  waterLevelDsGroup->setIsScalar( true );

  std::shared_ptr<DatasetGroup> flowDsGroup = std::make_shared< DatasetGroup >(
        name(),
        mMesh.get(),
        datFileName,
        "Velocity"
      );
  flowDsGroup->setIsOnVertices( false );
  flowDsGroup->setIsScalar( false );

  std::shared_ptr<MDAL::MemoryDataset> flowDataset;
  std::shared_ptr<MDAL::MemoryDataset> depthDataset;
  std::shared_ptr<MDAL::MemoryDataset> waterLevelDataset;

  while ( std::getline( inStream, line ) )
  {
    line = MDAL::rtrim( line );
    std::vector<std::string> lineParts = MDAL::split( line, ' ' );
    if ( lineParts.size() == 1 )
    {
      time = MDAL::toDouble( line );
      ntimes++;

      if ( depthDataset ) addDatasetToGroup( depthDsGroup, depthDataset );
      if ( flowDataset ) addDatasetToGroup( flowDsGroup, flowDataset );
      if ( waterLevelDataset ) addDatasetToGroup( waterLevelDsGroup, waterLevelDataset );

      depthDataset  = std::make_shared< MemoryDataset >( depthDsGroup.get() );
      flowDataset = std::make_shared< MemoryDataset >( flowDsGroup.get() );
      waterLevelDataset = std::make_shared< MemoryDataset >( waterLevelDsGroup.get() );

      depthDataset->setTime( time );
      flowDataset->setTime( time );
      waterLevelDataset->setTime( time );

      face_idx = 0;

    }
    else if ( ( lineParts.size() == 5 ) || ( lineParts.size() == 6 ) )
    {
      // new Vertex for time
      if ( !depthDataset || !flowDataset || !waterLevelDataset ) throw MDAL_Status::Err_UnknownFormat;
      if ( face_idx == nVertexs ) throw MDAL_Status::Err_IncompatibleMesh;

      // this is magnitude: getDouble(lineParts[2]);
      flowDataset->values()[2 * face_idx] = getDouble( lineParts[3] );
      flowDataset->values()[2 * face_idx + 1] = getDouble( lineParts[4] );

      double depth = getDouble( lineParts[1] );
      depthDataset->values()[face_idx] = depth;

      if ( !is_nodata( depth ) ) depth += elevations[face_idx];
      waterLevelDataset->values()[face_idx] = depth;

      face_idx ++;

    }
    else
    {
      throw MDAL_Status::Err_UnknownFormat;
    }
  }

  if ( depthDataset ) addDatasetToGroup( depthDsGroup, depthDataset );
  if ( flowDataset ) addDatasetToGroup( flowDsGroup, flowDataset );
  if ( waterLevelDataset ) addDatasetToGroup( waterLevelDsGroup, waterLevelDataset );

  depthDsGroup->setStatistics( MDAL::calculateStatistics( depthDsGroup ) );
  flowDsGroup->setStatistics( MDAL::calculateStatistics( flowDsGroup ) );
  waterLevelDsGroup->setStatistics( MDAL::calculateStatistics( waterLevelDsGroup ) );

  mMesh->datasetGroups.push_back( depthDsGroup );
  mMesh->datasetGroups.push_back( flowDsGroup );
  mMesh->datasetGroups.push_back( waterLevelDsGroup );
}