/******************************************************** ** Copyright 2004 Earth Resource Mapping Ltd. ** This document contains proprietary source code of ** Earth Resource Mapping Ltd, and can only be used under ** one of the three licenses as described in the ** license.txt file supplied with this distribution. ** See separate license.txt file for license details ** and conditions. ** ** This software is covered by US patent #6,442,298, ** #6,102,897 and #6,633,688. Rights to use these patents ** is included in the license agreements. ** ** FILE: $Archive: /NCS/Source/include/NCSGeoTIFFBoxUtil.h $ ** CREATED: 12/07/2004 3:27:34 PM ** AUTHOR: Tom Lynch ** PURPOSE: Static GeoTIFF file values for JPEG 2000 GeoTIFF UUID Box (GeoJP2) ** GeoTIFF related #defines ** Utility CNCSAffineTransform class definition ** EDITS: [xx] ddMmmyy NAME COMMENTS ** [01] 08Jul04 tfl Changes to write GeoJP2 headers correctly ** [02] 03Aug04 tfl More GeoTIFF Box header changes ** [03] 22Nov04 tfl Added photometric interpretation tag to GeoJP2 data to fix ERDAS load *******************************************************/ #ifndef NCSGEOTIFFBOXUTIL_H #define NCSGEOTIFFBOXUTIL_H #define TIFF_BIGENDIAN_CODE 0x4949 //Two byte TIFF header codes flagging endianness #define TIFF_LITTLEENDIAN_CODE 0x4d4d #define TIFF_IDENTITY_CODE 0x2a //Further magic number identifying file as a TIFF (42) #ifndef NCSECWCLIENT_H #include "NCSECWClient.h" //For NCSFileViewFileInfoEx #endif #ifndef NCSJP2FILE_H #include "NCSJP2File.h" //For TIFFTag #endif #ifndef ECW_MAX_PROJECTION_LEN #define ECW_MAX_PROJECTION_LEN 16 #endif class CNCSAffineTransform { public: IEEE8 fScaleX; IEEE8 fScaleY; IEEE8 fRotX; IEEE8 fRotY; IEEE8 fTransX; IEEE8 fTransY; CNCSAffineTransform(); CNCSAffineTransform(IEEE4 fPrecision); ~CNCSAffineTransform(); BOOLEAN GetFromFileInfoEx(NCSFileViewFileInfoEx &FileInfo); BOOLEAN GetFromFileInfo(NCSFileViewFileInfo &FileInfo); BOOLEAN GetFromGeoTIFFModelTransformationTag(CNCSJP2File::CNCSJP2PCSBox::TIFFTag *pTransformTag); BOOLEAN PopulateFileInfoEx(NCSFileViewFileInfoEx &FileInfo); BOOLEAN PopulateFileInfo(NCSFileViewFileInfo &FileInfo); BOOLEAN IsValid(); private: void Standardize(); IEEE4 m_fPrecision; }; //This static array contains most of the default byte values in the GeoTIFF box static UINT8 GeoTIFFInitialData[] = { 0xb1,0x4b,0xf8,0xbd,0x8,0x3d,0x4b,0x43,0xa5,0xae,0x8c,0xd7,0xd5,0xa6,0xce,0x3,//UUID //GeoTIFF file header 0x49,0x49,//TIFF_BIGENDIAN_CODE (little-endian in accordance with GeoJP2 spec) 0x2a,0x00,//TIFF_IDENTITY_CODE (42 little-endian) 0x08,0x00,0x00,0x00,//Offset of first IFD (8 bytes so follows on immediately) //First IFD 0x0c,0x00,//0x0b == 10 IFD entries //Entry 0 0x00,0x01,//TIFF tag value == 256, image width 0x03,0x00,//Type of field == 3, UINT16 0x01,0x00,0x00,0x00,//Only one such value 0x01,0x00,0x00,0x00,//Width is 1 //Entry 1 0x01,0x01,//TIFF tag value == 257, image height (otherwise same as above) 0x03,0x00, 0x01,0x00,0x00,0x00, 0x01,0x00,0x00,0x00, //Entry 2 0x02,0x01,//TIFF tag value == 258, bits per sample 0x03,0x00,//Type is UINT16 again 0x01,0x00,0x00,0x00, 0x08,0x00,0x00,0x00,//8 bits for our single pixel //Entry 3 0x03,0x01,//TIFF tag value == 259, compression technique 0x03,0x00, 0x01,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,//no compression used //Entry 4 0x06,0x01, //Photometric Interpretation [03] 0x03,0x00, //Type is SHORT 0x01,0x00,0x00,0x00, 0x01,0x00,0x00,0x00, //value 0x01 == BlackIsZero //Entry 5 0x11,0x01,//TIFF tag value == 273, strip offsets 0x04,0x00,//Type is UINT32 (TIFF_LONG) 0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //Entry 6 0x15,0x01,//TIFF tag value == 277, samples per pixel 0x03,0x00, 0x01,0x00,0x00,0x00, 0x01,0x00,0x00,0x00, //Entry 7 0x17,0x01,//TIFF tag value == 279, strip byte count 0x04,0x00, 0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //Entry 8 0x1c,0x01,//TIFF tag value == 284, storage organisation 0x03,0x00, 0x01,0x00,0x00,0x00, 0x01,0x00,0x00,0x00, //single contiguous image plane /*//Entry 8 0x0e,0x83,//TIFF tag value == 33550, ModelPixelScaleTag 0x0c,0x00,//Data type TIFF_DOUBLE, 64-bit floating point (IEEE8) 0x03,0x00,0x00,0x00,//3 such values 0x92,0x00,0x00,0x00,//value offset //Entry 9 0x82,0x84,//TIFF tag value == 33922, ModelTiePointTag 0x0c,0x00,//IEEE8 data type 0x06,0x00,0x00,0x00,//6 values representing (XYZ)<-->(IJK) 0xaa,0x00,0x00,0x00,//offset to values //Entry 10 0xaf,0x87,//TIFF tag value == 34735, GeoKeyDirectoryTag 0x03,0x00, 0x10,0x00,0x00,0x00,//16 values 0xda,0x00,0x00,0x00, //End of IFD entries 0x00,0x00,//Presumably this is the pixel value //Offset here is 0x92 - pixel scale values 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x4e,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 0x4e,0x40,0x00,0x00,0x00,0x00,0x00,0x00, //Offset here is 0xaa - tie point values 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xe6, 0x1a,0x41,0x00,0x00,0x00,0x00,0xcc,0x9e, 0x4c,0x41,0x00,0x00,0x00,0x00,0x00,0x00, //Offset here is 0xda - GeoKeyDirectoryTag values 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x00,0x00, 0x03,0x00, 0x00,0x04, 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x01,0x04, 0x00,0x00, 0x01,0x00, 0x01,0x00, 0x00,0x0c, 0x00,0x00, 0x01,0x00, 0x57,0x68*/ }; #endif