Skip to content

Commit e314555

Browse files
committed
Added KSprung Geometry and Drag and Drop for Files
1 parent 68d8dff commit e314555

9 files changed

+110
-108
lines changed

TRA.Lib/TrassenElementExt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public TrassenElementExt(double r1, double r2, double y, double x, double t, dou
169169
case Trassenkennzeichen.Knick:
170170
break;
171171
case Trassenkennzeichen.KSprung:
172-
TrassenGeometrie = new Gerade();
172+
TrassenGeometrie = new KSprung(l);
173173
break;
174174
case Trassenkennzeichen.S_Form_1f:
175175
break;

TRA.Lib/Trasseninterpolation.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,25 @@ public override double sAt(double X, double Y, double t = double.NaN)
278278
}
279279
}
280280

281+
public class KSprung : TrassenGeometrie
282+
{
283+
double length;
284+
public KSprung(double l)
285+
{
286+
length = l;
287+
}
288+
289+
public override (double X, double Y, double t, double k) PointAt(double s)
290+
{
291+
return (0, 0, 0, 0);
292+
}
293+
294+
public override double sAt(double X, double Y, double t = double.NaN)
295+
{
296+
return length;
297+
}
298+
}
299+
281300

282301
public class Transform2D
283302
{

TRA.Tool/InterpolationPanel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using LowDistortionProjection;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.ComponentModel;
54
using System.Data;

TRA.Tool/MainForm.cs

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
using LowDistortionProjection;
31
using Microsoft.Extensions.Logging;
42
using System;
53
using System.Windows.Forms;
@@ -85,14 +83,25 @@ private void TreeView_ItemDrag(object sender, ItemDragEventArgs e)
8583

8684
private void FlowLayoutPanel_DragEnter(object sender, DragEventArgs e)
8785
{
88-
if (e.Data.GetDataPresent(typeof(UserControl)))
86+
if (e.Data.GetDataPresent(typeof(UserControl)))
8987
{
9088
e.Effect = DragDropEffects.Move;
9189
}
90+
else if (e.Data.GetDataPresent(typeof(TreeNode)))
91+
{
92+
e.Effect = DragDropEffects.Copy;
93+
}
9294
}
9395
private void FlowLayoutPanel_DragOver(object sender, DragEventArgs e)
9496
{
95-
e.Effect = DragDropEffects.Move;
97+
if (e.Data.GetDataPresent(typeof(TreeNode)))
98+
{
99+
e.Effect = DragDropEffects.Copy;
100+
}
101+
else
102+
{
103+
e.Effect = DragDropEffects.Move;
104+
}
96105
Point point = flowLayoutPanel.PointToClient(new Point(e.X, e.Y));
97106
Control item = flowLayoutPanel.GetChildAtPoint(point);
98107
// Display the drop indicator panel at the appropriate position
@@ -113,6 +122,8 @@ private void FlowLayoutPanel_DragOver(object sender, DragEventArgs e)
113122
}
114123
private void FlowLayoutPanel_DragDrop(object sender, DragEventArgs e)
115124
{
125+
126+
//DragDrop for Panel Order
116127
UserControl control = null;
117128
if (e.Data.GetDataPresent(typeof(TrassenPanel)))
118129
{
@@ -141,6 +152,38 @@ private void FlowLayoutPanel_DragDrop(object sender, DragEventArgs e)
141152
panel.Controls.SetChildIndex(control, panel.Controls.Count - 2);
142153
}
143154
}
155+
//DragDrop for Import
156+
if (e.Data.GetDataPresent(typeof(TreeNode)))
157+
{
158+
TreeNode node = (TreeNode)e.Data.GetData(typeof(TreeNode));
159+
FileInfo fileInfo = new FileInfo(node.Tag.ToString());
160+
Color selectedColor = TrassenPanel.DefaultBackColor;
161+
if (fileInfo.Extension.Equals(".tra", StringComparison.OrdinalIgnoreCase))
162+
{
163+
TrassenPanel trassenPanel = new TrassenPanel();
164+
trassenPanel.set_TRA_L_Path(node);
165+
node.BackColor = trassenPanel.BackColor;
166+
panel.Controls.Add(trassenPanel);
167+
panel.Controls.SetChildIndex(trassenPanel, panel.Controls.Count - 2);
168+
}
169+
else if(fileInfo.Attributes == System.IO.FileAttributes.Directory)
170+
{
171+
LoadDirectoriesAndFiles(node);
172+
foreach (TreeNode childNode in node.Nodes)
173+
{
174+
fileInfo = new FileInfo(childNode.Tag.ToString());
175+
if (fileInfo.Extension.Equals(".tra", StringComparison.OrdinalIgnoreCase) && childNode.BackColor != selectedColor)
176+
{
177+
TrassenPanel trassenPanel = new TrassenPanel();
178+
trassenPanel.set_TRA_L_Path(childNode);
179+
childNode.BackColor = trassenPanel.BackColor;
180+
selectedColor = trassenPanel.BackColor;
181+
panel.Controls.Add(trassenPanel);
182+
panel.Controls.SetChildIndex(trassenPanel, panel.Controls.Count - 2);
183+
}
184+
}
185+
}
186+
}
144187
dropIndicatorPanel.Visible = false;
145188
}
146189

