File: ceos.h

package info (click to toggle)
gdal 3.11.3%2Bdfsg-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 89,016 kB
  • sloc: cpp: 1,165,048; ansic: 208,864; python: 26,958; java: 5,972; xml: 4,611; sh: 3,776; cs: 2,508; yacc: 1,306; makefile: 213
file content (328 lines) | stat: -rw-r--r-- 8,279 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/******************************************************************************
 *
 * Project:  ASI CEOS Translator
 * Purpose:  CEOS library prototypes
 * Author:   Paul Lahaie, pjlahaie@atlsci.com
 *
 ******************************************************************************
 * Copyright (c) 2000, Atlantis Scientific Inc
 *
 * SPDX-License-Identifier: MIT
 ****************************************************************************/

#ifndef CEOS_H
#define CEOS_H

#include "cpl_conv.h"

CPL_C_START

#define int32 GInt32
#define TBool int
#define uchar unsigned char

typedef struct Link_t_struct
{
    struct Link_t_struct *next;
    void *object;
} Link_t;

#define HMalloc CPLMalloc
#define HFree CPLFree
#define HCalloc CPLCalloc

Link_t *ceos2CreateLink(void *pObject);
Link_t *InsertLink(Link_t *psList, Link_t *psLink);
void DestroyList(Link_t *psList);
Link_t *AddLink(Link_t *psList, Link_t *psLink);

/* Basic CEOS header defs */

#define SEQUENCE_OFF 0
#define TYPE_OFF 4
#define LENGTH_OFF 8
#define CEOS_HEADER_LENGTH 12

/* Defines for CEOS banding type */

#define CEOS_IL_PIXEL 1
#define CEOS_IL_LINE 2
#define CEOS_IL_BAND 3

/* Defines for CEOS data types */

#define CEOS_TYP_CHAR 1
#define CEOS_TYP_UCHAR 2
#define CEOS_TYP_SHORT 3
#define CEOS_TYP_USHORT 4
#define CEOS_TYP_LONG 5
#define CEOS_TYP_ULONG 6
#define CEOS_TYP_FLOAT 7
#define CEOS_TYP_DOUBLE 8
#define CEOS_TYP_COMPLEX_CHAR 9
#define CEOS_TYP_COMPLEX_UCHAR 10
#define CEOS_TYP_COMPLEX_SHORT 11
#define CEOS_TYP_COMPLEX_USHORT 12
#define CEOS_TYP_COMPLEX_LONG 13
#define CEOS_TYP_COMPLEX_ULONG 14
#define CEOS_TYP_COMPLEX_FLOAT 15
#define CEOS_TYP_CCP_COMPLEX_FLOAT 16    /* COMPRESSED CROSS PRODUCT */
#define CEOS_TYP_PALSAR_COMPLEX_SHORT 17 /* PALSAR - treat as COMPLEX SHORT*/

/* Defines for CEOS file names */

#define CEOS_VOLUME_DIR_FILE 0
#define CEOS_LEADER_FILE 1
#define CEOS_IMAGRY_OPT_FILE 2
#define CEOS_TRAILER_FILE 3
#define CEOS_NULL_VOL_FILE 4
#define CEOS_ANY_FILE -1

/* Defines for Recipe values */

#define CEOS_REC_NUMCHANS 1
#define CEOS_REC_INTERLEAVE 2
#define CEOS_REC_DATATYPE 3
#define CEOS_REC_BPR 4
#define CEOS_REC_LINES 5
#define CEOS_REC_TBP 6
#define CEOS_REC_BBP 7
#define CEOS_REC_PPL 8
#define CEOS_REC_LBP 9
#define CEOS_REC_RBP 10
#define CEOS_REC_BPP 11
#define CEOS_REC_RPL 12
#define CEOS_REC_PPR 13
#define CEOS_REC_IDS 14
#define CEOS_REC_FDL 15
#define CEOS_REC_PIXORD 16
#define CEOS_REC_LINORD 17
#define CEOS_REC_PRODTYPE 18
#define CEOS_REC_RECORDSIZE 19
#define CEOS_REC_SUFFIX_SIZE 20
#define CEOS_REC_PDBPR 21

/* Defines for Recipe Types */

#define CEOS_REC_TYP_A 1
#define CEOS_REC_TYP_B 2
#define CEOS_REC_TYP_I 3

/* Defines for SAR Embedded info */

#define CEOS_SAR_ACQ_YEAR 1
#define CEOS_SAR_ACQ_DAY 2
#define CEOS_SAR_ACQ_MSEC 4
#define CEOS_SAR_TRANS_POL 8
#define CEOS_SAR_PULSE_REP 16
#define CEOS_SAR_SLANT_FIRST 32
#define CEOS_SAR_SLANT_MID 64
#define CEOS_SAR_SLANT_LAST 128

/* Maximum size of LUT for Calibration records */
#define CEOS_RADAR_MAX_LUT 512
#define CEOS_RADAR_FLIP_DATE 19980101
#define CEOS_RADAR_FACILITY "CDPF-RSAT"

/* Defines for GCP Ordering mode */
#define CEOS_STD_MAPREC_GCP_ORDER 0
#define CEOS_ASF_MAPREC_GCP_ORDER 1
#define CEOS_ASF_FACREC_GCP_ORDER 2

typedef union
{
    int32 Int32Code;

    struct
    {
        uchar Subtype1;
        uchar Type;
        uchar Subtype2;
        uchar Subtype3;
    } UCharCode;
} CeosTypeCode_t;

