Skip to content

Commit

Permalink
Integrated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-NRCan committed Feb 26, 2024
1 parent 477efaa commit 2b6667d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ import { AbstractEventProcessor, BatchedPropagationLayerDataArrayByMap } from '.
* Event processor focusing on interacting with the geochart state in the store.
*/
export class GeochartEventProcessor extends AbstractEventProcessor {
// **********************************************************
// Static functions for Typescript files to access store actions
// **********************************************************
//! Typescript MUST always use the defined store actions below to modify store - NEVER use setState!
//! Some action does state modifications AND map actions.
//! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler

// #region
// Holds the list of layer data arrays being buffered in the propagation process for the batch
static batchedPropagationLayerDataArray: BatchedPropagationLayerDataArrayByMap = {};

// The time delay between propagations in the batch layer data array.
// The longer the delay, the more the layers will have a chance to get in a loaded state before changing the layerDataArray.
// The longer the delay, the longer it'll take to update the UI. The delay can be bypassed using the layer path bypass method.
static timeDelayBetweenPropagationsForBatch = 2000;

/**
* Overrides initialization of the GeoChart Event Processor
* @param {GeoviewStoreType} store The store associated with the GeoChart Event Processor
Expand Down Expand Up @@ -67,6 +51,22 @@ export class GeochartEventProcessor extends AbstractEventProcessor {
return [unsubLayerRemoved, layerDataArrayUpdate];
}

// **********************************************************
// Static functions for Typescript files to access store actions
// **********************************************************
//! Typescript MUST always use the defined store actions below to modify store - NEVER use setState!
//! Some action does state modifications AND map actions.
//! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler

// #region
// Holds the list of layer data arrays being buffered in the propagation process for the batch
static batchedPropagationLayerDataArray: BatchedPropagationLayerDataArrayByMap = {};

// The time delay between propagations in the batch layer data array.
// The longer the delay, the more the layers will have a chance to get in a loaded state before changing the layerDataArray.
// The longer the delay, the longer it'll take to update the UI. The delay can be bypassed using the layer path bypass method.
static timeDelayBetweenPropagationsForBatch = 2000;

/**
* Shortcut to get the Geochart state for a given map id
* @param {string} mapId The mapId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import { AbstractEventProcessor } from '../abstract-event-processor';
* Event processor focusing on interacting with the swiper state in the store.
*/
export class SwiperEventProcessor extends AbstractEventProcessor {
// **********************************************************
// Static functions for Typescript files to access store actions
// **********************************************************
//! Typescript MUST always use the defined store actions below to modify store - NEVER use setState!
//! Some action does state modifications AND map actions.
//! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler

/**
* Overrides initialization of the Swiper Event Processor
* @param {GeoviewStoreType} store The store associated with the Swiper Event Processor
Expand Down Expand Up @@ -49,6 +42,13 @@ export class SwiperEventProcessor extends AbstractEventProcessor {
return [unsubLayerRemoved];
}

// **********************************************************
// Static functions for Typescript files to access store actions
// **********************************************************
//! Typescript MUST always use the defined store actions below to modify store - NEVER use setState!
//! Some action does state modifications AND map actions.
//! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler

/**
* Shortcut to get the Swiper state for a given map id
* @param {string} mapId The mapId
Expand Down Expand Up @@ -78,7 +78,7 @@ export class SwiperEventProcessor extends AbstractEventProcessor {
}

/**
* Adds a swipe functionality to the specified map id and layer path
* Adds a swiper functionality to the specified map id and layer path
* @param {string} mapId The map ID
* @param {string} layerPath The layer path
*/
Expand Down Expand Up @@ -108,7 +108,7 @@ export class SwiperEventProcessor extends AbstractEventProcessor {
}

/**
* Removes a swipe functionality for the specified map id and layer path
* Removes a swiper functionality for the specified map id and layer path
* @param {string} mapId The map ID
* @param {string} layerPath The layer path
*/
Expand Down Expand Up @@ -141,7 +141,7 @@ export class SwiperEventProcessor extends AbstractEventProcessor {
}

/**
* Removes the swipe functionality for all layer paths
* Removes the swiper functionality for all layer paths
* @param {string} mapId The map ID
*/
static removeAll(mapId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export function GuidePanel({ fullWidth }: GuidePanelType): JSX.Element {
const allTabs: TypeValidFooterBarTabsCoreProps | undefined = footerBarConfig?.tabs.core;

// fetch the content of general guide items with custom hook
let mdFilePath = '/geoview/public/locales/markdown/general-content.md';
if (process.env.NODE_ENV === 'development') mdFilePath = '/locales/markdown/general-content.md';
const mdFilePath = './locales/markdown/general-content.md';
useFetchAndParseMarkdown(mapId, mdFilePath, t('guide.errorMessage'), setLeftPanelHelpItems);

const leftPanelItemKeys = leftPanelHelpItems && Object.keys(leftPanelHelpItems);
Expand Down
6 changes: 3 additions & 3 deletions packages/geoview-core/src/geo/layer/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ export class Layer {
*
* @returns {BaseLayer | LayerGroup} Returns the OpenLayer layer associated to the layer path.
*/
getLayerByLayerPath = (layerPath: string): BaseLayer | LayerGroup => {
getOLLayerByLayerPath = (layerPath: string): BaseLayer | LayerGroup => {
// Return the olLayer object from the registered layers
const olLayer = api.maps[this.mapId].layer.registeredLayers[layerPath]?.olLayer;
if (olLayer) return olLayer;
Expand All @@ -536,12 +536,12 @@ export class Layer {
/**
* Asynchronously returns the OpenLayer layer associated to a specific layer path.
* This function waits the timeout period before abandonning (or uses the default timeout when not provided).
* Note this function uses the 'Async' suffix to differentiate it from 'getLayerByLayerPath'.
* Note this function uses the 'Async' suffix to differentiate it from 'getOLLayerByLayerPath'.
* @param {string} layerPath The layer path to the layer's configuration.
*
* @returns {BaseLayer | LayerGroup} Returns the OpenLayer layer associated to the layer path.
*/
getLayerByLayerPathAsync = async (layerPath: string, timeout?: number, checkFrequency?: number): Promise<BaseLayer | LayerGroup> => {
getOLLayerByLayerPathAsync = async (layerPath: string, timeout?: number, checkFrequency?: number): Promise<BaseLayer | LayerGroup> => {
// Make sure the open layer has been created, sometimes it can still be in the process of being created
const promisedLayer = await whenThisThen(
() => {
Expand Down
11 changes: 6 additions & 5 deletions packages/geoview-swiper/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ class SwiperPlugin extends MapPlugin {
* @param {string} layerPath The layer path to activate swiper functionality
*/
activateForLayer = (layerPath: string) => {
// Check if the layer exists on the map
const layer = this.map().layer.getLayerByLayerPath(layerPath);
if (layer) {
try {
// Check if the layer exists on the map
this.map().layer.getOLLayerByLayerPath(layerPath);

// Add the layer path
SwiperEventProcessor.addLayerPath(this.pluginProps.mapId, layerPath);
} else {
} catch (error) {
// Log
logger.logError(`Couldn't find the layer with layer path ${layerPath}`);
logger.logError(error);
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/geoview-swiper/src/swiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function Swiper(props: SwiperProps): JSX.Element {
async (layerPath: string) => {
try {
// Get the layer at the layer path
const olLayer = await mapViewer.layer.getLayerByLayerPathAsync(layerPath);
const olLayer = await mapViewer.layer.getOLLayerByLayerPathAsync(layerPath);
if (olLayer) {
// Set the OL layers
setOlLayers((prevArray: BaseLayer[]) => [...prevArray, olLayer]);
Expand Down Expand Up @@ -209,7 +209,7 @@ export function Swiper(props: SwiperProps): JSX.Element {
layerPaths.forEach((layerPath: string) => {
try {
// Get the layer at the layer path
const olLayer = mapViewer.layer.getLayerByLayerPath(layerPath);
const olLayer = mapViewer.layer.getOLLayerByLayerPath(layerPath);
if (olLayer) {
// Unwire the events on the layer
olLayer.un(['precompose' as EventTypes, 'prerender' as EventTypes], prerender);
Expand Down

0 comments on commit 2b6667d

Please sign in to comment.