The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CXC::Types::Astro::Coords::Util - Coordinate Type utilities

VERSION

version 0.12

SUBROUTINES

mkSexagesimal

 %type_components = mkSexagesimal( @flags );

Create components used to create validation and coercion routines for Sexagesimal types in CXC::Types::Astro::Coords.

The input is a list of flags (strings) which control the type of quantities to be recognized by the type. The output is a hash.

The input flags are:

  • coordinate systems

    These flags specify the coordinate system to recognize. The default is -any.

    It determines the accepted ranges on the coordinate components, the range of the coordinate after adding the components, and the accepted units for the components:

       +-----------+------------------------------+----------+-----------+
       |  Flag     |      Component's Range       |   Full   |   Units   |
       +-----------+----------+---------+---------+----------+-----------+
       | -ra       |   [0, 23]| [0, 59] | [0 ,60) |  [0,24)  |  h, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -dec      | [-90, 90]| [0, 59] | [0, 60) | [-90,90] |  d, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -deg      |  [0, 359]| [0, 59] | [0, 60) | [0,360)  |  d, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -lat      | [-90, 90]| [0, 59] | [0, 60) | [-90,90] |  d, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -long     |  [0, 359]| [0, 59] | [0, 60) | [0,360)  |  d, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -negdeg   |   none   | [0, 59] | [0, 60) |   none   |  d, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -neglong  |   none   | [0, 59] | [0, 60) |   none   |  d, m, s  |
       +-----------+----------+---------+---------+----------+-----------+
       | -any      |   none   | [0, 59] | [0, 60) |   none   | d|h, m, s |
       +-----------+----------+---------+---------+----------+-----------+

    The -any flag assumes that the input is in degrees, unless the d unit is specified. It always converts hours into degrees.

  • -units, -optunits

    Unit specification is required or optional.

  • -sep, -optsep

    The : character between components is required or optional. If -optsep is specified,

  • -ws, -optws

    White space is required or optional between components or after the unit. White space is never allowed before the unit.

    For example

     22h 5m 3.2s

    But not

     22 h 5 m 3.2 s
  • -trim

    leading and trailing white space is ignored.

The following combination of parse flags are legal:

 -sep
 -sep, -ws
 -sep, -optws

 -optsep, -optunits, -optws
 -optsep, -optunits, -ws
 -optsep, -optws
 -optsep, -ws

 -units
 -units, -optws
 -units, -ws

 -optunits, -optws
 -optunits, -ws

 -ws

Do not specify more than one coordinate system.

Other combinations may be nonsensical and result in an unmatchable regular expression. For example, -optsep without either -optws or -optunits is essentially -sep.

The output is a hash with the following elements:

  • qr

    A string containing the regular expression to match. This is not a compiled regular expression.

  • constraint

    A string containing code suitable to be passed as the constraint parameter to the Type::Tiny constructor.

  • Str_toArrayRef

    A string containing code suitable to be passed to the Type::Util coerce command, e.g.

  • StrMatch_toArrayRef

    A string containing code, which when executed directly after a successful match against qr returns an arrayref with the three coordinate components (degrees, minutes, seconds).

  • ArrayRef_toDegrees

    A string containing code returning the coordinate in degrees. It the coordinate components to be available in an array named @array.

from_Degrees

  \@components = from_Degrees( $degrees, $output_coord );

Convert from degrees to a three element array of the coordinate components.

$output_coord is one of the coordinate systems supported by "mkSexagesimal".

SUPPORT

Bugs

Please report any bugs or feature requests to bug-cxc-types-astro-coords@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=CXC-Types-Astro-Coords

Source

Source is available at

  https://gitlab.com/djerius/cxc-types-astro-coords

and may be cloned from

  https://gitlab.com/djerius/cxc-types-astro-coords.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHORS

  • Terry Gaetz <tgaetz@cfa.harvard.edu>

  • Diab Jerius <djerius@cfa.harvard.edu>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007