#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.
Character string containing the name of the file in which to enumerate GeoKeys.
Flags parameter reserved for future use. Pass 0.
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.
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.
Pointer to optional extended load options. Pass NULL to use the default load options.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
Win32, x64, Linux.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document