52 #ifndef __PCL_APASSDatabaseFile_h
53 #define __PCL_APASSDatabaseFile_h
85 namespace APASSStarFlag
203 static_assert(
sizeof( EncodedDR9StarData ) == 32,
"Invalid sizeof( APASSDatabaseFile::EncodedDR9StarData )" );
204 static_assert(
sizeof( EncodedDR10StarData ) == 36,
"Invalid sizeof( APASSDatabaseFile::EncodedDR10StarData )" );
205 if (
Metadata().databaseIdentifier ==
"APASSDR9" )
208 m_decoder = &APASSDatabaseFile::GetEncodedDR9Data;
210 else if (
Metadata().databaseIdentifier ==
"APASSDR10" )
213 m_decoder = &APASSDatabaseFile::GetEncodedDR10Data;
216 throw Error(
"Invalid or unsupported APASS database file with unknown identifier '"
217 +
Metadata().databaseIdentifier +
"': " + filePath );
271 for (
const XPSD::IndexTree& tree : m_index )
290 using star_decoder = void (
APASSDatabaseFile::*)(
const ByteArray&,
const XPSD::IndexTree&,
const XPSD::IndexNode&,
void* )
const;
291 star_decoder m_decoder =
nullptr;
293 #pragma pack(push, 1)
298 struct EncodedDR9StarData
325 struct EncodedDR10StarData
357 void GetEncodedData(
const ByteArray& data,
const XPSD::IndexTree& tree,
const XPSD::IndexNode& node,
void* searchData )
const override
359 (this->*m_decoder)( data, tree, node, searchData );
362 void GetEncodedDR9Data(
const ByteArray& data,
const XPSD::IndexTree& tree,
const XPSD::IndexNode& node,
void* searchData )
const
366 double r =
Rad( search->radius );
367 const EncodedDR9StarData* S =
reinterpret_cast<const EncodedDR9StarData*
>( data.Begin() );
368 int count = int( data.Size() /
sizeof( EncodedDR9StarData ) );
370 for (
int i = 0; i < count; ++i, ++S )
371 if ( search->requiredFlags == 0 || (S->flags & search->requiredFlags) == search->requiredFlags )
372 if ( search->inclusionFlags == 0 || (S->flags & search->inclusionFlags) != 0 )
373 if ( search->exclusionFlags == 0 || (S->flags & search->exclusionFlags) == 0 )
375 float mag_V = 0.001*S->mag_V - 1.5;
376 if ( mag_V >= search->magnitudeLow )
377 if ( mag_V <= search->magnitudeHigh )
380 double x = node.x0 + double( S->dx )/3600/1000;
381 double y = node.y0 + double( S->dy )/3600/1000;
382 tree.Unproject( star.ra, star.dec, x, y );
383 if ( unlikely( S->dra != 0 ) )
385 star.ra += double( S->dra )/3600/1000/10;
388 else if ( star.ra >= 360 )
391 if (
Distance( search->centerRA, search->centerDec, star.ra, star.dec ) < r )
393 if ( search->stars.Length() <
size_type( search->sourceLimit ) )
396 star.mag_B = 0.001*S->mag_B - 1.5;
397 star.mag_g = 0.001*S->mag_g - 1.5;
398 star.mag_r = 0.001*S->mag_r - 1.5;
399 star.mag_i = 0.001*S->mag_i - 1.5;
400 star.err_V = 0.001*S->err_V;
401 star.err_B = 0.001*S->err_B;
402 star.err_g = 0.001*S->err_g;
403 star.err_r = 0.001*S->err_r;
404 star.err_i = 0.001*S->err_i;
405 star.flags = S->flags;
406 search->stars << star;
409 ++search->excessCount;
415 search->rejectCount += count - matched;
416 search->timeDecode += T();
419 void GetEncodedDR10Data(
const ByteArray& data,
const XPSD::IndexTree& tree,
const XPSD::IndexNode& node,
void* searchData )
const
423 double r =
Rad( search->radius );
424 const EncodedDR10StarData* S =
reinterpret_cast<const EncodedDR10StarData*
>( data.Begin() );
425 int count = int( data.Size() /
sizeof( EncodedDR10StarData ) );
427 for (
int i = 0; i < count; ++i, ++S )
428 if ( search->requiredFlags == 0 || (S->flags & search->requiredFlags) == search->requiredFlags )
429 if ( search->inclusionFlags == 0 || (S->flags & search->inclusionFlags) != 0 )
430 if ( search->exclusionFlags == 0 || (S->flags & search->exclusionFlags) == 0 )
432 float mag_V = 0.001*S->mag_V - 1.5;
433 if ( mag_V >= search->magnitudeLow )
434 if ( mag_V <= search->magnitudeHigh )
437 double x = node.x0 + double( S->dx )/3600/1000;
438 double y = node.y0 + double( S->dy )/3600/1000;
439 tree.Unproject( star.ra, star.dec, x, y );
440 if ( unlikely( S->dra != 0 ) )
442 star.ra += double( S->dra )/3600/1000/10;
445 else if ( star.ra >= 360 )
448 if (
Distance( search->centerRA, search->centerDec, star.ra, star.dec ) < r )
450 if ( search->stars.Length() <
size_type( search->sourceLimit ) )
453 star.mag_B = 0.001*S->mag_B - 1.5;
455 star.mag_g = 0.001*S->mag_g - 1.5;
456 star.mag_r = 0.001*S->mag_r - 1.5;
457 star.mag_i = 0.001*S->mag_i - 1.5;
458 star.mag_z_s = 0.001*S->mag_z_s - 1.5;
460 star.err_V = 0.001*S->err_V;
461 star.err_B = 0.001*S->err_B;
463 star.err_g = 0.001*S->err_g;
464 star.err_r = 0.001*S->err_r;
465 star.err_i = 0.001*S->err_i;
466 star.err_z_s = 0.001*S->err_z_s;
468 star.flags = S->flags;
469 search->stars << star;
472 ++search->excessCount;
478 search->rejectCount += count - matched;
479 search->timeDecode += T();
482 friend class APASSDR9DatabaseFileGenerator;
483 friend class APASSDR10DatabaseFileGenerator;
APASS catalog star database file (XPSD format).
void Search(APASSSearchData &data) const
APASSDatabaseFile(const String &filePath)
const IsoString & DataRelease() const
APASSDatabaseFile(const APASSDatabaseFile &)=delete
APASSDatabaseFile()=default
Dynamic array of 8-bit unsigned integers.
High-resolution time stamp.
A simple exception with an associated error message.
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Point source and star catalog database files (XPSD format).
constexpr T Rad(T x) noexcept
distance_type Distance(FI i, FI j)
Data items and parameters for APASS catalog search operations.
Star data structure for APASS catalog search operations.
double radius
Field radius in degrees (search parameter).
double centerDec
Field center declination coordinate in degrees (search parameter).
double centerRA
Field center right ascension coordinate in degrees (search parameter).
double timeTotal
Total search time in seconds (output data).
Data items and parameters for catalog search operations.