@@ -198,7 +241,6 @@ private void MainForm_Shown(object sender, EventArgs e)
198241
logger = loggerFactory.CreateLogger<MainForm>();
199242
TrassierungLog.AssignLogger(loggerFactory);
200243
egbt22lib.LoggingInitializer.InitializeLogging(loggerFactory);
201-
SrsLogger.Instance.ConfigureLogger(logger);
202244
}
203245
}
204246

TRA.Tool/TRA.Tool.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
<Reference Include="egbt22lib">
3131
<HintPath>..\..\egbt22trans\egbt22trans\bin\Debug\net6.0\egbt22lib.dll</HintPath>
3232
</Reference>
33-
<Reference Include="LowDistortionProjection">
34-
<HintPath>..\..\LowDistortionProjection\LowDistortionProjection\bin\Debug\netstandard2.1\LowDistortionProjection.dll</HintPath>
35-
</Reference>
3633
</ItemGroup>
3734

3835
</Project>

TRA.Tool/TransformPanel.Designer.cs

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

TRA.Tool/TransformPanel.cs

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using LowDistortionProjection;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.ComponentModel;
54
using System.Data;
@@ -19,13 +18,9 @@ namespace TRA.Tool
1918
{
2019
public partial class TransformPanel : UserControl
2120
{
22-
SpatialReference SRS_Source = Srs.Get(5685); //DB_Ref
2321
public TransformPanel()
2422
{
2523
InitializeComponent();
26-
27-
//set default out SRS:
28-
tb_SRS.Text = @"PROJCS[""unnamed"",GEOGCS[""ETRS89"",DATUM[""European_Terrestrial_Reference_System_1989"",SPHEROID[""GRS 1980"",6378137,298.257222101,AUTHORITY[""EPSG"",""7019""]],AUTHORITY[""EPSG"",""6258""]],PRIMEM[""Greenwich"",0,AUTHORITY[""EPSG"",""8901""]],UNIT[""degree"",0.0174532925199433,AUTHORITY[""EPSG"",""9122""]],AUTHORITY[""EPSG"",""4258""]],PROJECTION[""Transverse_Mercator""],PARAMETER[""latitude_of_origin"",50.8247],PARAMETER[""central_meridian"",13.9027],PARAMETER[""scale_factor"",1.0000346],PARAMETER[""false_easting"",10000],PARAMETER[""false_northing"",50000],UNIT[""metre"",1,AUTHORITY[""EPSG"",""9001""]],AXIS[""Easting"",EAST],AXIS[""Northing"",NORTH]]";
2924
}
3025

3126
private void TransformPanel_MouseDown(object sender, MouseEventArgs e)
@@ -40,39 +35,19 @@ private static double DegreesToRadians(double degrees)
4035

4136
private void btn_Transform_Click(object sender, EventArgs e)
4237
{
43-
SpatialReference SRS_Target;
4438
//Get Target SRS
45-
int epsg;
46-
if (int.TryParse(tb_SRS.Text, out epsg))
47-
{
48-
SRS_Target = Srs.Get(epsg);
49-
}
50-
else
51-
{
52-
SRS_Target = Srs.Get(tb_SRS.Text);
53-
}
54-
//For testing:
55-
//int baseSrsEPSG = 4258;
56-
//double lat = 50.8247;
57-
//double lon = 13.9027;
58-
//double k = 1.0000346;
59-
//double falseEasting = 10000.0;
60-
//double falseNorthing = 50000.0;
61-
//SRS_Target = Srs.GetLocalTMSystemWithScale(in baseSrsEPSG, in lat, in lon, in k, in falseEasting, in falseNorthing);
62-
//string argout = """";
63-
//SRS_Target.ExportToWkt(out argout,new string[] { });
64-
//Get TRA-Files to transform
39+
6540
FlowLayoutPanel owner = Parent as FlowLayoutPanel;
6641
if (owner == null) { return; }
6742
int idx = owner.Controls.GetChildIndex(this) - 1;
68-
43+
6944
while (idx >= 0 && owner.Controls[idx].GetType() != typeof(TransformPanel))
7045
{
7146
if (owner.Controls[idx].GetType() == typeof(TrassenPanel))
7247
{
7348
TrassenPanel panel = (TrassenPanel)owner.Controls[idx];
7449
IEnumerable<TrassenElementExt> elements = Enumerable.Empty<TrassenElementExt>();
75-
if(panel.trasseL != null ) { elements = elements.Concat(panel.trasseL.Elemente); }
50+
if (panel.trasseL != null) { elements = elements.Concat(panel.trasseL.Elemente); }
7651
if (panel.trasseS != null) { elements = elements.Concat(panel.trasseS.Elemente); }
7752
if (panel.trasseR != null) { elements = elements.Concat(panel.trasseR.Elemente); }
7853
double previousdK = double.NaN;
@@ -84,46 +59,49 @@ private void btn_Transform_Click(object sender, EventArgs e)
8459
// TODO how to handle trasse without heights (like S) in transformations
8560
if (interp.H == null) { interp.H = new double[interp.X.Length]; }
8661
if (interp.X.Length > 0 && interp.H != null)
87-
{
62+
{
8863
try
8964
{
9065
double[][] points = { interp.Y, interp.X, interp.H };
9166
//Srs.ConvertInPlace(ref points, SRS_Source, SRS_Target);
9267
double[] gamma_i, k_i, gamma_o, k_o = new double[interp.X.Length];
93-
egbt22lib.Convert.DBRef_GK5_Gamma_k(points[0], points[1],out gamma_i,out k_i);
94-
egbt22lib.Convert.DBRef_GK5_to_EGBT22_Local(points[0], points[1], points[2],out points[0], out points[1]);
68+
egbt22lib.Convert.DBRef_GK5_Gamma_k(points[0], points[1], out gamma_i, out k_i);
69+
egbt22lib.Convert.DBRef_GK5_to_EGBT22_Local(points[0], points[1], points[2], out points[0], out points[1]);
9570
egbt22lib.Convert.EGBT22_Local_Gamma_k(points[0], points[1], out gamma_o, out k_o);
9671
//Workaround to set values in place
9772
for (int i = 0; i < interp.X.Length; i++)
9873
{
9974
interp.X[i] = points[1][i];
10075
interp.Y[i] = points[0][i];
10176
interp.H[i] = points[2][i];
102-
interp.T[i] = interp.T[i]-DegreesToRadians(gamma_o[i] - gamma_i[i]);
77+
interp.T[i] = interp.T[i] - DegreesToRadians(gamma_o[i] - gamma_i[i]);
10378
}
10479
}
105-
catch {
80+
catch
81+
{
10682
}
10783
}
10884
//Transform Element
10985
try
11086
{
11187
//Srs.ConvertInPlace(ref coordinate, SRS_Source, SRS_Target);
112-
double gamma_i, k_i,gamma_o,k_o;
88+
double gamma_i, k_i, gamma_o, k_o;
11389
double rechts, hoch;
114-
(gamma_i,k_i) = egbt22lib.Convert.DBRef_GK5_Gamma_k(element.Ystart, element.Xstart);
90+
(gamma_i, k_i) = egbt22lib.Convert.DBRef_GK5_Gamma_k(element.Ystart, element.Xstart);
11591
(rechts, hoch) = egbt22lib.Convert.DBRef_GK5_to_EGBT22_Local(element.Ystart, element.Xstart, Double.IsNaN(elementHeight) ? 0.0 : elementHeight);
116-
(gamma_o,k_o) = egbt22lib.Convert.EGBT22_Local_Gamma_k(rechts, hoch);
92+
(gamma_o, k_o) = egbt22lib.Convert.EGBT22_Local_Gamma_k(rechts, hoch);
11793
double dK = (k_i / k_o);
11894

119-
element.Relocate(hoch, rechts, DegreesToRadians(gamma_o - gamma_i), dK,previousdK);
95+
element.Relocate(hoch, rechts, DegreesToRadians(gamma_o - gamma_i), dK, previousdK);
12096
previousdK = element.ID == 0 ? double.NaN : dK; //reset prviousScale for next Element
12197
}
122-
catch {
98+
catch
99+
{
123100
}
124101
}
125102

126-
if (panel.trasseL != null) {
103+
if (panel.trasseL != null)
104+
{
127105
foreach (TrassenElementExt element in panel.trasseL.Elemente)
128106
{
129107
Interpolation interp = element.InterpolationResult;
@@ -134,7 +112,8 @@ private void btn_Transform_Click(object sender, EventArgs e)
134112
panel.trasseL.CalcGradientCoordinates();
135113
panel.trasseL.Plot();
136114
}
137-
if (panel.trasseS != null) {
115+
if (panel.trasseS != null)
116+
{
138117
foreach (TrassenElementExt element in panel.trasseS.Elemente)
139118
{
140119
Interpolation interp = element.InterpolationResult;
@@ -144,7 +123,8 @@ private void btn_Transform_Click(object sender, EventArgs e)
144123
}
145124
panel.trasseS.Plot();
146125
}
147-
if (panel.trasseR != null) {
126+
if (panel.trasseR != null)
127+
{
148128
foreach (TrassenElementExt element in panel.trasseR.Elemente)
149129
{
150130
Interpolation interp = element.InterpolationResult;

TRA.Tool/TrassenPanel.Designer.cs

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

0 commit comments

Comments
 (0)