L_EnumFileGeoKeys

#include "l_bitmap.h"

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

L_TCHAR* pszFile;

input file name

L_UINT uFlags;

reserved for future use.

ENUMGEOKEYSCALLBACK pfnCallback;

callback function

L_VOID* pUserData;

pointer to more parameters for the callback

pLOADFILEOPTION pLoadOptions;

pointer to optional extended load options

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

Parameter

Description

pszFile

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

uFlags

Flags parameter reserved for future use. Pass 0.

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.

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.

pLoadOptions

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

Returns

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

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.

Platforms

Win32, x64, Linux.

See Also

Functions:

L_SetGeoKey, L_GetGeoKey, L_WriteFileGeoKey, L_WriteFileMetaData, L_EnumFileGeoKeys, L_SaveFile, L_SaveBitmap, ENUMGEOKEYSCALLBACK

Topics:

Implementing GeoKeys (GeoTIFF tags)

 

Implementing TIFF Comments and Tags

 

Raster Image Functions: Working with GeoKeys

Example

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

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
#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 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help