handleImageryMetadataResponse(response) {
    if (
      response.statusCode != 200 ||
      response.statusDescription != 'OK' ||
      response.authenticationResultCode != 'ValidCredentials' ||
      response.resourceSets.length != 1 ||
      response.resourceSets[0].resources.length != 1
    ) {
      this.setState(SourceState.ERROR);
      return;
    }

    const resource = response.resourceSets[0].resources[0];
    const maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;

    const sourceProjection = this.getProjection();
    const extent = extentFromProjection(sourceProjection);
    const scale = this.hidpi_ ? 2 : 1;
    const tileSize =
      resource.imageWidth == resource.imageHeight
        ? resource.imageWidth / scale
        : [resource.imageWidth / scale, resource.imageHeight / scale];

    const tileGrid = createXYZ({
      extent: extent,
      minZoom: resource.zoomMin,
      maxZoom: maxZoom,
      tileSize: tileSize,
    });
    this.tileGrid = tileGrid;

    const culture = this.culture_;
    const hidpi = this.hidpi_;
    this.tileUrlFunction = createFromTileUrlFunctions(
      resource.imageUrlSubdomains.map(function (subdomain) {
        /** @type {import('../tilecoord.js').TileCoord} */
        const quadKeyTileCoord = [0, 0, 0];
        const imageUrl = resource.imageUrl
          .replace('{subdomain}', subdomain)
          .replace('{culture}', culture);
        return (
          /**
           * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
           * @param {number} pixelRatio Pixel ratio.
           * @param {import("../proj/Projection.js").default} projection Projection.
           * @return {string|undefined} Tile URL.
           */
          function (tileCoord, pixelRatio, projection) {
            if (!tileCoord) {
              return undefined;
            } else {
              createOrUpdate(
                tileCoord[0],
                tileCoord[1],
                tileCoord[2],
                quadKeyTileCoord
              );
              let url = imageUrl;
              if (hidpi) {
                url += '&dpi=d1&device=mobile';
              }
              return url.replace('{quadkey}', quadKey(quadKeyTileCoord));
            }
          }
        );
      })
    );

    if (resource.imageryProviders) {
      const transform = getTransformFromProjections(
        getProjection('EPSG:4326'),
        this.getProjection()
      );

      this.setAttributions(
        function (frameState) {
          const attributions = [];
          const viewState = frameState.viewState;
          const tileGrid = this.getTileGrid();
          const z = tileGrid.getZForResolution(
            viewState.resolution,
            this.zDirection
          );
          const tileCoord = tileGrid.getTileCoordForCoordAndZ(
            viewState.center,
            z
          );
          const zoom = tileCoord[0];
          resource.imageryProviders.map(function (imageryProvider) {
            let intersecting = false;
            const coverageAreas = imageryProvider.coverageAreas;
            for (let i = 0, ii = coverageAreas.length; i < ii; ++i) {
              const coverageArea = coverageAreas[i];
              if (
                zoom >= coverageArea.zoomMin &&
                zoom <= coverageArea.zoomMax
              ) {
                const bbox = coverageArea.bbox;
                const epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
                const extent = applyTransform(epsg4326Extent, transform);
                if (intersects(extent, frameState.extent)) {
                  intersecting = true;
                  break;
                }
              }
            }
            if (intersecting) {
              attributions.push(imageryProvider.attribution);
            }
          });

          attributions.push(TOS_ATTRIBUTION);
          return attributions;
        }.bind(this)
      );
    }

    this.setState(SourceState.READY);
  }
/**
   * @param {BingMapsImageryMetadataResponse} response Response.
   */
@param {BingMapsImageryMetadataResponse} response Response.
@param { BingMapsImageryMetadataResponse } response Response .
handleImageryMetadataResponse(response) {
    if (
      response.statusCode != 200 ||
      response.statusDescription != 'OK' ||
      response.authenticationResultCode != 'ValidCredentials' ||
      response.resourceSets.length != 1 ||
      response.resourceSets[0].resources.length != 1
    ) {
      this.setState(SourceState.ERROR);
      return;
    }
    const resource = response.resourceSets[0].resources[0];
    const maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
    const sourceProjection = this.getProjection();
    const extent = extentFromProjection(sourceProjection);
    const scale = this.hidpi_ ? 2 : 1;
    const tileSize =
      resource.imageWidth == resource.imageHeight
        ? resource.imageWidth / scale
        : [resource.imageWidth / scale, resource.imageHeight / scale];
    const tileGrid = createXYZ({
      extent: extent,
      minZoom: resource.zoomMin,
      maxZoom: maxZoom,
      tileSize: tileSize,
    });
    this.tileGrid = tileGrid;
    const culture = this.culture_;
    const hidpi = this.hidpi_;
    this.tileUrlFunction = createFromTileUrlFunctions(
      resource.imageUrlSubdomains.map(function (subdomain) {
        const quadKeyTileCoord = [0, 0, 0];
        const imageUrl = resource.imageUrl
          .replace('{subdomain}', subdomain)
          .replace('{culture}', culture);
        return (
          function (tileCoord, pixelRatio, projection) {
            if (!tileCoord) {
              return undefined;
            } else {
              createOrUpdate(
                tileCoord[0],
                tileCoord[1],
                tileCoord[2],
                quadKeyTileCoord
              );
              let url = imageUrl;
              if (hidpi) {
                url += '&dpi=d1&device=mobile';
              }
              return url.replace('{quadkey}', quadKey(quadKeyTileCoord));
            }
          }
        );
      })
    );
    if (resource.imageryProviders) {
      const transform = getTransformFromProjections(
        getProjection('EPSG:4326'),
        this.getProjection()
      );
      this.setAttributions(
        function (frameState) {
          const attributions = [];
          const viewState = frameState.viewState;
          const tileGrid = this.getTileGrid();
          const z = tileGrid.getZForResolution(
            viewState.resolution,
            this.zDirection
          );
          const tileCoord = tileGrid.getTileCoordForCoordAndZ(
            viewState.center,
            z
          );
          const zoom = tileCoord[0];
          resource.imageryProviders.map(function (imageryProvider) {
            let intersecting = false;
            const coverageAreas = imageryProvider.coverageAreas;
            for (let i = 0, ii = coverageAreas.length; i < ii; ++i) {
              const coverageArea = coverageAreas[i];
              if (
                zoom >= coverageArea.zoomMin &&
                zoom <= coverageArea.zoomMax
              ) {
                const bbox = coverageArea.bbox;
                const epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
                const extent = applyTransform(epsg4326Extent, transform);
                if (intersects(extent, frameState.extent)) {
                  intersecting = true;
                  break;
                }
              }
            }
            if (intersecting) {
              attributions.push(imageryProvider.attribution);
            }
          });
          attributions.push(TOS_ATTRIBUTION);
          return attributions;
        }.bind(this)
      );
    }
    this.setState(SourceState.READY);
  }
