Skip to content

Commit

Permalink
sigrennesmetropole#46 Urbanisme evolutions, updated layer addition & …
Browse files Browse the repository at this point in the history
…feature highlighting mechanism (sigrennesmetropole#43)
  • Loading branch information
alexander-fedorenko authored Feb 21, 2022
1 parent 825278a commit 8487f4a
Show file tree
Hide file tree
Showing 11 changed files with 890 additions and 163 deletions.
30 changes: 29 additions & 1 deletion js/extension/actions/__tests__/urbanisme-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
SET_URBANISME_DATA,
setAttributes,
toggleGFIPanel,
TOGGLE_VIEWER_PANEL
TOGGLE_VIEWER_PANEL,
featureInfoClick,
URBANISME_FEATURE_INFO_CLICK,
highlightFeature,
URBANISME_HIGHLIGHT_FEATURE,
resetFeatureHighlight, URBANISME_RESET_FEATURE_HIGHLIGHT
} from "../urbanisme";

describe('Test correctness of the urbanisme actions', () => {
Expand Down Expand Up @@ -45,4 +50,27 @@ describe('Test correctness of the urbanisme actions', () => {
expect(action.type).toBe(TOGGLE_VIEWER_PANEL);
expect(action.enabled).toEqual(true);
});
it('featureInfoClick', () => {
const action = featureInfoClick({}, 'test');
expect(action).toExist();
expect(action.type).toBe(URBANISME_FEATURE_INFO_CLICK);
expect(action.point).toEqual({});
expect(action.layer).toBe('test');
expect(action.filterNameList).toEqual([]);
expect(action.overrideParams).toEqual({});
expect(action.itemId).toBe(null);
});
it('highlightFeature', () => {
const action = highlightFeature({}, {}, 'test');
expect(action).toExist();
expect(action.type).toBe(URBANISME_HIGHLIGHT_FEATURE);
expect(action.point).toEqual({});
expect(action.feature).toEqual({});
expect(action.featureCrs).toBe('test');
});
it('resetFeatureHighlight', () => {
const action = resetFeatureHighlight();
expect(action).toExist();
expect(action.type).toBe(URBANISME_RESET_FEATURE_HIGHLIGHT);
});
});
48 changes: 43 additions & 5 deletions js/extension/actions/urbanisme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import { printError } from "@mapstore/actions/print";
import {printError} from "@mapstore/actions/print";

import { getUrbanismePrintSpec, retryDownload } from "../utils/UrbanismeUtils";
import { printPDF } from "@js/extension/api";
import {getUrbanismePrintSpec, retryDownload} from "../utils/UrbanismeUtils";
import {printPDF} from "@js/extension/api";

export * from "./setUp";
export const TOGGLE_TOOL = "URBANISME:TOGGLE_TOOL";
export const TOGGLE_VIEWER_PANEL = "URBANISME:TOGGLE_VIEWER_PANEL";
export const SET_URBANISME_DATA = "URBANISME:SET_URBANISME_DATA";
export const LOADING = "URBANISME:LOADING";
export const URBANISME_FEATURE_INFO_CLICK = 'URBANISME:FEATURE_INFO_CLICK';
export const URBANISME_HIGHLIGHT_FEATURE = 'URBANISME:HIGHLIGHT_FEATURE';
export const URBANISME_RESET_FEATURE_HIGHLIGHT = 'URBANISME:RESET_FEATURE_HIGHLIGHT';

/**
* Sets the status of loading of a resource called "name" and "value" as the information status
Expand Down Expand Up @@ -77,8 +80,8 @@ export const toggleGFIPanel = enabled => {
export const printSubmit = attributes => {
return (dispatch, getState) => {
const state = getState() || {};
const { outputFilename, layout = "A4 portrait", ...dataAttributes } =
attributes || {};
const {outputFilename, layout = "A4 portrait", ...dataAttributes} =
attributes || {};
const {
layers,
scaleForZoom,
Expand Down Expand Up @@ -110,3 +113,38 @@ export const printSubmit = attributes => {
});
};
};

/**
* Carries data needed for Get Feature Info request
* @param {object} point point clicked in this shape {latlng: {lat:1, lng:2}, pixel:{x:33 y:33}, modifiers:{} }
* @param {string} layer the name of the layer without workspace
* @param {object[]} [filterNameList=[]] list of layers to perform the GFI request
* @param {object} [overrideParams={}] a map based on name as key and object as value for overriding request params
* @param {string} [itemId=null] id of the item needed for filtering results
*/
export function featureInfoClick(point, layer, filterNameList = [], overrideParams = {}, itemId = null) {
return {
type: URBANISME_FEATURE_INFO_CLICK,
point,
layer,
filterNameList,
overrideParams,
itemId
};
}


export function highlightFeature(point, feature, featureCrs) {
return {
type: URBANISME_HIGHLIGHT_FEATURE,
point,
feature,
featureCrs
};
}

export function resetFeatureHighlight() {
return {
type: URBANISME_RESET_FEATURE_HIGHLIGHT
};
}
3 changes: 3 additions & 0 deletions js/extension/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

export const URBANISME_RASTER_LAYER_ID = "__URBANISME_RASTER_LAYER__";
export const URBANISME_VECTOR_LAYER_ID = "__URBANISME_VECTOR_LAYER__";
export const CONTROL_NAME = "urbanisme";
export const DEFAULT_URBANISME_LAYER = "urbanisme_parcelle";
export const DEFAULT_CADASTRAPP_URL = "/cadastrapp/services";
Expand All @@ -15,6 +16,8 @@ export const URBANISME_TOOLS = {
NRU: "NRU",
ADS: "ADS"
};
export const URBANISME_OWNER = "URBANISME";

export const ADS_DEFAULTS = {
parcelle: `Eléments d\'informations applicables à la parcelle cadastrale`,
secteur: `Secteur d\'instruction :`,
Expand Down
Loading

0 comments on commit 8487f4a

Please sign in to comment.