Skip to content

Commit

Permalink
Fix #9455 Longitudinal profile fixes (#9456)
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 authored Sep 18, 2023
1 parent 936c030 commit c3a14fa
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 45 deletions.
9 changes: 6 additions & 3 deletions web/client/epics/longitudinalProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ import {
isDockOpenSelector,
isListeningClickSelector,
isMaximizedSelector,
isSupportedLayerSelector
isSupportedLayerSelector,
noDataThresholdSelector
} from "../selectors/longitudinalProfile";
import {mapSelector} from "../selectors/map";
import {
Expand Down Expand Up @@ -182,6 +183,7 @@ export const LPonChartPropsChangeEpic = (action$, store) =>
const referential = configSelector(state)?.referential;
const distance = configSelector(state)?.distance;
const wpsBody = profileEnLong({identifier, geometry, distance, referential });
const noDataThreshold = noDataThresholdSelector(state);
return executeProcess(wpsurl, wpsBody, {outputsExtractor: makeOutputsExtractor()})
.switchMap((result) => {
if (typeof result === "string" && result.includes("ows:ExceptionReport")) {
Expand All @@ -207,7 +209,8 @@ export const LPonChartPropsChangeEpic = (action$, store) =>
f,
geometry.projection
)) : styledFeatures;
return infos && points ? Rx.Observable.from([
const filteredPoints = points.filter(point => point.altitude < noDataThreshold);
return infos && filteredPoints ? Rx.Observable.from([
updateAdditionalLayer(
LONGITUDINAL_VECTOR_LAYER_ID,
LONGITUDINAL_OWNER,
Expand Down Expand Up @@ -238,7 +241,7 @@ export const LPonChartPropsChangeEpic = (action$, store) =>
visibility: true
}),
zoomToExtent([minx, minY, maxX, maxY], 'EPSG:4326', 21),
addProfileData(infos, points, geometry.projection)
addProfileData(infos, filteredPoints, geometry.projection)
]) : Rx.Observable.empty();
})
.catch(e => {
Expand Down
2 changes: 2 additions & 0 deletions web/client/plugins/LongitudinalProfileTool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { createPlugin } from '../utils/PluginsUtils';
* @prop {Object} cfg.config the plugin configuration
* @prop {string} cfg.config.wpsurl optional, the geoserver url the the wps endpoint to use. It can be an absolute url. default is "/geoserver/wps".
* @prop {string} cfg.config.chartTitle the default title of the chart
* @prop {number} cfg.config.noDataThreshold the number that beyond it will exclude data
* @prop {number} cfg.config.defaultDistance the default distance value in meters
* @prop {string} cfg.config.identifier the profile to use in the wps request, defaulted to gs:LongitudinalProfile
* @prop {string} cfg.config.defaultReferentialName the default referential name
Expand All @@ -86,6 +87,7 @@ import { createPlugin } from '../utils/PluginsUtils';
* "wpsurl": "/geoserver/wps",
* "chartTitle": "Longitudinal profile",
* "defaultDistance": 75,
* "noDataThreshold": 999999,
* "defaultReferentialName": "sfdem",
* "referentials": [{
* "layerName": "sfdem",
Expand Down
87 changes: 58 additions & 29 deletions web/client/plugins/longitudinalProfile/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useCallback } from 'react';
import React, { useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import {DropdownButton, Glyphicon, MenuItem, NavDropdown} from 'react-bootstrap';
import {connect} from "react-redux";
Expand Down Expand Up @@ -34,6 +34,7 @@ const UserMenu = ({
className,
dataSourceMode,
initialized,
menuItem,
isParametersOpen,
menuIsActive,
nav,
Expand All @@ -49,36 +50,63 @@ const UserMenu = ({
onActivateTool();
onToggleSourceMode(toolName);
}, []);
const [open, setMenuOpen ] = useState(false);

return initialized ? (
<React.Fragment>
<DropDown
const body = (<>
{showDrawOption ? <MenuItem active={dataSourceMode === 'draw'} key="draw" onClick={onToggleTool('draw')}>
<Glyphicon glyph="pencil"/><Message msgId="longitudinalProfile.draw"/>
</MenuItem> : null}
<MenuItem active={dataSourceMode === 'import'} key="import" onClick={onToggleTool('import')}>
<Glyphicon glyph="upload"/> <Message msgId="longitudinalProfile.import"/>
</MenuItem>
<MenuItem active={dataSourceMode === 'select'} key="select" onClick={onToggleTool('select')}>
<Glyphicon glyph="1-layer"/> <Message msgId="longitudinalProfile.select"/>
</MenuItem>
<MenuItem key="divider" divider/>
<MenuItem active={isParametersOpen} key="parameters" onClick={onToggleParameters}>
<Glyphicon glyph="cog"/> <Message msgId="longitudinalProfile.parameters"/>
</MenuItem>
</>);
const DropDownMenu = (<DropDown
dropup
open={open}
onToggle={(val) => setMenuOpen(val)}
id="longitudinal-tool"
className={className}
pullRight
bsStyle={menuIsActive ? "primary" : "tray"}
title={<Glyphicon glyph="1-line"/>}
tooltipId="longitudinalProfile.title"
tooltipPosition={tooltipPosition}
noCaret
>
{body}
</DropDown>);

id="longitudinal-tool"
className={className}
pullRight
bsStyle={menuIsActive ? "primary" : "tray"}
title={<Glyphicon glyph="1-line"/>}
tooltipId="longitudinalProfile.title"
tooltipPosition={tooltipPosition}
noCaret
>
{showDrawOption ? <MenuItem active={dataSourceMode === 'draw'} key="draw" onClick={onToggleTool('draw')}>
<Glyphicon glyph="pencil"/><Message msgId="longitudinalProfile.draw"/>
</MenuItem> : null}
<MenuItem active={dataSourceMode === 'import'} key="import" onClick={onToggleTool('import')}>
<Glyphicon glyph="upload"/> <Message msgId="longitudinalProfile.import"/>
</MenuItem>
<MenuItem active={dataSourceMode === 'select'} key="select" onClick={onToggleTool('select')}>
<Glyphicon glyph="1-layer"/> <Message msgId="longitudinalProfile.select"/>
</MenuItem>
<MenuItem key="divider" divider/>
<MenuItem active={isParametersOpen} key="parameters" onClick={onToggleParameters}>
<Glyphicon glyph="cog"/> <Message msgId="longitudinalProfile.parameters"/>
</MenuItem>
</DropDown>
</React.Fragment>
) : false;
let Menu;
if (menuItem) {
// inside extra tools
Menu = (<> {
open ? <>
<div className="open dropup btn-group btn-group-tray" style={{display: "inline"}}>
<ul role="menu" className="dropdown-menu dropdown-menu-right" aria-labelledby="longitudinal-tool">
{body}
</ul>
</div>
<MenuItem active={menuIsActive || open} key="menu" onClick={() => setMenuOpen(!open)}>
<Glyphicon glyph="1-line"/>
<Message msgId="longitudinalProfile.title"/>
</MenuItem></> :
<MenuItem active={menuIsActive || open} key="menu" onClick={() => setMenuOpen(!open)}>
<Glyphicon glyph="1-line"/>
<Message msgId="longitudinalProfile.title"/>
</MenuItem> }
</>);
} else {
Menu = DropDownMenu;
}

return initialized ? Menu : false;
};

UserMenu.propTypes = {
Expand All @@ -87,6 +115,7 @@ UserMenu.propTypes = {
initialized: PropTypes.bool,
isParametersOpen: PropTypes.bool,
menuIsActive: PropTypes.bool,
menuItem: PropTypes.bool,
nav: PropTypes.bool,
showDrawOption: PropTypes.bool,
tooltipPosition: PropTypes.string,
Expand Down
2 changes: 2 additions & 0 deletions web/client/plugins/longitudinalProfile/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const FILE_TYPE_ALLOWED = [
"application/x-zip-compressed",
"application/zip"
];
export const DEFAULT_NODATA_THRESHOLD = 999999;

export const LONGITUDINAL_DISTANCES = [
1,
5,
Expand Down
3 changes: 2 additions & 1 deletion web/client/reducers/longitudinalProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
TOGGLE_MAXIMIZE,
TOGGLE_MODE
} from "../actions/longitudinalProfile";
import { LONGITUDINAL_DISTANCES } from '../plugins/longitudinalProfile/constants';
import { LONGITUDINAL_DISTANCES, DEFAULT_NODATA_THRESHOLD } from '../plugins/longitudinalProfile/constants';

const DEFAULT_STATE = {
initialized: false,
Expand Down Expand Up @@ -107,6 +107,7 @@ export default function longitudinalProfile(state = DEFAULT_STATE, action) {
...state,
config: {
...state.config,
noDataThreshold: DEFAULT_NODATA_THRESHOLD,
...action.config
}
};
Expand Down
13 changes: 12 additions & 1 deletion web/client/selectors/__tests__/longitudinalProfile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
CONTROL_NAME,
CONTROL_DOCK_NAME,
CONTROL_PROPERTIES_NAME,
LONGITUDINAL_VECTOR_LAYER_ID
LONGITUDINAL_VECTOR_LAYER_ID,
DEFAULT_NODATA_THRESHOLD
} from '../../plugins/longitudinalProfile/constants';

import {
Expand All @@ -28,6 +29,7 @@ import {
pointsSelector,
projectionSelector,
configSelector,
noDataThresholdSelector,
referentialSelector,
chartTitleSelector,
distanceSelector,
Expand Down Expand Up @@ -176,6 +178,15 @@ describe('Test longitudinalProfile selectors', () => {
};
expect(referentialSelector({longitudinalProfile})).toEqual("");
});
it('noDataThresholdSelector', () => {
expect(noDataThresholdSelector({longitudinalProfile: {
config: {noDataThreshold: 1234}
}})).toEqual(1234);

expect(noDataThresholdSelector({longitudinalProfile: {
config: {}
}})).toEqual(DEFAULT_NODATA_THRESHOLD);
});
it('chartTitleSelector', () => {
const longitudinalProfile = {
config: {chartTitle: ""}
Expand Down
4 changes: 3 additions & 1 deletion web/client/selectors/longitudinalProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
CONTROL_NAME,
CONTROL_PROPERTIES_NAME,
LONGITUDINAL_VECTOR_LAYER_ID,
LONGITUDINAL_VECTOR_LAYER_ID_POINT
LONGITUDINAL_VECTOR_LAYER_ID_POINT,
DEFAULT_NODATA_THRESHOLD
} from '../plugins/longitudinalProfile/constants';
import {additionalLayersSelector} from '../selectors/additionallayers';
import {getSelectedLayer} from "../selectors/layers";
Expand All @@ -38,6 +39,7 @@ export const infosSelector = (state) => state?.longitudinalProfile?.infos;
export const pointsSelector = (state) => state?.longitudinalProfile?.points;
export const projectionSelector = (state) => state?.longitudinalProfile?.projection;
export const configSelector = (state) => state?.longitudinalProfile?.config;
export const noDataThresholdSelector = (state) => configSelector(state)?.noDataThreshold || DEFAULT_NODATA_THRESHOLD;
export const referentialSelector = (state) => configSelector(state)?.referential;
export const chartTitleSelector = (state) => configSelector(state)?.chartTitle;
export const distanceSelector = (state) => configSelector(state)?.distance;
Expand Down
20 changes: 10 additions & 10 deletions web/client/translations/data.fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@
"noMapAvailable": "Aucune carte disponible",
"createNewOne": "Créer une nouvelle carte",
"unsavedMapConfirmTitle": "Modifications non enregistrées",
"unsavedMapConfirmMessage": "Êtes-vous sûr de vouloir laisser des modifications non enregistrées ?",
"unsavedMapConfirmButtonText": "Laisser",
"unsavedMapCancelButtonText": "Fermer"
"unsavedMapConfirmMessage": "Êtes-vous sûr de vouloir quitter la carte sans enregistrer les modifications ?",
"unsavedMapConfirmButtonText": "Quitter sans enregistrer",
"unsavedMapCancelButtonText": "Annuler"
},
"geostories": {
"newGeostory": "Nouvelle GeoStory",
Expand Down Expand Up @@ -2899,7 +2899,7 @@
"cancel": "Annuler",
"saveSuccessTitle": "Succès",
"saveSuccessMessage": "Enregistré avec succès",
"saveTooltip": "Salvar",
"saveTooltip": "Enregistrer",
"saveAsTooltip": "Enregistrer sous"
},
"mapEditor": {
Expand All @@ -2923,7 +2923,7 @@
"selectService": "Sélectionner un service",
"add": "Ajouter",
"back": "Retour",
"save": "Salvar",
"save": "Enregistrer",
"edit": "Modifier",
"sourcePlaceholder": "Entrer une source",
"source": "Source",
Expand Down Expand Up @@ -3818,19 +3818,19 @@
"infos": "Information",
"preferences": "Préférences",
"CRS": "CRS",
"uom": "Unités de mesure",
"uom": "Unité de mesure",
"fileSelected": "Fichier sélectionné: ",
"uomMeters": "mètres",
"source": "Source",
"downloadCSV": "CSV",
"downloadPNG": "PNG",
"downloadPDF": "PDF",
"info": {
"points": " points:",
"points": " points",
"totalPoints": "Nombre de points traités:",
"layer":"Layer:",
"layer":"Couche:",
"line":"Distance:",
"up":"Gain d'altitude cumulé.",
"up":"Gain d'altitude cumulé:",
"down":"Perte d'altitude cumulée:",
"noInfos": "Aucune information disponible"
},
Expand All @@ -3851,7 +3851,7 @@
"outsideCoverage": "La ligne fournie est en dehors de la couverture du profil",
"loadingError": "Erreur lors du chargement des données pour le profil longitudinal",
"unableToSetupPlugin": "Impossible de configurer l'extension du profil longitudinal.",
"defaultReferentialNotFound": "Le référentiel par défaut est configuré mais introuvable dans la liste des référentiels. Veuillez mettre à jour la configuration de l'extension.",
"defaultReferentialNotFound": "Le référentiel par défaut est configuré mais introuvable dans la liste des référentiels. Veuillez mettre à jour la configuration de l'extension Profil en long.",
"projectionNotSupported": "Le référentiel avec projection prise en charge par la carte est introuvable. Veuillez mettre à jour la configuration de l'extension ou ajouter la projection souhaitée dans la configuration de l'application.",
"cannotDownloadPDF": "Il n'est pas possible d'imprimer la carte actuelle car elle contient des références à un domaine externe, veuillez les supprimer, enregistrer la carte, actualiser la page et réessayer.",
"cannotDownloadPNG": "Impossible de télécharger le graphique en tant qu'image."
Expand Down

0 comments on commit c3a14fa

Please sign in to comment.