@@ -33,6 +33,11 @@ private void TransformPanel_MouseDown(object sender, MouseEventArgs e)
33
33
DoDragDrop ( this , DragDropEffects . Move ) ;
34
34
}
35
35
36
+ private static double DegreesToRadians ( double degrees )
37
+ {
38
+ return degrees * ( Math . PI / 180.0 ) ;
39
+ }
40
+
36
41
private void btn_Transform_Click ( object sender , EventArgs e )
37
42
{
38
43
SpatialReference SRS_Target ;
@@ -70,17 +75,28 @@ private void btn_Transform_Click(object sender, EventArgs e)
70
75
if ( panel . trasseL != null ) { elements = elements . Concat ( panel . trasseL . Elemente ) ; }
71
76
if ( panel . trasseS != null ) { elements = elements . Concat ( panel . trasseS . Elemente ) ; }
72
77
if ( panel . trasseR != null ) { elements = elements . Concat ( panel . trasseR . Elemente ) ; }
73
- foreach ( TrassenElementExt element in elements . Reverse ( ) ) //run reverse for having X/Yend from the successor is already transformed for plasability checks
78
+ double previousdK = double . NaN ;
79
+ foreach ( TrassenElementExt element in elements . Reverse ( ) ) //run reverse for having X/Yend from the successor is already transformed for plausability checks
74
80
{
75
81
//Transform Interpolation Points
76
82
Interpolation interp = element . InterpolationResult ;
77
83
double elementHeight = interp . H != null ? interp . H [ 0 ] : double . NaN ; //save original height befor transforming
78
- if ( interp . X . Length > 0 )
84
+ // TODO how to handle trasse without heights (like S) in transformations
85
+ if ( interp . H == null ) { interp . H = new double [ interp . X . Length ] ; }
86
+ if ( interp . X . Length > 0 && interp . H != null )
79
87
{
80
88
try
81
89
{
82
90
double [ ] [ ] points = { interp . Y , interp . X , interp . H } ;
83
- Srs . ConvertInPlace ( ref points , SRS_Source , SRS_Target ) ;
91
+ //Srs.ConvertInPlace(ref points, SRS_Source, SRS_Target);
92
+ egbt22lib . Convert . DBRef_GK5_to_EGBT22_Local ( points [ 0 ] , points [ 1 ] , points [ 2 ] , out points [ 0 ] , out points [ 1 ] ) ;
93
+ //Workaround to set values in place
94
+ for ( int i = 0 ; i < interp . X . Length ; i ++ )
95
+ {
96
+ interp . X [ i ] = points [ 1 ] [ i ] ;
97
+ interp . Y [ i ] = points [ 0 ] [ i ] ;
98
+ interp . H [ i ] = points [ 2 ] [ i ] ;
99
+ }
84
100
}
85
101
catch {
86
102
}
@@ -90,9 +106,16 @@ private void btn_Transform_Click(object sender, EventArgs e)
90
106
{
91
107
double [ ] [ ] coordinate = ! Double . IsNaN ( elementHeight ) ?
92
108
new double [ ] [ ] { new double [ ] { element . Ystart } , new double [ ] { element . Xstart } , new double [ ] { elementHeight } }
93
- : new double [ ] [ ] { new double [ ] { element . Ystart } , new double [ ] { element . Xstart } } ;
94
- Srs . ConvertInPlace ( ref coordinate , SRS_Source , SRS_Target ) ;
95
- element . Relocate ( coordinate [ 1 ] [ 0 ] , coordinate [ 0 ] [ 0 ] ) ;
109
+ : new double [ ] [ ] { new double [ ] { element . Ystart } , new double [ ] { element . Xstart } , new double [ ] { 0.0 } } ;
110
+ //Srs.ConvertInPlace(ref coordinate, SRS_Source, SRS_Target);
111
+ double [ ] gamma_i , k_i , gamma_o , k_o ;
112
+ egbt22lib . Convert . DBRef_GK5_Gamma_k ( coordinate [ 0 ] , coordinate [ 1 ] , out gamma_i , out k_i ) ;
113
+ egbt22lib . Convert . DBRef_GK5_to_EGBT22_Local ( coordinate [ 0 ] , coordinate [ 1 ] , coordinate [ 2 ] , out coordinate [ 0 ] , out coordinate [ 1 ] ) ;
114
+ egbt22lib . Convert . EGBT22_Local_Gamma_k ( coordinate [ 0 ] , coordinate [ 1 ] , out gamma_o , out k_o ) ;
115
+ double dK = ( k_i [ 0 ] / k_o [ 0 ] ) ;
116
+
117
+ element . Relocate ( coordinate [ 1 ] [ 0 ] , coordinate [ 0 ] [ 0 ] , DegreesToRadians ( gamma_o [ 0 ] - gamma_i [ 0 ] ) , dK , previousdK ) ;
118
+ previousdK = element . ID == 0 ? double . NaN : dK ; //reset prviousScale for next Element
96
119
}
97
120
catch {
98
121
}
@@ -106,6 +129,7 @@ private void btn_Transform_Click(object sender, EventArgs e)
106
129
string ownerString = panel . trasseL . Filename + "_" + element . ID ;
107
130
TrassierungLog . Logger ? . LogInformation ( ownerString + " " + "Deviation to geometry after transform: " + deviation ) ;
108
131
}
132
+ panel . trasseL . CalcGradientCoordinates ( ) ;
109
133
panel . trasseL . Plot ( ) ;
110
134
}
111
135
if ( panel . trasseS != null ) {
@@ -126,6 +150,7 @@ private void btn_Transform_Click(object sender, EventArgs e)
126
150
string ownerString = panel . trasseR . Filename + "_" + element . ID ;
127
151
TrassierungLog . Logger ? . LogInformation ( ownerString + " " + "Deviation to geometry after transform: " + deviation ) ;
128
152
}
153
+ panel . trasseR . CalcGradientCoordinates ( ) ;
129
154
panel . trasseR . Plot ( ) ;
130
155
}
131
156
}
0 commit comments