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();
303 void Verify(
DPoint& centerErrors,
305 DPoint& bottomLeftErrors,
DPoint& bottomRightErrors )
const;
324 void Validate(
double tolerance = 0.01 )
const;
336 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
338 void Write( pi::ImageWindow* window,
bool notify =
true )
const;
353 void Write(
ImageWindow& window,
bool notify =
true )
const;
413 m_refSys = refSys.Trimmed();
469 return Rect( m_width, m_height );
478 return m_projection.Pointer();
487 return m_transformWI.Pointer();
490 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
493 return m_transformWI.Pointer();
503 return (focal > 0) ? m_pixelSize.OrElse( 0 )/focal * 0.18/
Const<double>::pi() : 0.0;
512 return ResolutionFromFocal( resolution );
525 double Rotation(
bool& flipped )
const;
548 throw Error(
"Invalid call to AstrometricMetadata::SearchRadius(): No astrometric solution." );
550 if ( !ImageToCelestial( cRD,
DPoint( 0.5*m_width, 0.5*m_height ) ) )
551 throw Error(
"Failed to perform ImageToCelestial() coordinate transformation for the image center" );
552 DPoint pRD1, pRD2, pRD3, pRD4;
553 if ( !ImageToCelestial( pRD1,
DPoint( 0, 0 ) )
554 || !ImageToCelestial( pRD2,
DPoint( m_width, 0 ) )
555 || !ImageToCelestial( pRD3,
DPoint( 0, m_height ) )
556 || !ImageToCelestial( pRD4,
DPoint( m_width, m_height ) ) )
560 return Max(
Max(
Max( m_projection->Distance( cRD, pRD1 ), m_projection->Distance( cRD, pRD2 ) ),
561 m_projection->Distance( cRD, pRD3 ) ),
562 m_projection->Distance( cRD, pRD4 ) );
571 return m_obsStartTime;
580 m_obsStartTime = startTime;
598 m_obsEndTime = endTime;
609 if ( !m_obsStartTime.IsDefined() )
611 if ( !m_obsEndTime.IsDefined() )
612 return m_obsStartTime;
613 return m_obsStartTime() + (m_obsEndTime() - m_obsStartTime())/2;
623 return m_geoLongitude;
636 if ( longitude > 180 )
638 else if ( longitude <= -180 )
640 if ( longitude < -180 || longitude > +180 )
641 throw Error(
"AstrometricMetadata::SetLocationLongitude(): Geographic longitude out of range." );
642 m_geoLongitude = longitude;
652 return m_geoLatitude;
665 if ( latitude < -90 || latitude > +90 )
666 throw Error(
"AstrometricMetadata::SetLocationLatitude(): Geographic latitude out of range." );
667 m_geoLatitude = latitude;
684 m_geoHeight = height;
701 m_pixelSize = pixelSize;
702 m_focalLength = FocalFromResolution( m_resolution );
712 return m_creationTime;
743 return m_creatorModule;
783 throw Error(
"Invalid call to AstrometricMetadata::ImageToCelestial(): No astrometric solution." );
784 if ( m_projection->Inverse( pRD, m_transformWI->Inverse( pI ) ) )
789 else if ( pRD.
x >= 360 )
829 throw Error(
"Invalid call to AstrometricMetadata::RawImageToCelestial(): No astrometric solution." );
830 return m_projection->Inverse( pRD, m_transformWI->Inverse( pI ) );
856 throw Error(
"Invalid call to AstrometricMetadata::CelestialToImage(): No astrometric solution." );
858 if ( m_projection->Direct( pW, pRD ) )
860 pI = m_transformWI->Direct( pW );
1017 void UpdateWCSKeywords(
FITSKeywordArray& keywords,
bool generate =
false )
const;
1091 m_obsStartTime.Undefine();
1092 m_obsEndTime.Undefine();
1093 m_geoLongitude.Undefine();
1094 m_geoLatitude.Undefine();
1095 m_geoHeight.Undefine();
1153 static void RemoveKeywords(
FITSKeywordArray& keywords,
bool removeCenterKeywords =
true,
bool removeScaleKeywords =
true );
1171 static void RescalePixelSizeKeywords(
FITSKeywordArray& keywords,
double scalingFactor );
1221 static void RemoveProperties(
PropertyArray& properties,
bool removeCenterProperties =
true,
bool removeScaleProperties =
true );
1230 static void RemoveProperties(
ImageWindow& window,
bool removeCenterProperties =
true,
bool removeScaleProperties =
true );
1247 static void RescalePixelSizeProperties(
PropertyArray& properties,
double scalingFactor );
1256 static void RescalePixelSizeProperties(
ImageWindow& window,
double scalingFactor );
1275 UpdateDescription();
1282 static void RemoveSplineWorldTransformationProperties(
PropertyArray& );
1284 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
1286 static void RemoveSplineWorldTransformationProperties( pi::ImageWindow* );
1291 static void RemoveSplineWorldTransformationProperties(
ImageWindow& );
1308 double m_resolution = 0;
1319 void UpdateDescription()
const;
1324 #endif // __AstrometricMetadata_h