public void WritePointShapeTest()
    {
      string File = @"..\..\..\TestData\WriteTest.Shp";

      ShapeWriter PSW = new ShapeWriter(File);

      PSW.WritePointShape(10, 20);
      PSW.WritePointShape(20, 30);
      PSW.WritePointShape(30, 40);

      DataTable DT = new DataTable();
      DT.Columns.Add("Name", typeof(string));
      DT.Rows.Add(new object[] { "point1" });
      DT.Rows.Add(new object[] { "point2" });
      DT.Rows.Add(new object[] { "point3" });

      PSW.Data.WriteDate(DT);
      PSW.Dispose();


      ShapeReader PSR = new ShapeReader(File);

      IXYPoint p;
      DataTable DTread = PSR.Data.Read();
      int i = 0;
      foreach (DataRow dr in DTread.Rows)
      {
        Console.WriteLine(dr[0].ToString());
        p = (IXYPoint)PSR.ReadNext(i);
        Console.WriteLine(p.X.ToString() + "   " + p.Y.ToString());
        i++;

      }
    }
    public void WritePolyLineTest()
    {
      string File = @"..\..\..\TestData\PolyLineTest.Shp";
      XYPolyline line = new XYPolyline();
      line.Points.Add(new XYPoint(0, 0));
      line.Points.Add(new XYPoint(2, 2));
      line.Points.Add(new XYPoint(4, 5));

      DataTable dt = new DataTable();
      dt.Columns.Add("tekst", typeof(string));

      GeoRefData grf = new GeoRefData();
      grf.Geometry = line;
      grf.Data = dt.NewRow();
      grf.Data[0] = "Her er værdien";

      ShapeWriter sp = new ShapeWriter(File);
      sp.Write(grf);
      sp.Dispose();
    }
    private void button3_Click(object sender, EventArgs e)
    {
      if (saveFileDialog1.ShowDialog() == DialogResult.OK)
      {

        IEnumerable<Plant> plants =listBoxAnlaeg.Items.Cast<Plant>();
        IEnumerable<JupiterIntake> intakes = JupiterReader.AddDataForNovanaExtraction(plants, dateTimeStartExt.Value, dateTimeEndExt.Value);
        HeadObservations.WriteShapeFromDataRow(saveFileDialog1.FileName, intakes);

        IEnumerable<Plant> PlantWithoutIntakes = plants.Where(var => var.PumpingIntakes.Count == 0);
        if (PlantWithoutIntakes.Count()>0)
          if (DialogResult.Yes == MessageBox.Show("The list contains plants with no intakes attached. Should these be written to a new shape-file?", "Plants without intakes!", MessageBoxButtons.YesNo))
          {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                NovanaTables.IndvindingerDataTable dt = JupiterReader.FillPlantData(PlantWithoutIntakes, dateTimeStartExt.Value, dateTimeEndExt.Value);
                ShapeWriter PSW = new ShapeWriter(saveFileDialog1.FileName);
                PSW.WritePointShape(dt, dt.ANLUTMXColumn.ColumnName, dt.ANLUTMYColumn.ColumnName);
                PSW.Dispose();
            }

          }
      }

    }
예제 #4
0
      /// <summary>
      /// Writes the wells to a point shape
      /// Calculates statistics on the observations within the period from start to end
      /// </summary>
      /// <param name="FileName"></param>
      /// <param name="Wells"></param>
      /// <param name="Start"></param>
      /// <param name="End"></param>
      public static void WriteSimpleShape(string FileName, IEnumerable<IIntake> Intakes, DateTime Start, DateTime End)
      {
        ShapeWriter PSW = new ShapeWriter(FileName);
        OutputTables.PejlingerOutputDataTable PDT = new OutputTables.PejlingerOutputDataTable();

        foreach (Intake I in Intakes)
        {
          var SelectedObs = I.HeadObservations.ItemsInPeriod(Start, End);

          PSW.WritePointShape(I.well.X, I.well.Y);

          OutputTables.PejlingerOutputRow PR = PDT.NewPejlingerOutputRow();

          PR.NOVANAID = I.ToString();
          PR.LOCATION = I.well.Description;
          PR.XUTM = I.well.X;
          PR.YUTM = I.well.Y;
          PR.JUPKOTE = I.well.Terrain;

          if (I.Screens.Count > 0)
          {
            PR.INTAKETOP = I.Screens.Min(var => var.DepthToTop);
            PR.INTAKEBOT = I.Screens.Max(var => var.DepthToBottom);
          }

          PR.NUMBEROFOB = SelectedObs.Count();
          if (SelectedObs.Count() > 0)
          {
            PR.STARTDATO = SelectedObs.Min(x => x.Time);
            PR.ENDDATO = SelectedObs.Max(x => x.Time);
            PR.MAXOBS = SelectedObs.Max(num => num.Value);
            PR.MINOBS = SelectedObs.Min(num => num.Value);
            PR.MEANOBS = SelectedObs.Average(num => num.Value);
          }
          PDT.Rows.Add(PR);
        }


        PSW.Data.WriteDate(PDT);
        PSW.Dispose();
      }
