diff --git a/map/common/geotiff-grid-source.js b/map/common/geotiff-grid-source.js index 684c69139..8eaef1b84 100644 --- a/map/common/geotiff-grid-source.js +++ b/map/common/geotiff-grid-source.js @@ -1,4 +1,5 @@ import * as GeoTIFF from 'geotiff' +import _ from 'lodash' import { unitConverters, SortOrder, GridSource, Grid1D } from './grid.js' // pack r,g,b in an uint32 @@ -56,7 +57,8 @@ export class GeoTiffGridSource extends GridSource { this.rgb = config.rgb try { - this.geotiff = await GeoTIFF.fromUrl(config.url) + // forceXHR is useful for tests because nock doesn't know how to intercept fetch + this.geotiff = await GeoTIFF.fromUrl(config.url, { forceXHR: _.get(config, 'forceXHR', false) }) } catch (error) { // fetching may fail, in this case the source // will remain in unusable state diff --git a/test/api/map/grid-sources.test.js b/test/api/map/grid-sources.test.js index 8303c1eb1..564538529 100644 --- a/test/api/map/grid-sources.test.js +++ b/test/api/map/grid-sources.test.js @@ -155,7 +155,9 @@ describe('map:grid-source', () => { describe('geotiff', () => { const geotiffOptions = { geotiff: { - url: 'http://kMap.test/data.tif' + url: 'http://kMap.test/data.tif', + // because nock doesnt know howto intercept fecth + forceXHR: true } }