1
- using LowDistortionProjection ;
2
- using System ;
1
+ using System ;
3
2
using System . Collections . Generic ;
4
3
using System . ComponentModel ;
5
4
using System . Data ;
@@ -19,13 +18,9 @@ namespace TRA.Tool
19
18
{
20
19
public partial class TransformPanel : UserControl
21
20
{
22
- SpatialReference SRS_Source = Srs . Get ( 5685 ) ; //DB_Ref
23
21
public TransformPanel ( )
24
22
{
25
23
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]]" ;
29
24
}
30
25
31
26
private void TransformPanel_MouseDown ( object sender , MouseEventArgs e )
@@ -40,39 +35,19 @@ private static double DegreesToRadians(double degrees)
40
35
41
36
private void btn_Transform_Click ( object sender , EventArgs e )
42
37
{
43
- SpatialReference SRS_Target ;
44
38
//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
+
65
40
FlowLayoutPanel owner = Parent as FlowLayoutPanel ;
66
41
if ( owner == null ) { return ; }
67
42
int idx = owner . Controls . GetChildIndex ( this ) - 1 ;
68
-
43
+
69
44
while ( idx >= 0 && owner . Controls [ idx ] . GetType ( ) != typeof ( TransformPanel ) )
70
45
{
71
46
if ( owner . Controls [ idx ] . GetType ( ) == typeof ( TrassenPanel ) )
72
47
{
73
48
TrassenPanel panel = ( TrassenPanel ) owner . Controls [ idx ] ;
74
49
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 ) ; }
76
51
if ( panel . trasseS != null ) { elements = elements . Concat ( panel . trasseS . Elemente ) ; }
77
52
if ( panel . trasseR != null ) { elements = elements . Concat ( panel . trasseR . Elemente ) ; }
78
53
double previousdK = double . NaN ;
@@ -84,46 +59,49 @@ private void btn_Transform_Click(object sender, EventArgs e)
84
59
// TODO how to handle trasse without heights (like S) in transformations
85
60
if ( interp . H == null ) { interp . H = new double [ interp . X . Length ] ; }
86
61
if ( interp . X . Length > 0 && interp . H != null )
87
- {
62
+ {
88
63
try
89
64
{
90
65
double [ ] [ ] points = { interp . Y , interp . X , interp . H } ;
91
66
//Srs.ConvertInPlace(ref points, SRS_Source, SRS_Target);
92
67
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 ] ) ;
95
70
egbt22lib . Convert . EGBT22_Local_Gamma_k ( points [ 0 ] , points [ 1 ] , out gamma_o , out k_o ) ;
96
71
//Workaround to set values in place
97
72
for ( int i = 0 ; i < interp . X . Length ; i ++ )
98
73
{
99
74
interp . X [ i ] = points [ 1 ] [ i ] ;
100
75
interp . Y [ i ] = points [ 0 ] [ i ] ;
101
76
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 ] ) ;
103
78
}
104
79
}
105
- catch {
80
+ catch
81
+ {
106
82
}
107
83
}
108
84
//Transform Element
109
85
try
110
86
{
111
87
//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 ;
113
89
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 ) ;
115
91
( 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 ) ;
117
93
double dK = ( k_i / k_o ) ;
118
94
119
- element . Relocate ( hoch , rechts , DegreesToRadians ( gamma_o - gamma_i ) , dK , previousdK ) ;
95
+ element . Relocate ( hoch , rechts , DegreesToRadians ( gamma_o - gamma_i ) , dK , previousdK ) ;
120
96
previousdK = element . ID == 0 ? double . NaN : dK ; //reset prviousScale for next Element
121
97
}
122
- catch {
98
+ catch
99
+ {
123
100
}
124
101
}
125
102
126
- if ( panel . trasseL != null ) {
103
+ if ( panel . trasseL != null )
104
+ {
127
105
foreach ( TrassenElementExt element in panel . trasseL . Elemente )
128
106
{
129
107
Interpolation interp = element . InterpolationResult ;
@@ -134,7 +112,8 @@ private void btn_Transform_Click(object sender, EventArgs e)
134
112
panel . trasseL . CalcGradientCoordinates ( ) ;
135
113
panel . trasseL . Plot ( ) ;
136
114
}
137
- if ( panel . trasseS != null ) {
115
+ if ( panel . trasseS != null )
116
+ {
138
117
foreach ( TrassenElementExt element in panel . trasseS . Elemente )
139
118
{
140
119
Interpolation interp = element . InterpolationResult ;
@@ -144,7 +123,8 @@ private void btn_Transform_Click(object sender, EventArgs e)
144
123
}
145
124
panel . trasseS . Plot ( ) ;
146
125
}
147
- if ( panel . trasseR != null ) {
126
+ if ( panel . trasseR != null )
127
+ {
148
128
foreach ( TrassenElementExt element in panel . trasseR . Elemente )
149
129
{
150
130
Interpolation interp = element . InterpolationResult ;
0 commit comments