typedef struct
{
    int32 Sequence;
    CeosTypeCode_t TypeCode;
    int32 Length;
    int32 Flavor;
    int32 Subsequence;
    int32 FileId;
    uchar *Buffer;
} CeosRecord_t;

struct CeosSARImageDesc
{
    TBool ImageDescValid;
    int NumChannels;
    int32 ChannelInterleaving;
    int32 DataType;
    int BytesPerRecord;
    int Lines;
    int TopBorderPixels;
    int BottomBorderPixels;
    int PixelsPerLine;
    int LeftBorderPixels;
    int RightBorderPixels;
    int BytesPerPixel;
    int RecordsPerLine;
    int PixelsPerRecord;
    int ImageDataStart;
    int ImageSuffixData;
    int FileDescriptorLength;
    int32 PixelOrder;
    int32 LineOrder;
    int PixelDataBytesPerRecord;
};

typedef struct
{
    int32 Flavor;
    int32 Sensor;
    int32 ProductType;
    int32 FileNamingConvention;
    TBool VolumeDirectoryFile;
    TBool SARLeaderFile;
    TBool ImagryOptionsFile;
    TBool SARTrailerFile;
    TBool NullVolumeDirectoryFile;

    struct CeosSARImageDesc ImageDesc;

    Link_t *RecordList;
} CeosSARVolume_t;

typedef struct
{
    int ImageDescValue;
    int Override;
    int FileId;

    struct
    {
        unsigned char Subtype1, Type, Subtype2, Subtype3;
    } TypeCode;

    int Offset;
    int Length;
    int Type;
} CeosRecipeType_t;

typedef struct
{
    CeosRecipeType_t *Recipe;
} CeosSARImageDescRecipe_t;

typedef struct
{
    int32 ValidFields;
    TBool SensorUpdate;
    int32 AcquisitionYear;
    int32 AcquisitionDay;
    int32 AcquisitionMsec;
    int32 TransmittedPolarization;
    int32 ReceivedPolarization;
    int32 PulseRepetitionFrequency;
    int32 SlantRangeFirstPixel;
    int32 SlantRangeMidPixel;
    int32 SlantRangeLastPixel;
} CeosSAREmbeddedInfo_t;

typedef struct
{
    double Slant[6];
    double Lut[512];
    double SemiMajorAxis;
    double PlatformLatitude;
    double CalibrationScale;
    int NumberOfSamples;
    int Increment;
    TBool PossiblyFlipped;
} CeosRadarCalibration_t;

/* Function prototypes */

void InitEmptyCeosRecord(CeosRecord_t *record, int32 sequence,
                         CeosTypeCode_t typecode, int32 length);

void InitCeosRecord(CeosRecord_t *record, uchar *buffer);

void InitCeosRecordWithHeader(CeosRecord_t *record, uchar *header,
                              uchar *buffer);

int DetermineCeosRecordBodyLength(const uchar *header);

void DeleteCeosRecord(CeosRecord_t *record);

void GetCeosRecordStruct(const CeosRecord_t *record, void *struct_ptr);

void PutCeosRecordStruct(CeosRecord_t *record, const void *struct_ptr);

void GetCeosField(CeosRecord_t *, int32, const char *, void *);

void SetCeosField(CeosRecord_t *record, int32 start_byte, const char *format,
                  int intValue, double dblValue);

void SetIntCeosField(CeosRecord_t *record, int32 start_byte, int32 length,
                     int32 value);

CeosRecord_t *FindCeosRecord(Link_t *record_list, CeosTypeCode_t typecode,
                             int32 fileid, int32 flavor, int32 subsequence);

void SerializeCeosRecordsToFile(Link_t *record_list, VSILFILE *fp);

void SerializeCeosRecordsFromFile(Link_t *record_list, VSILFILE *fp);

void InitCeosSARVolume(CeosSARVolume_t *volume, int32 file_name_convention);

void GetCeosSARImageDesc(CeosSARVolume_t *volume);

void GetCeosSARImageDescInfo(CeosSARVolume_t *volume,
                             CeosSARImageDescRecipe_t *recipe);

void CalcCeosSARImageFilePosition(CeosSARVolume_t *volume, int channel,
                                  int line, int *record, int *file_offset);

int32 GetCeosSARImageData(CeosSARVolume_t *volume,
                          CeosRecord_t *processed_data_record, int channel,
                          int xoff, int xsize, int bufsize, uchar *buffer);

void DetermineCeosSARPixelOrder(CeosSARVolume_t *volume, CeosRecord_t *record);

void GetCeosSAREmbeddedInfo(CeosSARVolume_t *volume,
                            CeosRecord_t *processed_data_record,
                            CeosSAREmbeddedInfo_t *info);

void DeleteCeosSARVolume(CeosSARVolume_t *volume);

void RegisterRecipes(void);
void FreeRecipes(void);

void AddRecipe(int (*function)(CeosSARVolume_t *volume, const void *token),
               const void *token, const char *name);

int CeosDefaultRecipe(CeosSARVolume_t *volume, const void *token);
int ScanSARRecipeFCN(CeosSARVolume_t *volume, const void *token);

/* ceoscalib.c function declarations */

CeosRadarCalibration_t *GetCeosRadarCalibration(CeosSARVolume_t *volume);

/* CEOS byte swapping stuff */

#if defined(CPL_MSB)
#define NativeToCeos(a, b, c, d) memcpy(a, b, c)
#define CeosToNative(a, b, c, d) memcpy(a, b, c)
#else
void NativeToCeos(void *dst, const void *src, const size_t len,
                  const size_t swap_unit);
#define CeosToNative(a, b, c, d) NativeToCeos(a, b, c, d)
#endif

/* Recipe defines */

CPL_C_END

#endif