handleImageryMetadataResponse ( response ) { if ( response . statusCode != 200 || response . statusDescription != 'OK' || response . authenticationResultCode != 'ValidCredentials' || response . resourceSets . length != 1 || response . resourceSets [ 0 ] . resources . length != 1 ) { this . setState ( SourceState . ERROR ) ; return ; } const resource = response . resourceSets [ 0 ] . resources [ 0 ] ; const maxZoom = this . maxZoom_ == - 1 ? resource . zoomMax : this . maxZoom_ ; const sourceProjection = this . getProjection ( ) ; const extent = extentFromProjection ( sourceProjection ) ; const scale = this . hidpi_ ? 2 : 1 ; const tileSize = resource . imageWidth == resource . imageHeight ? resource . imageWidth / scale : [ resource . imageWidth / scale , resource . imageHeight / scale ] ; const tileGrid = createXYZ ( { extent : extent , minZoom : resource . zoomMin , maxZoom : maxZoom , tileSize : tileSize , } ) ; this . tileGrid = tileGrid ; const culture = this . culture_ ; const hidpi = this . hidpi_ ; this . tileUrlFunction = createFromTileUrlFunctions ( resource . imageUrlSubdomains . map ( function ( subdomain ) { const quadKeyTileCoord = [ 0 , 0 , 0 ] ; const imageUrl = resource . imageUrl . replace ( '{subdomain}' , subdomain ) . replace ( '{culture}' , culture ) ; return ( function ( tileCoord , pixelRatio , projection ) { if ( ! tileCoord ) { return undefined ; } else { createOrUpdate ( tileCoord [ 0 ] , tileCoord [ 1 ] , tileCoord [ 2 ] , quadKeyTileCoord ) ; let url = imageUrl ; if ( hidpi ) { url += '&dpi=d1&device=mobile' ; } return url . replace ( '{quadkey}' , quadKey ( quadKeyTileCoord ) ) ; } } ) ; } ) ) ; if ( resource . imageryProviders ) { const transform = getTransformFromProjections ( getProjection ( 'EPSG:4326' ) , this . getProjection ( ) ) ; this . setAttributions ( function ( frameState ) { const attributions = [ ] ; const viewState = frameState . viewState ; const tileGrid = this . getTileGrid ( ) ; const z = tileGrid . getZForResolution ( viewState . resolution , this . zDirection ) ; const tileCoord = tileGrid . getTileCoordForCoordAndZ ( viewState . center , z ) ; const zoom = tileCoord [ 0 ] ; resource . imageryProviders . map ( function ( imageryProvider ) { let intersecting = false ; const coverageAreas = imageryProvider . coverageAreas ; for ( let i = 0 , ii = coverageAreas . length ; i < ii ; ++ i ) { const coverageArea = coverageAreas [ i ] ; if ( zoom >= coverageArea . zoomMin && zoom <= coverageArea . zoomMax ) { const bbox = coverageArea . bbox ; const epsg4326Extent = [ bbox [ 1 ] , bbox [ 0 ] , bbox [ 3 ] , bbox [ 2 ] ] ; const extent = applyTransform ( epsg4326Extent , transform ) ; if ( intersects ( extent , frameState . extent ) ) { intersecting = true ; break ; } } } if ( intersecting ) { attributions . push ( imageryProvider . attribution ) ; } } ) ; attributions . push ( TOS_ATTRIBUTION ) ; return attributions ; } . bind ( this ) ) ; } this . setState ( SourceState . READY ) ; }
@param {BingMapsImageryMetadataResponse} response Response.
@param { BingMapsImageryMetadataResponse } response Response .
/** @type {import('../tilecoord.js').TileCoord} */ /**
           * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
           * @param {number} pixelRatio Pixel ratio.
           * @param {import("../proj/Projection.js").default} projection Projection.
           * @return {string|undefined} Tile URL.
           */