| 1 | package CXC::Astro::Regions::DS9::Types; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Types for DS9 Regions | ||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use v5.20; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 4 | our $VERSION = '0.05'; | |||||||||
| 9 | |||||||||||
| 10 | 4 | ▶ | use CXC::Types::Astro::Coords 'Sexagesimal'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 4 | ▶ | use Types::Standard qw( Enum Bool Num StrMatch ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 4 | ▶ | use Types::Common::Numeric qw( PositiveNum ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 4 | ▶ | use Type::Utils -all; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 4 | ▶ | use Regexp::Common qw( number ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | use Type::Library | ||||||||||
| 17 | 4 | ▶ | -base, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | -extends => [ 'Types::Common::Numeric', 'Types::Common::String', 'Types::Standard' ], | ||||||||||
| 19 | -declare => qw( | ||||||||||
| 20 | Angle | ||||||||||
| 21 | CoordSys | ||||||||||
| 22 | Length | ||||||||||
| 23 | LengthPair | ||||||||||
| 24 | OneZero | ||||||||||
| 25 | PointType | ||||||||||
| 26 | PositionAsNum | ||||||||||
| 27 | RulerCoords | ||||||||||
| 28 | Vertex | ||||||||||
| 29 | XPosition | ||||||||||
| 30 | YPosition | ||||||||||
| 31 | 4 | ); | |||||||||
| 32 | |||||||||||
| 33 | 4 | declare OneZero, as Enum [ 1, 0 ]; | |||||||||
| 34 | 3 | ▶ | coerce OneZero, from Bool->coercibles, via { to_Bool( $_ ) ? q{1} : q{0} }; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 35 | |||||||||||
| 36 | 4 | declare PositionAsNum, | |||||||||
| 37 | as StrMatch [qr{\A (?: $RE{num}{real} [drpi]?) \z}x]; | ||||||||||
| 38 | |||||||||||
| 39 | 4 | declare XPosition, | |||||||||
| 40 | as PositionAsNum | Sexagesimal( [ '-ra', '-units' ] ) | Sexagesimal( [ '-ra', '-sep' ] ); | ||||||||||
| 41 | 4 | declare YPosition, | |||||||||
| 42 | as PositionAsNum | Sexagesimal( [ '-dec', '-units' ] ) | Sexagesimal( [ '-dec', '-sep' ] ); | ||||||||||
| 43 | 4 | declare Vertex, as Tuple [ XPosition, YPosition ]; | |||||||||
| 44 | |||||||||||
| 45 | 4 | declare Length, as StrMatch [qr/$RE{num}{real} ["'drpi]?/x]; | |||||||||
| 46 | 4 | declare LengthPair, as Tuple [ Length, Length ]; | |||||||||
| 47 | |||||||||||
| 48 | 4 | declare Angle, as Num; | |||||||||
| 49 | |||||||||||
| 50 | ## no critic (RegularExpressions::ProhibitEnumeratedClasses) | ||||||||||
| 51 | 4 | declare CoordSys, as StrMatch->of( qr/wcs[a-z]/i ) | Enum->of( | |||||||||
| 52 | \1, # use Type::Tiny::Enum::closest_match | ||||||||||
| 53 | 'amplifier', | ||||||||||
| 54 | 'detector', | ||||||||||
| 55 | 'ecliptic', | ||||||||||
| 56 | 'fk4', | ||||||||||
| 57 | 'fk5', | ||||||||||
| 58 | 'galactic', | ||||||||||
| 59 | 'icrs', | ||||||||||
| 60 | 'image', | ||||||||||
| 61 | 'linear', | ||||||||||
| 62 | 'physical', | ||||||||||
| 63 | ), | ||||||||||
| 64 | coercion => 1; | ||||||||||
| 65 | |||||||||||
| 66 | 4 | declare PointType, as Enum [ | |||||||||
| 67 | \1, # use Type::Tiny::Enum::closest_match | ||||||||||
| 68 | qw( circle box diamond cross x arrow boxcircle ), | ||||||||||
| 69 | ], | ||||||||||
| 70 | coercion => 1; | ||||||||||
| 71 | |||||||||||
| 72 | 4 | declare RulerCoords, as Enum [ | |||||||||
| 73 | \1, # use Type::Tiny::Enum::closest_match | ||||||||||
| 74 | qw( pixels degrees arcmin arcsec ), | ||||||||||
| 75 | ], | ||||||||||
| 76 | coercion => 1; | ||||||||||
| 77 | |||||||||||
| 78 | 4 | 1; | |||||||||
| 79 | |||||||||||
| 80 | # | ||||||||||
| 81 | # This file is part of CXC-Astro-Regions | ||||||||||
| 82 | # | ||||||||||
| 83 | # This software is Copyright (c) 2023 by Smithsonian Astrophysical Observatory. | ||||||||||
| 84 | # | ||||||||||
| 85 | # This is free software, licensed under: | ||||||||||
| 86 | # | ||||||||||
| 87 | # The GNU General Public License, Version 3, June 2007 | ||||||||||
| 88 | # | ||||||||||
| 89 | |||||||||||
| 90 | __END__ | ||||||||||