52 #ifndef __PCL_AstrometricMetadata_h
53 #define __PCL_AstrometricMetadata_h
73 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
99 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
100 class PCL_CLASS ImageWindow;
103 class PCL_CLASS XISFReader;
104 class PCL_CLASS XISFWriter;
124 String wcsTransformationType;
133 String observationStartTime;
134 String observationEndTime;
140 String topLeftCoordinates;
141 String topRightCoordinates;
142 String bottomLeftCoordinates;
143 String bottomRightCoordinates;
159 : m_projection( x.m_projection->Clone() )
160 , m_transformWI( x.m_transformWI->Clone() )
161 , m_refSys( x.m_refSys )
162 , m_width( x.m_width )
163 , m_height( x.m_height )
164 , m_pixelSize( x.m_pixelSize )
165 , m_obsStartTime( x.m_obsStartTime )
166 , m_obsEndTime( x.m_obsEndTime )
167 , m_geoLongitude( x.m_geoLongitude )
168 , m_geoLatitude( x.m_geoLatitude )
169 , m_geoHeight( x.m_geoHeight )
170 , m_resolution( x.m_resolution )
171 , m_focalLength( x.m_focalLength )
172 , m_creationTime( x.m_creationTime )
173 , m_catalog( x.m_catalog )
174 , m_creatorApp( x.m_creatorApp )
175 , m_creatorModule( x.m_creatorModule )
176 , m_creatorOS( x.m_creatorOS )
177 , m_description( x.m_description )
207 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
236 m_projection = x.m_projection->Clone();
237 m_transformWI = x.m_transformWI->Clone();
238 m_refSys = x.m_refSys;
239 m_equinox = x.m_equinox;
241 m_height = x.m_height;
242 m_pixelSize = x.m_pixelSize;
243 m_obsStartTime = x.m_obsStartTime;
244 m_obsEndTime = x.m_obsEndTime;
245 m_geoLongitude = x.m_geoLongitude;
246 m_geoLatitude = x.m_geoLatitude;
247 m_geoHeight = x.m_geoHeight;
248 m_resolution = x.m_resolution;
249 m_focalLength = x.m_focalLength;
250 m_creationTime = x.m_creationTime;
251 m_catalog = x.m_catalog;
252 m_creatorApp = x.m_creatorApp;
253 m_creatorModule = x.m_creatorModule;
254 m_creatorOS = x.m_creatorOS;
255 m_description = x.m_description;
270 return !m_projection.IsNull() && !m_transformWI.IsNull();
305 DPoint& bottomLeftErrors,
DPoint& bottomRightErrors )
const;
357 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
359 void Write( pi::ImageWindow* window,
bool notify =
true )
const;
434 m_refSys = refSys.Trimmed();
490 return Rect( m_width, m_height );
499 return m_projection.Pointer();
508 return m_transformWI.Pointer();
511 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
514 return m_transformWI.Pointer();
524 return (focal > 0) ? m_pixelSize.OrElse( 0 )/focal * 0.18/
Const<double>::pi() : 0.0;
533 return ResolutionFromFocal( resolution );
576 template <
typename T>
580 throw Error(
"AstrometricMetadata::ResolutionAt(): No astrometric solution." );
581 DPoint pRD1, pRD2, pRD3, pRD4;
582 if ( !ImageToCelestial( pRD1,
DPoint( pI.
x, pI.
y - 0.5 ) )
583 || !ImageToCelestial( pRD2,
DPoint( pI.
x, pI.
y + 0.5 ) )
584 || !ImageToCelestial( pRD3,
DPoint( pI.
x - 0.5, pI.
y ) )
585 || !ImageToCelestial( pRD4,
DPoint( pI.
x + 0.5, pI.
y ) ) )
587 throw Error(
"AstrometricMetadata::ResolutionAt(): Failed to perform coordinate transformation(s)." );
589 return 0.5*(m_projection->Distance( pRD1, pRD2 ) + m_projection->Distance( pRD3, pRD4 ));
602 throw Error(
"AstrometricMetadata::SearchRadius(): No astrometric solution." );
604 if ( !ImageToCelestial( cRD,
DPoint( 0.5*m_width, 0.5*m_height ) ) )
605 throw Error(
"AstrometricMetadata::SearchRadius(): Failed to perform coordinate transformation." );
606 DPoint pRD1, pRD2, pRD3, pRD4;
607 if ( !ImageToCelestial( pRD1,
DPoint( 0, 0 ) )
608 || !ImageToCelestial( pRD2,
DPoint( m_width, 0 ) )
609 || !ImageToCelestial( pRD3,
DPoint( 0, m_height ) )
610 || !ImageToCelestial( pRD4,
DPoint( m_width, m_height ) ) )
614 return Max(
Max(
Max( m_projection->Distance( cRD, pRD1 ), m_projection->Distance( cRD, pRD2 ) ),
615 m_projection->Distance( cRD, pRD3 ) ),
616 m_projection->Distance( cRD, pRD4 ) );
625 return m_obsStartTime;
634 m_obsStartTime = startTime;
652 m_obsEndTime = endTime;
663 if ( !m_obsStartTime.IsDefined() )
665 if ( !m_obsEndTime.IsDefined() )
666 return m_obsStartTime;
667 return m_obsStartTime() + (m_obsEndTime() - m_obsStartTime())/2;
677 return m_geoLongitude;
690 if ( longitude > 180 )
692 else if ( longitude <= -180 )
694 if ( longitude < -180 || longitude > +180 )
695 throw Error(
"AstrometricMetadata::SetLocationLongitude(): Geographic longitude out of range." );
696 m_geoLongitude = longitude;
706 return m_geoLatitude;
719 if ( latitude < -90 || latitude > +90 )
720 throw Error(
"AstrometricMetadata::SetLocationLatitude(): Geographic latitude out of range." );
721 m_geoLatitude = latitude;
738 m_geoHeight = height;
751 m_geoLongitude.Undefine();
752 m_geoLatitude.Undefine();
753 m_geoHeight.Undefine();
770 m_pixelSize = pixelSize;
771 m_focalLength = FocalFromResolution( m_resolution );
781 return m_creationTime;
812 return m_creatorModule;
852 throw Error(
"AstrometricMetadata::ImageToCelestial(): No astrometric solution." );
853 if ( m_projection->Inverse( pRD, m_transformWI->Inverse( pI ) ) )
858 else if ( pRD.
x >= 360 )
898 throw Error(
"AstrometricMetadata::RawImageToCelestial(): No astrometric solution." );
899 return m_projection->Inverse( pRD, m_transformWI->Inverse( pI ) );
927 return ImageToCelestial( pRD,
DPoint( 0.5*m_width, 0.5*m_height ) );
953 throw Error(
"AstrometricMetadata::CelestialToImage(): No astrometric solution." );
955 if ( m_projection->Direct( pW, pRD ) )
957 pI = m_transformWI->Direct( pW );
1244 m_obsStartTime.Undefine();
1245 m_obsEndTime.Undefine();
1246 m_geoLongitude.Undefine();
1247 m_geoLatitude.Undefine();
1248 m_geoHeight.Undefine();
1261 m_obsStartTime = source.m_obsStartTime;
1262 m_obsEndTime = source.m_obsEndTime;
1263 m_geoLongitude = source.m_geoLongitude;
1264 m_geoLatitude = source.m_geoLatitude;
1265 m_geoHeight = source.m_geoHeight;
1281 m_obsStartTime.Undefine();
1286 m_obsEndTime.Undefine();
1289 m_geoLatitude = wcs.
latobs;
1290 m_geoHeight = wcs.
altobs;
1470 UpdateDescription();
1499 static void RemoveSplineWorldTransformationProperties(
PropertyArray& );
1501 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
1503 static void RemoveSplineWorldTransformationProperties( pi::ImageWindow* );
1508 static void RemoveSplineWorldTransformationProperties(
ImageWindow& );
1525 double m_resolution = 0;
1536 void UpdateDescription()
const;
A smart pointer with exclusive object ownership and optional automatic object destruction.
A simple exception with an associated error message.
A generic point in the two-dimensional space.
component x
Abscissa (horizontal, or X-axis coordinate).
component y
Ordinate (vertical, or Y-axis coordinate).
A generic rectangle in the two-dimensional space.
bool IsEmpty() const noexcept
High-level interface to an image window object in the PixInsight core application.
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
An object that can be in a defined or undefined state.
Base class of all projection systems.
An instant in any timescale.
A structure for management of WCS FITS header keywords and associated image properties.
Optional< double > altobs
Geodetic height of the observation location in meters.
Optional< double > longobs
Geodetic longitude of the observation location in degrees. Reckoned positive east of the reference me...
Optional< double > latobs
Geodetic latitude of the observation location in degrees. Reckoned positive north of the equator.
Optional< double > dateobs
Observation start time as a Julian date, UTC timescale.
Optional< double > dateend
Observation end time as a Julian date, UTC timescale.
constexpr const T & Max(const T &a, const T &b) noexcept