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 : * Permission is hereby granted, free of charge, to any person obtaining a 10 : * copy of this software and associated documentation files (the "Software"), 11 : * to deal in the Software without restriction, including without limitation 12 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 : * and/or sell copies of the Software, and to permit persons to whom the 14 : * Software is furnished to do so, subject to the following conditions: 15 : * 16 : * The above copyright notice and this permission notice shall be included 17 : * in all copies or substantial portions of the Software. 18 : * 19 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 : * DEALINGS IN THE SOFTWARE. 26 : ****************************************************************************/ 27 : #ifndef INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H 28 : #define INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H 29 : 30 : #include "pcidsk_ephemeris.h" 31 : #include "segment/cpcidsksegment.h" 32 : 33 : namespace PCIDSK { 34 : class PCIDSKFile; 35 : 36 : class CPCIDSKEphemerisSegment : public PCIDSKEphemerisSegment, 37 : public CPCIDSKSegment 38 : { 39 : public: 40 : CPCIDSKEphemerisSegment(PCIDSKFile *file, int segment,const char *segment_pointer,bool bLoad=true); 41 : ~CPCIDSKEphemerisSegment(); 42 : 43 0 : const EphemerisSeg_t& GetEphemeris() const override 44 : { 45 0 : return *mpoEphemeris; 46 : } 47 0 : void SetEphemeris(const EphemerisSeg_t& oEph) override 48 : { 49 0 : if(mpoEphemeris) 50 : { 51 0 : delete mpoEphemeris; 52 : } 53 0 : mpoEphemeris = new EphemerisSeg_t(oEph); 54 0 : mbModified = true; 55 : 56 : //we set loaded to true to trigger the Write during synchronize 57 : //else if the segment has just been created it will not be saved. 58 0 : this->loaded_ = true; 59 0 : } 60 : 61 : //synchronize the segment on disk. 62 : void Synchronize() override; 63 : private: 64 : 65 : // Helper housekeeping functions 66 : void Load(); 67 : void Write(); 68 : 69 : EphemerisSeg_t* mpoEphemeris; 70 : //functions to read/write binary information 71 : protected: 72 : // The raw segment data 73 : PCIDSKBuffer seg_data; 74 : bool loaded_; 75 : bool mbModified; 76 : void ReadAvhrrEphemerisSegment(int, 77 : EphemerisSeg_t *); 78 : void ReadAvhrrScanlineRecord(int nPos, 79 : AvhrrLine_t *psScanlineRecord); 80 : int ReadAvhrrInt32(unsigned char* pbyBuf); 81 : void WriteAvhrrEphemerisSegment(int , EphemerisSeg_t *); 82 : void WriteAvhrrScanlineRecord(AvhrrLine_t *psScanlineRecord, 83 : int nPos); 84 : void WriteAvhrrInt32(int nValue, unsigned char* pbyBuf); 85 : EphemerisSeg_t *BinaryToEphemeris( int nStartBlock ); 86 : void EphemerisToBinary( EphemerisSeg_t *, int ); 87 : double ConvertDeg(double degree, int mode); 88 : }; 89 : } 90 : 91 : #endif // INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H