Description
Module
- deck.gl-community/arrow-layers
- deck.gl-community/bing-maps
- deck.gl-community/editable-layers
- deck.gl-community/experimental
- deck.gl-community/graph-layers
- deck.gl-community/layers
- deck.gl-community/react
- deck.gl-community/react-graph-layer
Description
When modifying a geometry using ModifyMode there is an issue which can result in the wrong vertex being updated. This occurs when you "drop" a vertex close to another vertex (specifically one with a higher ordinal within coordinate list).
I believe getPickedEditHandle in handleStopDragging is returning the vertex with the highest ordinal from the geometry, which is why the handleStopDragging modifieds the wrong vertex in this situation.
I'm not 100% confident in the correct implementation, however the following override appears to solve the issue for me:
export default class CustomModifyMode extends ModifyMode {
handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {
const selectedFeatureIndexes = props.selectedIndexes;
const editHandle = getPickedEditHandle(event.pointerDownPicks);
if (selectedFeatureIndexes.length && editHandle) {
this._dragEditHandle('finishMovePosition', props, editHandle, event);
}
}
}
Attached is a video of the issue. See the below codesandbox for an interactive example of the problem with instructions and a visual aid to help observe the problem during editing:
https://codesandbox.io/p/sandbox/fwhvn7
example.mp4
Thanks :)
Expected Behavior
Only the dragged vertex should be updated to reflect the location where the user has dropped it.
Steps to Reproduce
Open the codesandbox:
https://codesandbox.io/p/sandbox/fwhvn7
Drag the left most vertex and place it so it overlaps one of the other vertexes. Observe how the the vertex you have dropped the point onto is modified unexpectedly. I believe getPickedEditHandle in handleStopDragging is returning the vertex with the highest ordinal from the linestring, which is why the handleStopDragging modifieds the wrong vertex in this situation.
Environment
- Framework version: @deck.gl-community/editable-layers 9.0.3
- Browser: Any
- OS: Any
Logs
No response