我正在创建一个GeoTIFF,并使用下面的代码似乎运行良好,但是该库会生成很多警告,特别是有关我要添加的自定义字段的警告。有人可以指出为什么是这种情况还是我做错了什么?
警告特别是:TIFFSetField: [filename]: Unknown tag 34264
和TIFFSetField: [filename]: Unknown tag 34736
#define TIFFTAG_GEOTRANSMATRIX 34264
#define TIFFTAG_GEOKEYDIRECTORY 34735
#define TIFFTAG_GEODOUBLEPARAMS 34736
TIFF* tif = TIFFOpen(filename.c_str(), "w");
if (!tif) throw std::runtime_error("Error creating TIFF object");
// Add custom tags
// [enum, read count, write count, type, bit, ok to change, pass count, name]
// -1 for read count/write count signifies variable length
const TIFFFieldInfo xtiffFieldInfo[] = {
{ TIFFTAG_GEOTRANSMATRIX, -1, -1, TIFF_DOUBLE, FIELD_CUSTOM, 1, 1, (char*)"GeoTransformationMatrix" },
{ TIFFTAG_GEOKEYDIRECTORY, -1, -1, TIFF_SHORT, FIELD_CUSTOM, 1, 1, (char*)"GeoKeyDirectory" },
{ TIFFTAG_GEODOUBLEPARAMS, -1, -1, TIFF_DOUBLE, FIELD_CUSTOM, 1, 1, (char*)"GeoDoubleParams" },
};
TIFFMergeFieldInfo(tif, xtiffFieldInfo, 3); // manually set 3 for testing
TIFFSetField(tif, TIFFTAG_GEOTRANSMATRIX, 16, &xform[0]); // <- generates warning
{
const Float64 tmp[2] = { 298.257223563, // GeogInvFlatteningGeoKey
6378137.0 }; // GeogSemiMajorAxisGeoKey; WGS 84 reference ellipsoid defines 6,378,137m
TIFFSetField(tif, TIFFTAG_GEODOUBLEPARAMS, 2, &tmp[0]); // <- generates warning
}
// Write a few other tags and image scanlines
TIFFClose(tif);