1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
|
Private Function SetConversion(ByVal eDe As eSCG, ByVal eVers As eSCG) As Variant
Dim avC(0 To 63) As Variant
Dim i As Integer
avC(0) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.NTF_Paris_Geo, True, Null, False)
avC(1) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(2) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(3) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(4) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(5) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(6) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.NTF_Paris_Geo, True, Null, False)
avC(7) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(8) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(9) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(10) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(11) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(12) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.NTF_Paris_Geo, True, Null, False)
avC(13) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(14) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(15) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(16) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(17) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(18) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.NTF_Paris_Geo, True, Null, False)
avC(19) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(20) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(21) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(22) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(23) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(24) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.NTF_Paris_Geo, True, Null, False)
avC(25) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(26) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(27) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(28) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(29) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.NTF_Lambert_II_Etendu, False, Null, True)
avC(30) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.RGF93_Geo, False, eTypeTrans.NTFtoRGF93, False)
avC(31) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.RGF93_Lambert_93, False, eTypeTrans.NTFtoRGF93, True)
avC(32) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.ED50_Geo, False, eTypeTrans.NTFtoED50, False)
avC(33) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.WGS84_Geo, False, eTypeTrans.NTFtoWGS84, False)
avC(34) = VBA.Array(eSCG.RGF93_Geo, eSCG.NTF_Lambert_II_Etendu, False, eTypeTrans.RGF93toNTF, True)
avC(35) = VBA.Array(eSCG.RGF93_Geo, eSCG.NTF_Paris_Geo, False, eTypeTrans.RGF93toNTF, False)
avC(36) = VBA.Array(eSCG.RGF93_Geo, eSCG.RGF93_Lambert_93, False, Null, True)
avC(37) = VBA.Array(eSCG.RGF93_Geo, eSCG.ED50_Geo, False, eTypeTrans.RGF93toED50, False)
avC(38) = VBA.Array(eSCG.RGF93_Geo, eSCG.WGS84_Geo, False, eTypeTrans.RGF93toWGS84, False)
avC(39) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.NTF_Paris_Geo, True, eTypeTrans.RGF93toNTF, False)
avC(40) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.NTF_Lambert_II_Etendu, True, eTypeTrans.RGF93toNTF, True)
avC(41) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.RGF93_Geo, True, Null, False)
avC(42) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.ED50_Geo, True, eTypeTrans.RGF93toED50, False)
avC(43) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.WGS84_Geo, True, eTypeTrans.RGF93toWGS84, False)
avC(44) = VBA.Array(eSCG.ED50_Geo, eSCG.NTF_Paris_Geo, False, eTypeTrans.ED50toNTF, False)
avC(45) = VBA.Array(eSCG.ED50_Geo, eSCG.NTF_Lambert_II_Etendu, False, eTypeTrans.ED50toNTF, True)
avC(46) = VBA.Array(eSCG.ED50_Geo, eSCG.RGF93_Geo, False, eTypeTrans.ED50toRGF93, False)
avC(47) = VBA.Array(eSCG.ED50_Geo, eSCG.RGF93_Lambert_93, False, eTypeTrans.ED50toRGF93, True)
avC(48) = VBA.Array(eSCG.ED50_Geo, eSCG.WGS84_Geo, False, eTypeTrans.ED50toWGS84, False)
avC(49) = VBA.Array(eSCG.WGS84_Geo, eSCG.NTF_Paris_Geo, False, eTypeTrans.WGS84toNTF, False)
avC(50) = VBA.Array(eSCG.WGS84_Geo, eSCG.NTF_Lambert_II_Etendu, False, eTypeTrans.WGS84toNTF, True)
avC(51) = VBA.Array(eSCG.WGS84_Geo, eSCG.RGF93_Geo, False, eTypeTrans.WGS84toRGF93, False)
avC(52) = VBA.Array(eSCG.WGS84_Geo, eSCG.RGF93_Lambert_93, False, eTypeTrans.WGS84toRGF93, True)
avC(53) = VBA.Array(eSCG.WGS84_Geo, eSCG.ED50_Geo, False, eTypeTrans.WGS84toED50, False)
avC(54) = VBA.Array(eSCG.BD72_Lambert72, eSCG.ETRS89_Lambert08, True, eTypeTrans.BD72toETRS89, True)
avC(55) = VBA.Array(eSCG.BD72_Lambert72, eSCG.BD72_Geo, True, Null, False)
avC(56) = VBA.Array(eSCG.BD72_Lambert72, eSCG.ETRS89_Geo, True, eTypeTrans.BD72toETRS89, False)
avC(57) = VBA.Array(eSCG.BD72_Geo, eSCG.ETRS89_Geo, False, eTypeTrans.BD72toETRS89, False)
avC(58) = VBA.Array(eSCG.ETRS89_Lambert08, eSCG.BD72_Lambert72, True, eTypeTrans.ETRS89toBD72, True)
avC(59) = VBA.Array(eSCG.ETRS89_Lambert08, eSCG.BD72_Geo, True, eTypeTrans.ETRS89toBD72, False)
avC(60) = VBA.Array(eSCG.ETRS89_Lambert08, eSCG.ETRS89_Geo, True, Null, False)
avC(61) = VBA.Array(eSCG.ETRS89_Geo, eSCG.BD72_Lambert72, False, eTypeTrans.ETRS89toBD72, True)
avC(62) = VBA.Array(eSCG.ETRS89_Geo, eSCG.BD72_Geo, False, eTypeTrans.ETRS89toBD72, False)
avC(63) = VBA.Array(eSCG.ETRS89_Geo, eSCG.ETRS89_Lambert08, False, Null, True)
For i = 0 To UBound(avC)
If avC(i)(eSchema.eInitial) = eDe And avC(i)(eSchema.eFinal) = eVers Then
SetConversion = avC(i)
Exit For
End If
Next i
End Function
Private Function CalculDemiPetitAxe(ByVal da As Double, ByVal df As Double) As Double
CalculDemiPetitAxe = da * (1 - df)
End Function
Private Function CalculPremiereExcentricite(ByVal da As Double, ByVal db As Double) As Double
Dim daCarre As Double
daCarre = da ^ 2
CalculPremiereExcentricite = Sqr((daCarre - db ^ 2) / daCarre)
End Function
Public Function GradeToRadian(ByVal dAngle As Double)
GradeToRadian = gdpi * dAngle / 200
End Function
Public Function RadianToGrade(ByVal dAngle As Double)
RadianToGrade = 200 * dAngle / gdpi
End Function
Public Function DegreDecToRadian(ByVal dAngle As Double)
DegreDecToRadian = gdpi * dAngle / 180
End Function
Public Function RadianToDegreDec(ByVal dAngle As Double)
RadianToDegreDec = 180 * dAngle / gdpi
End Function
Public Function DMSToDegreDec(ByVal iDegre As Integer, Optional ByVal byMin As Byte = 0, _
Optional ByVal fSec As Single = 0, _
Optional bNegatif As Boolean = False) As Double
If byMin < 60 And fSec < 60 Then
DMSToDegreDec = Abs(iDegre) + byMin / 60 + Abs(fSec) / 3600
If bNegatif Then DMSToDegreDec = -DMSToDegreDec
End If
End Function
Public Function AngleDMSToDegreDec(ByVal dAngle As Double) As Double
Dim fSec As Single
Dim iDegre As Integer, iMin As Integer, iSigne As Integer
iSigne = Sgn(dAngle)
dAngle = Abs(dAngle)
iDegre = Int(dAngle)
iMin = Int((dAngle - iDegre) * 100)
fSec = (dAngle - iDegre - iMin / 100) * 10000
AngleDMSToDegreDec = (iDegre + iMin / 60 + fSec / 3600) * iSigne
End Function
Public Function DMSToRadian(ByVal iDegre As Integer, Optional ByVal byMin As Byte = 0, _
Optional ByVal fSec As Single = 0, _
Optional bNegatif As Boolean = False) As Double
DMSToRadian = DegreDecToRadian(DMSToDegreDec(iDegre, byMin, fSec, bNegatif))
End Function
Public Function AngleDMSToRadian(ByVal dAngle As Double) As Double
AngleDMSToRadian = DegreDecToRadian(AngleDMSToDegreDec(dAngle))
End Function
Public Function DegreDecToAngleDMS(ByVal dAngle As Double) As Double
Dim iDegre As Integer, iMin As Integer, iSigne As Integer
Dim fSec As Single
iSigne = Sgn(dAngle)
dAngle = Abs(dAngle)
iDegre = Int(dAngle)
iMin = Int((dAngle - iDegre) * 60)
fSec = (dAngle - iDegre - iMin / 60) * 3600
DegreDecToAngleDMS = Arrondi((iDegre + (iMin + fSec / 100) / 100) * iSigne, 7)
End Function
Public Function AngleDMSToString(ByVal dAngle As Double, ByVal bLatitude As Boolean) As String
Dim iDegre As Integer, iMin As Integer, iSigne As Integer
Dim fSec As Single
Dim s As String
iSigne = Sgn(dAngle)
dAngle = Abs(dAngle)
iDegre = Int(dAngle)
iMin = Int((dAngle - iDegre) * 100)
fSec = (dAngle - iDegre - iMin / 100) * 10000
s = iDegre & "°" & format(iMin, "00'") & format(fSec, "00.0##''")
If iSigne < 0 Then
s = s & IIf(bLatitude, "S", "W")
Else
s = s & IIf(bLatitude, "N", "E")
End If
AngleDMSToString = s
End Function
Public Function RadianToStringDMS(ByVal dAngle As Double, ByVal bLatitude As Boolean) As String
RadianToStringDMS = AngleDMSToString(DegreDecToAngleDMS(RadianToDegreDec(dAngle)), bLatitude)
End Function
Public Function Arrondi(ByVal dVal As Double, Optional ByVal iDec As Integer = 0) As Double
Arrondi = Int((dVal * (10 ^ iDec)) + 0.5) / (10 ^ iDec)
End Function
Public Function DistanceKm(ByVal dRadLon1 As Double, ByVal dRadLat1 As Double, _
ByVal dRadLon2 As Double, ByVal dRadLat2 As Double) As Double
DistanceKm = 6371 * ArcCosRad(Cos(dRadLat1) * Cos(dRadLat2) * Cos(dRadLon2 - dRadLon1) + _
(Sin(dRadLat1) * Sin(dRadLat2)))
End Function
Private Function ArcCosRad(dRadian As Double) As Double
If dRadian > -1 And dRadian < 1 Then
ArcCosRad = Atn(-dRadian / Sqr(-dRadian * dRadian + 1)) + gdpi / 2
ElseIf dRadian = -1 Then
ArcCosRad = gdpi
End If
End Function
#If CCTEST Then
Public Function TestAngles()
Dim sTabs As String
sTabs = vbTab & vbTab
Debug.Print "--- Vérification des conversions d'angles ---"
Debug.Print vbTab & "+ Grade -> Radian"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & GradeToRadian(0)
Debug.Print sTabs & "Entrée : " & 200 & " - Attendu : " & gdpi & " - Obtenu : " & GradeToRadian(200)
Debug.Print sTabs & "Entrée : " & -200 & " - Attendu : " & -gdpi & " - Obtenu : " & GradeToRadian(-200)
Debug.Print sTabs & "Entrée : " & 600 & " - Attendu : " & (3 * gdpi) & " - Obtenu : " & GradeToRadian(600)
Debug.Print vbTab & "+ Radian -> Grade"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & RadianToGrade(0)
Debug.Print sTabs & "Entrée : " & "pi" & " - Attendu : " & 200 & " - Obtenu : " & RadianToGrade(gdpi)
Debug.Print sTabs & "Entrée : " & "-pi" & " - Attendu : " & -200 & " - Obtenu : " & RadianToGrade(-gdpi)
Debug.Print sTabs & "Entrée : " & (3 * gdpi) & " - Attendu : " & 600 & " - Obtenu : " & RadianToGrade(3 * gdpi)
Debug.Print vbTab & "+ Degré décimal -> Radian"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & DegreDecToRadian(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & "pi" & " - Obtenu : " & DegreDecToRadian(180)
Debug.Print sTabs & "Entrée : " & -180 & " - Attendu : " & "-pi" & " - Obtenu : " & DegreDecToRadian(-180)
Debug.Print sTabs & "Entrée : " & 540 & " - Attendu : " & (3 * gdpi) & " - Obtenu : " & DegreDecToRadian(540)
Debug.Print vbTab & "+ Radian -> Degré décimal"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & RadianToDegreDec(0)
Debug.Print sTabs & "Entrée : " & "pi" & " - Attendu : " & 180 & " - Obtenu : " & RadianToDegreDec(gdpi)
Debug.Print sTabs & "Entrée : " & "-pi" & " - Attendu : " & -180 & " - Obtenu : " & RadianToDegreDec(-gdpi)
Debug.Print sTabs & "Entrée : " & (3 * gdpi) & " - Attendu : " & 540 & " - Obtenu : " & RadianToDegreDec(3 * gdpi)
Debug.Print vbTab & "+ DMS(Deg,Min,Sec) -> Degré décimal"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & DMSToDegreDec(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & 180 & " - Obtenu : " & DMSToDegreDec(180)
Debug.Print sTabs & "Entrée : " & "45°35'25.566''" & " - Attendu : " & 45.590435 & " - Obtenu : " & Arrondi(DMSToDegreDec(45, 35, 25.567), 6)
Debug.Print sTabs & "Entrée : " & "-45°35'25.566''" & " - Attendu : " & -45.590435 & " - Obtenu : " & Arrondi(DMSToDegreDec(-45, 35, 25.566, True), 6)
Debug.Print sTabs & "Entrée : " & "-45°75'25.566''" & " - Attendu : " & 0 & " car erreur ! - Obtenu : " & Arrondi(DMSToDegreDec(-45, 75, 25.566, True), 6)
Debug.Print sTabs & "Entrée : " & "-45°35'85.566''" & " - Attendu : " & 0 & " car erreur ! - Obtenu : " & Arrondi(DMSToDegreDec(-45, 35, 85.566, True), 6)
Debug.Print vbTab & "+ Angle DMS (Degre.mmssxxx) -> Degré décimal"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & AngleDMSToDegreDec(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & 180 & " - Obtenu : " & AngleDMSToDegreDec(180)
Debug.Print sTabs & "Entrée : " & 45.3525566 & " - Attendu : " & 45.590435 & " - Obtenu : " & Arrondi(AngleDMSToDegreDec(45.3525566), 6)
Debug.Print sTabs & "Entrée : " & -45.3525566 & " - Attendu : " & -45.590435 & " - Obtenu : " & Arrondi(AngleDMSToDegreDec(-45.3525566), 6)
Debug.Print vbTab & "+ Degré décimal -> Angle DMS (Degre.mmssxxx)"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & DegreDecToAngleDMS(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & 180 & " - Obtenu : " & DegreDecToAngleDMS(180)
Debug.Print sTabs & "Entrée : " & 45.590435 & " - Attendu : " & 45.3525566 & " - Obtenu : " & Arrondi(DegreDecToAngleDMS(45.590435), 7)
Debug.Print sTabs & "Entrée : " & -45.590435 & " - Attendu : " & -45.3525566 & " - Obtenu : " & Arrondi(DegreDecToAngleDMS(-45.590435), 7)
Debug.Print vbTab & "+ Angle DMS (Degre.mmssxxx) -> String"
Debug.Print sTabs & "Entrée : " & 0 & " Lat - Attendu : " & "0°00'00,0''N" & " - Obtenu : " & AngleDMSToString(0, True)
Debug.Print sTabs & "Entrée : " & 45 & " Lon - Attendu : " & "45°00'00,0''E" & " - Obtenu : " & AngleDMSToString(45, False)
Debug.Print sTabs & "Entrée : " & 45.590435 & " Lat - Attendu : " & "45°59'04,35''N" & " - Obtenu : " & AngleDMSToString(45.590435, True)
Debug.Print sTabs & "Entrée : " & -45.3525566 & " Lat - Attendu : " & "45°35'25,566''S" & " - Obtenu : " & AngleDMSToString(-45.3525566, True)
Debug.Print "---"
End Function
Public Sub TestConversions()
Debug.Print "--- Vérification de certaines conversions ---"
Debug.Print vbTab & "+ NTF méridien de Paris -> ED50 Greenwich"
Test NTF_Paris_Geo, ED50_Geo, 6, 54, "7°44'16,4''", "48°36'03,3''", gr, dms
Debug.Print vbTab & "+ NTF méridien de Paris -> WGS84"
Test NTF_Paris_Geo, WGS84_Geo, 6, 54, "7°44'12,2''", "48°35'59,9''", gr, dms
Debug.Print vbTab & "+ NTF méridien de Paris -> NTF Lambert II étendu"
Test NTF_Paris_Geo, NTF_Lambert_II_Etendu, 6, 54, "998137m", "2413822m", gr, m, 0
Debug.Print vbTab & "+ NTF méridien de Paris -> RGF Lambert 93"
Test NTF_Paris_Geo, RGF93_Lambert_93, 6, 54, "1049052m", "6843777m", gr, m, 0
Debug.Print vbTab & "+ NTF Lambert I -> ED50 Greenwich"
Test NTF_Lambert_I, ED50_Geo, 997960, 114185, "7°44'16,4''", "48°36'03,3''", m, dms
Debug.Print vbTab & "+ NTF Lambert I -> WGS84"
Test NTF_Lambert_I, WGS84_Geo, 997960, 114185, "7°44'12,2''", "48°35'59,9''", m, dms
Debug.Print vbTab & "+ NTF Lambert I -> NTF Lambert II étendu"
Test NTF_Lambert_I, NTF_Lambert_II_Etendu, 997960, 114185, "998137m", "2413822m", m, m, 0
Debug.Print vbTab & "+ NTF Lambert I -> RGF Lambert 93"
Test NTF_Lambert_I, RGF93_Lambert_93, 997960, 114185, "1049052m", "6843777m", m, m, 0
Debug.Print vbTab & "+ NTF Lambert II étendu -> ED50 Greenwich"
Test NTF_Lambert_II_Etendu, ED50_Geo, 998137, 2413822, "7°44'16,4''", "48°36'03,3''", m, dms
Debug.Print vbTab & "+ NTF Lambert II étendu -> WGS84"
Test NTF_Lambert_II_Etendu, WGS84_Geo, 998137, 2413822, "7°44'12,2''", "48°35'59,9''", m, dms
Debug.Print vbTab & "+ NTF Lambert II étendu -> NTF méridien de Paris"
Test NTF_Lambert_II_Etendu, NTF_Paris_Geo, 998137, 2413822, "6gr", "54gr", m, gr, 0
Debug.Print vbTab & "+ NTF Lambert II étendu -> RGF Lambert 93"
Test NTF_Lambert_II_Etendu, RGF93_Lambert_93, 998137, 2413822, "1049052m", "6843777m", m, m, 1
Debug.Print vbTab & "+ RGF Lambert 93 -> NTF Lambert II étendu"
Test RGF93_Lambert_93, NTF_Lambert_II_Etendu, 1049052, 6843777, " 998137m", "2413822m", m, m, 1
Debug.Print vbTab & "+ BD72 Lambert 72 -> BD72"
Test BD72_Lambert72, BD72_Geo, 235000, 45000, "5°32'45.48188''", "49°42'40.06796''", m, dms
Debug.Print vbTab & "+ BD72 Lambert 72 -> ETRS89"
Test BD72_Lambert72, ETRS89_Geo, 235000, 45000, "5°32'50.09529''", "49°42'37.96785''", m, dms
Debug.Print vbTab & "+ ETRS Lambert 08 -> ETRS89"
Test ETRS89_Lambert08, ETRS89_Geo, 735000, 545000, "5°32'49.39407", "49°42'37.60005", m, dms
Debug.Print vbTab & "+ ETRS Lambert 08 -> BD72 Lambert 72"
Test ETRS89_Lambert08, BD72_Lambert72, 735000, 545000, "234986.1", "44988.4", m, m, 1
Debug.Print vbTab & "+ BD72 Lambert 72 -> ETRS Lambert 08"
Test BD72_Lambert72, ETRS89_Lambert08, 50000, 200000, "549996.807", "699988.150", m, m, 1
Debug.Print "---"
End Sub
Public Sub TestAlgos()
Dim tProj As tProjection
Dim tTrans As tTransformation
Dim tXYZ As t_XYZ
Dim dVal As Double
Dim av(0 To 2) As Variant
Dim i As Integer
Dim sTabs As String
sTabs = vbTab & vbTab
Debug.Print "--- Validation des algorithmes ---"
'utilisé par alg01 et 02
av(0) = VBA.Array(1.00552653648, 0.08199188998, 0.872664626)
av(1) = VBA.Array(-0.3026169006, 0.08199188998, -0.29999999997)
av(2) = VBA.Array(0.2, 0.08199188998, 0.19998903369)
'alg01
Debug.Print vbTab & "+ alg01 - Latitude isométrique à partir de la latitude"
For i = 0 To UBound(av)
Debug.Print sTabs & "Attendu -> phi(rad) : " & av(i)(0)
Debug.Print sTabs & "Obtenu -> phi(rad) : " & alg01(av(i)(2), av(i)(1))
Debug.Print sTabs & "---"
Next i
'alg02
Debug.Print vbTab & "+ alg02 - Latitude à partir de la latitude isométrique"
For i = 0 To UBound(av)
Debug.Print sTabs & "Attendu -> Lat iso : " & av(i)(2)
Debug.Print sTabs & "Obtenu -> Lat iso : " & alg02(av(i)(0), av(i)(1))
Debug.Print sTabs & "---"
Next i
'alg03
Debug.Print vbTab & "+ alg03 - Coordonnées géo vers Lambert"
Debug.Print sTabs & "Attendu -> X : " & 1029705.0818 & " m _ Y : " & 272723.851 & " m"
With tProj
.tEl.de = 0.0824832568
.dN = 0.760405966
.dc = 11603796.9767
.dlambda0 = 0.04079234433
.dXs = 600000
.dYs = 5657616.674
End With
tXYZ = alg03(0.145512099, 0.872664626, tProj)
Debug.Print sTabs & "Obtenu -> X : " & Arrondi(tXYZ.dX, 4) & " m _ Y : " & Arrondi(tXYZ.dY, 4) & " m"
Debug.Print sTabs & "---"
'alg04
Debug.Print vbTab & "+ alg04 - Lambert vers coordonnées géo "
Debug.Print sTabs & "Attendu -> lon : " & 0.14551209925 & " _ lat : " & 0.87266462567
With tProj
.tEl.de = 0.0824832568
.dN = 0.760405966
.dc = 11603796.9767
.dlambda0 = 0.04079234433
.dXs = 600000
.dYs = 5657616.674
End With
tXYZ = alg04(1029705.083, 272723.849, tProj)
Debug.Print sTabs & "Obtenu -> Lon : " & Arrondi(tXYZ.dX, 11) & " _ Lat : " & Arrondi(tXYZ.dY, 11)
Debug.Print sTabs & "---"
'alg21
Debug.Print vbTab & "+ alg21 - Calcul grande Normale"
Debug.Print sTabs & "Attendu -> N : " & 6393174.9755 & " m"
dVal = alg21(0.977384381, 6378388, 0.08199189)
Debug.Print sTabs & "Obtenu -> N : " & Arrondi(dVal, 4) & " m"
Debug.Print sTabs & "---"
'alg09
Debug.Print vbTab & "+ alg09 - Coordonnées géo vers cartésiennes"
Debug.Print sTabs & "Attendu -> X : " & 6376064.6955 & _
" m _ Y : " & 111294.623 & " m _ Z : " & 128984.725 & " m"
With tProj.tEl
.dh = 100
.da = 6378249.2
.de = 0.08248325679
End With
tXYZ = alg09(0.01745329248, 0.02036217457, tProj.tEl)
Debug.Print sTabs & "Obtenu -> X : " & Arrondi(tXYZ.dX, 4) & _
" m _ Y : " & Arrondi(tXYZ.dY, 4) & " m _ Z : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
Debug.Print sTabs & "Attendu -> X : " & 6378232.2149 & _
" m _ Y : " & 18553.578 & " m _ Z : " & 0 & " m"
With tProj.tEl
.dh = 10
.da = 6378249.2
.de = 0.08248325679
End With
tXYZ = alg09(0.00290888212, 0, tProj.tEl)
Debug.Print sTabs & "Obtenu -> X : " & Arrondi(tXYZ.dX, 4) & _
" m _ Y : " & Arrondi(tXYZ.dY, 4) & " m _ Z : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
'alg12
Debug.Print vbTab & "+ alg12 - Coordonnées cartésiennes vers géo"
Debug.Print sTabs & "Attendu -> Lon : " & 0.01745329248 & _
" _ Lat : " & 0.02036217457 & " _ h : " & 99.9995 & " m"
With tProj.tEl
.da = 6378249.2
.de = 0.08248325679
End With
With tXYZ
.dX = 6376064.695
.dY = 111294.623
.dZ = 128984.725
End With
tXYZ = alg12(tXYZ, tProj.tEl)
Debug.Print sTabs & "Obtenu -> Lon : " & Arrondi(tXYZ.dX, 11) & _
" _ Lat : " & Arrondi(tXYZ.dY, 11) & " _ h : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
Debug.Print sTabs & "Attendu -> Lon : " & 0.00581776423 & _
" _ Lat : " & -0.03199770301 & " _ h : " & 2000.0001 & " m"
With tXYZ
.dX = 6376897.537
.dY = 37099.705
.dZ = -202730.907
End With
tXYZ = alg12(tXYZ, tProj.tEl)
Debug.Print sTabs & "Obtenu -> Lon : " & Arrondi(tXYZ.dX, 11) & _
" _ Lat : " & Arrondi(tXYZ.dY, 11) & " _ h : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
'alg13
Debug.Print vbTab & "+ alg13 - Coordonnées cartésiennes vers cartésiennes"
Debug.Print sTabs & "Attendu -> Vx : " & 4154005.8099 & _
" m _ Vy : " & -80587.3284 & " m _ Vz : " & 4823289.5316 & " m"
With tTrans
.dTx = -69.4
.dTy = 18
.dTz = 452.2
.dRx = 0
.dRy = 0
.dRz = 0.00000499358
.dFacteurEchelle = 1 - 0.00000321
End With
With tXYZ
.dX = 4154088.142
.dY = -80626.331
.dZ = 4822852.813
End With
tXYZ = alg13(tXYZ, tTrans)
Debug.Print sTabs & "Obtenu -> Vx : " & Arrondi(tXYZ.dX, 4) & _
" m _ Vy : " & Arrondi(tXYZ.dY, 4) & " m _ Vz : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
'alg54
Debug.Print vbTab & "+ alg54 - Calcul paramètres lambert dans le cas sécant"
Debug.Print sTabs & "Attendu -> c (m): " & 11565915.8294 & _
" m _ n : " & 0.7716421867 & " _ Xs : " & 150000 & " _ Ys : " & 5400000
With tProj
.tEl.da = 6378388
.tEl.de = 0.08199189
.dlambda0 = 0.07623554539
.dphi0 = 1.570796327
.dXs = 0
.dYs = 0
.dphi1 = 0.869755744
.dphi2 = 0.893026801
End With
alg54 tProj, 150000, 5400000
Debug.Print sTabs & "Obtenu -> c (m): " & tProj.dc & " m _ n : " & tProj.dN & _
" _ Xs : " & tProj.dXs & " _ Ys : " & tProj.dYs
Debug.Print sTabs & "---"
Debug.Print sTabs & "Attendu -> c (m): " & -12453174.1795 & _
" m _ n : " & -0.63049633 & " _ Xs : " & 0 & " _ Ys : " & -12453174.1795
With tProj
.tEl.da = 6378388
.tEl.de = 0.08199189
.dlambda0 = 0
.dphi0 = 0
.dXs = 0
.dYs = 0
.dphi1 = -0.575958653
.dphi2 = -0.785398163
End With
alg54 tProj, 0, 0
Debug.Print sTabs & "Obtenu -> c (m): " & tProj.dc & " m _ n : " & tProj.dN & _
" _ Xs : " & tProj.dXs & " _ Ys : " & tProj.dYs
Debug.Print sTabs & "---"
End Sub
Private Sub Test(ByVal eDep As eSCG, ByVal eFin As eSCG, _
ByVal dXi As Double, dYi As Double, _
ByVal sXf As String, sYf As String, _
ByVal eUniteIn As eUnites, ByVal eUniteOut As eUnites, _
Optional ByVal byDecimal As Byte = 1)
Dim tRes As tResults
Dim sTabs As String
sTabs = vbTab & vbTab
Me.TypeConversion eDep, eFin
If Me.IsErreur Then
Debug.Print sTabs & "Erreur : " & Me.Erreur
Else
tRes = SetUnites(dXi, dYi, eUniteIn, True)
With tRes
Me.CalculSCG .dX, .dY
Debug.Print sTabs & "Entrée - Xi : " & .sX & " - Yi : " & .sY
Debug.Print sTabs & "Attendu - Xf : " & sXf & " - Yf : " & sYf
tRes = SetUnites(Me.X, Me.Y, eUniteOut, False, byDecimal)
Debug.Print sTabs & "Obtenu - Xc : " & .sX & " - Yc : " & .sY
End With
End If
End Sub
Private Function SetUnites(ByVal dX As Double, ByVal dY As Double, _
ByVal eUn As eUnites, ByVal bIn As Boolean, _
Optional ByVal byDecimal As Byte = 1) As tResults
Dim tRes As tResults
With tRes
Select Case eUn
Case eUnites.dms
If bIn Then
.dX = AngleDMSToRadian(dX)
.dY = AngleDMSToRadian(dY)
.sX = AngleDMSToString(dX, False)
.sY = AngleDMSToString(dY, True)
Else
.sX = RadianToStringDMS(dX, False)
.sY = RadianToStringDMS(dY, True)
End If
Case eUnites.gr
If bIn Then
.dX = GradeToRadian(dX)
.dY = GradeToRadian(dY)
.sX = dX & "gr"
.sY = dY & "gr"
Else
.sX = Arrondi(RadianToGrade(dX), byDecimal) & "gr"
.sY = Arrondi(RadianToGrade(dY), byDecimal) & "gr"
End If
Case eUnites.m
If bIn Then
.dX = dX
.dY = dY
.sX = dX & "m"
.sY = dY & "m"
Else
.sX = Arrondi(dX, byDecimal) & "m"
.sY = Arrondi(dY, byDecimal) & "m"
End If
Case eUnites.rad
If bIn Then
.dX = dX
.dY = dY
.sX = dX & "rad"
.sY = dY & "rad"
Else
.sX = Arrondi(dX, byDecimal) & "rad"
.sY = Arrondi(dY, byDecimal) & "rad"
End If
Case eUnites.DD
If bIn Then
.dX = DegreDecToRadian(dX)
.dY = DegreDecToRadian(dY)
.sX = dX & "°"
.sY = dY & "°"
Else
.sX = Arrondi(RadianToDegreDec(dX), byDecimal) & "°"
.sY = Arrondi(RadianToDegreDec(dY), byDecimal) & "°"
End If
End Select
End With
SetUnites = tRes
End Function
#End If |
Partager