Skip to content

Commit

Permalink
169 Adusting sequence of cadastrapp layers creation (#177)
Browse files Browse the repository at this point in the history
* #169 Making sure that vector layer is initialized only after raster layer

* Solving issue when initial load of layers does not get selections information from state.

* Updating dependencies to make project pass tests upon build.
See geosolutions-it/MapStore2@1ea2597

* Leftovers removal
alexander-fedorenko authored Aug 31, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 98d5c1e commit 4782ac5
Showing 4 changed files with 47 additions and 25 deletions.
8 changes: 8 additions & 0 deletions js/extension/actions/cadastrapp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

export const SETUP = "CADASTRAPP:SETUP";
export const SETUP_COMPLETED = "CADASTRAPP:SETUP_COMPLETED";
export const LAYERS_INITIALIZED = "CADASTRAPP:LAYERS_INITIALIZED";
export const TEAR_DOWN = "CADASTRAPP:TEAR_DOWN";
export const LOADING = "CADASTRAPP:LOADING";
export const SET_CONFIGURATION = "CADASTRAPP:SET_CONFIGURATION";
@@ -73,6 +74,13 @@ export const setUp = (cfg) => ({
cfg
});

/**
* triggered when layers are initialized upon setup, after setup is completed
*/
export const initializedLayers = () => ({
type: LAYERS_INITIALIZED
});

/**
* triggered when setup is completed
*/
30 changes: 18 additions & 12 deletions js/extension/epics/layerSync.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@ import {
SET_STYLES,
ZOOM_TO_RESULTS,
UPDATE_LAYER_STYLE,
ADD_PLOT_SELECTION
ADD_PLOT_SELECTION,
TEAR_DOWN,
LAYERS_INITIALIZED
} from '../actions/cadastrapp';
import {
getCurrentPlotFeatures,
@@ -33,18 +35,22 @@ import {


export const syncLayerForPlots = (action$, {getState = () => {}})=>
action$.ofType(SETUP_COMPLETED, ADD_PLOT_SELECTION, ADD_PLOTS, REMOVE_PLOTS, SET_ACTIVE_PLOT_SELECTION, REMOVE_PLOT_SELECTION, SELECT_PLOTS, DESELECT_PLOTS, SET_LAYER_STYLE, SET_STYLES, UPDATE_LAYER_STYLE) // actions that modify the layer, so it needs an update.
action$.ofType(SETUP_COMPLETED)
.switchMap(() => {
const features = getCurrentPlotFeatures(getState());
const options = getCadastrappVectorLayer(getState());
return Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
"overlay", {
...options,
features
}));
return action$.ofType(LAYERS_INITIALIZED, ADD_PLOT_SELECTION, ADD_PLOTS, REMOVE_PLOTS, SET_ACTIVE_PLOT_SELECTION, REMOVE_PLOT_SELECTION, SELECT_PLOTS, DESELECT_PLOTS, SET_LAYER_STYLE, SET_STYLES, UPDATE_LAYER_STYLE) // actions that modify the layer, so it needs an update.
.switchMap(() => {
const features = getCurrentPlotFeatures(getState());
const options = getCadastrappVectorLayer(getState());
return Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
"overlay", {
...options,
features
}));
})
.takeUntil(action$.ofType(TEAR_DOWN));
});

export const zoomToExtentAllResultsEpic = (action$, {getState = () => {}})=>
22 changes: 15 additions & 7 deletions js/extension/epics/setup.js
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ import {
setConfiguration,
setupCompleted,
loading,
toggleSelectionTool, TOGGLE_SELECTION
toggleSelectionTool, TOGGLE_SELECTION, initializedLayers
} from '../actions/cadastrapp';
import {
SET_CONTROL_PROPERTIES,
@@ -62,7 +62,13 @@ export const cadastrappSetup = (action$, store) =>
.switchMap(data => {
return Rx.Observable.of(setConfiguration(data));
})
.startWith(updateDockPanelsList(CONTROL_NAME, 'add', 'right'));
.startWith({
type: 'MAP_LAYOUT:UPDATE_DOCK_PANELS',
name: 'cadastrapp',
action: 'add',
location: 'right'
});
const mapInfoEnabled = get(store.getState(), "mapInfo.enabled");
return initStream$.concat(
Rx.Observable.defer(() => {
// here the configuration has been loaded
@@ -72,7 +78,7 @@ export const cadastrappSetup = (action$, store) =>
cadastreWFSLayerName,
cadastreWFSURL
} = configurationSelector(store.getState());
return Rx.Observable.from([
return Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_RASTER_LAYER_ID,
CADASTRAPP_OWNER,
@@ -88,7 +94,9 @@ export const cadastrappSetup = (action$, store) =>
name: cadastreWFSLayerName,
type: "wfs"
}
}, true),
}),
registerEventListener(MOUSE_EVENT, CONTROL_NAME) // Set map's mouse event trigger type
).concat([
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
@@ -100,12 +108,12 @@ export const cadastrappSetup = (action$, store) =>
name: "searchPoints",
visibility: true
}),
registerEventListener(MOUSE_EVENT, CONTROL_NAME), // Set map's mouse event trigger type
...(get(store.getState(), "mapInfo.enabled") ? [toggleMapInfoState(), hideMapinfoMarker()] : [])
...(mapInfoEnabled ? [toggleMapInfoState(), hideMapinfoMarker()] : [])
]);
})
)
.concat(Rx.Observable.of(setupCompleted())) // required to sync the layer the first time (if closed/reopen)
.concat(Rx.Observable.of(setupCompleted())) // subscribes app to sync selection layer upon several actions
.concat(Rx.Observable.of(initializedLayers())) // required to sync the layer the first time (if closed/reopen)
.let(
wrapStartStop(
loading(true, 'configuration'),
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -57,14 +57,14 @@
"html-loader": "0.5.1",
"html-webpack-plugin": "4.5.0",
"jsdoc-jsx": "0.1.0",
"karma": "5.2.3",
"karma-chrome-launcher": "3.1.0",
"karma": "6.4.0",
"karma-chrome-launcher": "3.1.1",
"karma-cli": "2.0.0",
"karma-coverage": "2.0.3",
"karma-coverage": "2.2.0",
"karma-coveralls": "2.1.0",
"karma-firefox-launcher": "2.1.0",
"karma-firefox-launcher": "2.1.2",
"karma-ie-launcher": "1.0.0",
"karma-junit-reporter": "1.2.0",
"karma-junit-reporter": "2.0.1",
"karma-mocha": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"karma-sourcemap-loader": "0.3.8",
@@ -96,7 +96,7 @@
"vusion-webfonts-generator": "0.4.1",
"webpack": "5.9.0",
"webpack-bundle-size-analyzer": "2.0.2",
"webpack-cli": "4.9.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "3.11.0",
"zip-webpack-plugin": "^3.0.0",
"git-revision-webpack-plugin": "5.0.0"

0 comments on commit 4782ac5

Please sign in to comment.