-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #9685 measurements issues and added some enhancements to it #9809
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
See comments inline
-
When I try to select, I have an error and a success notification at the same time.
screencast-github.aaakk.us.kg-2023.12.13-10_35_57.webm
-
Selection do not look to work as expected.
-
When I try to select the buffered geometry, I have a crash (the video shows the selection issue above and the crash).
screencast-github.aaakk.us.kg-2023.12.13-10_37_09.webm
Error in console:
StandardRouter.jsx:86 TypeError: Cannot read properties of undefined (reading 'id')
at createFeatureId (GeoProcessingUtils.js:77:18)
at eval (SourceLayer.jsx:119:89)
at Array.map (<anonymous>)
at Source (SourceLayer.jsx:118:29)
at renderWithHooks (react-dom.development.js:16320:18)
at updateFunctionComponent (react-dom.development.js:18284:20)
at beginWork$1 (react-dom.development.js:20098:16)
at HTMLUnknownElement.callCallback (react-dom.development.js:362:14)
at Object.invokeGuardedCallbackDev (react-dom.development.js:411:16)
at invokeGuardedCallback (react-dom.development.js:466:31)
at beginWork$$1 (react-dom.development.js:25730:7)
at performUnitOfWork (react-dom.development.js:24638:12)
at workLoopSync (react-dom.development.js:24614:22)
at performSyncWorkOnRoot (react-dom.development.js:24182:11)
at eval (react-dom.development.js:12238:24)
at unstable_runWithPriority (scheduler.development.js:815:12) '\n at ErrorBoundary (webpack://mapstore2/./node_modules/react-error-boundary/dist/commonjs/ErrorBoundary.js?:36:5)\n at div\n at Router (webpack://mapstore2/./node_modules/react-router/es/Router.js?:36:5)\n at ConnectedRouter (webpack://mapstore2/./node_modules/connected-react-router/esm/ConnectedRouter.js?:60:7)\n at ConnectedRouterWithContext (webpack://mapstore2/./node_modules/connected-react-router/esm/ConnectedRouter.js?:158:25)\n at Connect (webpack://mapstore2/./node_modules/react-redux/es/components/connectAdvanced.js?:152:37)\n at IntlProvider (webpack://mapstore2/./node_modules/react-intl/lib/index.es.js?:804:9)\n at Localized (webpack://mapstore2/./web/client/components/I18N/Localized.jsx?:28:5)\n at eval (webpack://mapstore2/./web/client/components/theme/Theme.jsx?:42:5)\n at Connect (webpack://mapstore2/./node_modules/react-redux/es/components/connectAdvanced.js?:152:37)\n at div\n at StandardRouter (webpack://mapstore2/./web/client/components/app/StandardRouter.jsx?:51:5)\n at Connect (webpack://mapstore2/./node_modules/react-redux/es/components/connectAdvanced.js?:152:37)\n at DragDropContextContainer (webpack://mapstore2/./node_modules/react-dnd/lib/DragDropContext.js?:81:5)\n at Provider (webpack://mapstore2/./node_modules/react-redux/es/components/Provider.js?:24:24)\n at StandardApp (webpack://mapstore2/./web/client/components/app/StandardApp.jsx?:78:5)\n at WithExtensions (webpack://mapstore2/./web/client/components/app/withExtensions.js?:50:7)'
web/client/reducers/geoProcessing.js
Outdated
features: (state[action.source].features || []).concat(action.data.features || []).filter(f => !f?.properties?.measureId).map((ft, i) => ({...ft, | ||
id: createFeatureId(ft, i)})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain why you are filtering out all features that do not have measureId
and creating ids for all features. It is not trivial the reason and it is a special behaviour that have to be commented.
I suggest to do this changes outside the reducer. The reducer should expect well formed features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the main problem was that the vector layer generated from feature measurements are missing ids and it makes some other part of the code to fail. i'll centralize this behaviour in the layers selector of the geoprocessing tool and also in epics
* @return {object} the transformed feature if geodesic | ||
*/ | ||
export const transformLineToArc = (feature) => { | ||
if (feature?.properties?.geodesic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it handles only linestrings, than do this check before transformation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding a condition check for the geometry property? doing it external to the function is worse imo
web/client/epics/geoProcessing.js
Outdated
@@ -589,12 +603,12 @@ export const runBufferProcessGPTEpic = (action$, store) => action$ | |||
})); | |||
}) | |||
); | |||
const feature = sourceFeatureSelector(state); | |||
const feature = transformLineToArc(sourceFeatureSelector(state)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we have to transform the geometry in 8 different points of the code risk to make the feature not maintainable. Try to centralize this behavior in a single place (selector).
Try to do also the normalization once (labels, ids, managemant of measureId etc...). The geodesic tool should be as much transparent as possible to the special case of measure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, let me better see this
@offtherailz this pr is ready for a new review. measurement.vector.demo.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll test it as well as the changes suggested are applied.
Thank you .
@@ -73,5 +74,20 @@ export const wfsBackedLayersSelector = (state) => { | |||
const layers = layersSelector(state); | |||
return layers | |||
.filter(l => l.group !== "background") | |||
.filter(layer => hasWFSService(layer) || layer.type === "vector"); | |||
.filter(layer => hasWFSService(layer) || layer.type === "vector") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this with "vectorLayerSelector". I suggest to separate densification where effectively needed, and cache using reselect to avoid to densify features on every state update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it does not fetch only vector layers
web/client/selectors/layers.js
Outdated
export const layersSelector = ({layers: layersProp, config} = {}) => { | ||
const layers = layersProp && isArray(layersProp) ? layersProp : layersProp && layersProp.flat || config && config.layers || []; | ||
// adding foreach feature an id if missing | ||
return layers?.map(layer => { | ||
return layer?.features?.length ? { | ||
...layer, | ||
features: layer?.features | ||
?.map((ft, i) => ({ | ||
...ft, | ||
id: createFeatureId(ft, i) | ||
|
||
})) | ||
} : layer; | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be done. It creates temporary ids that are not unique, and it does it on every state update.
Let's save instead the ids where missing on layer add or map load.
@offtherailz review is ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to use this map to select the buffer layer but I see a warning of no feature clicked.
screencast-localhost_8081-2023.12.15-10_22_56.webm
same issue if I try to select as vector layer of input natural earth 10m admin data (Can not upload it here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 works quite fine.
The only things I noticed here:
- Circle annotation cause an error because internally is handled as a point
- When using big sets of data (e.g. natural earth 10m admin boundaries) the geoprocessing tool slows down a bit. It happens also to the map, until I hide the layer anyway. Probably some optimizations can be done on this side.
Because circle annotation was not strictly a part of this issue and because the performance are anyway acceptable under stress, I think I can approve this PR, that fulfills the requirements and does not introduce any regression.
Please @MV88 and @tdipisa decide what to do with my notes.
Thank you for your development @MV88 now this tool is really powerful.
@offtherailz thank you
it would be good to understand where is the performance issue, if it is on the client side when rendering complex features or on the WPS side. @MV88 please complete the fix for the first point, please. Then, we can maybe open a dedicated issue for the other one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElenaGallo please test in DEV once deployed and let us know for the backport. |
Test passed @MV88 please backport to 2023.02.xx. Thanks |
…nts to it (geosolutions-it#9809) * Fix geosolutions-it#9685 measurements issues and added some enhancements to it * adding some extra tests * Fixed problems related to measurements and missing ids * refactor and optimization * final fixes for vector layers for the click on map action * fix geodesic circle * Fix tests # Conflicts: # web/client/epics/widgets.js # web/client/reducers/config.js # web/client/utils/LayersUtils.js
@offtherailz backport is here #9835 for you to review |
Description
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
What is the current behavior?
Fix #9685
What is the new behavior?
arc length as a buffer and blue line highlight
intersection of a buffer with states, (check lower parts should be the dark one
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)
Other useful information