Astro-App-Satpass2
view release on metacpan or search on metacpan
eg/pass_ics view on Meta::CPAN
# Astro::App::Satpass2 source file. Invoke as (e.g.)
# satpass2> source eg/pass_vcalendar
#
# Do satellite pass calculations, displaying the results in vCalendar
# format. The output may be redirected to a .vcal file. The start and
# end dates for the pass calculation can be passed as arguments to the
# 'source' statement, and default to 'today noon' and '+8' respectively.
# This whole thing (less the comments) could be wrapped up as a macro
# if desired.
# CAVEAT: My ancient Palm desktop software appears not to properly
# handle the switch between normal and daylight-saving time
# (a.k.a. summer time), in that predictions made before the switch
# for events after the switch get assigned the wrong time, even
# though the UT event time is correct in the emitted file. I have
# not changed the event times to local time eg/flare_vcalendar
# because the vcalendar standard specifies UT.
localize formatter
# An iCal file is supposed to have <cr><lf> line breaks
# set output_layers :encoding(utf-8):crlf
# The individual pass events get concatenated to the description, with
# no newline between.
formatter template pass <<'EOD'
[% UNLESS data %]
[%- SET data = sp.pass( arg ) %]
[%- END -%]
BEGIN:VCALENDAR
VERSION:2.0
[%- FOR pass IN data %]
[%- events = pass.events %]
[%- CALL events.fixed_width( 0 ) %]
[%- first = events.first %]
[%- punct = '' %]
BEGIN:VEVENT
DTSTART:[% first.date( format = '%Y%m%dT%H%M%SZ', units = 'zulu' ) %]
BEGIN:VALARM
TRIGGER:-PT5M
ACTION:DISPLAY
END:VALARM
BEGIN:VALARM
TRIGGER:PT0M
ACTION:DISPLAY
END:VALARM
SUMMARY:[% first.name %]
DESCRIPTION:
[%- FOREACH evt IN events %][% punct %]
[%- evt_name = evt.event %]
[%- end_date = evt.date( format = '%Y%m%dT%H%M%SZ', units = 'z' ) %]
[%- evt_name %]
[%- IF 'apls' == evt_name %]
[%- appulse = evt.appulse %]
[%= appulse.angle %]
[%= appulse.name %]
[%- END %]
[%= evt.time %] Az
[%= evt.azimuth( places = 0, bearing = 2 ) %]
[%- IF 'rise' != evt_name and 'set' != evt_name %] Ele
[%= evt.elevation( places = 0 ) %]
[%- END %]
[%- IF '' != evt.magnitude %] Mag
[%= evt.magnitude %]
[%- END %]
[%- punct = '\n' %]
[%- END %]
DTEND:[% end_date %]
END:VEVENT
( run in 1.937 second using v1.01-cache-2.11-cpan-d8267643d1d )