terra-draw
terra-draw copied to clipboard
[Bug] Duplicate coordinates in feature while drawing polygon
trafficstars
Describe the bug While in polygon drawing mode the lastly committed vertex coordinate is duplicated in the feature in the validation method. It's only there on "commit" update type. It's gone when update type is "finished".
Terra Draw npm version
"maplibre-gl": "^5.4.0",
"terra-draw": "^1.6.2",
"terra-draw-maplibre-gl-adapter": "^1.1.0",
To Reproduce Steps to reproduce the behavior:
- Draw a polygon
- Keep checking the polygon feature from the validation method
- Finish drawing
- See logs
new TerraDrawPolygonMode({
validation: (feature, { updateType }) => {
if (updateType === 'finish' || updateType === 'commit') {
console.log(updateType, feature.geometry.coordinates[0])
}
return { valid: true }
}
Expected behavior In validation function, the polygon feature does not have duplicate coordinates.
Screenshots
Additional context I am trying to add a custom validator that prevents drawing polygons above a certain vertex limit. For this I have to check n+1 in the validator function as a workaround and I check for n in other place (i.e form validator). So it's not only a minor annoyance for now.