Function lupnt::spk_extract

Function Documentation

segment_t *lupnt::spk_extract(char const *path, long *segs)

Scan through the SPK file path and extract all of the Chebyshev position-only segments, saving them in an allocated array of segment_t, which is returned. If there is an error, NULL is returned. *segs is set to the number of segments in the array. Once this is done, this array can be used by cheby_verify() and cheby_posvel() above, with no dependency on or reference to the SPICE library.

Extract all Chebyshev-position-only (Type 2) segments from an SPK file into a heap-allocated array of segment_t, without requiring the SPICE library afterwards.

Called once by spice::LoadSpiceKernel on de440.bsp (planetary/lunar ephemeris), producing the segment table that spice::GetBodyPosVelBase searches (by target/center body codes) and evaluates via cheby_posvel_ad for every spice::GetBodyPosVel call.

Parameters:
  • path – SPK (.bsp) file path

  • segs – Output: number of segments in the returned array

Returns:

Heap-allocated array of *segs segment descriptors, or nullptr on error (e.g. not a valid SPK / no Chebyshev position-only segments)