PCL
EphemerisFile.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.4.9
6 // ----------------------------------------------------------------------------
7 // pcl/EphemerisFile.h - Released 2021-04-09T19:40:59Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2021 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_EphemerisFile_h
53 #define __PCL_EphemerisFile_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/Atomic.h>
60 #include <pcl/AutoLock.h>
61 #include <pcl/ChebyshevFit.h>
62 #include <pcl/File.h>
63 #include <pcl/Mutex.h>
64 #include <pcl/Optional.h>
65 #include <pcl/TimePoint.h>
66 
67 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
68 namespace pi
69 {
70  class JSEphemerisFileObject;
71  class JSEphemerisHandleObject;
72 }
73 #endif
74 
75 namespace pcl
76 {
77 
78 // ----------------------------------------------------------------------------
79 
97 struct PCL_CLASS EphemerisMetadata
98 {
108 };
109 
110 // ----------------------------------------------------------------------------
111 
127 struct PCL_CLASS EphemerisConstant
128 {
130  double value;
131 
135  EphemerisConstant( const IsoString& n = IsoString(), double v = 0 )
136  : name( n )
137  , value( v )
138  {
139  }
140 
144  EphemerisConstant( const EphemerisConstant& ) = default;
145 
149  EphemerisConstant( EphemerisConstant&& ) = default;
150 
154  EphemerisConstant& operator =( const EphemerisConstant& ) = default;
155 
159  EphemerisConstant& operator =( EphemerisConstant&& ) = default;
160 
165  bool operator ==( const EphemerisConstant& x ) const
166  {
167  return name.CompareIC( x.name ) == 0;
168  }
169 
175  bool operator <( const EphemerisConstant& x ) const
176  {
177  return name.CompareIC( x.name ) < 0;
178  }
179 };
180 
193 
194 // ----------------------------------------------------------------------------
195 
217 {
223 
232 
237  : startTime( t )
238  , expansion( T )
239  {
240  }
241 
246 
251 
255  SerializableEphemerisData& operator =( const SerializableEphemerisData& ) = default;
256 
260  SerializableEphemerisData& operator =( SerializableEphemerisData&& ) = default;
261 };
262 
281 
282 // ----------------------------------------------------------------------------
283 
311 {
323 
339 
349 
355 
364  SerializableEphemerisDataList data[ 2 ];
365 
366  /*
367  * Absolute magnitude. H is the visual magnitude of the object as seen at 1
368  * au of the Earth, 1 au from the Sun, and with a phase angle of 0 degrees.
369  *
370  * <b>References</b>
371  *
372  * E. Bowell et al., <em>Asteroids II</em>, R. P. Binzel et al. (eds.), The
373  * University of Arizona Press, Tucson, 1989, pp. 549-554.
374  *
375  * Urban, Sean E., Kenneth Seidelmann, P., ed. (2013), <em>The Explanatory
376  * Supplement to the Astronomical Almanac</em> 3rd Edition, Section 10.4.3.
377  */
379 
380  /*
381  * Slope parameter. See the H data member for references.
382  */
384 
385  /*
386  * Color index B-V in magnitudes.
387  */
388  Optional<double> B_V;
389 
390  /*
391  * Diameter of the object in km.
392  */
394 
399  const IsoString& origin,
400  const String& name = String(),
401  const String& desc = String() )
402  : objectId( id.Trimmed() )
403  , originId( origin.Trimmed() )
404  , objectName( name.Trimmed() )
405  , description( desc )
406  {
407  }
408 
413 
418 
423 
428 };
429 
436 
437 // ----------------------------------------------------------------------------
438 
453 struct PCL_CLASS EphemerisObject
454 {
467 
481 
489 
494 
508 
513 
518 
523 
527  EphemerisObject( const IsoString& objectId_,
528  const IsoString& originId_,
529  const String& objectName_ = String(),
530  const String& objectDescription_ = String(),
535  : objectId( objectId_ )
536  , originId( originId_ )
537  , objectName( objectName_ )
538  , objectDescription( objectDescription_ )
539  , H( H_ )
540  , G( G_ )
541  , B_V( B_V_ )
542  , D( D_ )
543  {
544  }
545 
549  EphemerisObject( const EphemerisObject& ) = default;
550 
554  EphemerisObject( EphemerisObject&& ) = default;
555 
559  EphemerisObject& operator =( const EphemerisObject& ) = default;
560 
564  EphemerisObject& operator =( EphemerisObject&& ) = default;
565 };
566 
573 
574 // ----------------------------------------------------------------------------
575 
615 class PCL_CLASS EphemerisFile
616 {
617 public:
618 
625  EphemerisFile() = default;
626 
634  EphemerisFile( const String& filePath )
635  {
636  Open( filePath );
637  }
638 
643  : m_file( std::move( x.m_file ) )
644  , m_startTime( x.m_startTime )
645  , m_endTime( x.m_endTime )
646  , m_constants( std::move( x.m_constants ) )
647  , m_index( std::move( x.m_index ) )
648  {
649  }
650 
654  EphemerisFile& operator =( EphemerisFile&& x )
655  {
656  m_file = std::move( x.m_file );
657  m_startTime = x.m_startTime;
658  m_endTime = x.m_endTime;
659  m_constants = std::move( x.m_constants );
660  m_index = std::move( x.m_index );
661  return *this;
662  }
663 
668  EphemerisFile( const EphemerisFile& ) = delete;
669 
674  EphemerisFile& operator =( const EphemerisFile& ) = delete;
675 
679  virtual ~EphemerisFile() noexcept( false );
680 
698  void Open( const String& filePath );
699 
713  void Close();
714 
719  bool IsOpen() const
720  {
721  return m_file.IsOpen();
722  }
723 
728  const String& FilePath() const
729  {
730  return m_file.FilePath();
731  }
732 
739  {
740  return m_startTime;
741  }
742 
748  {
749  return m_endTime;
750  }
751 
764  const EphemerisConstantList& Constants() const
765  {
766  return m_constants;
767  }
768 
773  bool IsConstantAvailable( const IsoString& name ) const
774  {
775  return BinarySearch( m_constants.Begin(), m_constants.End(),
776  EphemerisConstant( name ) ) != m_constants.End();
777  }
778 
786  double ConstantValue( const IsoString& name ) const
787  {
789  BinarySearch( m_constants.Begin(), m_constants.End(), EphemerisConstant( name ) );
790  if ( i == m_constants.End() )
791  throw Error( "Undefined ephemeris constant '" + name + '\'' );
792  return i->value;
793  }
794 
802  EphemerisObjectList Objects() const
803  {
804  EphemerisObjectList objects;
805  for ( const Index& ix : m_index )
806  objects << EphemerisObject( ix.objectId, ix.originId,
807  ix.objectName, ix.objectDescription,
808  ix.H, ix.G, ix.B_V, ix.D );
809  return objects;
810  }
811 
835  bool IsObjectAvailable( const IsoString& object, const IsoString& origin = IsoString() ) const
836  {
837  Array<Index>::const_iterator i = BinarySearch( m_index.Begin(), m_index.End(), Index( object, origin ) );
838  if ( i != m_index.End() )
839  return true;
840  String name = object.UTF8ToUTF16();
841  for ( const Index& index : m_index )
842  if ( index.objectName.CompareIC( name ) == 0 )
843  if ( origin.IsEmpty() || index.originId == origin )
844  return true;
845  return false;
846  }
847 
861  String ObjectName( const IsoString& object, const IsoString& origin = IsoString() ) const
862  {
863  Array<Index>::const_iterator i = BinarySearch( m_index.Begin(), m_index.End(), Index( object, origin ) );
864  if ( i != m_index.End() )
865  return i->objectName;
866  return String();
867  }
868 
874  {
875  return m_metadata;
876  }
877 
890  int NumberOfHandles() const
891  {
892  return m_handleCount.Load();
893  }
894 
943  static void Serialize( const String& filePath,
944  TimePoint startTime, TimePoint endTime,
945  const SerializableEphemerisObjectDataList& data,
946  const EphemerisMetadata& metadata = EphemerisMetadata(),
947  const EphemerisConstantList& constants = EphemerisConstantList() );
948 
997  static const EphemerisFile& FundamentalEphemerides();
998 
1020  static const EphemerisFile& ShortTermFundamentalEphemerides();
1021 
1060  static const EphemerisFile& AsteroidEphemerides();
1061 
1083  static const EphemerisFile& ShortTermAsteroidEphemerides();
1084 
1139  static const EphemerisFile& KBOEphemerides();
1140 
1161  static const EphemerisFile& ShortTermKBOEphemerides();
1162 
1183  static const EphemerisFile& NutationModel();
1184 
1211  static const EphemerisFile& ShortTermNutationModel();
1212 
1248  static String DeltaTDataFilePath();
1249 
1272  static String DeltaATDataFilePath();
1273 
1290  static String CIP_ITRSDataFilePath();
1291 
1308  static void OverrideFundamentalEphemerides( const String& filePath );
1309 
1327  static void OverrideShortTermFundamentalEphemerides( const String& filePath );
1328 
1345  static void OverrideAsteroidEphemerides( const String& filePath );
1346 
1363  static void OverrideShortTermAsteroidEphemerides( const String& filePath );
1364 
1381  static void OverrideKBOEphemerides( const String& filePath );
1382 
1400  static void OverrideShortTermKBOEphemerides( const String& filePath );
1401 
1418  static void OverrideNutationModel( const String& filePath );
1419 
1437  static void OverrideShortTermNutationModel( const String& filePath );
1438 
1458  static void OverrideDeltaTDataFilePath( const String& filePath );
1459 
1479  static void OverrideDeltaATDataFilePath( const String& filePath );
1480 
1501  static void OverrideCIP_ITRSDataFilePath( const String& filePath );
1502 
1503 private:
1504 
1509  struct IndexNode
1510  {
1511  int32 jdi = 0; // Starting point of time span covered by this expansion, int( JD ).
1512  float jdf = 0; // Ditto, frac( JD ).
1513  uint8 n[ 4 ] = {}; // For each component: number of Chebyshev coefficients in this expansion.
1514  int64 position = 0; // File byte position of first Chebyshev coefficient.
1515 
1516  constexpr bool operator ==( const IndexNode& n ) const
1517  {
1518  return jdi == n.jdi && jdf == n.jdf;
1519  }
1520 
1521  constexpr bool operator <( const IndexNode& n ) const
1522  {
1523  return jdi < n.jdi || jdi == n.jdi && jdf < n.jdf;
1524  }
1525 
1526  constexpr int NumberOfComponents() const
1527  {
1528  return (n[0] > 0) ? ((n[1] > 0) ? ((n[2] > 0) ? ((n[3] > 0) ? 4 : 3) : 2) : 1) : 0;
1529  }
1530 
1531  constexpr int NumberOfCoefficients() const
1532  {
1533  return n[0] + n[1] + n[2] + n[3];
1534  }
1535 
1536  TimePoint StartTime() const
1537  {
1538  return TimePoint( jdi, jdf );
1539  }
1540  };
1541 
1546  struct Index
1547  {
1548  IsoString objectId; // Object identifier (mandatory, case-sensitive).
1549  IsoString originId; // Identifier of the origin of coordinates (mandatory, case-sensitive).
1550  String objectName; // Object name (optional, case-insensitive).
1551  String objectDescription; // Object description (optional, arbitrary)
1552  Optional<double> H; // Absolute magnitude.
1553  Optional<double> G; // Slope parameter.
1554  Optional<double> B_V; // Color index B-V in magnitudes.
1555  Optional<double> D; // Diameter of the object in km.
1556  Array<IndexNode> nodes[ 2 ]; // Expansion indexes: 0=function 1=derivative.
1557 
1558  Index( const IsoString& objectId_,
1559  const IsoString& originId_ = IsoString(),
1560  const String& objectName_ = String(),
1561  const String& objectDescription_ = String() )
1562  : objectId( objectId_.Trimmed() )
1563  , originId( originId_.Trimmed() )
1564  , objectName( objectName_.Trimmed() )
1565  , objectDescription( objectDescription_.Trimmed() )
1566  {
1567  }
1568 
1569  bool operator ==( const Index& x ) const
1570  {
1571  return objectId == x.objectId && originId == x.originId;
1572  }
1573 
1574  bool operator <( const Index& x ) const
1575  {
1576  return (objectId != x.objectId) ? objectId < x.objectId : originId < x.originId;
1577  }
1578 
1579  bool HasDerivative() const
1580  {
1581  return !nodes[1].IsEmpty();
1582  }
1583  };
1584 
1585  mutable File m_file;
1586  mutable AtomicInt m_handleCount;
1587  mutable Mutex m_mutex;
1588  TimePoint m_startTime;
1589  TimePoint m_endTime;
1590  EphemerisMetadata m_metadata;
1591  EphemerisConstantList m_constants;
1592  Array<Index> m_index;
1593 
1594  // Current data files.
1595  // If empty, i.e. if not overridden, use platform defaults.
1596  static String s_ephFilePath;
1597  static String s_ephFilePath_s;
1598  static String s_astFilePath;
1599  static String s_astFilePath_s;
1600  static String s_kboFilePath;
1601  static String s_kboFilePath_s;
1602  static String s_nutFilePath;
1603  static String s_nutFilePath_s;
1604  static String s_deltaTFilePath;
1605  static String s_deltaATFilePath;
1606  static String s_cipITRSFilePath;
1607 
1613  const Index* FindObject( const IsoString& object, const IsoString& origin ) const
1614  {
1615  if ( origin.IsEmpty() )
1616  {
1617  for ( const Index& index : m_index )
1618  if ( index.objectId == object )
1619  return &index;
1620  }
1621  else
1622  {
1623  Array<Index>::const_iterator i = BinarySearch( m_index.Begin(), m_index.End(), Index( object, origin ) );
1624  if ( i != m_index.End() )
1625  return i;
1626  }
1627  String name = object.UTF8ToUTF16();
1628  for ( const Index& index : m_index )
1629  if ( index.objectName.CompareIC( name ) == 0 )
1630  if ( origin.IsEmpty() || index.originId == origin )
1631  return &index;
1632  throw Error( "Unavailable object '" + name + "\' with origin '" + String( origin ) + "'." );
1633  }
1634 
1635 public:
1636 
1663  class PCL_CLASS Handle
1664  {
1665  public:
1666 
1693  Handle( const EphemerisFile& parent, const IsoString& object, const IsoString& origin = IsoString() )
1694  {
1695  if ( !parent.IsOpen() )
1696  throw Error( "Cannot create a handle to a closed ephemeris file." );
1697  m_parent = &parent;
1698  m_parent->m_handleCount.Increment();
1699  m_index = m_parent->FindObject( object, origin );
1700  }
1701 
1705  Handle( const Handle& x )
1706  {
1707  m_parent = x.m_parent;
1708  m_index = x.m_index;
1709  m_node[0] = x.m_node[0];
1710  m_node[1] = x.m_node[1];
1711  m_node[2] = x.m_node[2];
1712  if ( m_parent != nullptr )
1713  m_parent->m_handleCount.Increment();
1714  }
1715 
1720  {
1721  m_parent = x.m_parent;
1722  x.m_parent = nullptr;
1723  m_index = x.m_index;
1724  m_node[0] = x.m_node[0];
1725  m_node[1] = x.m_node[1];
1726  m_node[2] = x.m_node[2];
1727  }
1728 
1732  virtual ~Handle()
1733  {
1734  if ( m_parent != nullptr )
1735  m_parent->m_handleCount.Decrement();
1736  }
1737 
1741  Handle& operator =( const Handle& x )
1742  {
1743  if ( m_parent != nullptr )
1744  m_parent->m_handleCount.Decrement();
1745  m_parent = x.m_parent;
1746  m_index = x.m_index;
1747  m_node[0] = x.m_node[0];
1748  m_node[1] = x.m_node[1];
1749  m_node[2] = x.m_node[2];
1750  if ( m_parent != nullptr )
1751  m_parent->m_handleCount.Increment();
1752  return *this;
1753  }
1754 
1758  Handle& operator =( Handle&& x )
1759  {
1760  if ( m_parent != nullptr )
1761  m_parent->m_handleCount.Decrement();
1762  m_parent = x.m_parent;
1763  x.m_parent = nullptr;
1764  m_index = x.m_index;
1765  m_node[0] = x.m_node[0];
1766  m_node[1] = x.m_node[1];
1767  m_node[2] = x.m_node[2];
1768  return *this;
1769  }
1770 
1795  {
1796  Update( t, 0 );
1797  p = m_node[0].expansion( t - m_node[0].startTime );
1798  }
1799 
1836  {
1837  ComputeState( p, t );
1838  ComputeFirstDerivative( v, t );
1839  }
1840 
1872  {
1873  if ( HasDerivative() )
1874  Update( t, 1 );
1875  else if ( m_node[1].current != m_node[0].current )
1876  {
1877  m_node[1].current = m_node[0].current;
1878  m_node[1].startTime = m_node[0].startTime;
1879  m_node[1].endTime = m_node[0].endTime;
1880  m_node[1].expansion = m_node[0].expansion.Derivative();
1881  }
1882  v = m_node[1].expansion( t - m_node[1].startTime );
1883  }
1884 
1916  {
1917  if ( HasDerivative() )
1918  Update( t, 1 );
1919  else if ( m_node[1].current != m_node[0].current )
1920  {
1921  m_node[1].current = m_node[0].current;
1922  m_node[1].startTime = m_node[0].startTime;
1923  m_node[1].endTime = m_node[0].endTime;
1924  m_node[1].expansion = m_node[0].expansion.Derivative();
1925  }
1926  if ( m_node[2].current != m_node[0].current )
1927  {
1928  m_node[2].current = m_node[0].current;
1929  m_node[2].startTime = m_node[0].startTime;
1930  m_node[2].endTime = m_node[0].endTime;
1931  m_node[2].expansion = m_node[1].expansion.Derivative();
1932  }
1933  a = m_node[2].expansion( t - m_node[2].startTime );
1934  }
1935 
1948  {
1949  Vector p;
1950  ComputeState( p, t );
1951  return p;
1952  }
1953 
1969  {
1970  Vector p, v;
1971  ComputeState( p, v, t );
1972  return MultiVector( p, v );
1973  }
1974 
1989  {
1990  Vector v;
1991  ComputeFirstDerivative( v, t );
1992  return v;
1993  }
1994 
2009  {
2010  Vector v;
2011  ComputeSecondDerivative( v, t );
2012  return v;
2013  }
2014 
2019  const EphemerisFile& ParentFile() const
2020  {
2021  return *m_parent;
2022  }
2023 
2028  const IsoString& ObjectId() const
2029  {
2030  return m_index->objectId;
2031  }
2032 
2041  const IsoString& OriginId() const
2042  {
2043  return m_index->originId;
2044  }
2045 
2052  const String& ObjectName() const
2053  {
2054  return m_index->objectName;
2055  }
2056 
2067  TimePoint StartTime( int i = 0 ) const
2068  {
2069  return m_node[Range( i, 0, 1 )].startTime;
2070  }
2071 
2082  TimePoint EndTime( int i = 0 ) const
2083  {
2084  return m_node[Range( i, 0, 1 )].endTime;
2085  }
2086 
2096  bool HasDerivative() const
2097  {
2098  return m_index->HasDerivative();
2099  }
2100 
2115  const Optional<double>& H() const
2116  {
2117  return m_index->H;
2118  }
2119 
2123  const Optional<double>& G() const
2124  {
2125  return m_index->G;
2126  }
2127 
2131  const Optional<double>& B_V() const
2132  {
2133  return m_index->B_V;
2134  }
2135 
2140  const Optional<double>& D() const
2141  {
2142  return m_index->D;
2143  }
2144 
2145  private:
2146 
2147  struct NodeInfo
2148  {
2149  int current = -1;
2150  TimePoint startTime;
2151  TimePoint endTime;
2152  ChebyshevFit expansion;
2153  };
2154 
2155  const EphemerisFile* m_parent = nullptr;
2156  const EphemerisFile::Index* m_index = nullptr;
2157  NodeInfo m_node[ 3 ];
2158 
2165  void Update( TimePoint t, int index )
2166  {
2167  if ( !t.IsValid() )
2168  throw Error( "Invalid time point." );
2169  if ( t < m_parent->StartTime() || t > m_parent->EndTime() )
2170  throw Error( "Time point out of range." );
2171 
2172  const Array<IndexNode>& nodes = m_index->nodes[index];
2173  NodeInfo& info = m_node[index];
2174 
2175  for ( int N = int( nodes.Length() ), l = 0, r = N-1; ; )
2176  {
2177  int m = (l + r) >> 1;
2178  const IndexNode& node = nodes[m];
2179  TimePoint t0 = node.StartTime();
2180  if ( t < t0 )
2181  r = m;
2182  else
2183  {
2184  if ( m == N-1 || t < nodes[m+1].StartTime() )
2185  {
2186  if ( m != info.current )
2187  {
2188  ChebyshevFit::coefficient_series coefficients;
2189  {
2190  volatile AutoLock lock( m_parent->m_mutex );
2191  m_parent->m_file.SetPosition( node.position );
2192  for ( int i = 0, n = node.NumberOfComponents(); i < n; ++i )
2193  {
2194  Vector c( node.n[i] );
2195  m_parent->m_file.Read( reinterpret_cast<void*>( c.Begin() ), c.Size() );
2196  coefficients << c;
2197  }
2198  }
2199  info.current = m;
2200  info.startTime = t0;
2201  info.endTime = (m < N-1) ? nodes[m+1].StartTime() : m_parent->EndTime();
2202  info.expansion = ChebyshevFit( coefficients, 0, info.endTime - info.startTime );
2203  }
2204  break;
2205  }
2206 
2207  l = m + 1;
2208  }
2209  }
2210  }
2211  };
2212 
2213 private:
2214 
2215 #if defined( __clang__ )
2216 # pragma GCC diagnostic ignored "-Wunused-private-field"
2217 #endif
2218 
2219  /*
2220  * For the core JavaScript engine we need garbage-collector-safe
2221  * asynchronous destruction of these objects.
2222  */
2223  mutable bool m_finalized = false;
2224 
2225  /*
2226  * In the core JavaScript engine we must identify static objects that can be
2227  * shared and must never be destroyed. This includes fundamental
2228  * ephemerides, nutation, etc.
2229  */
2230  mutable bool m_internal = false;
2231 
2232 #if defined( __clang__ )
2233 # pragma GCC diagnostic warning "-Wunused-private-field"
2234 #endif
2235 
2236 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
2237  friend class pi::JSEphemerisFileObject;
2238  friend class pi::JSEphemerisHandleObject;
2239 #endif
2240 };
2241 
2242 // ----------------------------------------------------------------------------
2243 
2244 } // pcl
2245 
2246 #endif // __PCL_EphemerisFile_h
2247 
2248 // ----------------------------------------------------------------------------
2249 // EOF pcl/EphemerisFile.h - Released 2021-04-09T19:40:59Z
Optional< double > D
String description
A full description of the data stored in this XEPH file.
const Optional< double > & G() const
Dynamic list of object identifiers and descriptions.
An instant in any timescale.
Definition: TimePoint.h:102
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2092
const Optional< double > & D() const
unsigned char uint8
Definition: Defs.h:638
String copyright
Copyright information applicable to the data stored in this XEPH file.
Adaptive mutual exclusion lock variable.
Definition: Mutex.h:208
Atomic operations on integers.
Definition: Atomic.h:94
64-bit floating point Chebyshev function approximation.
TimePoint EndTime(int i=0) const
bool IsEmpty() const noexcept
Definition: String.h:795
PCL root namespace.
Definition: AbstractImage.h:76
TimePoint StartTime(int i=0) const
iterator Begin()
Definition: Array.h:428
MultiVector StateVectors(TimePoint t)
const EphemerisMetadata & Metadata() const
String ObjectName(const IsoString &object, const IsoString &origin=IsoString()) const
const Optional< double > & B_V() const
FI BinarySearch(FI i, FI j, const T &v) noexcept
Definition: Search.h:170
void Increment()
Definition: Atomic.h:207
virtual void Read(void *buffer, fsize_type len)
Solar system ephemerides from XEPH files.
String title
A title that represents or identifies this XEPH file.
Vector FirstDerivative(TimePoint t)
String authors
The names of one or more persons or groups that have created the data in this file.
Calculation of ephemerides from data stored in XEPH files.
const String & FilePath() const
String creatorOS
The operating system on which this file was created.
const EphemerisFile & ParentFile() const
virtual void SetPosition(fpos_type pos)
EphemerisObjectList Objects() const
TimePoint StartTime() const
const IsoString & ObjectId() const
Vector SecondDerivative(TimePoint t)
bool IsEmpty() const noexcept
Definition: Array.h:314
void ComputeState(Vector &p, Vector &v, TimePoint t)
void ComputeFirstDerivative(Vector &v, TimePoint t)
IsoString name
The constant name (case-insensitive).
SerializableEphemerisData(TimePoint t, const ChebyshevFit &T)
EphemerisConstant(const IsoString &n=IsoString(), double v=0)
ustring_base UTF8ToUTF16(size_type i=0, size_type n=maxPos) const
Definition: String.h:12047
64-bit floating point real multivector.
size_type Length() const noexcept
Definition: Array.h:268
EphemerisObject(const IsoString &objectId_, const IsoString &originId_, const String &objectName_=String(), const String &objectDescription_=String(), Optional< double > H_=Optional< double >(), Optional< double > G_=Optional< double >(), Optional< double > B_V_=Optional< double >(), Optional< double > D_=Optional< double >())
Unicode (UTF-16) string.
Definition: String.h:7923
EphemerisFile(EphemerisFile &&x)
bool operator<(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2103
double ConstantValue(const IsoString &name) const
String organizationName
The name of the organization responsible for this file.
double value
The constant value.
Optional< double > H
Optional< double > G
Dynamic list of ephemeris numerical constants.
signed int int32
Definition: Defs.h:656
Automatic mutex lock/unlock.
Definition: AutoLock.h:83
String creatorApplication
The software application or program that created this file.
bool IsObjectAvailable(const IsoString &object, const IsoString &origin=IsoString()) const
EphemerisFile(const String &filePath)
Dynamic list of Chebyshev polynomial expansions for ephemeris serialization.
A simple exception with an associated error message.
Definition: Exception.h:238
SerializableEphemerisObjectData(const IsoString &id, const IsoString &origin, const String &name=String(), const String &desc=String())
Chebyshev polynomial expansion coefficients for ephemeris serialization.
const Optional< double > & H() const
64-bit floating point real vector.
Identifiers and descriptive data of an object available in an ephemeris file.
String briefDescription
A brief (single-line) description of this XEPH file.
Vector StateVector(TimePoint t)
TimePoint creationTime
The date this file was created.
Definition: EphemerisFile.h:99
A numerical constant defined in an ephemeris file (XEPH format).
void ComputeState(Vector &p, TimePoint t)
const EphemerisConstantList & Constants() const
void ComputeSecondDerivative(Vector &a, TimePoint t)
iterator End()
Definition: Array.h:453
bool IsConstantAvailable(const IsoString &name) const
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
Definition: Utility.h:190
Handle(const EphemerisFile &parent, const IsoString &object, const IsoString &origin=IsoString())
Dynamic list of per-object data for ephemeris serialization.
constexpr bool IsValid() const
Definition: TimePoint.h:231
bool IsOpen() const
const String & ObjectName() const
Metadata items available in ephemeris files (XEPH format).
Definition: EphemerisFile.h:97
A set of Chebyshev polynomial expansions and associated ancillary data for ephemeris serialization...
Optional< double > B_V
const IsoString & OriginId() const
int CompareIC(const GenericString< T, R1, A1 > &s, bool localeAware=true) const noexcept
Definition: String.h:3797
signed long long int64
Definition: Defs.h:672
TimePoint EndTime() const
A platform-independent interface to the local file system.
Definition: File.h:496
int NumberOfHandles() const
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5397