public void PropertyTest() { XYPoint xypoint = new XYPoint(2, 3); Assert.AreEqual((double)2, xypoint.X); Assert.AreEqual((double)3, xypoint.Y); xypoint.X = 6; xypoint.Y = 7; Assert.AreEqual((double)6, xypoint.X); Assert.AreEqual((double)7, xypoint.Y); }
public void Equals() { XYPoint p1 = new XYPoint(2, 3); XYPoint p2 = new XYPoint(2, 3); XYPoint p3 = new XYPoint(2, -3); XYLine l1 = new XYLine(2, 3, 3, 4); Assert.AreEqual(true, p1.Equals(p1), "Test1"); Assert.AreEqual(true, p1.Equals(p2), "Test2"); Assert.AreEqual(false, p1.Equals(p3), "Test3"); Assert.AreEqual(false, p1.Equals(l1), "Test4"); }
/// <summary> /// PictureBox (pb) 上の座標から、pb.Image 上の座標に変換する。 /// pb.SizeMode == PictureBoxSizeMode.Zoom であること。 /// </summary> /// <param name="pb"></param> /// <param name="pbPt"></param> /// <param name="toRangeFlag"></param> /// <returns>null == 枠外 || 画像が設定されていない。</returns> public static XYPoint getPictureBoxPointToImagePoint(PictureBox pb, XYPoint pbPt, bool toRangeFlag = false) { Image img = pb.Image; if (img == null) { return(null); } double w = (double)img.Width; double h = (double)img.Height; double screen_w = (double)pb.Width; double screen_h = (double)pb.Height; Rect imgRect = new Rect(w, h); Rect screenRect = new Rect(0, 0, screen_w, screen_h); imgRect.adjustInside(screenRect); double x = pbPt.x; double y = pbPt.y; x -= imgRect.l; y -= imgRect.t; x /= imgRect.w; y /= imgRect.h; if (toRangeFlag) { x = DoubleTools.toRange(x, 0.0, 1.0); y = DoubleTools.toRange(y, 0.0, 1.0); } else { if (DoubleTools.isRange(x, 0.0, 1.0) == false) { return(null); } if (DoubleTools.isRange(y, 0.0, 1.0) == false) { return(null); } } x *= img.Width; y *= img.Height; return(new XYPoint(x, y)); }
public void DrawdownTest() { TheisAnalysis target = new TheisAnalysis(); // TODO: Initialize to an appropriate value IXYPoint PumpingWell = new XYPoint(0, 0); double PumpingRate = 5000.0 / 24.0 / 3600.0; //5000 m3/day double Storativity = 1.83e-3; double Transmissivity = 164.49 / 24.0 / 3600.0; //90 m2/day TimeSpan Time = TimeSpan.FromMinutes(100); IXYPoint ObservationPoint = new XYPoint(50, 50); double actual; actual = target.Drawdown(PumpingWell, PumpingRate, Storativity, Transmissivity, Time, ObservationPoint); Assert.AreEqual(2.959, actual, 0.01); }
public void AdjacencyEdgePointsMethodWorksWithOffset() { var centrePoint = new XYPoint(-1, 0); var actualOutput = centrePoint.GetEdgeAdjacentPoints(eDirection.South, eDirectionChange.AntiClockwise); var expectedOutput = new[] { new XYPoint(-1, -1), new XYPoint(0, 0), new XYPoint(-1, 1), new XYPoint(-2, 0) }; CollectionAssert.AreEqual(expectedOutput, actualOutput); }
public void AdjacencyMethodsWithDefaultParametersWorkAsPerPrimaryMethod(int centreX, int centreY) { var centrePoint = new XYPoint(centreX, centreY); CollectionAssert.AreEqual(centrePoint.GetAllAdjacentPoints(), centrePoint.GetAdjacentPoints()); CollectionAssert.AreEqual(centrePoint.GetAllAdjacentPoints(), centrePoint.GetAdjacentPoints(eDirection.North, eDirectionChange.Clockwise, adjacencyType: XYPoint.eAdjacencyType.All)); CollectionAssert.AreEqual(centrePoint.GetAllAdjacentPoints(eDirection.South), centrePoint.GetAdjacentPoints(eDirection.South)); CollectionAssert.AreEqual(centrePoint.GetAllAdjacentPoints(eDirection.South), centrePoint.GetAdjacentPoints(eDirection.South, eDirectionChange.Clockwise, XYPoint.eAdjacencyType.All)); CollectionAssert.AreEqual(centrePoint.GetAllAdjacentPoints(eDirection.West, eDirectionChange.AntiClockwise), centrePoint.GetAdjacentPoints(eDirection.West, eDirectionChange.AntiClockwise)); CollectionAssert.AreEqual(centrePoint.GetAllAdjacentPoints(eDirection.West, eDirectionChange.AntiClockwise), centrePoint.GetAdjacentPoints(eDirection.West, eDirectionChange.AntiClockwise, XYPoint.eAdjacencyType.All)); CollectionAssert.AreEqual(centrePoint.GetEdgeAdjacentPoints(), centrePoint.GetAdjacentPoints(adjacencyType: XYPoint.eAdjacencyType.Orthogonal)); CollectionAssert.AreEqual(centrePoint.GetEdgeAdjacentPoints(), centrePoint.GetAdjacentPoints(eDirection.North, eDirectionChange.Clockwise, XYPoint.eAdjacencyType.Orthogonal)); CollectionAssert.AreEqual(centrePoint.GetEdgeAdjacentPoints(eDirection.South), centrePoint.GetAdjacentPoints(eDirection.South, eDirectionChange.Clockwise, XYPoint.eAdjacencyType.Orthogonal)); CollectionAssert.AreEqual(centrePoint.GetEdgeAdjacentPoints(eDirection.West, eDirectionChange.AntiClockwise), centrePoint.GetAdjacentPoints(eDirection.West, eDirectionChange.AntiClockwise, XYPoint.eAdjacencyType.Orthogonal)); }
public void GetImageryTest() { XYPoint point = new XYPoint(715281.56, 6189341.78); double dx = 5000; double dy = 5000; BitmapImage actual; actual = Map.GetImagery(point, dx, dy); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2)); FileStream filestream = new FileStream(@"c:\temp\pict.jpg", FileMode.Create); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(actual)); encoder.Save(filestream); filestream.Dispose(); }
/// <summary> /// Returns the height at the point using the method selected with the enums /// </summary> /// <param name="point"></param> /// <param name="height"></param> /// <returns></returns> public bool TryFindDemHeight(IXYPoint point, out double?height) { height = null; switch (DEMSource) { case SourceType.Oracle: return(Oracle.TryGetHeight(point, out height)); case SourceType.KMSWeb: return(KMSData.TryGetHeight(point, 32, out height)); case SourceType.DFS2: int col = DFSdem.GetColumnIndex(point.X); int row = DFSdem.GetRowIndex(point.Y); if (col >= 0 & row >= 0) { height = DFSdem.GetData(0, 1)[row, col]; return(true); } else { return(false); } default: return(false); case SourceType.HydroInform: { XYPoint p = point as XYPoint; if (LDC.State == System.ServiceModel.CommunicationState.Faulted) { return(false); } var d = LDC.GetHeight(p.Latitude, p.Longitude); if (d.HasValue) { height = d.Value; } return(d.HasValue); } } return(false); }
static void Main(string[] args) { XYPoint point = new XYPoint(715281.56, 6189341.78); double dx = 5000; double dy = 5000; actual = Map.GetImagery(point, dx, dy); actual.DownloadCompleted += new EventHandler(actual_DownloadCompleted); System.Windows.Controls.Image im = new System.Windows.Controls.Image(); im.Source = actual; im.SourceUpdated += new EventHandler <System.Windows.Data.DataTransferEventArgs>(im_SourceUpdated); im.UpdateLayout(); Console.WriteLine(DateTime.Now.Second); Console.ReadLine(); }
public void AdjacencyAllPointsMethodWorks() { var centrePoint = new XYPoint(0, 0); var actualOutput = centrePoint.GetAllAdjacentPoints(); var expectedOutput = new[] { new XYPoint(0, 1), new XYPoint(1, 1), new XYPoint(1, 0), new XYPoint(1, -1), new XYPoint(0, -1), new XYPoint(-1, -1), new XYPoint(-1, 0), new XYPoint(-1, 1) }; CollectionAssert.AreEqual(expectedOutput, actualOutput); }
private void pb_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { psp = new List <XYPoint>(); psp.Clear(); for (int i = 0; i < curves.Count; i++) { // malen der Punkte fuer jede Kurve Kurve curve = (Kurve)(curves[i]); if ((curve.getParser() != null) && (!(curve.isDatum))) { // wenn Parser vorhanden, dann Werte bestimmen fuer // eingestellten x_Bereich (umweg ueber weitere Kurve) for (int k = 0; k < curve.getWerte().Count; k++) { psp.Add(curve.getWerte()[k]); } } else { // bei DB - Werten direkt nur die // importierten Daten darstellen psp = curve.getWerte(); break; } } //g.setColor(curve.getKurvenfarbe()); for (int j = 0; j < psp.Count; j++) { // Punkt bestimmen XYPoint xp = psp[j]; if ((Math.Abs(xp.getIx() - e.X) < 4) && (Math.Abs(xp.getIy() - e.Y) < 4)) { CanGetPoint = false; MouseDownString = xp.getstr(); XPointValue = xp.getX(); YPointValue = xp.getY(); CanGetPoint = true; break; } else { MouseDownString = ""; } } }
public IList <SupportRectangleWithId> Generate(Random random, int numPoints, double x, double y, double width, double height) { IDictionary <XYPoint, SupportRectangleWithId> points = new Dictionary <XYPoint, SupportRectangleWithId>(); int pointNum = 0; while (points.Count < numPoints) { float fx = random.Next(numPoints); float fy = random.Next(numPoints); XYPoint p = new XYPoint(fx, fy); if (points.ContainsKey(p)) { continue; } points.Put(p, new SupportRectangleWithId("P" + pointNum, fx, fy, 0, 0)); pointNum++; } return(new List <SupportRectangleWithId>(points.Values)); }
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is XYPolyline) { var Locations = new LocationCollection(); foreach (var p in ((XYPolyline)value).Points.Cast <XYPoint>().Where(pp => pp.Latitude != 0)) { Locations.Add(new Location(p.Latitude, p.Longitude)); } return(Locations); } else if (value is IXYPoint) { XYPoint p = new XYPoint(((IXYPoint)value).X, ((IXYPoint)value).Y); return(new Location(p.Latitude, p.Longitude)); } return(new LocationCollection()); }
public DoubleSeries GenerateEEG(int count, ref double startPhase, double phaseStep) { var doubleSeries = new DoubleSeries(); var rand = new Random((int)DateTime.Now.Ticks); for (int i = 0; i < count; i++) { var xyPoint = new XYPoint(); var time = i / (double)count; xyPoint.X = time; //double mod = 0.2 * Math.Sin(startPhase); xyPoint.Y = //mod * Math.Sin(startPhase / 4.9) + 0.05 * (rand.NextDouble() - 0.5) + 1.0; doubleSeries.Add(xyPoint); startPhase += phaseStep; } return(doubleSeries); }
//--------------------------------------------------------------------------- /** * * @param xMin * : Unterer Grenzwert * @param xMax * : Oberer Grenzwert * @param steps * : Anzahl der Zwischenwerte - 2 * @return * Bestimmt die Werte einer Funktion */ public Kurve bestimmeKurve(double xMin, double xMax, int steps) { Kurve ret = null; double xStep = 0.0; werte.Clear(); // Hier wird ein Array uebergeben, // weil sich in Java uebergebene // Werte nicht aendern, nur Objektwerte (brauche nur den Ersten wert Double[] ergebnis = new Double[1]; String[] errorText = new String[1]; xStep = ((xMax - xMin) / steps); for (int i = 0; i <= steps; i++) { double x = xMin + xStep * i; try { errorText[0] = ""; int error = doubleFktValue(x, ergebnis, errorText); if ((error == 0) && (String.IsNullOrEmpty(errorText[0]))) { // XYPoint xy = new XYPoint( Math.round( x * 1000.0 ) / 1000.0, Math.round( ergebnis[0] * 1000.0 ) / 1000.0 ); XYPoint xy = new XYPoint(x, ergebnis[0]); xy.setstr("(" + xy.getX().ToString("0.##", CultureInfo.InvariantCulture) + "," + xy.getY().ToString("0.##", CultureInfo.InvariantCulture) + ")"); werte.Add(xy); } } catch (Exception ex) { string str = ex.Message; } } // neue Kurve aus den Werte erzeugen ret = new Kurve(werte); return(ret); }
public static BitmapImage GetImagery(XYPoint point, double dx, double dy) { try { string key = "ArfYQbvMgvi7NOpxSAuS3lkBlVc3NqzgBcVo-yxNyr_KPVJbhwR22c9cVfG7AnwY"; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps key mapUriRequest.Credentials = new Credentials(); mapUriRequest.Credentials.ApplicationId = key; // Set the location of the requested image mapUriRequest.Center = new Location(); mapUriRequest.Center.Latitude = point.Latitude; mapUriRequest.Center.Longitude = point.Longitude; // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); mapUriOptions.Style = MapStyle.AerialWithLabels_v1; mapUriOptions.ZoomLevel = 13; // Set the size of the requested image in pixels mapUriOptions.ImageSize = new SizeOfint(); mapUriOptions.ImageSize.Height = (int)(dy / 19.11); //19.11 to get meters mapUriOptions.ImageSize.Width = (int)(dx / 19.11); mapUriRequest.Options = mapUriOptions; //Make the request and return the URI ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(new BitmapImage(new Uri(mapUriResponse.Uri))); } catch (Exception e) { return(null); } }
public DoubleSeries GetSquirlyWave() { var doubleSeries = new DoubleSeries(); var rand = new Random((int)DateTime.Now.Ticks); const int COUNT = 1000; for (int i = 0; i < COUNT; i++) { var xyPoint = new XYPoint(); var time = i / (double)COUNT; xyPoint.X = time; xyPoint.Y = time * Math.Sin(2 * Math.PI * i / (double)COUNT) + 0.2 * Math.Sin(2 * Math.PI * i / (COUNT / 7.9)) + 0.05 * (rand.NextDouble() - 0.5) + 1.0; doubleSeries.Add(xyPoint); } return(doubleSeries); }
public void ContainsTest() { List <IXYPolygon> pols = new List <IXYPolygon>(); using (Geometry.Shapes.ShapeReader sr = new Geometry.Shapes.ShapeReader(@"D:\NitrateModel\Overfladevand\Punktkilder\kystzone.shp")) { foreach (var pol in sr.GeoData) { if (pol.Data[1].ToString().Trim().ToLower() == "land") { pols.Add(pol.Geometry as IXYPolygon); } } } List <XYPoint> points = new List <XYPoint>(); using (Geometry.Shapes.ShapeReader sr = new Geometry.Shapes.ShapeReader(@"D:\NitrateModel\Overfladevand\Punktkilder\spredt_pkt.shp")) { for (int i = 0; i < sr.Data.NoOfEntries; i++) { XYPoint p = sr.ReadNext(i) as XYPoint; Parallel.ForEach(pols, (pol, state) => { if (pol.Contains(p)) { points.Add(p); state.Break(); } }); } } int k = points.Count; }
public DoubleSeries GetFourierSeries(double amplitude, double phaseShift, int count = 5000) { var doubleSeries = new DoubleSeries(); for (int i = 0; i < count; i++) { var xyPoint = new XYPoint(); double time = 10 * i / (double)count; double wn = 2 * Math.PI / (count / 10); xyPoint.X = time; xyPoint.Y = Math.PI * amplitude * (Math.Sin(i * wn + phaseShift) + 0.33 * Math.Sin(i * 3 * wn + phaseShift) + 0.20 * Math.Sin(i * 5 * wn + phaseShift) + 0.14 * Math.Sin(i * 7 * wn + phaseShift) + 0.11 * Math.Sin(i * 9 * wn + phaseShift) + 0.09 * Math.Sin(i * 11 * wn + phaseShift)); doubleSeries.Add(xyPoint); } return(doubleSeries); }
protected bool Equals(XYPoint other) { return X.Equals(other.X) && Y.Equals(other.Y); }
//TODO add try/catch #region Input_Parse //RayonRs232 old parser public void ParseInputData(int length, byte[] dataInput) { if (Rs232Interface.GetInstance.IsSynced == false)//TODO { Rs232Interface.GetInstance.IsSynced = true; //Rs232Interface.GetInstance. } else { //Parser int PlotDataSampleLSB; int PlotDataSampleMSB; int PlotDataSample; int i = 0; //int limit = (dataInput.Length - (dataInput.Length%12)); for (; i < dataInput.Length - 24;) { if (dataInput[i] == 0xbb && dataInput[i + 1] == 0xcc) { XYPoint xyPoint1 = new XYPoint(); XYPoint xyPoint2 = new XYPoint(); XYPoint xyPoint3 = new XYPoint(); XYPoint xyPoint4 = new XYPoint(); XYPoint xyPoint5 = new XYPoint(); // //First Sample // try // { PlotDataSampleLSB = (short)dataInput[i + 2]; PlotDataSampleMSB = (short)dataInput[i + 3]; PlotDataSample = (PlotDataSampleMSB << 8) | PlotDataSampleLSB; xyPoint1.Y = (double)PlotDataSample; xyPoint1.X = _deltaTOneChen; _deltaTOneChen += 0.1; datasource1.Add(xyPoint1); //Second PlotDataSampleLSB = (short)dataInput[i + 4]; PlotDataSampleMSB = (short)dataInput[i + 5]; PlotDataSample = (PlotDataSampleMSB << 8) | PlotDataSampleLSB; xyPoint2.Y = (double)PlotDataSample; xyPoint2.X = _deltaTOneChen; _deltaTOneChen += 0.1; datasource1.Add(xyPoint2); //Third Sample PlotDataSampleLSB = (short)dataInput[i + 6]; PlotDataSampleMSB = (short)dataInput[i + 7]; PlotDataSample = (PlotDataSampleMSB << 8) | PlotDataSampleLSB; xyPoint3.Y = (double)PlotDataSample; xyPoint3.X = _deltaTOneChen; _deltaTOneChen += 0.1; datasource1.Add(xyPoint3); //Fourth sample PlotDataSampleLSB = (short)dataInput[i + 8]; PlotDataSampleMSB = (short)dataInput[i + 9]; PlotDataSample = (PlotDataSampleMSB << 8) | PlotDataSampleLSB; xyPoint4.Y = (double)PlotDataSample; xyPoint4.X = _deltaTOneChen; datasource1.Add(xyPoint4); _deltaTOneChen += 0.1; //Fifth sample PlotDataSampleLSB = (short)dataInput[i + 10]; PlotDataSampleMSB = (short)dataInput[i + 11]; PlotDataSample = (PlotDataSampleMSB << 8) | PlotDataSampleLSB; if (PlotDataSample != 4.0) { // int a = 5; } xyPoint5.Y = (double)PlotDataSample; xyPoint5.X = _deltaTOneChen; _deltaTOneChen += 0.1; datasource1.Add(xyPoint5); i = i + 11; } i++; } Parser2Plot(this, new Parser2SendEventArgs(datasource1)); datasource1.Clear(); } }
public MUNode(Node N) { Links = new List <MULink>(); pfsnode = N; Location = new XYPoint(pfsnode.X, pfsnode.Y); }
public static bool AIsPointInLineInterior(XYPoint point, XYLine line) { return(IsPointInLineInterior(point, line)); }
public static bool AIntersectionPoint(XYLine lineA, XYLine lineB, ref XYPoint intersectionPoint) { return(IntersectionPoint(lineA, lineB, ref intersectionPoint)); }
public override void Initialize(DateTime Start, DateTime End, IEnumerable <Catchment> Catchments) { base.Initialize(Start, End, Catchments); Dictionary <XYPoint, List <double> > Data = new Dictionary <XYPoint, List <double> >(); XSSFWorkbook hssfwb; using (FileStream file = new FileStream(ExcelFile.FileName, FileMode.Open, FileAccess.Read)) { hssfwb = new XSSFWorkbook(file); } List <IRow> DataRows = new List <IRow>(); var sheet = hssfwb.GetSheet("Ndep_Tot"); for (int row = 1; row <= sheet.LastRowNum; row++) { if (sheet.GetRow(row) != null) //null is when the row only contains empty cells { DataRows.Add(sheet.GetRow(row)); } } using (ShapeReader sr = new ShapeReader(Shapefile.FileName)) { FirstYear = (int)DataRows.First().Cells[0].NumericCellValue; for (int i = 0; i < sr.Data.NoOfEntries; i++) { int icoor = sr.Data.ReadInt(i, "i"); int jcoor = sr.Data.ReadInt(i, "j"); XYPoint point = (XYPoint)sr.ReadNext(i); //Create the timestampseries and set unit to kg/m2/s; var data = DataRows.Where(v => (int)v.Cells[3].NumericCellValue == icoor & (int)v.Cells[4].NumericCellValue == jcoor).OrderBy(v => (int)v.Cells[0].NumericCellValue).Select(v => v.Cells[6].NumericCellValue / (365.0 * 86400.0 * 1.0e6)).ToList(); if (data.Count() > 0) { Data.Add(point, data); } } } foreach (var c in Catchments) { XYPolygon poly = null; if (c.Geometry is XYPolygon) { poly = c.Geometry as XYPolygon; } else if (c.Geometry is MultiPartPolygon) { poly = ((MultiPartPolygon)c.Geometry).Polygons.First(); //Just use the first polygon } double LakeArea = c.Lakes.Sum(l => l.Geometry.GetArea()); //Get the area of the lakes if (c.BigLake != null) //Add the big lake { LakeArea += c.BigLake.Geometry.GetArea(); } if (poly != null) { var point = new XYPoint(poly.PlotPoints.First().Longitude, poly.PlotPoints.First().Latitude); //Take one point in the polygon var closestpoint = Data.Keys.Select(p => new Tuple <XYPoint, double>(p, p.GetDistance(point))).OrderBy(s => s.Item2).First().Item1; deposition.Add(c.ID, new List <double>(Data[closestpoint].Select(v => v * LakeArea))); } } NewMessage("Initialized"); }
private void maleDiagramm() { if (!chkParameter.Checked) { string err = ""; curves.Clear(); if (chkAktiv1.Checked) { Parser ps = new Parser(); err = ps.parsen(curve1.getFktText()); if (err.Trim() == "") { ps.bestimmeKurve((double)numericUpDown1.Value, (double)numericUpDown2.Value, curve1.getSteps()); curve1.setParser(ps); curves.Add(curve1); } else { tbCurve1.Text += " - " + err; chkAktiv1.Checked = false; } } if (chkAktiv2.Checked) { Parser ps = new Parser(); err = ps.parsen(curve2.getFktText()); if (err.Trim() == "") { ps.bestimmeKurve((double)numericUpDown1.Value, (double)numericUpDown2.Value, curve2.getSteps()); curve2.setParser(ps); curves.Add(curve2); } else { tbCurve2.Text += " - " + err; chkAktiv2.Checked = false; } } if (chkAktiv3.Checked) { Parser ps = new Parser(); err = ps.parsen(curve3.getFktText()); if (err.Trim() == "") { ps.bestimmeKurve((double)numericUpDown1.Value, (double)numericUpDown2.Value, curve3.getSteps()); curve3.setParser(ps); curves.Add(curve3); } else { tbCurve3.Text += " - " + err; chkAktiv3.Checked = false; } } } else { string err = ""; curves.Clear(); Parser ps1 = new Parser(); string str = curve1.getFktText(); err = ps1.parsen(curve1.getFktText()); if (err.Trim() != "") { tbCurve1.Text = err; return; } //curve1.setParser(ps1); Kurve curvea = ps1.bestimmeKurve(diag.getxMin(), diag.getxMax(), curve1.getSteps()); err = ""; Parser ps2 = new Parser(); err = ps2.parsen(curve2.getFktText()); if (err.Trim() != "") { tbCurve2.Text = err; return; } //curve2.setParser(ps2); Kurve curveb = ps2.bestimmeKurve(diag.getxMin(), diag.getxMax(), curve2.getSteps()); List <XYPoint> lx1 = curvea.getWerte(); List <XYPoint> lx2 = curveb.getWerte(); Kurve ka = new Kurve(); List <XYPoint> pk = new List <XYPoint>(); pk.Clear(); for (int i = 0; i < lx1.Count; i++) { XYPoint pxy = new XYPoint(lx1[i].getY(), lx2[i].getY()); pxy.setstr("(" + pxy.getX().ToString("0.##", CultureInfo.InvariantCulture) + "," + pxy.getY().ToString("0.##", CultureInfo.InvariantCulture) + ")"); pk.Add(pxy); } ka.setParser(null); ka.setKurvenart(Punktform.DICKER_PUNKT); ka.setKurvenfarbe(Color.Yellow); ka.setXEinheit(""); ka.setYEinheit(""); ka.setFktText(""); ka.setWerte(pk); curves.Add(ka); } this.Refresh(); }
//@Override // public void paint(Graphics g0) protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //Graphics g = CreateGraphics(); Rectangle r = this.ClientRectangle; //e.Graphics.FillRectangle(new SolidBrush(Color.Blue), r); e.Graphics.FillRectangle(new SolidBrush(this.BackColor), r); e.Graphics.DrawRectangle(Pens.Gray, 0, 0, ClientSize.Width - 1, ClientSize.Height - 1); Kurve curve_intern = null; // ausprobiert - soviel, dass für doe beschriftung genug Platz int nRandxu = 60; int nRandyu = 60; // weitere Hilfsgroessen festlegen // Diagramm wird in 10 Unterabschnitte eingeteilt // jeweils in Breite und Hoehe int nDx = (this.Width - 2 * nRandxu) / 10; int nRandxo = this.Width - nRandxu - 10 * nDx; int nWidth = this.Width - nRandxu - nRandxo; int nDy = (this.Height - 2 * nRandyu) / 10; int nRandyo = this.Height - nRandyu - 10 * nDy; int nHeight = this.Height - nRandyu - nRandyo; // super.paint(g); // der Rand wird gemalt //g.setColor(mp.getcRahmenfarbe()); Pen pe = new Pen(mp.getcRahmenfarbe()); Brush br = new SolidBrush(Color.Red); //mp.setcRahmenfarbe(Color.Red); e.Graphics.DrawLine(pe, nRandxu, nRandyu, this.Width - nRandxo, nRandyu); e.Graphics.DrawLine(pe, nRandxu, nRandyu, nRandxu, this.Height - nRandyo); e.Graphics.DrawLine(pe, nRandxu, this.Height - nRandyo, this.Width - nRandxo, this.Height - nRandyo); e.Graphics.DrawLine(pe, this.Width - nRandxo, nRandyu, this.Width - nRandxo, this.Height - nRandyo); if (this.yRaster) { // yRaster auf true, dann wird 10er Unterteilung gemalt // Führungslinien for (int i = 1; i < 10; i++) { e.Graphics.DrawLine(pe, nRandxu, nRandyu + i * nDy, this.Width - nRandxo, nRandyu + i * nDy); } } if (this.xRaster) { // xRaster auf true, dann wird 10er Unterteilung gemalt // Führungslinien for (int i = 1; i < 10; i++) { e.Graphics.DrawLine(pe, nRandxu + i * nDx, nRandyu, nRandxu + i * nDx, this.Height - nRandyo); } } if ((curves.Count == 1) && ((Kurve)(curves[0])).isDatum) { // nur wenn Datenbank x - Feld ein Datum ist und wenn nur // eine Kurve naemlich die Datenbankkurve gemalt werden soll // Datumwerte sind eigentlich Double - Werte (sehr grosse) // neue Minimal und Maximalwerte bestimmen ((Kurve)(curves[0])).bestimmeMinMaxWerte(); psp = ((Kurve)(curves[0])).getWerte(); xMin = (((Kurve)(curves[0])).getxMin()); xMax = (((Kurve)(curves[0])).getxMax()); yMin = ((Kurve)(curves[0])).getyMin(); yMax = ((Kurve)(curves[0])).getyMax();; } double diffx = xMax - xMin; double diffy = yMax - yMin; // wenn Werte (x oder y) sehr gross sind, dann werden // statt Dezimalwertdarstellung eine Exponentendarstellung // gewaehlt, dazu wird die Potenz der Differenzen zwischen // Minimal und Maximalwert bestimmt int nPotx = bestimmePotenz(diffx); //System.out.println( "nPotx: " + nPotx ); double w10x = 1.0; int wnPotx = nPotx; if (wnPotx > 0) { while (wnPotx > 0) { w10x = 10 * w10x; wnPotx--; } } else if (wnPotx < 0) { while (wnPotx < 0) { w10x = w10x / 10; wnPotx++; } } int nPoty = bestimmePotenz(diffy); //System.out.println( "nPoty: " + nPoty ); double w10y = 1.0; int wnPoty = nPoty; if (wnPoty > 0) { while (wnPoty > 0) { w10y = 10 * w10y; wnPoty--; } } else if (wnPoty < 0) { while (wnPoty < 0) { w10y = w10y / 10; wnPoty++; } } // alten Werte merken - beachte Unterschied zu BWerten double xMinAlt = xMin; double xMaxAlt = xMax; double yMinAlt = yMin; double yMaxAlt = yMax; if ((nPotx < -2) || (2 < nPotx)) { xMin = Math.Round((xMin / w10x) * 100) / 100.0; xMax = Math.Round((xMax / w10x) * 100) / 100.0; } if ((nPoty < -2) || (2 < nPoty)) { yMin = Math.Round((yMin / w10y) * 100) / 100.0; yMax = Math.Round((yMax / w10y) * 100) / 100.0; } drawRaster(nRandxu, nRandxo, nRandyu, nRandyo, nDx, nDy, e.Graphics); /* * if ((curves.Count == 1) && ((Kurve)(curves[0])).isDatum) * { // hier wieder nur wenn Datum angezeigt * xMin = xMinAlt; * xMax = xMaxAlt; * psp = ((Kurve)(curves[0])).getWerte(); * double xDatumDiff = 1.0 * (xMax - xMin) / 10; * * if ((((Kurve)(curves[0])).getDatumart() == Datumart.NurDatum) || * (((Kurve)(curves[0])).getDatumart() == Datumart.DatumUndZeit)) * { // verschiedene Darstellungen des Datums wie im MainTool festgelegt * for (int i = 0; i < 11; i = i + 2) * { // aus Platzgruenden nur 6 Datumswerte * e.Graphics.DrawString(new DateTime((xMin + xDatumDiff * i)).ToShortDateString, * nRandxu - 30 + i * nDx, this.Height - nRandyo + 30); * } * } * if ((((Kurve)(curves.get(0))).getDatumart() == Datumart.DatumUndZeit)) * { * for (int i = 0; i < 11; i = i + 2) * { * g.drawString(new Time(new Double(xMin + xDatumDiff * i).longValue()).toString(), * nRandxu - 30 + i * nDx, this.getHeight() - nRandyo + 45); * } * } * if ((((Kurve)(curves.get(0))).getDatumart() == Datumart.NurZeit)) * { * for (int i = 0; i < 11; i = i + 2) * { * g.drawString(new Time(new Double(xMin + xDatumDiff * i).longValue()).toString(), * nRandxu - 30 + i * nDx, this.getHeight() - nRandyo + 30); * } * } * for (int i = 0; i < 11; i++) * { // bei der y-Achse normale Zahlendarstellung * // hier die linke Achse * g.drawString(NumberFormat.getInstance(). * format(yMin + (yMax - yMin) / 10 * i), * nRandxu - 30, this.getHeight() - nRandyo - i * nDy); * } * for (int i = 0; i < 11; i++) * { // Beide Achsen (hier die rechte) * g.drawString(NumberFormat.getInstance(). * format(yMin + (yMax - yMin) / 10 * i), * this.getWidth() - nRandxo + 20, this.getHeight() - nRandxo - i * nDy); * } * * } * else * */ // hier die normale Beschriftung (kein Datum, .. drawBezeichnung(xMin, xMax, yMin, yMax, nRandxu, nRandxo, nRandyu, nRandyo, nDx, nDy, e.Graphics); if (!(String.IsNullOrEmpty(mp.getxAchse().Trim()) && String.IsNullOrEmpty(mp.getyAchse().Trim()))) { // Achsenbeschriftung (z.B. Einheiten) e.Graphics.DrawString(mp.getxAchse(), this.Font, br, nRandxu + 10 * nDx - 30, this.Height - nRandyo + 45); e.Graphics.DrawString(mp.getyAchse(), this.Font, br, nRandxu - 55, this.Height - nRandxo - 10 * nDy - 40); } else if (curves.Count == 1) { // Achsenbeschriftung (z.B. Einheiten) Kurve curve = (Kurve)(curves[0]); e.Graphics.DrawString(curve.getXEinheit(), this.Font, br, nRandxu + 10 * nDx - 30, this.Height - nRandyo + 45); e.Graphics.DrawString(curve.getYEinheit(), this.Font, br, nRandxu - 55, this.Height - nRandxo - 10 * nDy - 40); } if ((nPoty > 2) || (nPoty < -2)) { // nur bei Potenzialdarstellung e.Graphics.DrawString("* 10", this.Font, br, nRandxu - 50, nRandyu + 37); e.Graphics.DrawString(nPoty.ToString(), this.Font, br, nRandxu - 30, nRandyu + 27); } if (!((curves.Count == 1) && ((Kurve)(curves[0])).isDatum)) { // nur bei Potenzialdarstellung (und kein Datum) if ((nPotx > 2) || (nPotx < -2)) { e.Graphics.DrawString("* 10", this.Font, br, nRandxu + 10 * nDx + 20, this.Height - nRandyo + 45); e.Graphics.DrawString(nPotx.ToString(), this.Font, br, nRandxu + 10 * nDx + 42, this.Height - nRandyo + 35); } } xMin = xMinAlt; xMax = xMaxAlt; yMin = yMinAlt; yMax = yMaxAlt; for (int i = 0; i < curves.Count; i++) { // malen der Punkte fuer jede Kurve Kurve curve = (Kurve)(curves[i]); if ((curve.getParser() != null) && (!(curve.isDatum))) { // wenn Parser vorhanden, dann Werte bestimmen fuer // eingestellten x_Bereich (umweg ueber weitere Kurve) Parser p = curve.getParser(); curve_intern = p.bestimmeKurve(xMin, xMax, curve.getSteps()); psp = curve_intern.getWerte(); curve.setWerte(psp); } else { // bei DB - Werten direkt nur die // importierten Daten darstellen psp = curve.getWerte(); } //g.setColor(curve.getKurvenfarbe()); Pen penKurvenfarbe = new Pen(curve.getKurvenfarbe()); Punktform ka = curve.getKurvenart(); for (int j = 0; j < psp.Count; j++) { // Punkt bestimmen XYPoint xp = psp[j]; //int nj = 0; //if (j == 200) // nj++; // x und y - Wert bestimmen int xx = (int)((nWidth) * (xp.getX() - xMin) / (xMax - xMin)); int yy = (int)((nHeight) - (nHeight) * (xp.getY() - yMin) / (yMax - yMin)); // Falls ausserhalb des Randes, dann nicht plotten if ((nRandxu + xx) > (this.Width - nRandxo)) { continue; } if ((nRandxu + xx) < (nRandxu)) { continue; } if ((nRandyu + yy) > (this.Height - nRandyo)) { continue; } if ((nRandyu + yy) < (nRandyu)) { continue; } xp.setIx(nRandxu + xx); xp.setIy(nRandyu + yy); // alle Werte werden angezeigt male(nRandxu + xx, nRandyu + yy, e.Graphics, ka, penKurvenfarbe); } curve.setWerte(psp); } // Nur die besonderen Werte werden angezeigt if (ShowSpecialValues) { for (int i = 0; i < curves.Count; i++) { // malen der Punkte fuer jede Kurve Kurve curve = (Kurve)(curves[i]); if ((curve.getParser() != null) && (!(curve.isDatum))) { // wenn Parser vorhanden, dann Werte bestimmen fuer // eingestellten x_Bereich (umweg ueber weitere Kurve) Parser p = curve.getParser(); curve_intern = p.bestimmeKurve(xMin, xMax, curve.getSteps()); psp = curve_intern.getWerte(); curve.setWerte(psp); } else { // bei DB - Werten direkt nur die // importierten Daten darstellen psp = curve.getWerte(); } //g.setColor(curve.getKurvenfarbe()); Pen penKurvenfarbe = new Pen(curve.getKurvenfarbe()); Punktform ka = curve.getKurvenart(); for (int j = 0; j < psp.Count; j++) { // Punkt bestimmen XYPoint xp = psp[j]; //int nj = 0; //if (j == 200) // nj++; // x und y - Wert bestimmen int xx = (int)((nWidth) * (xp.getX() - xMin) / (xMax - xMin)); int yy = (int)((nHeight) - (nHeight) * (xp.getY() - yMin) / (yMax - yMin)); // Falls ausserhalb des Randes, dann nicht plotten if ((nRandxu + xx) > (this.Width - nRandxo)) { continue; } if ((nRandxu + xx) < (nRandxu)) { continue; } if ((nRandyu + yy) > (this.Height - nRandyo)) { continue; } if ((nRandyu + yy) < (nRandyu)) { continue; } xp.setIx(nRandxu + xx); xp.setIy(nRandyu + yy); if (xp.getstr().Contains(ShowSpecialValuesString)) { e.Graphics.FillRectangle(new SolidBrush(ShowSpecialValuesColor), nRandxu + xx - 2, nRandyu + yy - 2, 5, 5); } } curve.setWerte(psp); } } //Graphics2D g = (Graphics2D)g0; if (WithShowString) { if (bPaintmousePos) // if (false) { Font fn = new Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Bold); e.Graphics.DrawString(MouseOverString, fn, new SolidBrush(this.HintColor), mx + 12, my); bPaintmousePos = false; } } xMin = xMinB; xMax = xMaxB; yMin = yMinB; yMax = yMaxB; }
public XYPoint(XYPoint other) { this.X = other is null ? 0 : other.X; this.Y = other is null ? 0 : other.Y; }
public void NovoTest() { TheisAnalysis target = new TheisAnalysis(); // TODO: Initialize to an appropriate value IXYPoint PumpingWell = new XYPoint(0, 0); double PumpingRate = 15 / 3600.0; // double Storativity = 5e-3; double Transmissivity = 1e-3; // List <IXYPoint> InjectionWells = new List <IXYPoint>(); // InjectionWells.Add(new XYPoint(704288.01, 6201186.04)); // InjectionWells.Add(new XYPoint(704455.3,6201201.6 )); // InjectionWells.Add(new XYPoint(704621.99, 6201219)); //// InjectionWells.Add(new XYPoint(704951.98, 6201249.18)); List <IXYPoint> ExtractionWells = new List <IXYPoint>(); //ExtractionWells.Add(new XYPoint(704934.54, 6200994.85)); //ExtractionWells.Add(new XYPoint(704896.26, 6200720.37)); //ExtractionWells.Add(new XYPoint(704940, 6200550)); //InjectionWells.Add(new XYPoint(704698, 6202442)); //ExtractionWells.Add(new XYPoint(704850, 6202365)); using (ShapeReader sr = new ShapeReader(@"C:\Users\Jacob\Dropbox\Enopsol\BiogenLocation.shp")) { foreach (var g in sr.GeoData) { if ((int)g.Data[0] == 1) { InjectionWells.Add((IXYPoint)g.Geometry); } else if ((int)g.Data[0] == 2) { ExtractionWells.Add((IXYPoint)g.Geometry); } } } var d = target.Drawdown(InjectionWells.First(), 56.0 / 3600.0, Storativity, Transmissivity, TimeSpan.FromHours(4), new XYPoint(InjectionWells.First().X + 2, InjectionWells.First().Y + 2)); List <List <double> > drawdowns = new List <List <double> >(); drawdowns.Add(new List <double>()); drawdowns.Add(new List <double>()); drawdowns.Add(new List <double>()); //Frederiksgade IXYPoint ObservationPoint = new XYPoint(705669, 6202256); int j = 0; for (int i = 0; i < 100; i++) { double s = 0; TimeSpan Time = TimeSpan.FromDays(i); foreach (var w in ExtractionWells) { s += target.Drawdown(w, +PumpingRate, Storativity, Transmissivity, Time, ObservationPoint); } drawdowns[j].Add(s); foreach (var w in InjectionWells) { s += target.Drawdown(w, -PumpingRate, Storativity, Transmissivity, Time, ObservationPoint); } drawdowns[j + 1].Add(s); double dw = target.Drawdown(ExtractionWells[0], PumpingRate, Storativity, Transmissivity, Time, new XYPoint(ExtractionWells[0].X + 0.5, ExtractionWells[0].Y + 0.5)); drawdowns[j + 2].Add(dw); } using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\temp\enopsol.txt")) { for (int i = 0; i < 100; i++) { sw.WriteLine(drawdowns[0][i].ToString() + "\t" + drawdowns[1][i].ToString() + "\t" + drawdowns[2][i].ToString()); } } }
public static double ACalculateLineToPointDistance(XYLine line, XYPoint point) { return(CalculateLineToPointDistance(line, point)); }