L_EnumFileGeoKeys

#include "l_bitmap.h"

L_LTFIL_API L_INT L_EnumFileGeoKeys(pszFile, uFlags, pfnCallback, pUserData, pLoadOptions)

This function will enumerate all the GeoKeys in a GeoTIFF file.

Parameters

L_TCHAR* pszFile

Character string containing the name of the file in which to enumerate GeoKeys.

L_UINT uFlags

Flags parameter reserved for future use. Pass 0.

ENUMGEOKEYSCALLBACK pfnCallback

Callback function for enumerating each GeoKey. Use the function pointer as the value of this parameter.L_EnumFileGeoKeys calls this callback function for each tag. The callback function must adhere to the function prototype described in the ENUMGEOKEYSCALLBACK Function.

L_VOID* pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

pLOADFILEOPTION pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

For multipage GeoTIFF files, you can enumerate the tags from a particular page. Specify the page number on which to enumerate the keys using the pLoadOptions parameter.

The callback is called for each GeoKey value stored in the three standard GeoTIFF tags (34735, 34736 and 34737). For enumerating the other standard GeoTIFF data stored as separate tags, you can use L_EnumFileTags. Or you can call L_ReadFileTag for each of these tags (since there are not that many of them to warrant the use of L_EnumFileTags).

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

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This is an efficient way of reading all the GeoKeys in a file

#define FILENAME MAKE_IMAGE_PATH(TEXT("clean.tif")) /* change this to point to a GeoTIFF file */ 
 
L_INT EXT_CALLBACK EnumGeoKeysCallback(L_UINT16 uTag, 
                                       L_UINT16 uType, 
                                       L_UINT32 uCount, 
                                       L_VOID * pData, 
                                       L_VOID * pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   L_TCHAR s[500]; 
 
   wsprintf(s, TEXT("Key = %d, Type = %s, Count = %d"), uTag, uType == TAG_ASCII ? TEXT("ASCII") : (uType == TAG_SHORT ? TEXT("SHORT") : TEXT("DOUBLE")), uCount); 
   MessageBox(NULL, s, TEXT("Key Info"), MB_OK); 
    
 
   if(uType == TAG_ASCII) 
   { 
      /* LEADTOOLS makes the string null-terminated, so it is OK to pass it to MessageBox. 
         Note that for Unicode builds you will need to convert this array of bytes to array of WCHAR 
      */ 
      MessageBox(NULL, (LPCTSTR)pData, TEXT("Key Value"), MB_OK); 
   } 
   else  
   { 
      if(uType == TAG_SHORT) 
         if(uCount == 1) 
            wsprintf(s, TEXT("%d"), *(L_UINT16 *)pData); 
         else 
            wsprintf(s, TEXT("{%d, ...}"), *(L_UINT16 *)pData); 
      else 
         if(uCount == 1) 
            wsprintf(s, TEXT("%g"), *(L_DOUBLE *)pData); 
         else 
            wsprintf(s, TEXT("{%g, ...}"), *(L_DOUBLE *)pData); 
      MessageBox(NULL, s, TEXT("Key Value"), MB_OK); 
   } 
   return SUCCESS; 
} 
 
L_INT EnumFileGeoKeysExample(HWND hWnd) 
{ 
   L_INT nRet = L_EnumFileGeoKeys(FILENAME, 0, EnumGeoKeysCallback, NULL, NULL); 
   if(nRet != SUCCESS) 
   { 
      MessageBox(hWnd, TEXT("Error enumerating GeoKeys"), TEXT("ERROR"), MB_OK); 
      return nRet; 
   } 
   else 
      MessageBox(hWnd,TEXT("Enumeration SUCCEEDED!"),TEXT("Notice"), MB_OK); 
   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.