3DSoftware.com > Programming > File Formats > FIN > Page 4
FIN File Format  Page 4
 
File Header
 
Each FIN file contains data at the beginning of the file to provide information about the file.
 
 
File Signature Bytes
Bytes 0 – 3

 
The first 4 bytes of the FIN file are the File Signature Bytes which identify the file as a FIN file, and must have these values:
 
Byte 0  =  
Byte 1  =  
Byte 2  =  
Byte 3  =  
0x46
0x49
0x4e
0x00
 
Those are the ASCII characters ‘F’, ‘I’ and ‘N’ respectively.
 

 
File Header (Unsigned Integers)
Bytes 0 – 80   (0x0 – 0x50)

 
The first 80 bytes of the FIN file is file header information in an array of unsigned integers. There are 20 unsigned integers in this array. Each unsigned integer is 32-bits. In C/C++, we declare the array:
 
unsigned int uivecHeader[ 20 ];        
 
When writing this array to file, since each variable in the array is multi-byte, write one variable at a time to ensure proper byte ordering of each 32-bit variable:
 
for ( i = 0; i < 20; i++ )
    WriteUIntMSBFIRST( uivecHeader[ i ], pFile );
 
When reading the multi-byte variables from file, read one variable at a time:
 
for ( i = 0; i < 20; i++ )
    uivecHeader[ i ] = ReadUIntMSBFIRST( pFile );
 
This array of variables defines the following file settings:
 
uivecHeader[ 0 ]  =  
uivecHeader[ 1 ]  =  
uivecHeader[ 2 ]  =  
uivecHeader[ 3 ]  =  
uivecHeader[ 4 ]  =  
uivecHeader[ 5 ]  =  
uivecHeader[ 6 ]  =  
uivecHeader[ 7 ]  =  
uivecHeader[ 8 ]  =  
uivecHeader[ 9 ]  =  
uivecHeader[ 10 ]  =  
uivecHeader[ 11 ]  =  
uivecHeader[ 12 ]  =  
uivecHeader[ 13 ]  =  
uivecHeader[ 14 ]  =  
uivecHeader[ 15 ]  =  
uivecHeader[ 16 ]  =  
uivecHeader[ 17 ]  =  
uivecHeader[ 18 ]  =  
uivecHeader[ 19 ]  =  
File Signature
File Version
File Size High
File Size
Grid Width
Grid Height
Tile Width
Tile Height
Number of Matrices
Byte Flags
Ptr to Tile Addresses
Ptr to Block Addresses
Ptr to Band Addresses
Reserved
Ptr to File Dynamic Range
Ptr to File Bias
Ptr to Copyright Notice
Ptr to Text Titles
Ptr to Text Comments
Ptr to Custom Data
 
File Signature (Magic Number)
Must be 0x46494e00
 
File Version
Must be 1
 
File Size High
0 = Default
If the file size is 64 bits, then this is the high order 32 bits of the file size. If the file size is 32 bits, then this is zero.
 
File Size
Size of the file (number of bytes).  If the file size is 64 bits, this is the low order 32 bits of the file size.
 
Grid Width and Height
Size of grid, in floating point numbers or integers. The grid width is the number of columns in the grid. The grid height is the number of rows in the grid.
        Both of these variables (Grid Width and Height) can be zero if only blocks are used (without bands), and if both variables (not just one of these variables) are zero, in which case the two variables can be ignored (or determined by examining the blocks). For example, you can store a file of vector polylines with each polyline as a block without specifying grid extents.
 
Tile Width and Tile Height
Size of each tile. Tile width is the number of columns in the tile. Tile Height is the number of rows in the tile. Both can be set to zero if tiling will not be used, or if the file will be a single tile and blocks and bands are not used.
 
Number of Matrices
This is how many channels (planes) of data are stored. For example, if the file stores a matrix of longitude values and a matrix of latitude values, the Number of Matrices is 2.
 
