function calculateSourceExtentResolution(
  sourceProj,
  targetProj,
  targetExtent,
  targetResolution,
) {
  const targetCenter = getCenter(targetExtent);
  let sourceResolution = calculateSourceResolution(
    sourceProj,
    targetProj,
    targetCenter,
    targetResolution,
  );

  if (!isFinite(sourceResolution) || sourceResolution <= 0) {
    forEachCorner(targetExtent, function (corner) {
      sourceResolution = calculateSourceResolution(
        sourceProj,
        targetProj,
        corner,
        targetResolution,
      );
      return isFinite(sourceResolution) && sourceResolution > 0;
    });
  }

  return sourceResolution;
}
Calculates ideal resolution to use from the source in order to achieve
pixel mapping as close as possible to 1:1 during reprojection.
The resolution is calculated regardless of what resolutions
are actually available in the dataset (TileGrid, Image, ...).

@param {import("./proj/Projection.js").default} sourceProj Source projection.
@param {import("./proj/Projection.js").default} targetProj Target projection.
@param {import("./extent.js").Extent} targetExtent Target extent
@param {number} targetResolution Target resolution.
@return {number} The best resolution to use. Can be +-Infinity, NaN or 0.