public WFDLakesViewModel()
    {
      ShapeReader psp = new ShapeReader(@"soervp1.shp");
      Lakes = new Dictionary<string, WFDLake>();

      DT = psp.Data.Read();

      psp.Data.SpoolBack();
      
      foreach (var l in psp.GeoData)
      {
        WFDLake wf = new WFDLake(); 

        wf.Polygon = (XYPolygon)l.Geometry;
        wf.Data = l.Data;
        string name =(string) l.Data[0];
        if (!Lakes.ContainsKey(name))
          Lakes.Add(name, wf);
  
      }
      psp.Dispose();

      Precipitation = new TimespanSeries();
      Precipitation.Name = "Precipitation";
      double[] values = new double[] { 108, 83, 73, 52, 61, 86, 99, 101, 75, 108, 85, 101 };
      AddMonthlyValues(Precipitation, 2007, values);

      Evaporation = new TimespanSeries();
      Evaporation.Name = "Evaporation";
      double[] values2 = new double[] { 4, 11, 34, 66, 110, 118, 122, 103, 61, 26, 7, 1 };
      AddMonthlyValues(Evaporation, 2007, values2);

    }
Esempio n. 2
0
 public static Lake GetLake(string Name)
 {
   ShapeReader psp = new ShapeReader(@"soervp1.shp");
   foreach (var l in psp.GeoData)
   {
     Lake L = new Lake((string)l.Data[0], (XYPolygon)l.Geometry);
     
     if (L.Name.ToLower().Equals(Name.ToLower()))
     {
       psp.Dispose();
       return L;
     }
   }
   psp.Dispose();
   return null;
 }
Esempio n. 3
0
    public void ReadWellsFromShape()
    {
      ShapeReader SR = new ShapeReader(_config.WellShapeFile);
      DataTable _wellData = SR.Data.Read();
      SR.Dispose();
      
      foreach (DataRow dr in _wellData.Rows)
      {
        IrrigationWell IW = new IrrigationWell(dr[_config.IdHeader].ToString());
          IW.X =  Convert.ToDouble(dr[_config.XHeader]);
          IW.Y = Convert.ToDouble(dr[_config.YHeader]);

        IIntake I = IW.AddNewIntake(1);

        IW.MaxDepth = Convert.ToDouble(dr[_config.MaxDepthHeader]);
        IW.MaxRate = Convert.ToDouble(dr[_config.MaxRateHeader]);

        Screen CurrentScreen = new Screen(I);
        CurrentScreen.DepthToBottom =  Convert.ToDouble(dr[_config.BottomHeader]);
        CurrentScreen.DepthToTop = Convert.ToDouble(dr[_config.TopHeader]);
        _wells.Add(IW);
      }
      _wellData.Dispose();
    }
    /// <summary>
    /// Opens a point shape
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button2_Click(object sender, EventArgs e)
    {
        openFileDialog2.Filter = "Known file types (*.shp)|*.shp";
        this.openFileDialog2.ShowReadOnly = true;
        this.openFileDialog2.Title = "Select a shape file with data for wells or intakes";

        if (openFileDialog2.ShowDialog() == DialogResult.OK)
        {
            string FileName = openFileDialog2.FileName;

            ShapeReader SR = new ShapeReader(FileName);

            DataTable FullDataSet = SR.Data.Read();
            //Launch a data selector
            DataSelector DS = new DataSelector(FullDataSet);

            if (DS.ShowDialog() == DialogResult.OK)
            {
                if (ShpConfig == null)
                {
                    XmlSerializer x = new XmlSerializer(typeof(ShapeReaderConfiguration));
                    string InstallationPath = Path.GetDirectoryName(this.GetType().Assembly.Location);
                    string config = Path.Combine(InstallationPath, "ShapeReaderConfig.xml");
                    using (FileStream fs = new FileStream(config, FileMode.Open))
                    {
                        ShpConfig = (ShapeReaderConfiguration)x.Deserialize(fs);

                        if (CheckColumn(FullDataSet, ShpConfig.WellIDHeader, config))
                            if (CheckColumn(FullDataSet, ShpConfig.IntakeNumber, config))
                                if (CheckColumn(FullDataSet, ShpConfig.XHeader, config))
                                    if (CheckColumn(FullDataSet, ShpConfig.YHeader, config))
                                        if (CheckColumn(FullDataSet, ShpConfig.TOPHeader, config))
                                          if (CheckColumn(FullDataSet, ShpConfig.BOTTOMHeader, config))
                                          {
                                            Wells = new IWellCollection();
                                            if (FullDataSet.Columns.Contains(ShpConfig.PlantIDHeader))
                                            {
                                              DPlants = new IPlantCollection();
                                              HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells, DPlants);
                                            }
                                            else
                                              HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells);
                                            UpdateListsAndListboxes();
                                          }
                    }
                }
            }
            SR.Dispose();
        }
    }