Пример #1
0
        private List <Catchment> getCatchments(string[,] paramTable)
        {
            var xcatchments = new List <Catchment>();

            bool bInRunoffSection        = false;
            bool bInSurfaceModelsSection = false;

            for (int i = 0; i < paramTable.GetLength(0); i++)
            {
                if (paramTable[i, 0] == "[Runoff]")
                {
                    bInRunoffSection = true;
                }

                if (bInRunoffSection)
                {
                    if (paramTable[i, 0] == "[SurfaceModels]")
                    {
                        bInSurfaceModelsSection = true;
                    }

                    if (bInSurfaceModelsSection)
                    {
                        if (paramTable[i, 0] == "[EndSect]")
                        {
                            bInSurfaceModelsSection = false;
                            i++;
                        }

                        while (paramTable[i, 0] == "<SurfMod>")
                        {
                            switch (paramTable[i, 2])
                            {
                            case "TA1":
                                TA1 taCatch = new TA1(getNode(paramTable[i, 1]), paramTable[i, 3]);
                                taCatch.setRainfallData(raindata);
                                xcatchments.Add(taCatch);
                                break;

                            case "LinResSurf2":
                                LinResSurf2 LrSurf = new LinResSurf2(getNode(paramTable[i, 1]), paramTable[i, 3]);
                                LrSurf.setRainfallData(raindata);
                                xcatchments.Add(LrSurf);
                                break;

                            case "PlainArea":
                                PlainArea plAr = new PlainArea(getNode(paramTable[i, 1]), paramTable[i, 3]);
                                plAr.setRainfallData(raindata);
                                xcatchments.Add(plAr);
                                break;

                            default:
                                throw new Exception("Error constructing surface model. Unknown SurfModel type: " + paramTable[i, 2]);
                            }

                            i++;
                        }
                    }

                    if (paramTable[i, 0] == "[EndSect]")
                    {
                        bInRunoffSection = false;
                        i++;
                    }
                }
            }

            return(xcatchments);
        }
Пример #2
0
      private List <Catchment> getCatchments(string[,] paramTable)
      {
          var xcatchments = new List <Catchment>();

          bool bInRunoffSection        = false;
          bool bInSurfaceModelsSection = false;

          for (int i = 0; i < paramTable.GetLength(0); i++)
          {
              if (paramTable[i, 0] == "[Runoff]")
              {
                  bInRunoffSection = true;
              }

              if (bInRunoffSection)
              {
                  if (paramTable[i, 0] == "[SurfaceModels]")
                  {
                      bInSurfaceModelsSection = true;
                  }

                  if (bInSurfaceModelsSection)
                  {
                      if (paramTable[i, 0] == "[EndSect]")
                      {
                          bInSurfaceModelsSection = false;
                          i++;
                      }
                      try
                      {
                          while (paramTable[i, 0] == "<SurfMod>")
                          {
                              Catchment catx;
                              switch (paramTable[i, 2])
                              {
                              case "TA1":
                                  catx = new TA1(getNodeOrDivider(paramTable[i, 1]), paramTable[i, 3]);
                                  break;

                              case "LinResSurf2":
                                  catx = new LinResSurf2(getNodeOrDivider(paramTable[i, 1]), paramTable[i, 3]);
                                  break;

                              case "PlainArea":
                                  catx = new PlainArea(getNodeOrDivider(paramTable[i, 1]), paramTable[i, 3]);
                                  break;

                              default:
                                  throw new Exception("Error constructing surface model. Unknown SurfModel type: " + paramTable[i, 2]);
                              }
                              catx.setRainfallData(raindata);

                              if (paramTable[i, 4] != null)
                              {
                                  catx.bHasAdditionalFlow = true;

                                  System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo();
                                  provider.NumberDecimalSeparator = ".";
                                  string[] split = paramTable[i, 4].Split(new Char[] { ' ', '\t', '=', ',', '(', ')', ';' }, StringSplitOptions.RemoveEmptyEntries);
                                  catx.numberOfUnits = Convert.ToDouble(split[0], provider);
                                  catx.profileIndex  = Convert.ToInt32(split[1], provider);
                              }
                              xcatchments.Add(catx);
                              i++;
                          }
                      }

                      catch (Exception e)
                      {
                          throw new Exception("Error constructing surface model: " + e.Message);
                      }
                  }

                  if (paramTable[i, 0] == "[EndSect]")
                  {
                      bInRunoffSection = false;
                      i++;
                  }
              }
          }

          return(xcatchments);
      }