1 : /******************************************************************************
2 : *
3 : * Purpose: Support for reading and manipulating PCIDSK Ephemeris Segments
4 : *
5 : ******************************************************************************
6 : * Copyright (c) 2009
7 : * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, 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
44 : {
45 0 : return *mpoEphemeris;
46 : };
47 0 : void SetEphemeris(const EphemerisSeg_t& oEph)
48 : {
49 0 : if(mpoEphemeris)
50 : {
51 0 : delete mpoEphemeris;
52 : }
53 0 : mpoEphemeris = new EphemerisSeg_t(oEph);
54 0 : mbModified = true;
55 0 : };
56 :
57 : //synchronize the segment on disk.
58 : void Synchronize();
59 : private:
60 :
61 : // Helper housekeeping functions
62 : void Load();
63 : void Write();
64 :
65 : EphemerisSeg_t* mpoEphemeris;
66 : //functions to read/write binary information
67 : protected:
68 : // The raw segment data
69 : PCIDSKBuffer seg_data;
70 : bool loaded_;
71 : bool mbModified;
72 : void ReadAvhrrEphemerisSegment(int,
73 : EphemerisSeg_t *);
74 : void ReadAvhrrScanlineRecord(int nPos,
75 : AvhrrLine_t *psScanlineRecord);
76 : int ReadAvhrrInt32(unsigned char* pbyBuf);
77 : void WriteAvhrrEphemerisSegment(int , EphemerisSeg_t *);
78 : void WriteAvhrrScanlineRecord(AvhrrLine_t *psScanlineRecord,
79 : int nPos);
80 : void WriteAvhrrInt32(int nValue, unsigned char* pbyBuf);
81 : EphemerisSeg_t *BinaryToEphemeris( int nStartBlock );
82 : void EphemerisToBinary( EphemerisSeg_t *, int );
83 : double ConvertDeg(double degree, int mode);
84 : };
85 : }
86 :
87 : #endif // __INCLUDE_PCIDSK_SEGMENT_PCIDSKEPHEMERIS_SEG_H
|