Skip to content

Commit

Permalink
fixup! Fix circular dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Kumer committed Aug 1, 2024
1 parent e4b7397 commit 1dc4837
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/layer/AbstractSentinelHubV1OrV2Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { stringify } from 'query-string';

import { BBox } from '../bbox';
import { Fis } from '../statistics/Fis';
import { StatisticsProviderType } from '../statistics/StatisticsProvider';
import { CACHE_CONFIG_NOCACHE } from '../utils/cacheHandlers';
import { getAxiosReqParams, RequestConfiguration } from '../utils/cancelRequests';
import { ensureTimeout } from '../utils/ensureTimeout';
Expand All @@ -23,6 +22,7 @@ import {
} from './const';
import { fetchLayersFromGetCapabilitiesXml } from './utils';
import { wmsGetMapUrl } from './wms';
import { StatisticsProviderType } from '../statistics';

interface ConstructorParameters {
instanceId?: string | null;
Expand Down
2 changes: 1 addition & 1 deletion src/layer/AbstractSentinelHubV3Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import { Effects } from '../mapDataManipulation/const';
import { runEffectFunctions } from '../mapDataManipulation/runEffectFunctions';
import { Fis } from '../statistics/Fis';
import { StatisticalApi } from '../statistics/StatisticalApi';
import { StatisticsProviderType } from '../statistics/StatisticsProvider';
import { CACHE_CONFIG_30MIN, CACHE_CONFIG_NOCACHE } from '../utils/cacheHandlers';
import { fetchLayerParamsFromConfigurationService, getSHServiceRootUrl } from './utils';
import { StatisticsProviderType } from '../statistics/const';

interface ConstructorParameters {
instanceId?: string | null;
Expand Down
2 changes: 1 addition & 1 deletion src/layer/BYOCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { ProcessingPayload } from './processing';
import { getAxiosReqParams, RequestConfiguration } from '../utils/cancelRequests';
import { ensureTimeout } from '../utils/ensureTimeout';
import { CACHE_CONFIG_30MIN } from '../utils/cacheHandlers';
import { StatisticsProviderType } from '../statistics/StatisticsProvider';
import { getSHServiceRootUrl, metersPerPixel } from './utils';
import { StatisticsProviderType } from '../statistics/const';

interface ConstructorParameters {
instanceId?: string | null;
Expand Down
19 changes: 14 additions & 5 deletions src/statistics/StatisticsProvider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { AbstractLayer } from '../layer/AbstractLayer';
import { GetStatsParams, Stats } from '../layer/const';
import { RequestConfiguration } from '../utils/cancelRequests';

export enum StatisticsProviderType {
FIS = 'FIS',
STAPI = 'STAPI',
}
import { StatisticsProviderType } from './const';
import { Fis } from './Fis';
import { StatisticalApi } from './StatisticalApi';

export interface StatisticsProvider {
getStats(layer: AbstractLayer, params: GetStatsParams, reqConfig?: RequestConfiguration): Promise<Stats>;
}

export function getStatisticsProvider(statsProvider: StatisticsProviderType): StatisticsProvider {
switch (statsProvider) {
case StatisticsProviderType.STAPI:
return new StatisticalApi();
case StatisticsProviderType.FIS:
return new Fis();
default:
throw new Error(`Unknows statistics provider ${statsProvider}`);
}
}
5 changes: 5 additions & 0 deletions src/statistics/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,8 @@ export type StatisticalApiResponse = {

error?: StatisticalApiResponseError;
}[];

export enum StatisticsProviderType {
FIS = 'FIS',
STAPI = 'STAPI',
}
3 changes: 2 additions & 1 deletion src/statistics/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { getStatisticsProvider } from './StatisticsProvider';
export {
BandHistogram,
BandStats,
Expand All @@ -7,6 +8,6 @@ export {
StatisticalApiOutput,
StatisticalApiPayload,
StatisticalApiResponse,
StatisticsProviderType,
} from './const';
export { StatisticsProviderType } from './StatisticsProvider';
export { StatisticsUtils } from './statistics.utils';

0 comments on commit 1dc4837

Please sign in to comment.