File Coverage

blib/lib/Astro/App/Satpass2/Locale/C.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Astro::App::Satpass2::Locale::C;
2              
3 8     8   3858 use 5.008;
  8         62  
4              
5 8     8   49 use strict;
  8         20  
  8         287  
6 8     8   43 use warnings;
  8         16  
  8         612  
7              
8 8     8   48 use utf8; # Not actually needed for C locale, but maybe for others
  8         15  
  8         74  
9              
10 8     8   1725 use Astro::Coord::ECI::TLE 0.059 qw{ :constants };
  8         107194  
  8         2609  
11 8     8   64 use Astro::App::Satpass2::Utils qw{ @CARP_NOT };
  8         18  
  8         970  
12 8     8   55 use Scalar::Util ();
  8         17  
  8         8042  
13              
14             our $VERSION = '0.057_01';
15              
16             my @event_names;
17             $event_names[PASS_EVENT_NONE] = '';
18             $event_names[PASS_EVENT_SHADOWED] = 'shdw';
19             $event_names[PASS_EVENT_LIT] = 'lit';
20             $event_names[PASS_EVENT_DAY] = 'day';
21             $event_names[PASS_EVENT_RISE] = 'rise';
22             $event_names[PASS_EVENT_MAX] = 'max';
23             $event_names[PASS_EVENT_SET] = 'set';
24             $event_names[PASS_EVENT_APPULSE] = 'apls';
25             $event_names[PASS_EVENT_START] = 'strt';
26             $event_names[PASS_EVENT_END] = 'end';
27             $event_names[PASS_EVENT_BRIGHTEST] = 'brgt';
28              
29             my @sun_quarters = (
30             'Spring equinox',
31             'Summer solstice',
32             'Autumn equinox',
33             'Winter solstice',
34             );
35              
36             # Any hash reference is a true value, but perlcritic seems not to know
37             # this.
38              
39             { ## no critic (Modules::RequireEndWithOne)
40             '+message' => {
41             },
42             '+template' => {
43              
44             # Local coordinates
45              
46             az_rng => <<'EOD',
47             [% data.azimuth( arg, bearing = 2 ) %]
48             [%= data.range( arg ) -%]
49             EOD
50              
51             azel => <<'EOD',
52             [% data.elevation( arg ) %]
53             [%= data.azimuth( arg, bearing = 2 ) -%]
54             EOD
55              
56             azel_rng => <<'EOD',
57             [% data.elevation( arg ) %]
58             [%= data.azimuth( arg, bearing = 2 ) %]
59             [%= data.range( arg ) -%]
60             EOD
61              
62             equatorial => <<'EOD',
63             [% data.right_ascension( arg ) %]
64             [%= data.declination( arg ) -%]
65             EOD
66              
67             equatorial_rng => <<'EOD',
68             [% data.right_ascension( arg ) %]
69             [%= data.declination( arg ) %]
70             [%= data.range( arg ) -%]
71             EOD
72              
73             # Main templates
74              
75             almanac => <<'EOD',
76             [% UNLESS data %]
77             [%- SET data = sp.almanac( arg ) %]
78             [%- END %]
79             [%- FOREACH item IN data %]
80             [%- item.date %] [% item.time %]
81             [%= item.almanac( units = 'description' ) %]
82             [% END -%]
83             EOD
84              
85             flare => <<'EOD',
86             [% UNLESS data %]
87             [%- SET data = sp.flare( arg ) %]
88             [%- END %]
89             [%- CALL title.title_gravity( TITLE_GRAVITY_BOTTOM ) %]
90             [%- WHILE title.more_title_lines %]
91             [%- title.time %]
92             [%= title.name( width = 12 ) %]
93             [%= title.local_coord %]
94             [%= title.magnitude %]
95             [%= title.angle( 'Degrees From Sun' ) %]
96             [%= title.azimuth( 'Center Azimuth', bearing = 2 ) %]
97             [%= title.range( 'Center Range', width = 6 ) %]
98              
99             [%- END %]
100             [%- prior_date = '' -%]
101             [% FOR item IN data %]
102             [%- center = item.center %]
103             [%- current_date = item.date %]
104             [%- IF prior_date != current_date %]
105             [%- prior_date = current_date %]
106             [%- current_date %]
107              
108             [%- END %]
109             [%- item.time %]
110             [%= item.name( units = 'title_case', width = 12 ) %]
111             [%= item.local_coord %]
112             [%= item.magnitude %]
113             [%= IF 'day' == item.type( width = '' ) %]
114             [%- item.appulse.angle %]
115             [%- ELSE %]
116             [%- item.appulse.angle( literal = 'night' ) %]
117             [%- END %]
118             [%= center.azimuth( bearing = 2 ) %]
119             [%= center.range( width = 6 ) %]
120             [% END -%]
121             EOD
122              
123             list => <<'EOD',
124             [% UNLESS data %]
125             [%- SET data = sp.list( arg ) %]
126             [%- END %]
127             [%- CALL title.title_gravity( TITLE_GRAVITY_BOTTOM ) %]
128             [%- WHILE title.more_title_lines %]
129             [%- title.list %]
130             [% END %]
131             [%- FOR item IN data %]
132             [%- item.list( arg ) %]
133             [% END -%]
134             EOD
135              
136             list_inertial => <<'EOD',
137             [% data.oid( align_left = 0, arg ) %] [% data.name( arg ) %]
138             [%= data.epoch( arg ) %]
139             [%= data.period( arg, align_left = 1 ) -%]
140             EOD
141              
142             list_fixed => <<'EOD',
143             [% data.oid( align_left = 0, arg ) %] [% data.name( arg ) %]
144             [%= data.latitude( arg ) %]
145             [%= data.longitude( arg ) %] [% data.altitude( arg ) -%]
146             EOD
147              
148             location => <<'EOD',
149             [% UNLESS data %]
150             [%- SET data = sp.location( arg ) %]
151             [%- END -%]
152             [% localize( 'Location' ) %]: [% data.name( width = '' ) %]
153             [% localize( 'Latitude' ) %] [% data.latitude( places = 4,
154             width = '' ) %], [% localize( 'longitude' ) %]
155             [%= data.longitude( places = 4, width = '' )
156             %], [% localize( 'height' ) %]
157             [%= data.altitude( units = 'meters', places = 0,
158             width = '' ) %] m
159             EOD
160              
161             pass => <<'EOD',
162             [% UNLESS data %]
163             [%- SET data = sp.pass( arg ) %]
164             [%- END %]
165             [%- CALL title.title_gravity( TITLE_GRAVITY_BOTTOM ) %]
166             [%- WHILE title.more_title_lines %]
167             [%- format_detail( 'event', title ) %]
168              
169             [%- END %]
170             [%- FOR pass IN data %]
171             [%- events = pass.events %]
172             [%- evt = events.first_tle %]
173              
174             [%- evt.date %] [% evt.oid %] - [% evt.name( width = '' ) %]
175              
176             [%- FOREACH evt IN events %]
177             [%- format_detail( 'event', evt ) %]
178              
179             [%- END %]
180             [%- END -%]
181             EOD
182             'pass:event' => <<'EOD',
183             [%- evt.time %]
184             [%= evt.local_coord %]
185             [%= evt.latitude %]
186             [%= evt.longitude %]
187             [%= evt.altitude %]
188             [%= evt.illumination %]
189             [%- IF sp.want_pass_variant( 'brightest' ) %]
190             [%= evt.magnitude %]
191             [%- END %]
192             [%= evt.event %]
193             EOD
194             'pass:event:almanac' => <<'EOD',
195             [%- evt.time %] [% evt.almanac %]
196             EOD
197             'pass:event:apls' => <<'EOD',
198             [%- evt.time %]
199             [%= evt.local_coord %]
200             [%= evt.latitude %]
201             [%= evt.longitude %]
202             [%= evt.altitude %]
203             [%= evt.illumination %]
204             [%- IF sp.want_pass_variant( 'brightest' ) %]
205             [%= evt.magnitude %]
206             [%- END %]
207             [%= evt.event %]
208             [%- apls = evt.appulse %]
209              
210             [%- title.time( '' ) %]
211             [%= apls.local_coord %]
212             [%= apls.angle %] degrees from [% apls.name( width = '' ) %]
213             EOD
214              
215             pass_events => <<'EOD',
216             [% UNLESS data %]
217             [%- SET data = sp.pass( arg ) %]
218             [%- END %]
219             [%- CALL title.title_gravity( TITLE_GRAVITY_BOTTOM ) %]
220             [%- WHILE title.more_title_lines %]
221             [%- format_detail( 'event', title ) %]
222              
223             [%- END %]
224             [%- FOREACH evt IN data.events %]
225             [%- format_detail( 'event', evt ) %]
226             [% END -%]
227             EOD
228             'pass_events:event' => <<'EOD',
229             [%- evt.date %] [% evt.time %]
230             [%= evt.oid %] [% evt.event %]
231             [%= evt.illumination %] [% evt.local_coord %]
232             EOD
233             'pass_events:event:almanac' => <<'EOD',
234             [%- evt.date %] [% evt.time %] [% evt.almanac %]
235             EOD
236              
237             pass_ics => <<'EOD',
238             [% UNLESS data %]
239             [%- SET data = sp.pass( arg ) %]
240             [%- END -%]
241             BEGIN:VCALENDAR
242             VERSION:2.0
243             [%- FOR pass IN data %]
244             [%- events = pass.events %]
245             [%- CALL events.fixed_width( 0 ) %]
246             [%- tle_events = pass.tle_events %]
247             [%- first = tle_events.first %]
248             [%- last = tle_events.last %]
249             [%- punct = '' %]
250             BEGIN:VEVENT
251             DTSTART:[% first.date( format = '%Y%m%dT%H%M%SZ', units = 'zulu' ) %]
252             BEGIN:VALARM
253             TRIGGER:-PT5M
254             ACTION:DISPLAY
255             END:VALARM
256             BEGIN:VALARM
257             TRIGGER:PT0M
258             ACTION:DISPLAY
259             END:VALARM
260             SUMMARY:[% first.name( width = '' ) %]
261             DESCRIPTION:
262             [%- FOREACH evt IN events %][% punct %]
263             [%- format_detail( 'event', evt ) %]
264             [%- punct = '\n' %]
265             [%- END %]
266             DTEND:[% last.date( format = '%Y%m%dT%H%M%SZ', units = 'z' ) %]
267             END:VEVENT
268             [%- END %]
269             END:VCALENDAR
270             EOD
271             'pass_ics:event' => <<'EOD',
272             [%- evt.event %]
273             [%= evt.time %] [% localize( 'Az' ) %]
274             [%= evt.azimuth( places = 0, bearing = 2 ) %] [% localize( 'Ele' ) %]
275             [%= evt.elevation( places = 0 ) %]
276             [%- IF sp.want_pass_variant( 'brightest' ) && '' != evt.magnitude %]
277             [%= localize( 'Mag' ) %] [% evt.magnitude %]
278             [%- END %]
279             EOD
280             'pass_ics:event:almanac' => <<'EOD',
281             [%- evt.almanac %] [% evt.time %]
282             EOD
283             'pass_ics:event:apls' => <<'EOD',
284             [%- evt.event %]
285             [%- appulse = evt.appulse %]
286             [%= appulse.angle %]
287             [%= appulse.name %]
288             [%= evt.time %] [% localize( 'Az' ) %]
289             [%= evt.azimuth( places = 0, bearing = 2 ) %]
290             [%= evt.elevation( places = 0 ) %]
291             [%- IF sp.want_pass_variant( 'brightest' ) && '' != evt.magnitude %]
292             [%= localize( 'Mag' ) %] [% evt.magnitude %]
293             [%- END %]
294             EOD
295             'pass_ics:event:rise' => <<'EOD',
296             [%- evt.event %]
297             [%= evt.time %] [% localize( 'Az' ) %]
298             [%= evt.azimuth( places = 0, bearing = 2 ) %]
299             [%- IF sp.want_pass_variant( 'brightest' ) && '' != evt.magnitude %]
300             [%= localize( 'Mag' ) %] [% evt.magnitude %]
301             [%- END %]
302             EOD
303             'pass_ics:event:set' => <<'EOD',
304             [%- evt.event %]
305             [%= evt.time %] [% localize( 'Az' ) %]
306             [%= evt.azimuth( places = 0, bearing = 2 ) %]
307             [%- IF sp.want_pass_variant( 'brightest' ) && '' != evt.magnitude %]
308             [%= localize( 'Mag' ) %] [% evt.magnitude %]
309             [%- END %]
310             EOD
311              
312             phase => <<'EOD',
313             [% UNLESS data %]
314             [%- SET data = sp.phase( arg ) %]
315             [%- END %]
316             [%- CALL title.title_gravity( TITLE_GRAVITY_BOTTOM ) %]
317             [%- WHILE title.more_title_lines %]
318             [%- title.date( align_left = 0 ) %]
319             [%= title.time( align_left = 0 ) %]
320             [%= title.name( width = 8, align_left = 0 ) %]
321             [%= title.phase( places = 0, width = 4 ) %]
322             [%= title.phase( width = 16, units = 'phase',
323             align_left = 1 ) %]
324             [%= title.fraction_lit( title = 'Lit', places = 0, width = 4,
325             units = 'percent', align_left = 0 ) %]
326              
327             [%- END %]
328             [%- FOR item IN data %]
329             [%- item.date %] [% item.time %]
330             [%= item.name( width = 8, align_left = 0 ) %]
331             [%= item.phase( places = 0, width = 4 ) %]
332             [%= item.phase( width = 16, units = 'phase',
333             align_left = 1 ) %]
334             [%= item.fraction_lit( places = 0, width = 4,
335             units = 'percent' ) %]%
336             [% END -%]
337             EOD
338              
339             position => <<'EOD',
340             [% UNLESS data %]
341             [%- SET data = sp.position( arg ) %]
342             [%- END %]
343             [%- CALL title.title_gravity( TITLE_GRAVITY_BOTTOM ) %]
344             [%- data.date %] [% data.time %]
345             [%- WHILE title.more_title_lines %]
346             [%- title.name( align_left = 0, width = 16 ) %]
347             [%= title.local_coord %]
348             [%= title.epoch( align_left = 0 ) %]
349             [%= title.illumination %]
350              
351             [%- END %]
352             [%- FOR item IN data.bodies() %]
353             [%- item.name( width = 16, missing = 'oid', align_left = 0 ) %]
354             [%= item.local_coord %]
355             [%= item.epoch( align_left = 0 ) %]
356             [%= item.illumination %]
357              
358             [%- FOR refl IN item.reflections() %]
359             [%- item.name( literal = '', width = 16 ) %]
360             [%= item.local_coord( literal = '' ) %] MMA
361             [%- IF refl.status( width = '' ) %]
362             [%= refl.mma( width = '' ) %] [% refl.status( width = '' ) %]
363             [%- ELSE %]
364             [%= refl.mma( width = '' ) %] mirror angle [%
365             refl.angle( width = '' ) %] magnitude [%
366             refl.magnitude( width = '' ) %]
367             [%- END %]
368              
369             [%- END -%]
370             [% END -%]
371             EOD
372              
373             tle => <<'EOD',
374             [% UNLESS data %]
375             [%- SET data = sp.tle( arg ) %]
376             [%- END %]
377             [%- FOR item IN data %]
378             [%- item.tle -%]
379             [% END -%]
380             EOD
381              
382             tle_json => <<'EOD',
383             [% UNLESS data %]
384             [%- SET data = sp.tle( arg ) %]
385             [%- END %]
386             [%- data.bodies.to_json -%]
387             EOD
388              
389             # NOTE that templates that consist entirely of an outline-tag
390             # INCLUDE are special-cased.
391             tle_tle => '%% INCLUDE tle',
392              
393             tle_verbose => <<'EOD',
394             [% UNLESS data %]
395             [%- SET data = sp.tle( arg ) %]
396             [%- END %]
397             [%- CALL title.fixed_width( 0 ) -%]
398             [% FOR item IN data -%]
399             [% UNLESS item.tle -%]
400             [% NEXT -%]
401             [% END -%]
402             [% CALL item.fixed_width( 0 ) -%]
403             [% title.oid %]: [% item.oid %]
404             [% title.name %]: [% item.name %]
405             [% title.international %]: [% item.international %]
406             [% title.epoch %]: [% item.epoch( units = 'zulu' ) %] GMT
407             [% title.effective_date %]: [%
408             item.effective_date( units = 'zulu',
409             missing = '' ) %] GMT
410             [% title.classification %]: [% item.classification %]
411             [% title.mean_motion %]: [% item.mean_motion( places = 8 )
412             %] degrees/minute
413             [% title.first_derivative %]: [%
414             item.first_derivative( places = 8 ) %] degrees/minute squared
415             [% title.second_derivative %]: [%
416             item.second_derivative( places = 5 ) %] degrees/minute cubed
417             [% title.b_star_drag %]: [% item.b_star_drag( places = 5 ) %]
418             [% title.ephemeris_type %]: [% item.ephemeris_type %]
419             [% title.inclination %]: [% item.inclination( places = 4 ) %] degrees
420             [% title.ascending_node %]: [% item.ascending_node(
421             places = 0 ) %] in right ascension
422             [% title.eccentricity %]: [% item.eccentricity( places = 7 ) %]
423             [% title.argument_of_perigee %]: [%
424             item.argument_of_perigee( places = 4 )
425             %] degrees from ascending node
426             [% title.mean_anomaly %]: [%
427             item.mean_anomaly( places = 4 ) %] degrees
428             [% title.element_number %]: [% item.element_number %]
429             [% title.revolutions_at_epoch %]: [% item.revolutions_at_epoch %]
430             [% title.period %]: [% item.period %]
431             [% title.semimajor %]: [% item.semimajor( places = 1 ) %] kilometers
432             [% title.perigee %]: [% item.perigee( places = 1 ) %] kilometers
433             [% title.apogee %]: [% item.apogee( places = 1 ) %] kilometers
434             [% END -%]
435             EOD
436             },
437              
438             # By convention, -report_name is localizations of headings
439             '-flare' => {
440             string => {
441             'Degrees From Sun' => 'Degrees From Sun',
442             'Center Azimuth' => 'Center Azimuth',
443             'Center Range' => 'Center Range',
444             'night' => 'night',
445             },
446             },
447             '-location' => {
448             string => {
449             'Location' => 'Location',
450             'Latitude' => 'Latitude',
451             'longitude' => 'longitude',
452             'height' => 'height',
453             },
454             },
455             '-pass_ics' => {
456             string => {
457             'Az' => 'Az',
458             'Ele' => 'Ele',
459             'Mag' => 'Mag',
460             },
461             },
462              
463             almanac => {
464             title => 'Almanac',
465             Moon => {
466             horizon => [ 'Moon set', 'Moon rise' ],
467             quarter => [
468             'New Moon',
469             'First quarter Moon',
470             'Full Moon',
471             'Last quarter Moon',
472             ],
473             transit => [ undef, 'Moon transits meridian' ],
474             },
475             Sun => {
476             horizon => [ 'Sunset', 'Sunrise' ],
477             quarter => sub {
478             my ( $key, $arg ) = @_;
479             Scalar::Util::blessed( $arg )
480             and return $arg->__quarter_name( $key,
481             \@sun_quarters );
482             return $sun_quarters[$key];
483             },
484             transit => [ 'local midnight', 'local noon' ],
485             twilight => [ 'end twilight', 'begin twilight' ],
486             },
487             },
488             altitude => {
489             title => 'Altitude',
490             },
491             angle => {
492             title => 'Angle',
493             },
494             apoapsis => {
495             title => 'Apoapsis',
496             },
497             apogee => {
498             title => 'Apogee',
499             },
500             argument_of_perigee => {
501             title => 'Argument Of Perigee',
502             },
503             ascending_node => {
504             title => 'Ascending Node',
505             },
506             azimuth => {
507             title => 'Azimuth',
508             },
509             bearing => {
510             table => [
511             [ qw{ N E S W } ],
512             [ qw{ N NE E SE S SW W NW } ],
513             [ qw{ N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW
514             NNW } ],
515             ],
516             },
517             b_star_drag => {
518             title => 'B Star Drag',
519             },
520             classification => {
521             title => 'Classification',
522             },
523             date => {
524             title => 'Date',
525             },
526             declination => {
527             title => 'Declination',
528             },
529             eccentricity => {
530             title => 'Eccentricity',
531             },
532             effective_date => {
533             title => 'Effective Date',
534             },
535             element_number => {
536             title => 'Element Number',
537             },
538             elevation => {
539             title => 'Elevation',
540             },
541             ephemeris_type => {
542             title => 'Ephemeris Type',
543             },
544             epoch => {
545             title => 'Epoch',
546             },
547             event => {
548             table => [ @event_names ],
549             title => 'Event',
550             },
551             first_derivative => {
552             title => 'First Derivative',
553             },
554             fraction_lit => {
555             title => 'Fraction Lit',
556             },
557             illumination => {
558             title => 'Illumination',
559             },
560             inclination => {
561             title => 'Inclination',
562             },
563             international => {
564             title => 'International Launch Designator',
565             },
566             latitude => {
567             title => 'Latitude',
568             },
569             longitude => {
570             title => 'Longitude',
571             },
572             magnitude => {
573             title => 'Magnitude',
574             },
575             maidenhead => {
576             title => 'Maidenhead Grid Square',
577             },
578             mean_anomaly => {
579             title => 'Mean Anomaly',
580             },
581             mean_motion => {
582             title => 'Mean Motion',
583             },
584             mma => {
585             title => 'MMA',
586             },
587             name => {
588             title => 'Name',
589             localize_value => {
590             Sun => 'Sun',
591             Moon => 'Moon',
592             },
593             },
594             oid => {
595             title => 'OID',
596             },
597             operational => {
598             title => 'Operational',
599             },
600             periapsis => {
601             title => 'Periapsis',
602             },
603             perigee => {
604             title => 'Perigee',
605             },
606             period => {
607             title => 'Period',
608             },
609             phase => {
610             table => [
611             [ 6.1 => 'new' ],
612             [ 83.9 => 'waxing crescent' ],
613             [ 96.1 => 'first quarter' ],
614             [ 173.9 => 'waxing gibbous' ],
615             [ 186.1 => 'full' ],
616             [ 263.9 => 'waning gibbous' ],
617             [ 276.1 => 'last quarter' ],
618             [ 353.9 => 'waning crescent' ],
619             ],
620             title => 'Phase',
621             },
622             range => {
623             title => 'Range',
624             },
625             revolutions_at_epoch => {
626             title => 'Revolutions At Epoch',
627             },
628             right_ascension => {
629             title => 'Right Ascension',
630             },
631             second_derivative => {
632             title => 'Second Derivative',
633             },
634             semimajor => {
635             title => 'Semimajor Axis',
636             },
637             semiminor => {
638             title => 'Semiminor Axis',
639             },
640             status => {
641             title => 'Status',
642             },
643             time => {
644             title => 'Time',
645             },
646             tle => {
647             title => 'TLE',
648             },
649             type => {
650             title => 'Type',
651             },
652             };
653              
654             __END__