-
Notifications
You must be signed in to change notification settings - Fork 11
/
geometryProcessors.pm
698 lines (529 loc) · 21.6 KB
/
geometryProcessors.pm
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
#!/usr/bin/perl
# Copyright (C) 2013 Jesse McGraw ([email protected])
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
package geometryProcessors;
use 5.018;
use strict;
use warnings;
use Params::Validate qw(:all);
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use processFaaData;
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(
geometry_AFF_AFF1
geometry_AFF_AFF3
geometry_APT_APT
geometry_APT_RWY
geometry_ARB_ARB
geometry_ATS_ATS2
geometry_ATS_ATS3
geometry_AWOS_AWOS1
geometry_AWY_AWY2
geometry_AWY_AWY3
geometry_COM_COM
geometry_FIX_FIX1
geometry_FSS_FSS
geometry_HARFIX_HARFIX
geometry_HPF_HP1
geometry_ILS_ILS2
geometry_ILS_ILS3
geometry_ILS_ILS4
geometry_ILS_ILS5
geometry_MTR_MTR5
geometry_NAV_NAV1
geometry_NATFIX_NATFIX
geometry_PJA_PJA1
geometry_SSD_SSD
geometry_STARDP_STARDP
geometry_TWR_TWR1
geometry_TWR_TWR7
geometry_WXL_WXL
geometry_OBSTACLE_OBSTACLE);
sub geometry_OBSTACLE_OBSTACLE {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude = &coordinateToDecimal2(
$hashRef->{latitude_degrees}, $hashRef->{latitude_minutes},
$hashRef->{latitude_seconds}, $hashRef->{latitude_hemisphere},
);
my $longitude = &coordinateToDecimal2(
$hashRef->{longitude_degrees}, $hashRef->{longitude_minutes},
$hashRef->{longitude_seconds}, $hashRef->{longitude_hemisphere},
);
# #and save in the hash as a POINT
# $hashRef->{Geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{obstacle_latitude} = $latitude;
$hashRef->{obstacle_longitude} = $longitude;
}
sub geometry_AFF_AFF1 {
# AIR ROUTE TRAFFIC CONTROL CENTER FACILITIES AND COMMUNICATIONS
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# #Calculate the decimal representation of lon/lat
$hashRef->{latitude} =
&coordinateToDecimal( $hashRef->{site_latitude_formatted} );
$hashRef->{longitude} =
&coordinateToDecimal( $hashRef->{site_longitude_formatted} );
}
sub geometry_AFF_AFF3 {
# AIR ROUTE TRAFFIC CONTROL CENTER FACILITIES AND COMMUNICATIONS
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# #Calculate the decimal representation of lon/lat
$hashRef->{latitude} =
&coordinateToDecimal( $hashRef->{latitude_of_the_airport_formatted} );
$hashRef->{longitude} =
&coordinateToDecimal( $hashRef->{longitude_of_the_airport_formatted} );
}
sub geometry_ARB_ARB {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{latitude_of_the_boundary_point}, );
my $longitude =
&coordinateToDecimal( $hashRef->{longitude_of_the_boundary_point} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_ATS_ATS2 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{navaid_facility_fix_latitude}, );
my $longitude =
&coordinateToDecimal( $hashRef->{navaid_facility_fix_longitude} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_ATS_ATS3 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{navaid_facility_latitude}, );
my $longitude =
&coordinateToDecimal( $hashRef->{navaid_facility_longitude} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_AWY_AWY2 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{navaid_facility_fix_latitude}, );
my $longitude =
&coordinateToDecimal( $hashRef->{navaid_facility_fix_longitude} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_AWY_AWY3 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{navaid_facility_latitude}, );
my $longitude =
&coordinateToDecimal( $hashRef->{navaid_facility_longitude} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_COM_COM {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# associated_navaid_latitude:14
# associated_navaid_longitude:14
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{communications_outlet_latitude}, );
my $longitude =
&coordinateToDecimal( $hashRef->{communications_outlet_longitude} );
#and save in the hash
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_FSS_FSS {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# latitude_of_direction_finding_df_equipment:14
# longitude_of_direction_finding_df_equipment:14
# geographical_latitude_of_communication_facility_not_used_when_c:420
# geographical_longitude_of_communication_facility_not_used_when:420
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{airport_latitude_fss_on_arpt}, );
my $longitude =
&coordinateToDecimal( $hashRef->{airport_longitude_fss_on_arpt} );
my $latitudeNotOnAirport =
&coordinateToDecimal(
$hashRef->{latitude_when_fss_is_not_on_airport_see_f6},
);
my $longitudeNotOnAirport =
&coordinateToDecimal(
$hashRef->{longitude_when_fss_is_not_on_airport_see_f6} );
if ( $latitude && $longitude ) {
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
elsif ( $latitudeNotOnAirport && $longitudeNotOnAirport ) {
$hashRef->{latitude} = $latitudeNotOnAirport;
$hashRef->{longitude} = $longitudeNotOnAirport;
}
}
sub geometry_HARFIX_HARFIX {
#TODO
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# #Calculate the decimal representation of lon/lat
# my $latitude =
# &coordinateToDecimal(
# $hashRef->{airport_reference_point_latitude_formatted},
# );
# my $longitude =
# &coordinateToDecimal(
# $hashRef->{airport_reference_point_longitude_formatted} );
# # #and save in the hash as a POINT
# # $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
# $hashRef->{apt_latitude} = $latitude;
# $hashRef->{apt_longitude} = $longitude;
}
sub geometry_HPF_HP1 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# #Calculate the decimal representation of lon/lat
$hashRef->{latitude_of_the_associated_fix} =
&coordinateToDecimal(
$hashRef->{latitude_of_the_associated_fix_dd_mm_ss_sssn} );
$hashRef->{longitude_of_the_associated_fix} =
&coordinateToDecimal(
$hashRef->{longitude_of_the_associated_fix_ddd_mm_ss_sssw} );
$hashRef->{latitude_of_the_associated_navaid} =
&coordinateToDecimal(
$hashRef->{latitude_of_the_associated_navaid_dd_mm_ss_sssn} );
$hashRef->{longitude_of_the_associated_navaid} =
&coordinateToDecimal(
$hashRef->{longitude_of_the_associated_navaid_ddd_mm_ss_sssw} );
}
sub geometry_ILS_ILS2 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal(
$hashRef->{latitude_of_localizer_antenna_formatted} );
my $longitude =
&coordinateToDecimal(
$hashRef->{longitude_of_localizer_antenna_formatted} );
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_ILS_ILS3 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal(
$hashRef->{latitude_of_glide_slope_transmitter_antenna_formatted} );
my $longitude =
&coordinateToDecimal(
$hashRef->{longitude_of_glide_slope_transmitter_antenna_formatted} );
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_ILS_ILS4 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal(
$hashRef->{latitude_of_dme_transponder_antenna_formatted} );
my $longitude =
&coordinateToDecimal(
$hashRef->{longitude_of_dme_transponder_antenna_formatted} );
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_ILS_ILS5 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{latitude_of_marker_beacon_formatted} );
my $longitude =
&coordinateToDecimal( $hashRef->{longitude_of_marker_beacon_formatted} );
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_MTR_MTR5 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
$hashRef->{latitude} =
&coordinateToDecimal3( $hashRef->{latitude_location_of_point}, );
$hashRef->{longitude} =
&coordinateToDecimal3( $hashRef->{longitude_location_of_point} );
}
sub geometry_NATFIX_NATFIX {
#TODO
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
# #Calculate the decimal representation of lon/lat
# my $latitude =
# &coordinateToDecimal(
# $hashRef->{airport_reference_point_latitude_formatted},
# );
# my $longitude =
# &coordinateToDecimal(
# $hashRef->{airport_reference_point_longitude_formatted} );
# # #and save in the hash as a POINT
# # $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
# $hashRef->{apt_latitude} = $latitude;
# $hashRef->{apt_longitude} = $longitude;
}
sub geometry_SSD_SSD {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude = $hashRef->{fix_navaid_airport_latitude_format_xddmmsst};
my $longitude = $hashRef->{fix_navaid_airport_longitude_format_xdddmmsst};
if ( $longitude && $latitude ) {
# say $longitude . " " . $latitude;
# ( $deg, $min, $sec, $declination )
my $latD = substr( $latitude, 1, 2 );
my $latM = substr( $latitude, 3, 2 );
my $latS = substr( $latitude, 5, 2 ) . "." . substr( $latitude, 7, 1 );
my $latDeclination = substr( $latitude, 0, 1 );
$latitude =
coordinateToDecimal2( $latD, $latM, $latS, $latDeclination );
my $lonD = substr( $longitude, 1, 3 );
my $lonM = substr( $longitude, 4, 2 );
my $lonS =
substr( $longitude, 6, 2 ) . "." . substr( $longitude, 8, 1 );
my $lonDeclination = substr( $longitude, 0, 1 );
$longitude =
coordinateToDecimal2( $lonD, $lonM, $lonS, $lonDeclination );
}
# 5614486N 13438533W
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_STARDP_STARDP {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude = $hashRef->{fix_navaid_airport_latitude_format_xddmmsst};
my $longitude = $hashRef->{fix_navaid_airport_longitude_format_xdddmmsst};
if ( $longitude && $latitude ) {
# say $longitude . " " . $latitude;
# ( $deg, $min, $sec, $declination )
my $latDeclination = substr( $latitude, 0, 1 );
my $latD = substr( $latitude, 1, 2 );
my $latM = substr( $latitude, 3, 2 );
my $latS = substr( $latitude, 5, 2 ) . "." . substr( $latitude, 7, 1 );
$latitude =
coordinateToDecimal2( $latD, $latM, $latS, $latDeclination );
my $lonDeclination = substr( $longitude, 0, 1 );
my $lonD = substr( $longitude, 1, 3 );
my $lonM = substr( $longitude, 4, 2 );
my $lonS =
substr( $longitude, 6, 2 ) . "." . substr( $longitude, 8, 1 );
$longitude =
coordinateToDecimal2( $lonD, $lonM, $lonS, $lonDeclination );
}
# 5614486N 13438533W
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_TWR_TWR1 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Airport Reference Point
$hashRef->{airport_reference_point_latitude} =
&coordinateToDecimal(
$hashRef->{airport_reference_point_latitude_formatted} );
$hashRef->{airport_reference_point_longitude} =
&coordinateToDecimal(
$hashRef->{airport_reference_point_longitude_formatted} );
#Airport Surveillance Radar
$hashRef->{airport_surveillance_radar_latitude} =
&coordinateToDecimal(
$hashRef->{airport_surveillance_radar_latitude_formatted} );
$hashRef->{airport_surveillance_radar_longitude} =
&coordinateToDecimal(
$hashRef->{airport_surveillance_radar_longitude_formatted} );
#Direction Finding Antenna
$hashRef->{latitude_of_direction_finding_antenna} =
&coordinateToDecimal(
$hashRef->{latitude_of_direction_finding_antenna_formatted} );
$hashRef->{longitude_of_direction_finding_antenna} =
&coordinateToDecimal(
$hashRef->{longitude_of_direction_finding_antenna_formatted} );
}
sub geometry_TWR_TWR7 {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
$hashRef->{airport_latitude} =
&coordinateToDecimal( $hashRef->{airport_latitude_formatted} );
$hashRef->{airport_longitude} =
&coordinateToDecimal( $hashRef->{airport_longitude_formatted} );
}
sub geometry_APT_APT {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal(
$hashRef->{airport_reference_point_latitude_formatted},
);
my $longitude =
&coordinateToDecimal(
$hashRef->{airport_reference_point_longitude_formatted} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{apt_latitude} = $latitude;
$hashRef->{apt_longitude} = $longitude;
}
sub geometry_APT_RWY {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $base_latitude =
&coordinateToDecimal(
$hashRef->{base_latitude_of_physical_runway_end_formatted} );
my $base_longitude =
&coordinateToDecimal(
$hashRef->{base_longitude_of_physical_runway_end_formatted} );
my $reciprocal_latitude =
&coordinateToDecimal(
$hashRef->{reciprocal_latitude_of_physical_runway_end_formatted} );
my $reciprocal_longitude =
&coordinateToDecimal(
$hashRef->{reciprocal_longitude_of_physical_runway_end_formatted} );
#Displaced threshold endpoints
my $base_displaced_threshold_latitude =
&coordinateToDecimal(
$hashRef->{base_latitude_at_displaced_threshold_formatted} );
my $base_displaced_threshold_longitude =
&coordinateToDecimal(
$hashRef->{base_longitude_at_displaced_threshold_formatted} );
my $reciprocal_displaced_threshold_latitude =
&coordinateToDecimal(
$hashRef->{reciprocal_latitude_at_displaced_threshold_formatted} );
my $reciprocal_displaced_threshold_longitude =
&coordinateToDecimal(
$hashRef->{reciprocal_longitude_at_displaced_threshold_formatted} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "LINESTRING("
# . $base_longitude . " " . $base_latitude
# . " , "
# . $reciprocal_longitude . " " . $reciprocal_latitude
# . ")";
$hashRef->{base_latitude} = $base_latitude;
$hashRef->{base_longitude} = $base_longitude;
$hashRef->{reciprocal_latitude} = $reciprocal_latitude;
$hashRef->{reciprocal_longitude} = $reciprocal_longitude;
$hashRef->{base_displaced_threshold_latitude} =
$base_displaced_threshold_latitude;
$hashRef->{base_displaced_threshold_longitude} =
$base_displaced_threshold_longitude;
$hashRef->{reciprocal_displaced_threshold_latitude} =
$reciprocal_displaced_threshold_latitude;
$hashRef->{reciprocal_displaced_threshold_longitude} =
$reciprocal_displaced_threshold_longitude;
# my $runwayLineTrueHeading =
# round( trueHeading( $_x1, $_y1, $_x2, $_y2 ) );
}
sub geometry_AWOS_AWOS1 {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{station_latitude_dd_mm_ss_ssssh}, );
my $longitude =
&coordinateToDecimal( $hashRef->{station_longitude_ddd_mm_ss_ssssh} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_FIX_FIX1 {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{geographical_latitude_of_the_fix}, );
my $longitude =
&coordinateToDecimal( $hashRef->{geographical_longitude_of_the_fix} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_NAV_NAV1 {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude =
&coordinateToDecimal( $hashRef->{navaid_latitude_formatted}, );
my $longitude =
&coordinateToDecimal( $hashRef->{navaid_longitude_formatted} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_PJA_PJA1 {
# my $hashRef = shift;
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude = &coordinateToDecimal( $hashRef->{pja_latitude_formatted}, );
my $longitude = &coordinateToDecimal( $hashRef->{pja_longitude_formatted} );
# #and save in the hash as a POINT
# $hashRef->{geometry} = "POINT(" . $longitude . " " . $latitude . ")";
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
sub geometry_WXL_WXL {
my ($hashRef) = validate_pos( @_, { type => HASHREF } );
#Calculate the decimal representation of lon/lat
my $latitude = $hashRef->{latitude_of_the_weather_reporting_location};
my $longitude = $hashRef->{longitude_of_the_weather_reporting_location};
if ( $longitude && $latitude ) {
# ( $deg, $min, $sec, $declination )
my $latD = substr( $latitude, 0, 2 );
my $latM = substr( $latitude, 2, 2 );
my $latS = substr( $latitude, 4, 2 ) . "." . substr( $latitude, 6, 1 );
my $latDeclination = substr( $latitude, 7, 1 );
$latitude =
coordinateToDecimal2( $latD, $latM, $latS, $latDeclination );
my $lonD = substr( $longitude, 0, 3 );
my $lonM = substr( $longitude, 3, 2 );
my $lonS =
substr( $longitude, 5, 2 ) . "." . substr( $longitude, 7, 1 );
my $lonDeclination = substr( $longitude, 8, 1 );
$longitude =
coordinateToDecimal2( $lonD, $lonM, $lonS, $lonDeclination );
}
# 5614486N 13438533W
$hashRef->{latitude} = $latitude;
$hashRef->{longitude} = $longitude;
}
# sub trueHeading {
# # my ( ) = @_;
# my ( $_x1, $_y1, $_x2, $_y2) = validate_pos( @_, { type => SCALAR, type => SCALAR,type => SCALAR,type => SCALAR,} );
# return rad2deg( pi / 2 - atan2( $_y2 - $_y1, $_x2 - $_x1 ) );
# }
# sub WGS84toGoogleBing {
# # my ( ) = @_;
# my ( $lon, $lat) = validate_pos( @_, { type => SCALAR, type => SCALAR} );
# my $x = $lon * 20037508.34 / 180;
# my $y = log( tan( ( 90 + $lat ) * pi / 360 ) ) / ( pi / 180 );
# $y = $y * 20037508.34 / 180;
# return ( $x, $y );
# }
1;