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 329 330 331 332
|
/******************************************************************************
* $Id: ceos.h 20996 2010-10-28 18:38:15Z rouault $
*
* Project: ASI CEOS Translator
* Purpose: CEOS library prototypes
* Author: Paul Lahaie, pjlahaie@atlsci.com
*
******************************************************************************
* Copyright (c) 2000, Atlantis Scientific Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#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"
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 Flavour;
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 Flavour;
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 PulsRepetitionFrequency;
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, char *format, void *value);
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 flavour, 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 AddRecipe( int ( *function )( CeosSARVolume_t *volume, void *token ),
void *token, const char *name );
int CeosDefaultRecipe( CeosSARVolume_t *volume, void *token );
int ScanSARRecipeFCN( CeosSARVolume_t *volume, 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
|