ol 10.6.2-dev.1758267478938 → 10.6.2-dev.1758555392798
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/events/SnapEvent.d.ts.map +1 -1
- package/events/SnapEvent.js +5 -0
- package/interaction/Snap.d.ts +4 -4
- package/interaction/Snap.d.ts.map +1 -1
- package/interaction/Snap.js +42 -60
- package/package.json +1 -1
- package/util.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnapEvent.d.ts","sourceRoot":"","sources":["SnapEvent.js"],"names":[],"mappings":"4BAMU,MAAM;;;;;
|
|
1
|
+
{"version":3,"file":"SnapEvent.d.ts","sourceRoot":"","sources":["SnapEvent.js"],"names":[],"mappings":"4BAMU,MAAM;;;;;AAiBhB;;;GAGG;AACH;IACE;;;;;;;OAOG;IACH,kBAPW,aAAa,WAErB;QAAuD,MAAM,EAArD,OAAO,kBAAkB,EAAE,UAAU;QACU,WAAW,EAA1D,OAAO,kBAAkB,EAAE,UAAU;QACI,OAAO,EAAhD,OAAO,eAAe,EAAE,OAAO;QAC4B,OAAO,EAAlE,KAAK,CAAC,OAAO,kBAAkB,EAAE,UAAU,CAAC,GAAC,IAAI;KAC3D,EA2BA;IAxBC;;;;OAIG;IACH,QAHU,OAAO,kBAAkB,EAAE,UAAU,CAGnB;IAC5B;;;;OAIG;IACH,aAHU,KAAK,CAAC,MAAM,CAAC,GAAC,KAAK,CAAC,MAAM,CAAC,CAGC;IACtC;;;;OAIG;IACH,SAHU,OAAO,eAAe,EAAE,OAAO,CAAC,OAAO,qBAAqB,EAAE,OAAO,CAAC,CAGlD;IAC9B;;;;OAIG;IACH,SAHU,KAAK,CAAC,OAAO,kBAAkB,EAAE,UAAU,CAAC,GAAC,IAAI,CAG7B;CAEjC;kBA5DiB,YAAY"}
|
package/events/SnapEvent.js
CHANGED
package/interaction/Snap.d.ts
CHANGED
|
@@ -10,13 +10,13 @@ export type SegmentData = {
|
|
|
10
10
|
*/
|
|
11
11
|
feature: import("../Feature.js").default;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Feature which intersects.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
intersectionFeature?: import("../Feature.js").default<import("../geom/Geometry.js").default> | undefined;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Segment.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
segment: Segment;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* A function taking a {@link module :ol/geom/Geometry~Geometry} as argument and returning an array of {@link Segment}s.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snap.d.ts","sourceRoot":"","sources":["Snap.js"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Snap.d.ts","sourceRoot":"","sources":["Snap.js"],"names":[],"mappings":";;;;;sBAkCa,KAAK,CAAC,OAAO,kBAAkB,EAAE,UAAU,CAAC;;;;;aAO3C,OAAO,eAAe,EAAE,OAAO;;;;;;;;aAE/B,OAAO;;;;;sBAIiC,YAAY,SAArD,OAAQ,qBAAqB,EAAE,OAAQ,4CACvC,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,OAAO,uBAAuB,EAAE,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA2C/F,OAAO,kBAAkB,EAAE,UAAU,GAAC,IAAI;;;;iBAC1C,OAAO,aAAa,EAAE,KAAK,GAAC,IAAI;;;;aAChC,OAAO,eAAe,EAAE,OAAO,GAAC,IAAI;;;;aACpC,OAAO,GAAC,IAAI;;;;;4BAgMb,MAAM,IACN,OAAO,eAAe,EAAE,WAAW,CAAC,OAAO,eAAe,EAAE,UAAU,E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;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,6BAMC;IAED;;;OAGG;IACH,6BAOC;IAmBD;;;;;;OAMG;IACH,uBALW,OAAO,eAAe,EAAE,OAAO,aAC/B,OAAO,QAqBjB;IAED;;;;;;OAMG;IACH,qBAHW,OAAO,WAAW,EAAE,OAAO,QAwDrC;IAED;;;;;OAKG;IACH,cALW,OAAO,aAAa,EAAE,KAAK,mBAC3B,OAAO,kBAAkB,EAAE,UAAU,OACrC,OAAO,WAAW,EAAE,OAAO,GAC1B,WAAW,GAAC,IAAI,CAkH3B;IAED;;;OAGG;IACH,uBAGC;CACF;0BA71BsC,wBAAwB;+BAqBhC,cAAc"}
|
package/interaction/Snap.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import {FALSE, TRUE} from '../functions.js';
|
|
20
20
|
import {fromCircle} from '../geom/Polygon.js';
|
|
21
21
|
import {getIntersectionPoint} from '../geom/flat/segments.js';
|
|
22
|
+
import {clear} from '../obj.js';
|
|
22
23
|
import {
|
|
23
24
|
fromUserCoordinate,
|
|
24
25
|
getUserProjection,
|
|
@@ -39,8 +40,8 @@ import PointerInteraction from './Pointer.js';
|
|
|
39
40
|
/**
|
|
40
41
|
* @typedef {Object} SegmentData
|
|
41
42
|
* @property {import("../Feature.js").default} feature Feature.
|
|
43
|
+
* @property {import("../Feature.js").default} [intersectionFeature] Feature which intersects.
|
|
42
44
|
* @property {Segment} segment Segment.
|
|
43
|
-
* @property {boolean} [isIntersection] Is intersection.
|
|
44
45
|
*/
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -128,7 +129,7 @@ const GEOMETRY_SEGMENTERS = {
|
|
|
128
129
|
const segments = [];
|
|
129
130
|
const geometries = geometry.getGeometriesArray();
|
|
130
131
|
for (let i = 0; i < geometries.length; ++i) {
|
|
131
|
-
const segmenter =
|
|
132
|
+
const segmenter = this[geometries[i].getType()];
|
|
132
133
|
if (segmenter) {
|
|
133
134
|
segments.push(segmenter(geometries[i], projection));
|
|
134
135
|
}
|
|
@@ -323,19 +324,10 @@ class Snap extends PointerInteraction {
|
|
|
323
324
|
constructor(options) {
|
|
324
325
|
options = options ? options : {};
|
|
325
326
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (!pointerOptions.handleDownEvent) {
|
|
331
|
-
pointerOptions.handleDownEvent = TRUE;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (!pointerOptions.stopDown) {
|
|
335
|
-
pointerOptions.stopDown = FALSE;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
super(pointerOptions);
|
|
327
|
+
super({
|
|
328
|
+
handleDownEvent: TRUE,
|
|
329
|
+
stopDown: FALSE,
|
|
330
|
+
});
|
|
339
331
|
|
|
340
332
|
/***
|
|
341
333
|
* @type {SnapOnSignature<import("../events").EventsKey>}
|
|
@@ -460,7 +452,8 @@ class Snap extends PointerInteraction {
|
|
|
460
452
|
if (segmenter) {
|
|
461
453
|
this.indexedFeaturesExtents_[feature_uid] =
|
|
462
454
|
geometry.getExtent(createEmpty());
|
|
463
|
-
const segments = segmenter(
|
|
455
|
+
const segments = segmenter.call(
|
|
456
|
+
this.segmenters_,
|
|
464
457
|
geometry,
|
|
465
458
|
this.getMap().getView().getProjection(),
|
|
466
459
|
);
|
|
@@ -473,8 +466,6 @@ class Snap extends PointerInteraction {
|
|
|
473
466
|
segment: segment,
|
|
474
467
|
};
|
|
475
468
|
}
|
|
476
|
-
tempExtents.length = segmentCount;
|
|
477
|
-
tempSegmentData.length = segmentCount;
|
|
478
469
|
|
|
479
470
|
if (this.intersection_) {
|
|
480
471
|
for (let j = 0, jj = segments.length; j < jj; ++j) {
|
|
@@ -483,12 +474,9 @@ class Snap extends PointerInteraction {
|
|
|
483
474
|
continue;
|
|
484
475
|
}
|
|
485
476
|
const extent = tempExtents[j];
|
|
486
|
-
// Calculate intersections with own segments
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
// Exclude self and neighbours
|
|
490
|
-
continue;
|
|
491
|
-
}
|
|
477
|
+
// Calculate intersections with own segments excluding self and
|
|
478
|
+
// neighbors
|
|
479
|
+
for (let k = 0, kk = j - 1; k < kk; ++k) {
|
|
492
480
|
const otherSegment = segments[k];
|
|
493
481
|
if (!intersectsExtent(extent, tempExtents[k])) {
|
|
494
482
|
continue;
|
|
@@ -501,13 +489,14 @@ class Snap extends PointerInteraction {
|
|
|
501
489
|
tempExtents[segmentCount] = boundingExtent(intersectionSegment);
|
|
502
490
|
tempSegmentData[segmentCount++] = {
|
|
503
491
|
feature,
|
|
492
|
+
intersectionFeature: feature,
|
|
504
493
|
segment: intersectionSegment,
|
|
505
|
-
isIntersection: true,
|
|
506
494
|
};
|
|
507
495
|
}
|
|
508
496
|
// Calculate intersections with existing segments
|
|
509
497
|
const otherSegments = this.rBush_.getInExtent(tempExtents[j]);
|
|
510
|
-
for (
|
|
498
|
+
for (let k = 0, kk = otherSegments.length; k < kk; ++k) {
|
|
499
|
+
const otherSegment = otherSegments[k].segment;
|
|
511
500
|
if (otherSegment.length === 1) {
|
|
512
501
|
continue;
|
|
513
502
|
}
|
|
@@ -519,8 +508,8 @@ class Snap extends PointerInteraction {
|
|
|
519
508
|
tempExtents[segmentCount] = boundingExtent(intersectionSegment);
|
|
520
509
|
tempSegmentData[segmentCount++] = {
|
|
521
510
|
feature,
|
|
511
|
+
intersectionFeature: otherSegments[k].feature,
|
|
522
512
|
segment: intersectionSegment,
|
|
523
|
-
isIntersection: true,
|
|
524
513
|
};
|
|
525
514
|
}
|
|
526
515
|
}
|
|
@@ -529,6 +518,8 @@ class Snap extends PointerInteraction {
|
|
|
529
518
|
if (segmentCount === 1) {
|
|
530
519
|
this.rBush_.insert(tempExtents[0], tempSegmentData[0]);
|
|
531
520
|
} else {
|
|
521
|
+
tempExtents.length = segmentCount;
|
|
522
|
+
tempSegmentData.length = segmentCount;
|
|
532
523
|
this.rBush_.load(tempExtents, tempSegmentData);
|
|
533
524
|
}
|
|
534
525
|
}
|
|
@@ -628,6 +619,7 @@ class Snap extends PointerInteraction {
|
|
|
628
619
|
const feature = getFeatureFromEvent(evt);
|
|
629
620
|
if (feature) {
|
|
630
621
|
this.removeFeature(feature);
|
|
622
|
+
delete this.pendingFeatures_[getUid(feature)];
|
|
631
623
|
}
|
|
632
624
|
}
|
|
633
625
|
|
|
@@ -638,10 +630,7 @@ class Snap extends PointerInteraction {
|
|
|
638
630
|
handleFeatureChange_(evt) {
|
|
639
631
|
const feature = /** @type {import("../Feature.js").default} */ (evt.target);
|
|
640
632
|
if (this.handlingDownUpSequence) {
|
|
641
|
-
|
|
642
|
-
if (!(uid in this.pendingFeatures_)) {
|
|
643
|
-
this.pendingFeatures_[uid] = feature;
|
|
644
|
-
}
|
|
633
|
+
this.pendingFeatures_[getUid(feature)] = feature;
|
|
645
634
|
} else {
|
|
646
635
|
this.updateFeature_(feature);
|
|
647
636
|
}
|
|
@@ -659,6 +648,7 @@ class Snap extends PointerInteraction {
|
|
|
659
648
|
for (const feature of featuresToUpdate) {
|
|
660
649
|
this.updateFeature_(feature);
|
|
661
650
|
}
|
|
651
|
+
clear(this.pendingFeatures_);
|
|
662
652
|
}
|
|
663
653
|
return false;
|
|
664
654
|
}
|
|
@@ -676,15 +666,11 @@ class Snap extends PointerInteraction {
|
|
|
676
666
|
const extent = this.indexedFeaturesExtents_[feature_uid];
|
|
677
667
|
if (extent) {
|
|
678
668
|
const rBush = this.rBush_;
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
nodesToRemove.push(node);
|
|
669
|
+
rBush.getInExtent(extent).forEach((node) => {
|
|
670
|
+
if (feature === node.feature || feature === node.intersectionFeature) {
|
|
671
|
+
rBush.remove(node);
|
|
683
672
|
}
|
|
684
673
|
});
|
|
685
|
-
for (let i = nodesToRemove.length - 1; i >= 0; --i) {
|
|
686
|
-
rBush.remove(nodesToRemove[i]);
|
|
687
|
-
}
|
|
688
674
|
}
|
|
689
675
|
|
|
690
676
|
if (unregister) {
|
|
@@ -783,30 +769,23 @@ class Snap extends PointerInteraction {
|
|
|
783
769
|
let minSquaredDistance = Infinity;
|
|
784
770
|
let closestFeature;
|
|
785
771
|
let closestSegment = null;
|
|
786
|
-
let isIntersection;
|
|
787
772
|
|
|
788
773
|
const squaredPixelTolerance = this.pixelTolerance_ * this.pixelTolerance_;
|
|
789
774
|
const getResult = () => {
|
|
790
|
-
if (closestVertex) {
|
|
791
|
-
|
|
792
|
-
const squaredPixelDistance = squaredDistance(pixel, vertexPixel);
|
|
793
|
-
if (
|
|
794
|
-
squaredPixelDistance <= squaredPixelTolerance &&
|
|
795
|
-
((isIntersection && this.intersection_) ||
|
|
796
|
-
(!isIntersection && (this.vertex_ || this.edge_)))
|
|
797
|
-
) {
|
|
798
|
-
return {
|
|
799
|
-
vertex: closestVertex,
|
|
800
|
-
vertexPixel: [
|
|
801
|
-
Math.round(vertexPixel[0]),
|
|
802
|
-
Math.round(vertexPixel[1]),
|
|
803
|
-
],
|
|
804
|
-
feature: closestFeature,
|
|
805
|
-
segment: closestSegment,
|
|
806
|
-
};
|
|
807
|
-
}
|
|
775
|
+
if (!closestVertex) {
|
|
776
|
+
return null;
|
|
808
777
|
}
|
|
809
|
-
|
|
778
|
+
const vertexPixel = map.getPixelFromCoordinate(closestVertex);
|
|
779
|
+
const squaredPixelDistance = squaredDistance(pixel, vertexPixel);
|
|
780
|
+
if (squaredPixelDistance > squaredPixelTolerance) {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
vertex: closestVertex,
|
|
785
|
+
vertexPixel: [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])],
|
|
786
|
+
feature: closestFeature,
|
|
787
|
+
segment: closestSegment,
|
|
788
|
+
};
|
|
810
789
|
};
|
|
811
790
|
|
|
812
791
|
if (this.vertex_ || this.intersection_) {
|
|
@@ -816,11 +795,14 @@ class Snap extends PointerInteraction {
|
|
|
816
795
|
for (const vertex of segmentData.segment) {
|
|
817
796
|
const tempVertexCoord = fromUserCoordinate(vertex, projection);
|
|
818
797
|
const delta = squaredDistance(projectedCoordinate, tempVertexCoord);
|
|
819
|
-
if (
|
|
798
|
+
if (
|
|
799
|
+
delta < minSquaredDistance &&
|
|
800
|
+
((this.intersection_ && segmentData.intersectionFeature) ||
|
|
801
|
+
(this.vertex_ && !segmentData.intersectionFeature))
|
|
802
|
+
) {
|
|
820
803
|
closestVertex = vertex;
|
|
821
804
|
minSquaredDistance = delta;
|
|
822
805
|
closestFeature = segmentData.feature;
|
|
823
|
-
isIntersection = segmentData.isIntersection;
|
|
824
806
|
}
|
|
825
807
|
}
|
|
826
808
|
}
|
package/package.json
CHANGED
package/util.js
CHANGED