Skip to content

Commit

Permalink
Merge pull request #1498 from ychoquet/Event-processors-restructuration
Browse files Browse the repository at this point in the history
Event processors restructuration (#1498)
  • Loading branch information
jolevesq authored Nov 14, 2023
2 parents ed051e4 + 9e11133 commit 87e7af7
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GeoViewStoreType } from '@/core/stores/geoview-store';
import { AbstractEventProcessor } from './abstract-event-processor';
import { AbstractEventProcessor } from '../abstract-event-processor';
import { getGeoViewStore } from '@/core/stores/stores-managers';
import { NotificationDetailsType } from '@/core/types/cgpv-types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GeoViewStoreType } from '@/core/stores/geoview-store';
import { AbstractEventProcessor } from './abstract-event-processor';
import { AbstractEventProcessor } from '../abstract-event-processor';
import { EVENT_NAMES } from '@/api/events/event-types';
import {
TypeFeatureInfoResultSets,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GeoViewStoreType } from '@/core/stores/geoview-store';
import { AbstractEventProcessor } from './abstract-event-processor';
import { AbstractEventProcessor } from '../abstract-event-processor';
import { EVENT_NAMES } from '@/api/events/event-types';
import { payloadIsLegendsLayersetUpdated } from '@/api/events/payloads/get-legends-payload';
import { api } from '@/app';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Overlay from 'ol/Overlay';
import { fromLonLat } from 'ol/proj';

import { GeoViewStoreType } from '@/core/stores/geoview-store';
import { AbstractEventProcessor } from './abstract-event-processor';
import { AbstractEventProcessor } from '../abstract-event-processor';
import { api, NORTH_POLE_POSITION, TypeClickMarker } from '@/app';
import { CustomAttribution } from '@/geo/utils/custom-attribution';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AppEventProcessor } from '@/api/eventProcessors/app-event-processor';
import { FeatureInfoEventProcessor } from '@/api/eventProcessors/feature-info-event-processor';
import { AppEventProcessor } from '@/api/event-processors/event-processor-children/app-event-processor';
import { FeatureInfoEventProcessor } from '@/api/event-processors/event-processor-children/feature-info-event-processor';
import { GeoViewStoreType } from '@/core/stores/geoview-store';
import { LegendEventProcessor } from '@/api/eventProcessors/legend-event-processor';
import { MapEventProcessor } from '@/api/eventProcessors/map-event-processor';
import { LegendEventProcessor } from '@/api/event-processors/event-processor-children/legend-event-processor';
import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';

const appEventProcessor = new AppEventProcessor();
const featureInfoEventProcessor = new FeatureInfoEventProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function initializeLayerState(set: TypeSetStore, get: TypeGetStore): ILay
layer.allItemsChecked = visibility;
layer.isVisible = visibility;
}

set({
legendState: {
...get().legendState,
Expand All @@ -116,7 +117,7 @@ export function initializeLayerState(set: TypeSetStore, get: TypeGetStore): ILay
});
},
},
};
} as ILayerState;

return init;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
fixNorth: false,
mapLoaded: false,
northArrow: false,
northArrowElement: { degreeRotation: '180.0', isNorthVisible: true },
northArrowElement: { degreeRotation: '180.0', isNorthVisible: true } as TypeNorthArrow,
overviewMap: false,
overviewMapHideZoom: 0,
pointerPosition: undefined,
Expand Down Expand Up @@ -338,7 +338,7 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
api.maps[get().mapId].zoomToExtent(extent, options);
},
},
};
} as IMapState;

return init;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function initializeUIState(set: TypeSetStore, get: TypeGetStore): IUIStat
});
},
},
};
} as IUIState;

return init;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/src/core/stores/stores-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useContext } from 'react';
import { create, createStore } from 'zustand';
import { mountStoreDevtool } from 'simple-zustand-devtools';

import { initializeEventProcessors } from '@/api/eventProcessors';
import { initializeEventProcessors } from '@/api/event-processors';
import { TypeMapFeaturesConfig } from '../types/global-types';
import { IGeoViewState, GeoViewStoreType, geoViewStoreDefinitionWithSubscribeSelector } from './geoview-store';
import { MapContext } from '@/core/app-start';
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/src/core/utils/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function _addNotification(mapId: string, type: NotificationType = 'info', messag
};

