openlayers-editor
openlayers-editor copied to clipboard
feat: limit max guides generated per feature via an option
trafficstars
How to
Create some absurd shapes as described in #267 or allow a high nbFeatures. Set limitGuidesPerFeature on your cad control (defaults to 3). Observe that the max number of snapping guides ever shown on the screen is nbFeatures X limitGuidesPerFeatures
Notes on Implementation
I included lodash here as a peer dependency as my project uses it anyway. The main need was to get access to sortByIndex which allows the includedCoords array to be built optimally in the parseCoordList function. This can easily be replaced by something like the following with efficiency tradeoffs
coords.sort((a, b) => euclideanDistance(a, coordinate) - euclideanDistance(b, coordinate));
const includedCoords = coords.slice(0, this.limitGuidesPerFeature);
Others
- [x] It's not a hack or at least an unauthorized hack :).
- [x] Everything in ticket description has been fixed.
- [x] The author of the MR has made its own review before assigning the reviewer.
- [x] The title is formatted as a conventional-commit message.
- [ ] Tests added.
Fixes #267