LFile::SetGeoKey

#include "ltwrappr.h"

L_INT LFile::SetGeoKey(uTag, uType, uCount, pData)

L_UINT16 uTag;

/* GeoKey ID */

L_UINT uType;

/* GeoKey type */

L_UINT uCount;

/* number of GeoKey values */

L_VOID *pData;

/* pointer to GeoKey data */

Sets the GeoKey data to be saved in a file.

Parameter

Description

uTag

ID of the GeoKey to set. Values of the GeoKey ID range between 0 and 65535. Possible ranges are:

 

Range

Meaning

 

0..1023

Do not use; reserved for future use.

 

1024..2047

GeoTIFF configuration keys.

 

2048..3071

Geographic/Geocentric CS Parameter keys.

 

3072..4095

Projected CS Parameter keys.

 

4096..5119

Vertical CS Parameter keys.

 

5120..32767

Reserved.

 

32768..65535

Private use use to store your own data

uType

The type of GeoKey to set. This indicates whether the data pointed to by pData is SHORT, DOUBLE or ASCII. Possible values are:

 

Value

Meaning

 

TAG_ASCII

[2] The data pointed to by pData is an array of ASCII bytes.

 

TAG_SHORT

[3] The data pointed to by pData is an array of SHORT values (2 bytes each).

 

TAG_DOUBLE

[12] The data pointed to by pData is an array of floating points in DOUBLE format (8 bytes each).

uCount

The number of items in the pData buffer. Note that this doesn't describe the number of bytes. The number of bytes is uCount * number of bytes per value (1 for ASCII, 2 for SHORT, 8 for DOUBLE).

pData

Pointer to a buffer that contains the GeoKey data.

If the pData passed as NULL, the GeoKey data associated with uTag will be cleared; and the uType and uCount parameters will be ignored.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function copies the data pointed to by pData into an internal list of buffers maintained by LTFIL. The user is responsible for freeing the buffer pointed to by pData after calling this function.

Any GeoTIFF file that you save will include the GeoKey data set until you clear the GeoKey data. To save this data to a file, save FILE_GEOTIFF files.

To clear a particular GeoKey, call LFile::SetGeoKey(uTag, 0, 0, NULL).

To clear all the GeoKeys, call LFile::SetGeoKey(0, 0, 0, NULL).

The data set will be saved in the files into 3 TIFF tags:

LFile::SetGeoKey will overwrite any values saved for these tags previously using LFileSettings::SetTag.

For more information on the various GeoKey values and for links to the GeoTIFF specification, refer to Implementing GeoKeys (GeoTIFF tags).

You can get the last value set with LFile::SetGeoKey by using LFile::GetGeoKey.

To write the GeoKey data directly to an existing file, call LFile::WriteGeoKey.

Note that LEADTOOLS does not verify the validity of the GeoKeys that you set. It is your responsibility to make sure you write correct values according to the GeoTIFF specification.

Required DLLs and Libraries

LTFIL

LFTIF

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LFile::GetGeoKey, LFile::WriteGeoKey, LFile::ReadGeoKey, LFile::EnumGeoKeys, LFile::SaveFile, LFile::Save

Topics:

Implementing GeoKeys (GeoTIFF tags)

 

Implementing TIFF Comments and Tags

 

Raster Image Functions: Working with GeoKeys

Example

This example sets the GTModelTypeGeoKey key to the Project Coordination System value.

L_INT LFile__SetGeoKeyExample(LFile& file) 
{
   L_INT nRet;
   L_UINT16 uProjectCoordinationSystem = 1; 
   nRet = file.SetGeoKey(1024, TAG_SHORT, 1, &uProjectCoordinationSystem); 
   if (nRet == SUCCESS) 
      MessageBox(NULL, TEXT("works Fine!"), TEXT("SUCCESS"), MB_OK); 
   else
      return nRet;
   //Every GeoTIFF file I save from now on will contain this GeoKey
   return SUCCESS;
}