function getRequestUrl(
  baseUrl,
  extent,
  resolution,
  pixelRatio,
  projection,
  params,
) {
  // ArcGIS Server only wants the numeric portion of the projection ID.
  // (if there is no numeric portion the entire projection code must
  // form a valid ArcGIS SpatialReference definition).
  const srid = projection
    .getCode()
    .split(/:(?=\d+$)/)
    .pop();

  const imageResolution = resolution / pixelRatio;

  const imageSize = [
    round(getWidth(extent) / imageResolution, DECIMALS),
    round(getHeight(extent) / imageResolution, DECIMALS),
  ];

  params['SIZE'] = imageSize[0] + ',' + imageSize[1];
  params['BBOX'] = extent.join(',');
  params['BBOXSR'] = srid;
  params['IMAGESR'] = srid;
  params['DPI'] = Math.round(
    params['DPI'] ? params['DPI'] * pixelRatio : 90 * pixelRatio,
  );

  const modifiedUrl = baseUrl
    .replace(/MapServer\/?$/, 'MapServer/export')
    .replace(/ImageServer\/?$/, 'ImageServer/exportImage');
  return appendParams(modifiedUrl, params);
}
@param {string} baseUrl Base URL for the ArcGIS Rest service.
@param {import("../extent.js").Extent} extent Extent.
@param {number} resolution Resolution.
@param {number} pixelRatio Pixel ratio.
@param {import("../proj/Projection.js").default} projection Projection.
@param {Object} params Params.
@return {string} Request URL.