-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improvs snapping on the feature drawn
- Loading branch information
Showing
5 changed files
with
94 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
import { MultiPoint } from 'ol/geom'; | ||
import { MultiPoint, LineString } from 'ol/geom'; | ||
|
||
/** | ||
* Removes the closest node to a given coordinate from a given geometry. | ||
* Removes the last coordinate of a given geometry (Line or Polygon). | ||
* When we draw the last coordinate if tat mouse cursor. | ||
* @private | ||
* @param {ol.Geometry} geometry An openlayers geometry. | ||
* @param {ol.Coordinate} coordinate Coordinate. | ||
* @returns {ol.Geometry.MultiPoint} An openlayers MultiPoint geometry. | ||
*/ | ||
const getShiftedMultipoint = (geometry, coordinate) => { | ||
// Include all but the closest vertex to the coordinate (e.g. at mouse position) | ||
const getShiftedMultipoint = (geometry) => { | ||
// Include all but the last vertex to the coordinate (e.g. at mouse position) | ||
// to prevent snapping on mouse cursor node | ||
const isPolygon = geometry.getType() === 'Polygon'; | ||
const shiftedMultipoint = new MultiPoint( | ||
isPolygon ? geometry.getCoordinates()[0] : geometry.getCoordinates(), | ||
); | ||
const lineGeometry = isPolygon | ||
? new LineString(geometry.getCoordinates()[0]) | ||
: geometry; | ||
|
||
const drawNodeCoordinate = shiftedMultipoint.getClosestPoint(coordinate); | ||
|
||
// Exclude the node being modified | ||
shiftedMultipoint.setCoordinates( | ||
shiftedMultipoint | ||
.getCoordinates() | ||
.filter((coord) => coord.toString() !== drawNodeCoordinate.toString()), | ||
); | ||
|
||
return shiftedMultipoint; | ||
const coordinates = []; | ||
lineGeometry.forEachSegment((start) => { | ||
coordinates.push(start); | ||
}); | ||
return new MultiPoint(coordinates); | ||
}; | ||
|
||
export default getShiftedMultipoint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,7 +226,7 @@ | |
resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-4.0.0.tgz#7dfccb9df5499e627e7bfdbb4021a06813a45dba" | ||
integrity sha512-189nelqtPd8++phaHNwYovKZI0FOzH1vQEE3QhHHkNIGrg5fSs9CbYP3RvfEH5geztnIA9Jwq91wyOIwAW5JIQ== | ||
|
||
"@cypress/request@^3.0.1": | ||
"@cypress/request@^3.0.4": | ||
version "3.0.5" | ||
resolved "https://registry.yarnpkg.com/@cypress/request/-/request-3.0.5.tgz#d893a6e68ce2636c085fcd8d7283c3186499ba63" | ||
integrity sha512-v+XHd9XmWbufxF1/bTaVm2yhbxY+TB4YtWRqF2zaXBlDNMkls34KiATz0AVDLavL3iB6bQk9/7n3oY1EoLSWGA== | ||
|
@@ -790,62 +790,69 @@ | |
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" | ||
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== | ||
|
||
"@vitest/[email protected].1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-2.1.1.tgz#907137a86246c5328929d796d741c4e95d1ee19d" | ||
integrity sha512-YeueunS0HiHiQxk+KEOnq/QMzlUuOzbU1Go+PgAsHvvv3tUkJPm9xWt+6ITNTlzsMXUjmgm5T+U7KBPK2qQV6w== | ||
"@vitest/[email protected].2": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-2.1.2.tgz#e92fa284b8472548f72cacfe896020c64af6bf78" | ||
integrity sha512-FEgtlN8mIUSEAAnlvn7mP8vzaWhEaAEvhSXCqrsijM7K6QqjB11qoRZYEd4AKSCDz8p0/+yH5LzhZ47qt+EyPg== | ||
dependencies: | ||
"@vitest/spy" "2.1.1" | ||
"@vitest/utils" "2.1.1" | ||
"@vitest/spy" "2.1.2" | ||
"@vitest/utils" "2.1.2" | ||
chai "^5.1.1" | ||
tinyrainbow "^1.2.0" | ||
|
||
"@vitest/[email protected].1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-2.1.1.tgz#3e37c80ac267318d4aa03c5073a017d148dc8e67" | ||
integrity sha512-LNN5VwOEdJqCmJ/2XJBywB11DLlkbY0ooDJW3uRX5cZyYCrc4PI/ePX0iQhE3BiEGiQmK4GE7Q/PqCkkaiPnrA== | ||
"@vitest/[email protected].2": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-2.1.2.tgz#08853a9d8d12afba284aebdf9b5ea26ddae5f20a" | ||
integrity sha512-ExElkCGMS13JAJy+812fw1aCv2QO/LBK6CyO4WOPAzLTmve50gydOlWhgdBJPx2ztbADUq3JVI0C5U+bShaeEA== | ||
dependencies: | ||
"@vitest/spy" "^2.1.0-beta.1" | ||
estree-walker "^3.0.3" | ||
magic-string "^0.30.11" | ||
|
||
"@vitest/[email protected].1", "@vitest/pretty-format@^2.1.1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-2.1.1.tgz#fea25dd4e88c3c1329fbccd1d16b1d607eb40067" | ||
integrity sha512-SjxPFOtuINDUW8/UkElJYQSFtnWX7tMksSGW0vfjxMneFqxVr8YJ979QpMbDW7g+BIiq88RAGDjf7en6rvLPPQ== | ||
"@vitest/[email protected].2", "@vitest/pretty-format@^2.1.2": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-2.1.2.tgz#42882ea18c4cd40428e34f74bbac706a82465193" | ||
integrity sha512-FIoglbHrSUlOJPDGIrh2bjX1sNars5HbxlcsFKCtKzu4+5lpsRhOCVcuzp0fEhAGHkPZRIXVNzPcpSlkoZ3LuA== | ||
dependencies: | ||
tinyrainbow "^1.2.0" | ||
|
||
"@vitest/[email protected].1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-2.1.1.tgz#f3b1fbc3c109fc44e2cceecc881344453f275559" | ||
integrity sha512-uTPuY6PWOYitIkLPidaY5L3t0JJITdGTSwBtwMjKzo5O6RCOEncz9PUN+0pDidX8kTHYjO0EwUIvhlGpnGpxmA== | ||
"@vitest/[email protected].2": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-2.1.2.tgz#14da1f5eac43fbd9a37d7cd72de102e8f785d727" | ||
integrity sha512-UCsPtvluHO3u7jdoONGjOSil+uON5SSvU9buQh3lP7GgUXHp78guN1wRmZDX4wGK6J10f9NUtP6pO+SFquoMlw== | ||
dependencies: | ||
"@vitest/utils" "2.1.1" | ||
"@vitest/utils" "2.1.2" | ||
pathe "^1.1.2" | ||
|
||
"@vitest/[email protected].1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-2.1.1.tgz#38ef23104e90231fea5540754a19d8468afbba66" | ||
integrity sha512-BnSku1WFy7r4mm96ha2FzN99AZJgpZOWrAhtQfoxjUU5YMRpq1zmHRq7a5K9/NjqonebO7iVDla+VvZS8BOWMw== | ||
"@vitest/[email protected].2": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-2.1.2.tgz#e20bd794b33fdcd4bfe69138baac7bb890c4d51f" | ||
integrity sha512-xtAeNsZ++aRIYIUsek7VHzry/9AcxeULlegBvsdLncLmNCR6tR8SRjn8BbDP4naxtccvzTqZ+L1ltZlRCfBZFA== | ||
dependencies: | ||
"@vitest/pretty-format" "2.1.1" | ||
"@vitest/pretty-format" "2.1.2" | ||
magic-string "^0.30.11" | ||
pathe "^1.1.2" | ||
|
||
"@vitest/[email protected]", "@vitest/spy@^2.1.0-beta.1": | ||
"@vitest/[email protected]": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-2.1.2.tgz#bccdeca597c8fc3777302889e8c98cec9264df44" | ||
integrity sha512-GSUi5zoy+abNRJwmFhBDC0yRuVUn8WMlQscvnbbXdKLXX9dE59YbfwXxuJ/mth6eeqIzofU8BB5XDo/Ns/qK2A== | ||
dependencies: | ||
tinyspy "^3.0.0" | ||
|
||
"@vitest/spy@^2.1.0-beta.1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-2.1.1.tgz#20891f7421a994256ea0d739ed72f05532c78488" | ||
integrity sha512-ZM39BnZ9t/xZ/nF4UwRH5il0Sw93QnZXd9NAZGRpIgj0yvVwPpLd702s/Cx955rGaMlyBQkZJ2Ir7qyY48VZ+g== | ||
dependencies: | ||
tinyspy "^3.0.0" | ||
|
||
"@vitest/[email protected].1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-2.1.1.tgz#284d016449ecb4f8704d198d049fde8360cc136e" | ||
integrity sha512-Y6Q9TsI+qJ2CC0ZKj6VBb+T8UPz593N113nnUykqwANqhgf3QkZeHFlusgKLTqrnVHbj/XDKZcDHol+dxVT+rQ== | ||
"@vitest/[email protected].2": | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-2.1.2.tgz#222ac35ba02493173e40581256eb7a62520fcdba" | ||
integrity sha512-zMO2KdYy6mx56btx9JvAqAZ6EyS3g49krMPPrgOp1yxGZiA93HumGk+bZ5jIZtOg5/VBYl5eBmGRQHqq4FG6uQ== | ||
dependencies: | ||
"@vitest/pretty-format" "2.1.1" | ||
"@vitest/pretty-format" "2.1.2" | ||
loupe "^3.1.1" | ||
tinyrainbow "^1.2.0" | ||
|
||
|
@@ -1700,12 +1707,12 @@ cssesc@^3.0.0: | |
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" | ||
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== | ||
|
||
cypress@13.14.2: | ||
version "13.14.2" | ||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.14.2.tgz#4237eb7b26de2baeaa1f01e585f965d88fca7f39" | ||
integrity sha512-lsiQrN17vHMB2fnvxIrKLAjOr9bPwsNbPZNrWf99s4u+DVmCY6U+w7O3GGG9FvP4EUVYaDu+guWeNLiUzBrqvA== | ||
cypress@13.15.0: | ||
version "13.15.0" | ||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.15.0.tgz#5eca5387ef34b2e611cfa291967c69c2cd39381d" | ||
integrity sha512-53aO7PwOfi604qzOkCSzNlWquCynLlKE/rmmpSPcziRH6LNfaDUAklQT6WJIsD8ywxlIy+uVZsnTMCCQVd2kTw== | ||
dependencies: | ||
"@cypress/request" "^3.0.1" | ||
"@cypress/request" "^3.0.4" | ||
"@cypress/xvfb" "^1.2.4" | ||
"@types/sinonjs__fake-timers" "8.1.1" | ||
"@types/sizzle" "^2.3.2" | ||
|
@@ -2177,10 +2184,10 @@ eslint-import-resolver-node@^0.3.9: | |
is-core-module "^2.13.0" | ||
resolve "^1.22.4" | ||
|
||
eslint-module-utils@^2.9.0: | ||
version "2.11.0" | ||
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.11.0.tgz#b99b211ca4318243f09661fae088f373ad5243c4" | ||
integrity sha512-gbBE5Hitek/oG6MUVj6sFuzEjA/ClzNflVrLovHi/JgLdC7fiN5gLAY1WIPW1a0V5I999MnsrvVrCOGmmVqDBQ== | ||
eslint-module-utils@^2.12.0: | ||
version "2.12.0" | ||
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.12.0.tgz#fe4cfb948d61f49203d7b08871982b65b9af0b0b" | ||
integrity sha512-wALZ0HFoytlyh/1+4wuZ9FJCD/leWHQzzrxJ8+rebyReSLk7LApMyd3WJaLVoN+D5+WIdJyDK1c6JnE65V4Zyg== | ||
dependencies: | ||
debug "^3.2.7" | ||
|
||
|
@@ -2191,10 +2198,10 @@ [email protected]: | |
dependencies: | ||
globals "^13.20.0" | ||
|
||
eslint-plugin-import@2.30.0: | ||
version "2.30.0" | ||
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.30.0.tgz#21ceea0fc462657195989dd780e50c92fe95f449" | ||
integrity sha512-/mHNE9jINJfiD2EKkg1BKyPyUk4zdnT54YgbOgfjSakWT5oyX/qQLVNTkehyfpcMxZXMy1zyonZ2v7hZTX43Yw== | ||
eslint-plugin-import@2.31.0: | ||
version "2.31.0" | ||
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.31.0.tgz#310ce7e720ca1d9c0bb3f69adfd1c6bdd7d9e0e7" | ||
integrity sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A== | ||
dependencies: | ||
"@rtsao/scc" "^1.1.0" | ||
array-includes "^3.1.8" | ||
|
@@ -2204,7 +2211,7 @@ [email protected]: | |
debug "^3.2.7" | ||
doctrine "^2.1.0" | ||
eslint-import-resolver-node "^0.3.9" | ||
eslint-module-utils "^2.9.0" | ||
eslint-module-utils "^2.12.0" | ||
hasown "^2.0.2" | ||
is-core-module "^2.15.1" | ||
is-glob "^4.0.3" | ||
|
@@ -2213,6 +2220,7 @@ [email protected]: | |
object.groupby "^1.0.3" | ||
object.values "^1.2.0" | ||
semver "^6.3.1" | ||
string.prototype.trimend "^1.0.8" | ||
tsconfig-paths "^3.15.0" | ||
|
||
[email protected]: | ||
|
@@ -4027,10 +4035,10 @@ object.values@^1.2.0: | |
define-properties "^1.2.1" | ||
es-object-atoms "^1.0.0" | ||
|
||
ol@^10.2.0: | ||
version "10.2.0" | ||
resolved "https://registry.yarnpkg.com/ol/-/ol-10.2.0.tgz#e3a5afaeb67b29cce87d16898a8a907bca57699d" | ||
integrity sha512-yYFNV8LzN3uOP9qDecMdq07IKlD5P3KfbT+pfOje/XlsnMNLXOb3ZjCZN86wtbew8aq+RfdJ+XylVI8MZsp4Vw== | ||
ol@^10.2.1: | ||
version "10.2.1" | ||
resolved "https://registry.yarnpkg.com/ol/-/ol-10.2.1.tgz#05143d0bbc0d8761385e0acae4ec9074a570bf64" | ||
integrity sha512-2bB/y2vEnmzjqynP0NA7Cp8k86No3Psn63Dueicep3E3i09axWRVIG5IS/bylEAGfWQx0QXD/uljkyFoY60Wig== | ||
dependencies: | ||
"@types/rbush" "3.0.3" | ||
color-rgba "^3.0.0" | ||
|
@@ -5509,10 +5517,10 @@ [email protected]: | |
core-util-is "1.0.2" | ||
extsprintf "^1.2.0" | ||
|
||
[email protected].1: | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-2.1.1.tgz#7d46f623c04dfed6df34e7127711508a3386fa1c" | ||
integrity sha512-N/mGckI1suG/5wQI35XeR9rsMsPqKXzq1CdUndzVstBj/HvyxxGctwnK6WX43NGt5L3Z5tcRf83g4TITKJhPrA== | ||
[email protected].2: | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-2.1.2.tgz#f5491a2b399959c9e2f3c4b70cb0cbaecf9be6d2" | ||
integrity sha512-HPcGNN5g/7I2OtPjLqgOtCRu/qhVvBxTUD3qzitmL0SrG1cWFzxzhMDWussxSbrRYWqnKf8P2jiNhPMSN+ymsQ== | ||
dependencies: | ||
cac "^6.7.14" | ||
debug "^4.3.6" | ||
|
@@ -5530,18 +5538,18 @@ vite@^5.0.0: | |
optionalDependencies: | ||
fsevents "~2.3.3" | ||
|
||
vitest@^2.1.1: | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/vitest/-/vitest-2.1.1.tgz#24a6f6f5d894509f10685b82de008c507faacbb1" | ||
integrity sha512-97We7/VC0e9X5zBVkvt7SGQMGrRtn3KtySFQG5fpaMlS+l62eeXRQO633AYhSTC3z7IMebnPPNjGXVGNRFlxBA== | ||
dependencies: | ||
"@vitest/expect" "2.1.1" | ||
"@vitest/mocker" "2.1.1" | ||
"@vitest/pretty-format" "^2.1.1" | ||
"@vitest/runner" "2.1.1" | ||
"@vitest/snapshot" "2.1.1" | ||
"@vitest/spy" "2.1.1" | ||
"@vitest/utils" "2.1.1" | ||
vitest@^2.1.2: | ||
version "2.1.2" | ||
resolved "https://registry.yarnpkg.com/vitest/-/vitest-2.1.2.tgz#f285fdde876749fddc0cb4d9748ae224443c1694" | ||
integrity sha512-veNjLizOMkRrJ6xxb+pvxN6/QAWg95mzcRjtmkepXdN87FNfxAss9RKe2far/G9cQpipfgP2taqg0KiWsquj8A== | ||
dependencies: | ||
"@vitest/expect" "2.1.2" | ||
"@vitest/mocker" "2.1.2" | ||
"@vitest/pretty-format" "^2.1.2" | ||
"@vitest/runner" "2.1.2" | ||
"@vitest/snapshot" "2.1.2" | ||
"@vitest/spy" "2.1.2" | ||
"@vitest/utils" "2.1.2" | ||
chai "^5.1.1" | ||
debug "^4.3.6" | ||
magic-string "^0.30.11" | ||
|
@@ -5552,7 +5560,7 @@ vitest@^2.1.1: | |
tinypool "^1.0.0" | ||
tinyrainbow "^1.2.0" | ||
vite "^5.0.0" | ||
vite-node "2.1.1" | ||
vite-node "2.1.2" | ||
why-is-node-running "^2.3.0" | ||
|
||
[email protected]: | ||
|