L_GetGeoKey

#include "l_bitmap.h"

L_LTFIL_API L_INT L_GetGeoKey(uTag, puType, puCount, pData)

Gets the data that is ready to be saved as GeoKeys in a GeoTIFF file.

Parameters

L_UINT16 uTag

ID of the GeoKey to get. 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.

L_UINT* puType

Pointer to the variable to be updated with the GeoKey type. It 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).

L_UINT* puCount

Pointer to the variable to be updated with the number of items required for the pData buffer. Note that this is not the required number of bytes. The required number of will be (*puCount) * number of bytes per value (1 for ASCII, 2 for SHORT, 8 for DOUBLE).

If pData passed as NOT NULL, this variable will be updated with the number of data items.

L_VOID* pData

Pointer to the buffer to be updated with the data. You can pass NULL if you want to use this function's return value to determine the required buffer size.

Returns

Value Meaning
> 0 The length of the GeoKey data in bytes.
0 There is no GeoKey data with this GeoKey.
< 0 An error occurred. Refer to Return Codes.

Comments

You can use this function to obtain GeoKey data that will be saved the next time you save a GeoTIFF (FILE_GEOTIFF) file.

If you want to get the GeoKey data from a particular file, use the L_ReadFileGeoKey function.

It is often convenient to call this function twice, as follows:

  1. Call the function the first time, specifying NULL in the pData parameter, and using the return value to determine the required size of the buffer.

  2. Allocate the buffer.

  3. Call the function the second time, passing a pointer to your buffer in the pData parameter.

For more information about GeoKeys, refer to Implementing GeoKeys (GeoTIFF tags).

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example gets the value set for the GTModelTypeGeoKey key.
Note that the example can be simpler by not allocating memory because this particular GeoKey has only one SHORT item. But I want to demonstrate how you call L_GetGeoKey twice and get the required size in the first call

L_INT GetGeoKeyExample(L_VOID) 
{ 
   L_UINT16 *pData = NULL; 
   L_UINT uCount; 
   L_UINT uType; 
   L_INT nSize; 
 
   nSize = L_GetGeoKey(1024, &uType, &uCount, NULL); 
   if(nSize <= 0) 
   { 
      MessageBox(NULL, TEXT("The GeoKey was not set, or an error occurred!"), TEXT("FAILURE"), MB_OK); 
      return nSize; 
   } 
   else 
   { 
      // allocate an array large enough to store the GeoKey data 
      pData = (L_UINT16 *)malloc(nSize); 
      if(pData != NULL) 
      { 
         nSize = L_GetGeoKey(1024, &uType, &uCount, pData); 
         if(nSize <= 0) 
            MessageBox(NULL,TEXT("Error getting the GeoKey!"), TEXT("FAILURE"), MB_OK); 
         else 
         { 
            // do whatever you want with the GeoKey data 
         } 
         free(pData); //// free the pData buffer 
      } 
   } 
   return SUCCESS; 
} 

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.