// ? Need to do lazy import, if not viewer crashes (AppEventProcessor.addAppNotification(mapId, notification));
import('@/api/eventProcessors/app-event-processor').then((mod) => mod.AppEventProcessor.addAppNotification(mapId, notification));
import('@/api/event-processors/event-processor-children/app-event-processor').then((mod) => mod.AppEventProcessor.addAppNotification(mapId, notification));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface TypeWmsLegend extends Omit<TypeLegend, 'styleConfig'> {

/**
* type guard function that redefines a TypeLegend as a TypeImageStaticLegend
* if the event attribute of the verifyIfPayload parameter is valid. The type ascention
* if the type attribute of the verifyIfLegend parameter is valid. The type ascention
* applies only to the true block of the if clause.
*
* @param {TypeLegend} verifyIfLegend object to test in order to determine if the type ascention is valid
Expand All @@ -101,17 +101,17 @@ export interface TypeImageStaticLegend extends Omit<TypeLegend, 'styleConfig'> {
legend: HTMLCanvasElement;
}

const validEvents: TypeGeoviewLayerType[] = ['GeoJSON', 'esriDynamic', 'esriFeature', 'ogcFeature', 'ogcWfs', 'GeoPackage'];
const validVectorLayerLegendTypes: TypeGeoviewLayerType[] = ['GeoJSON', 'esriDynamic', 'esriFeature', 'ogcFeature', 'ogcWfs', 'GeoPackage'];
/**
* type guard function that redefines a TypeLegend as a TypeVectorLegend
* if the event attribute of the verifyIfPayload parameter is valid. The type ascention
* if the type attribute of the verifyIfLegend parameter is valid. The type ascention
* applies only to the true block of the if clause.
*
* @param {TypeLegend} verifyIfLegend object to test in order to determine if the type ascention is valid
* @returns {boolean} returns true if the payload is valid
*/
export const isVectorLegend = (verifyIfLegend: TypeLegend): verifyIfLegend is TypeVectorLegend => {
return validEvents.includes(verifyIfLegend?.type);
return validVectorLayerLegendTypes.includes(verifyIfLegend?.type);
};

export interface TypeVectorLegend extends TypeLegend {
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/src/geo/map/map-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { generateId, getValidConfigFromString } from '@/core/utils/utilities';
import { TypeListOfGeoviewLayerConfig, TypeDisplayLanguage, TypeViewSettings } from '@/geo/map/map-schema-types';
import { TypeMapFeaturesConfig, TypeHTMLElement } from '@/core/types/global-types';
import { layerConfigIsGeoCore } from '@/geo/layer/other/geocore';
import { MapEventProcessor } from '@/api/eventProcessors/map-event-processor';
import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';

interface TypeDcoument extends Document {
webkitExitFullscreen: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@/api/events/payloads';
import { api, getLocalizedValue } from '@/app';
import { LayerSet } from './layer-set';
import { FeatureInfoEventProcessor } from '@/api/eventProcessors/feature-info-event-processor';
import { FeatureInfoEventProcessor } from '@/api/event-processors/event-processor-children/feature-info-event-processor';

/** ***************************************************************************************************************************
* A class to hold a set of layers associated with an array of TypeArrayOfFeatureInfoEntries. When this class is instantiated,
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/src/geo/utils/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { xmlToJson } from '@/core/utils/utilities';
import { TypeLayerEntryConfig, TypeListOfLayerEntryConfig, layerEntryIsGroupLayer } from '@/geo/map/map-schema-types';
import { AbstractGeoViewLayer } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { Layer } from '@/geo/layer/layer';
import { AppEventProcessor } from '@/api/eventProcessors/app-event-processor';
import { AppEventProcessor } from '@/api/event-processors/event-processor-children/app-event-processor';
import { NORTH_POLE_POSITION } from '@/core/utils/constant';

/**
Expand Down

0 comments on commit 87e7af7

Please sign in to comment.