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 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
|
/******************************************************************************
* $Id$
*
* Project: NITF Read/Write Library
* Purpose: Main GDAL independent include file for NITF support.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
**********************************************************************
* Copyright (c) 2002, Frank Warmerdam
* Copyright (c) 2007-2011, Even Rouault <even dot rouault at spatialys.com>
*
* 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 NITFLIB_H_INCLUDED
#define NITFLIB_H_INCLUDED
#include "cpl_port.h"
#include "cpl_error.h"
#include "cpl_vsi.h"
#include "cpl_minixml.h"
CPL_C_START
/* 1e-12 - 1 */
#define NITF_MAX_FILE_SIZE 999999999999ULL
/* 1e-10 - 1 */
#define NITF_MAX_IMAGE_SIZE 9999999999ULL
typedef struct
{
char szSegmentType[3]; /* one of "IM", ... */
GUIntBig nSegmentHeaderStart;
GUInt32 nSegmentHeaderSize;
GUIntBig nSegmentStart;
GUIntBig nSegmentSize;
void *hAccess;
/* extra info related to relative display */
int nDLVL;
int nALVL;
int nLOC_R;
int nLOC_C;
int nCCS_R;
int nCCS_C;
} NITFSegmentInfo;
typedef struct
{
VSILFILE *fp;
char szVersion[10];
int nSegmentCount;
NITFSegmentInfo *pasSegmentInfo;
char *pachHeader;
int nTREBytes;
char *pachTRE;
char **papszMetadata;
CPLXMLNode *psNITFSpecNode;
} NITFFile;
/* -------------------------------------------------------------------- */
/* File level prototypes. */
/* -------------------------------------------------------------------- */
NITFFile CPL_DLL *NITFOpen(const char *pszFilename, int bUpdatable);
NITFFile *NITFOpenEx(VSILFILE *fp, const char *pszFilename);
void CPL_DLL NITFClose(NITFFile *);
int CPL_DLL NITFCreate(const char *pszFilename, int nPixels, int nLines,
int nBands, int nBitsPerSample, const char *pszPVType,
char **papszOptions);
int NITFCreateEx(const char *pszFilename, int nPixels, int nLines, int nBands,
int nBitsPerSample, const char *pszPVType, char **papszOptions,
int *pnIndex, int *pnImageCount, vsi_l_offset *pnImageOffset,
vsi_l_offset *pnICOffset);
const char CPL_DLL *NITFFindTRE(const char *pszTREData, int nTREBytes,
const char *pszTag, int *pnFoundTRESize);
const char CPL_DLL *NITFFindTREByIndex(const char *pszTREData, int nTREBytes,
const char *pszTag, int nTreIndex,
int *pnFoundTRESize);
int CPL_DLL NITFCollectAttachments(NITFFile *psFile);
int CPL_DLL NITFReconcileAttachments(NITFFile *psFile);
/* -------------------------------------------------------------------- */
/* Image level access. */
/* -------------------------------------------------------------------- */
typedef struct
{
char szIREPBAND[3];
char szISUBCAT[7];
int nSignificantLUTEntries;
int nLUTLocation;
unsigned char *pabyLUT;
} NITFBandInfo;
typedef struct
{
GUInt16 nLocId;
GUInt32 nLocOffset;
GUInt32 nLocSize;
} NITFLocation;
typedef struct
{
unsigned short tableId;
unsigned int nRecords;
unsigned char elementLength;
unsigned short histogramRecordLength;
unsigned int colorTableOffset;
unsigned int histogramTableOffset;
} NITFColormapRecord;
typedef struct
{
NITFFile *psFile;
int iSegment;
char *pachHeader;
int nRows;
int nCols;
int nBands;
int nBitsPerSample;
NITFBandInfo *pasBandInfo;
char chIMODE;
int nBlocksPerRow;
int nBlocksPerColumn;
int nBlockWidth;
int nBlockHeight;
char szPVType[4];
char szIREP[9];
char szICAT[9];
int nABPP; /* significant bits per pixel */
char chICORDS;
int bHaveIGEOLO;
int nZone;
double dfULX;
double dfULY;
double dfURX;
double dfURY;
double dfLRX;
double dfLRY;
double dfLLX;
double dfLLY;
int bIsBoxCenterOfPixel;
char *pszComments;
char szIC[3];
char szCOMRAT[5];
int nILOCColumn;
int nILOCRow;
int nIALVL;
int nIDLVL;
char szIMAG[5];
int bNoDataSet;
int nNoDataValue;
int nTREBytes;
char *pachTRE;
int nIXSOFL;
int nIXSOFLOffsetInSubfileHeader;
/* Internal information not for application use. */
int nWordSize;
GUIntBig nPixelOffset;
GUIntBig nLineOffset;
GUIntBig nBlockOffset;
GUIntBig nBandOffset;
GUIntBig *panBlockStart;
char **papszMetadata;
GUInt32 *apanVQLUT[4];
int nLocCount;
NITFLocation *pasLocations;
} NITFImage;
NITFImage CPL_DLL *NITFImageAccess(NITFFile *, int iSegment);
void CPL_DLL NITFImageDeaccess(NITFImage *);
int CPL_DLL NITFReadImageBlock(NITFImage *, int nBlockX, int nBlockY, int nBand,
void *pData);
int CPL_DLL NITFReadImageLine(NITFImage *, int nLine, int nBand, void *pData);
int CPL_DLL NITFWriteImageBlock(NITFImage *, int nBlockX, int nBlockY,
int nBand, void *pData);
int CPL_DLL NITFWriteImageLine(NITFImage *, int nLine, int nBand, void *pData);
int CPL_DLL NITFWriteLUT(NITFImage *psImage, int nBand, int nColors,
unsigned char *pabyLUT);
int CPL_DLL NITFWriteIGEOLO(NITFImage *psImage, char chICORDS, int nZone,
double dfULX, double dfULY, double dfURX,
double dfURY, double dfLRX, double dfLRY,
double dfLLX, double dfLLY);
char CPL_DLL **NITFReadCSEXRA(NITFImage *psImage);
char CPL_DLL **NITFReadPIAIMC(NITFImage *psImage);
char CPL_DLL **NITFReadUSE00A(NITFImage *psImage);
char CPL_DLL **NITFReadSTDIDC(NITFImage *psImage);
char CPL_DLL **NITFReadBLOCKA(NITFImage *psImage);
GUIntBig CPL_DLL NITFIHFieldOffset(NITFImage *psImage,
const char *pszFieldName);
#define BLKREAD_OK 0
#define BLKREAD_NULL 1
#define BLKREAD_FAIL 2
int NITFUncompressARIDPCM(NITFImage *psImage, GByte *pabyInputData,
int nInputBytes, GByte *pabyOutputImage);
int NITFUncompressBILEVEL(NITFImage *psImage, GByte *pabyInputData,
int nInputBytes, GByte *pabyOutputImage);
NITFLocation *NITFReadRPFLocationTable(VSILFILE *fp, int *pnLocCount);
/* -------------------------------------------------------------------- */
/* DE segment access. */
/* -------------------------------------------------------------------- */
typedef struct
{
NITFFile *psFile;
int iSegment;
char *pachHeader;
char **papszMetadata;
} NITFDES;
NITFDES CPL_DLL *NITFDESAccess(NITFFile *, int iSegment);
void CPL_DLL NITFDESDeaccess(NITFDES *);
int CPL_DLL NITFDESGetTRE(NITFDES *psDES, int nOffset, char szTREName[7],
char **ppabyTREData, int *pnFoundTRESize);
void CPL_DLL NITFDESFreeTREData(char *pabyTREData);
int CPL_DLL NITFDESExtractShapefile(NITFDES *psDES,
const char *pszRadixFileName);
CPLXMLNode *NITFCreateXMLDesUserDefinedSubHeader(NITFFile *psFile,
const NITFDES *psDES);
CPLXMLNode CPL_DLL *NITFDESGetXml(NITFFile *, int iSegment);
/* -------------------------------------------------------------------- */
/* These are really intended to be private helper stuff for the */
/* library. */
/* -------------------------------------------------------------------- */
char *NITFGetField(char *pszTarget, const char *pszSource, int nStart,
int nLength);
void NITFExtractMetadata(char ***ppapszMetadata, const char *pachHeader,
int nStart, int nLength, const char *pszName);
/* -------------------------------------------------------------------- */
/* location ids from the location table (from MIL-STD-2411-1). */
/* -------------------------------------------------------------------- */
typedef enum
{
LID_HeaderComponent = 128,
LID_LocationComponent = 129,
LID_CoverageSectionSubheader = 130,
LID_CompressionSectionSubsection = 131,
LID_CompressionLookupSubsection = 132,
LID_CompressionParameterSubsection = 133,
LID_ColorGrayscaleSectionSubheader = 134,
LID_ColormapSubsection = 135,
LID_ImageDescriptionSubheader = 136,
LID_ImageDisplayParametersSubheader = 137,
LID_MaskSubsection = 138,
LID_ColorConverterSubsection = 139,
LID_SpatialDataSubsection = 140,
LID_AttributeSectionSubheader = 141,
LID_AttributeSubsection = 142,
LID_ExplicitArealCoverageTable = 143,
LID_RelatedImagesSectionSubheader = 144,
LID_RelatedImagesSubsection = 145,
LID_ReplaceUpdateSectionSubheader = 146,
LID_ReplaceUpdateTable = 147,
LID_BoundaryRectangleSectionSubheader = 148,
LID_BoundaryRectangleTable = 149,
LID_FrameFileIndexSectionSubHeader = 150,
LID_FrameFileIndexSubsection = 151,
LID_ColorTableIndexSectionSubheader = 152,
LID_ColorTableIndexRecord = 153
} NITFLocId;
/* -------------------------------------------------------------------- */
/* RPC structure, and function to fill it. */
/* -------------------------------------------------------------------- */
typedef struct
{
int SUCCESS;
double ERR_BIAS;
double ERR_RAND;
double LINE_OFF;
double SAMP_OFF;
double LAT_OFF;
double LONG_OFF;
double HEIGHT_OFF;
double LINE_SCALE;
double SAMP_SCALE;
double LAT_SCALE;
double LONG_SCALE;
double HEIGHT_SCALE;
double LINE_NUM_COEFF[20];
double LINE_DEN_COEFF[20];
double SAMP_NUM_COEFF[20];
double SAMP_DEN_COEFF[20];
} NITFRPC00BInfo;
char *NITFFormatRPC00BFromMetadata(char **papszRPC, int *pbPrecisionLoss);
int NITFDeserializeRPC00B(const GByte *pabyTRE, NITFRPC00BInfo *psRPC,
int bIsRPC00A);
int CPL_DLL NITFReadRPC00B(NITFImage *psImage, NITFRPC00BInfo *);
int CPL_DLL NITFRPCGeoToImage(NITFRPC00BInfo *, double, double, double,
double *, double *);
/* -------------------------------------------------------------------- */
/* ICHIP structure, and function to fill it. */
/* -------------------------------------------------------------------- */
typedef struct
{
int XFRM_FLAG;
double SCALE_FACTOR;
int ANAMORPH_CORR;
int SCANBLK_NUM;
double OP_ROW_11;
double OP_COL_11;
double OP_ROW_12;
double OP_COL_12;
double OP_ROW_21;
double OP_COL_21;
double OP_ROW_22;
double OP_COL_22;
double FI_ROW_11;
double FI_COL_11;
double FI_ROW_12;
double FI_COL_12;
double FI_ROW_21;
double FI_COL_21;
double FI_ROW_22;
double FI_COL_22;
int FI_ROW;
int FI_COL;
} NITFICHIPBInfo;
int CPL_DLL NITFReadICHIPB(NITFImage *psImage, NITFICHIPBInfo *);
double CPL_DLL
NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude(double dfLat);
typedef struct
{
const char *code;
const char *abbreviation;
const char *scaleResolution;
const char *name;
const char *rpfDataType;
} NITFSeries;
/** Return not freeable (maybe NULL if no matching) */
const NITFSeries CPL_DLL *NITFGetSeriesInfo(const char *pszFilename);
/* -------------------------------------------------------------------- */
/* Internal use */
/* -------------------------------------------------------------------- */
char **NITFGenericMetadataRead(char **papszMD, NITFFile *psFile,
NITFImage *psImage,
const char *pszSpecificTREName);
CPLXMLNode *NITFCreateXMLTre(NITFFile *psFile, const char *pszTREName,
const char *pachTRE, int nTRESize);
CPL_C_END
#endif /* ndef NITFLIB_H_INCLUDED */
|