Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Purpose: Support for reading and manipulating PCIDSK Ephemeris Segments 4 : * 5 : ****************************************************************************** 6 : * Copyright (c) 2009 7 : * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada. 8 : * 9 : * SPDX-License-Identifier: MIT 10 : ****************************************************************************/ 11 : #ifndef INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H 12 : #define INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H 13 : 14 : #include "pcidsk_ephemeris.h" 15 : #include "segment/cpcidsksegment.h" 16 : 17 : namespace PCIDSK { 18 : class PCIDSKFile; 19 : 20 : class CPCIDSKEphemerisSegment : public PCIDSKEphemerisSegment, 21 : public CPCIDSKSegment 22 : { 23 : public: 24 : CPCIDSKEphemerisSegment(PCIDSKFile *file, int segment,const char *segment_pointer,bool bLoad=true); 25 : ~CPCIDSKEphemerisSegment(); 26 : 27 0 : const EphemerisSeg_t& GetEphemeris() const override 28 : { 29 0 : return *mpoEphemeris; 30 : } 31 0 : void SetEphemeris(const EphemerisSeg_t& oEph) override 32 : { 33 0 : if(mpoEphemeris) 34 : { 35 0 : delete mpoEphemeris; 36 : } 37 0 : mpoEphemeris = new EphemerisSeg_t(oEph); 38 0 : mbModified = true; 39 : 40 : //we set loaded to true to trigger the Write during synchronize 41 : //else if the segment has just been created it will not be saved. 42 0 : this->loaded_ = true; 43 0 : } 44 : 45 : //synchronize the segment on disk. 46 : void Synchronize() override; 47 : private: 48 : 49 : // Helper housekeeping functions 50 : void Load(); 51 : void Write(); 52 : 53 : EphemerisSeg_t* mpoEphemeris; 54 : //functions to read/write binary information 55 : protected: 56 : // The raw segment data 57 : PCIDSKBuffer seg_data; 58 : bool loaded_; 59 : bool mbModified; 60 : void ReadAvhrrEphemerisSegment(int, 61 : EphemerisSeg_t *); 62 : void ReadAvhrrScanlineRecord(int nPos, 63 : AvhrrLine_t *psScanlineRecord); 64 : int ReadAvhrrInt32(unsigned char* pbyBuf); 65 : void WriteAvhrrEphemerisSegment(int , EphemerisSeg_t *); 66 : void WriteAvhrrScanlineRecord(AvhrrLine_t *psScanlineRecord, 67 : int nPos); 68 : void WriteAvhrrInt32(int nValue, unsigned char* pbyBuf); 69 : EphemerisSeg_t *BinaryToEphemeris( int nStartBlock ); 70 : void EphemerisToBinary( EphemerisSeg_t *, int ); 71 : double ConvertDeg(double degree, int mode); 72 : }; 73 : } 74 : 75 : #endif // INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H