예제 #5
0
      /// <summary>
      /// Writes a point shape with entries for each intake in the list. Uses the dataRow as attributes.
      /// </summary>
      /// <param name="FileName"></param>
      /// <param name="Intakes"></param>
      /// <param name="Start"></param>
      /// <param name="End"></param>
      public static void WriteShapeFromDataRow(string FileName, IEnumerable<JupiterIntake> Intakes)
      {
        ShapeWriter PSW = new ShapeWriter(FileName);
        foreach (JupiterIntake JI in Intakes)
        {
          PSW.WritePointShape(JI.well.X, JI.well.Y);
          PSW.Data.WriteData(JI.Data);
        }
        PSW.Dispose();

      }
예제 #6
0
    /// <summary>
    /// Writes a polyline shape file with the network
    /// </summary>
    /// <param name="shapefilename"></param>
    public void WriteToShape(string shapefilename)
    {
      using (ShapeWriter swc = new ShapeWriter(shapefilename + "_QHPoints"))
      {
        DataTable dat = new DataTable();
        dat.Columns.Add("BranchName", typeof(string));
        dat.Columns.Add("Chainage", typeof(double));
        dat.Columns.Add("Type", typeof(string));
        foreach (var b in nwkfile.MIKE_11_Network_editor.COMPUTATIONAL_SETUP.branchs)
        {
          foreach (var p in b.points.points)
          {
            GeoRefData gd = new GeoRefData();
            gd.Data = dat.NewRow();
            gd.Data["BranchName"] = b.name;
            gd.Data["Chainage"] = p.Par1;

            if(p.Par3 ==0)
            gd.Data["Type"] = "h";
            else
              gd.Data["Type"] = "q";

            var bran = Branches.FirstOrDefault(br => br.Name == b.name);
            if (bran != null)
            {
              gd.Geometry = bran.GetPointAtChainage(p.Par1);
              swc.Write(gd);
            }
          }
        }
      }

      ShapeWriter sw = new ShapeWriter(shapefilename);


      ShapeWriter swCsc = new ShapeWriter(shapefilename + "_CrossSections");
      DataTable dtCsc = new DataTable();
      dtCsc.Columns.Add("Name", typeof(string));
      dtCsc.Columns.Add("TopoID", typeof(string));
      dtCsc.Columns.Add("Chainage", typeof(double));

      DataTable dt = new DataTable();
      dt.Columns.Add("Name", typeof(string));
      dt.Columns.Add("TopoID", typeof(string));
      dt.Columns.Add("ChainageStart", typeof(double));
      dt.Columns.Add("ChainageEnd", typeof(double));

      foreach (var b in branches)
      {
        GeoRefData grf = new GeoRefData();
        grf.Geometry = b.Line;
        grf.Data=dt.NewRow();
        grf.Data[0] = b.Name;
        grf.Data[1] = b.TopoID;
        grf.Data[2] = b.ChainageStart;
        grf.Data[3] = b.ChainageEnd;
        sw.Write(grf);

        foreach (var Csc in b.CrossSections)
        {
          GeoRefData csc_data = new GeoRefData();
          csc_data.Geometry = Csc.Line;
          csc_data.Data = dtCsc.NewRow();
          csc_data.Data[0] = Csc.BranchName;
          csc_data.Data[1] = Csc.TopoID;
          csc_data.Data[2] = Csc.Chainage;

          swCsc.Write(csc_data);
        }
      }
      sw.Dispose();
      swCsc.Dispose();
    }