KMLSuperOverlay: Reapply 4745.6.diff from #4745 to add 'AUTO' format.

Conflicts:
	gdal/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
HFA: Trim identical trailing entries in RAT tables that are smaller
than the colour table. Helps when RATs travel via GTiff.
Don't pass resolution information from TIFFTAG into Kakadu if it's not finite
Better support for writing RATs, re #4903

Updated from 4903.9.diff to apply to latest trunk.
 * track thematic/athematic RAT type
 * Write RATs for Imagine/HFA output by default
 * Copy RATs during gdalwarp file-creation as well (if using nearest).
 * Copy RATs during gdal_translate VRT-path as well.
 * but, discard RATs if the operation makes them invalid
gdal_calc: convert data types earlier so output numbers don't get wrapped to the input data-type.

Includes a test