Skip to content

Commit bbb215e

Browse files
committed
BugFix:
-Workarround for ScottPlot chrashes on NaNs ScottPlot/ScottPlot#4770 - Important signum issues for curvature and heading
1 parent 40dabb5 commit bbb215e

8 files changed

+40
-20
lines changed

TRA.Lib/Trasse.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Numerics;
66
using System.Runtime.CompilerServices;
77
using System.Collections.Specialized;
8+
using ScottPlot.Colormaps;
89

910
#if USE_SCOTTPLOT
1011
using ScottPlot.Plottables;
@@ -539,10 +540,10 @@ public void Plot()
539540

540541
if (interpolation.H != null && interpolation.s != null)
541542
{
542-
var scatterH = PlotG.Plot.Add.Scatter(interpolation.Y, interpolation.H, color);
543+
var scatterH = PlotG.Plot.Add.Scatter(interpolation.Y, interpolation.H.Where(i => !double.IsNaN(i)).ToArray(), color); //BugFix as ScottPlot Crashes on NaNs should be fixed in future release https://github.com/ScottPlot/ScottPlot/pull/4770
543544
//scatterH.LegendText = "Elevation";
544545
scatterH.Axes.YAxis = PlotG.Plot.Axes.Left;
545-
var scatterSlope = PlotG.Plot.Add.ScatterLine(interpolation.Y, interpolation.s, color);
546+
var scatterSlope = PlotG.Plot.Add.ScatterLine(interpolation.Y, interpolation.s.Where(i => !double.IsNaN(i)).ToArray(), color); //BugFix as ScottPlot Crashes on NaNs should be fixed in future release https://github.com/ScottPlot/ScottPlot/pull/4770
546547
//scatterSlope.LegendText = "Slope";
547548
scatterSlope.Axes.YAxis = PlotG.Plot.Axes.Right;
548549
}

TRA.Lib/TrassenElementExt.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public Interpolation(int num = 0)
5252
}
5353
public void Concat(Interpolation interp)
5454
{
55+
if (interp.X == null || interp.Y == null || interp.S == null || interp.T == null || interp.K == null) { return; }
5556
X = X.Concat(interp.X).ToArray();
5657
Y = Y.Concat(interp.Y).ToArray();
5758
S = S.Concat(interp.S).ToArray();
@@ -273,7 +274,11 @@ void AddWarningCallout(string text, double X, double Y)
273274
public ref Interpolation Interpolate(double delta = 1.0, double allowedTolerance = 0.001)
274275
{
275276
Transform2D transform = new Transform2D(x, y, t);
276-
if (TrassenGeometrie == null) { AddWarningCallout("No Gemetry for interpolation " + kz.ToString() + "set, maybe not implemented yet", Xstart,Ystart); return ref Interpolation; }
277+
if (TrassenGeometrie == null) {
278+
AddWarningCallout("No Gemetry for interpolation " + kz.ToString() + "set, maybe not implemented yet", Xstart,Ystart);
279+
Interpolation = new Interpolation(0);
280+
return ref Interpolation;
281+
}
277282
if (Double.IsNaN(l)) { AddWarningCallout("Length is NaN, no interpolation calculated", Xstart, Ystart); return ref Interpolation; }
278283
List<double> Xlst = new List<double>();
279284
List<double> Ylst = new List<double>();
@@ -320,6 +325,7 @@ public ref Interpolation Interpolate(double delta = 1.0, double allowedTolerance
320325

321326
public double GetSAtPoint(double X, double Y, double T = double.NaN)
322327
{
328+
if (TrassenGeometrie == null) return (0);
323329
Transform2D transform = new Transform2D(x, y, t);
324330
transform.ApplyInverse(ref X, ref Y, ref T);
325331
return TrassenGeometrie.sAt(X, Y, T) + s;
@@ -331,6 +337,7 @@ public double GetSAtPoint(double X, double Y, double T = double.NaN)
331337
/// <returns>Hochwert X,Rechtswert Y, Heading T</returns>
332338
public (double, double, double) GetPointAtS(double S)
333339
{
340+
if (TrassenGeometrie == null) return (0, 0, 0);// (Double.NaN, Double.NaN, Double.NaN);
334341
(double X, double Y, double T, _) = TrassenGeometrie.PointAt(S - s);
335342
Transform2D transform = new Transform2D(x, y, t);
336343
transform.Apply(ref X, ref Y, ref T);

TRA.Lib/Trasseninterpolation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override (double X, double Y, double t, double k) PointAt(double s)
6666
double r = Math.Abs(radius);
6767
if (r == 0) { return (s, 0.0, 0.0, 0.0); } //Gerade
6868
(double X, double Y) = Math.SinCos(s / r);
69-
return (X * r, sig * ((1 - Y) * r), s / r, 1 / radius);
69+
return (X * r, sig * ((1 - Y) * r), s / radius, 1 / radius);
7070
}
7171

7272
public override double sAt(double X, double Y, double t = double.NaN)
@@ -177,7 +177,7 @@ public override (double X, double Y, double t, double k) PointAt(double s)
177177

178178
//Tangent at point
179179
double theta = gamma * s * s * 0.5 + curvature1 * s;
180-
return (Cs.Real, dir * Math.Sign(gamma) * Cs.Imaginary, theta, curvature1 + gamma * s);
180+
return (Cs.Real, dir * Math.Sign(gamma) * Cs.Imaginary, dir * theta, dir* (curvature1 + gamma * s));
181181
}
182182

183183
// Implementing the Fresnel integrals using numerical integration

TRA.Tool/GCG2016v2023

3.81 MB
Binary file not shown.

TRA.Tool/TRA.Tool.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,13 @@
4747
</EmbeddedResource>
4848
</ItemGroup>
4949

50+
<ItemGroup>
51+
<None Update="bkg_license.txt">
52+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
53+
</None>
54+
<None Update="GCG2016v2023">
55+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
56+
</None>
57+
</ItemGroup>
58+
5059
</Project>

TRA.Tool/TrassenPanel.Designer.cs

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TRA.Tool/TrassenPanel.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<data name="btn_delete.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
6565
<value>
6666
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
67-
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA6+AAAOvgHqQrHAAAAAV0lE
67+
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAV0lE
6868
QVQ4T2PABhQUFI4qKir+h2Eg/zBUijgA0gRlggE6HwMg20YshmpFAJCgnJycJCGMVTMIUNUAGBudhrGh
6969
WlDBqAHDzgB8mKYGPABJEoEfQLUAAQMDAOE0kkF4hF42AAAAAElFTkSuQmCC
7070
</value>

TRA.Tool/bkg_license.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
© GeoBasis-DE / BKG 2025 CC BY 4.0
2+
BKG: https://www.bkg.bund.de
3+
CC BY 4.0: https://creativecommons.org/licenses/by/4.0/

0 commit comments

Comments
 (0)