File Coverage

blib/lib/CXC/Astro/Regions/DS9/Types.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 31 31 100.0


line stmt bran cond sub pod time code
1             package CXC::Astro::Regions::DS9::Types;
2              
3             # ABSTRACT: Types for DS9 Regions
4              
5 4     4   601179 use v5.20;
  4         21  
6 4     4   25 use warnings;
  4         7  
  4         328  
7              
8             our $VERSION = '0.03';
9              
10 4     4   2352 use CXC::Types::Astro::Coords 'Sexagesimal';
  4         2276226  
  4         48  
11              
12 4     4   5959 use Types::Standard qw( Enum Bool Num StrMatch );
  4         8  
  4         34  
13 4     4   11178 use Types::Common::Numeric qw( PositiveNum );
  4         8  
  4         28  
14 4     4   2946 use Type::Utils -all;
  4         10  
  4         27  
15 4     4   11152 use Regexp::Common qw( number );
  4         8  
  4         49  
16             use Type::Library
17 4         26 -base,
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     4   831 );
  4         13  
32              
33             declare OneZero, as Enum [ 1, 0 ];
34             coerce OneZero, from Bool->coercibles, via { to_Bool( $_ ) ? q{1} : q{0} };
35              
36             declare PositionAsNum,
37             as StrMatch [qr{\A (?: $RE{num}{real} [drpi]?) \z}x];
38              
39             declare XPosition,
40             as PositionAsNum | Sexagesimal( [ '-ra', '-units' ] ) | Sexagesimal( [ '-ra', '-sep' ] );
41             declare YPosition,
42             as PositionAsNum | Sexagesimal( [ '-dec', '-units' ] ) | Sexagesimal( [ '-dec', '-sep' ] );
43             declare Vertex, as Tuple [ XPosition, YPosition ];
44              
45             declare Length, as StrMatch [qr/$RE{num}{real} ["'drpi]?/x];
46             declare LengthPair, as Tuple [ Length, Length ];
47              
48             declare Angle, as Num;
49              
50             ## no critic (RegularExpressions::ProhibitEnumeratedClasses)
51             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             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             declare RulerCoords, as Enum [
73             \1, # use Type::Tiny::Enum::closest_match
74             qw( pixels degrees arcmin arcsec ),
75             ],
76             coercion => 1;
77              
78             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__