Byte Flags
Bytes settings that are accessed with shifting. Byte settings that are not used must be 0x00. The following byte settings are always used:
Compression = 
Type of Grid Node  = 
 
uivecHeader[ 9 ] & 255
( uivecHeader[ 9 ] >> 8 ) & 255
 
Compression
0x00 if compression is turned OFF for the file, or 0x01 if compression is turned ON for the file.
 
Type of Grid Node
0x00 = ANSI/IEEE Floating Point
0x01 = Integer
0x02 = FloatBin
Type of uncompressed grid node. All grid nodes of the file will be of this type before any compression/encoding.
 
If the Type of Grid Node is 0x00 or 0x01, then the Size of Grid Node is stored as:
 
Size of Grid Node = ( uivecHeader[ 9 ] >> 8 ) & 255
Specifies the size in bytes of an uncompressed grid node: 0x04 or 0x08 if the Grid Node Type is 0x00 (ANSI/IEEE floating point numbers); at least 0x01 if Grid Node Type is 0x01 (integers); can be 0x00 if Grid Node Type is 0x00 (then 0x08 is assumed as the Grid Node Size).
 
If the Type of Grid Node is 0x02, then each uncompressed grid node is 18 bytes (see the FloatBin specification) and the Size of Grid Node should be zero.
 
Pointer to Tile Addresses
This is the offset in bytes (from beginning of file) to the list of Tile Addresses. This is zero if tiles are not used. Tiles are used if Blocks and Bands are not used. If Blocks or Diagonal Bands are used, then this Pointer to Tile Addresses must be zero and tiles are not used.
 
Pointer to Block Addresses
This variable points (is the offset in bytes from beginning of file) to the list of Block Addresses. This must be zero if blocks are not used. Blocks can only be used if Tiles are not used (if Pointer to Tile Addresses is zero).
 
Pointer to Band Addresses
This variable points (is the offset in bytes from beginning of file) to the list of Diagonal Bands. This must be zero if diagonal bands are not used. Diagonal bands can only be used if Tiles are not used (if Pointer to Tile Addresses is zero).
 
Reserved
uivecHeader[ 13 ] is reserved for future use and must be zero.
 
Pointer to File Dynamic Range
0 = Default
If this variable is non-zero, it is the offset in bytes (from beginning of file) to the Dynamic Range of the entire file integer grid. This is optional, and is only supported for an integer grid.
 
Pointer to File Bias
0 = Default
This variable specifies the optional bias for the entire file integer grid. Application programs can subtract this variable from each integer in the grid to recover original signed data. This is only supported for an integer grid.
 
Pointer to Copyright Notice
This is the offset in bytes (from beginning of file) to a Copyright Notice. This is optional. If this is null (zero), there is no copyright notice. The Copyright Notice consists of Simple Unicode UTF-16 text characters.
 
Pointer to Text Titles
This is the offset in bytes (from beginning of file) to Column and Row Titles. If this is null (zero), there are no titles. Titles are optional, and are Simple Unicode UTF-16 text characters.
 
Pointer to Text Comments
This is the offset in bytes (from beginning of file) to Text Comments. If this is null (zero), there are no comments. That is the default. Comments are optional, and are Simple Unicode UTF-16 text characters.
 
Pointer to Custom Data
0 = Default
If this variable is non-zero, it is the offset in bytes (from beginning of file) to Custom Data. The Custom Data consists of an unsigned int (32-bit number) that specifies the size (in bytes) of the custom data, followed by that many bytes of your custom binary data. The binary data can be any binary data you need to transfer with the file, and can be ignored by decoders.
 
—  Page 4  —
 « Page 3 Contents Page 5 » 
 
Copyright © 2008 by 3D Software. All rights reserved.
3D Software, P.O. Box 221190, Sacramento CA 95822 USA
www.3DSoftware.com     Contact us
Tuesday, 06-Jan-2009 04:36:19 GMT