L_INT LFile::EnumGeoKeys(uFlags, pLoadOptions)
Enumerates all the GeoKeys in a GeoTIFF file.
Flags parameter reserved for future use. Pass 0.
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 LFile::EnumTags. Or you can call LFile::ReadTag for each of these tags (since there are not that many of them to warrant the use of LFile::EnumTags).
For more information about GeoKeys tags, refer to Implementing GeoKeys (GeoTIFF tags).
Win32, x64.
/* Displays a GeoKey in a message box*/
static L_VOID DisplayKey(L_UINT16 uTag,L_UINT16 uType,L_UINT32 uCount,L_VOID *pData)
{
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);
/* 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*/
if(uType == TAG_ASCII)
MessageBox(NULL, (LPCWSTR)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);
}
}
/*<struct>*/
#ifdef LFileChild
class LFileChild : public LFile
{
L_INT EnumGeoKeysCallBack(L_UINT16 uTag,L_UINT16 uType,L_UINT32 uCount, L_VOID *pData);
};
#endif // #ifdef LFileChild
/*</struct>*/
L_INT LFileChild::EnumGeoKeysCallBack(L_UINT16 uTag,L_UINT16 uType,L_UINT32 uCount, L_VOID *pData)
{
DisplayKey(uTag,uType,uCount,pData) ;
return SUCCESS ;
}
L_INT LFile__EnumGeoKeysExample(LFileChild& file)
{
L_INT nRet;
file.SetFileName(MAKE_IMAGE_PATH(TEXT("clean.tif")));
file.EnableCallBack(TRUE) ;
nRet = file.EnumGeoKeys( 0, NULL);
if(nRet != SUCCESS)
{
MessageBox(NULL, TEXT("Error enumerating GeoKeys"), TEXT("ERROR"), MB_OK);
return nRet;
}
else
MessageBox(NULL, TEXT("Enumeration SUCCEEDED!"), TEXT("SUCCESS"), 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