ol 10.2.2-dev.1729019374816 → 10.2.2-dev.1729036924104
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.d.ts +2 -0
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/interaction/Modify.d.ts +46 -9
- package/interaction/Modify.d.ts.map +1 -1
- package/interaction/Modify.js +274 -134
- package/package.json +1 -1
- package/renderer/webgl/TileLayerBase.d.ts +6 -1
- package/renderer/webgl/TileLayerBase.d.ts.map +1 -1
- package/renderer/webgl/TileLayerBase.js +6 -1
- package/source/SentinelHub.d.ts +503 -0
- package/source/SentinelHub.d.ts.map +1 -0
- package/source/SentinelHub.js +641 -0
- package/util.js +1 -1
package/interaction/Modify.js
CHANGED
|
@@ -88,6 +88,10 @@ const ModifyEventType = {
|
|
|
88
88
|
* @property {Array<SegmentData>} [featureSegments] FeatureSegments.
|
|
89
89
|
*/
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {[SegmentData, number]} DragSegment
|
|
93
|
+
*/
|
|
94
|
+
|
|
91
95
|
/**
|
|
92
96
|
* @typedef {Object} Options
|
|
93
97
|
* @property {import("../events/condition.js").Condition} [condition] A function that
|
|
@@ -110,7 +114,8 @@ const ModifyEventType = {
|
|
|
110
114
|
* Style used for the modification point or vertex. For linestrings and polygons, this will
|
|
111
115
|
* be the affected vertex, for circles a point along the circle, and for points the actual
|
|
112
116
|
* point. If not configured, the default edit style is used (see {@link module:ol/style/Style~Style}).
|
|
113
|
-
* When using a style function, the point feature passed to the function will have
|
|
117
|
+
* When using a style function, the point feature passed to the function will have an `existing` property -
|
|
118
|
+
* indicating whether there is an existing vertex underneath or not, a `features`
|
|
114
119
|
* property - an array whose entries are the features that are being modified, and a `geometries`
|
|
115
120
|
* property - an array whose entries are the geometries that are being modified. Both arrays are
|
|
116
121
|
* in the same order. The `geometries` are only useful when modifying geometry collections, where
|
|
@@ -313,7 +318,7 @@ class Modify extends PointerInteraction {
|
|
|
313
318
|
this.changingFeature_ = false;
|
|
314
319
|
|
|
315
320
|
/**
|
|
316
|
-
* @type {Array}
|
|
321
|
+
* @type {Array<DragSegment>}
|
|
317
322
|
* @private
|
|
318
323
|
*/
|
|
319
324
|
this.dragSegments_ = [];
|
|
@@ -439,14 +444,14 @@ class Modify extends PointerInteraction {
|
|
|
439
444
|
}
|
|
440
445
|
const map = this.getMap();
|
|
441
446
|
if (map && map.isRendered() && this.getActive()) {
|
|
442
|
-
this.handlePointerAtPixel_(this.lastPixel_
|
|
447
|
+
this.handlePointerAtPixel_(map.getCoordinateFromPixel(this.lastPixel_));
|
|
443
448
|
}
|
|
444
449
|
feature.addEventListener(EventType.CHANGE, this.boundHandleFeatureChange_);
|
|
445
450
|
}
|
|
446
451
|
|
|
447
452
|
/**
|
|
448
453
|
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
449
|
-
* @param {Array<
|
|
454
|
+
* @param {Array<SegmentData>} segments The segments subject to modification.
|
|
450
455
|
* @private
|
|
451
456
|
*/
|
|
452
457
|
willModifyFeatures_(evt, segments) {
|
|
@@ -454,12 +459,9 @@ class Modify extends PointerInteraction {
|
|
|
454
459
|
this.featuresBeingModified_ = new Collection();
|
|
455
460
|
const features = this.featuresBeingModified_.getArray();
|
|
456
461
|
for (let i = 0, ii = segments.length; i < ii; ++i) {
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (feature && !features.includes(feature)) {
|
|
461
|
-
this.featuresBeingModified_.push(feature);
|
|
462
|
-
}
|
|
462
|
+
const feature = segments[i].feature;
|
|
463
|
+
if (feature && !features.includes(feature)) {
|
|
464
|
+
this.featuresBeingModified_.push(feature);
|
|
463
465
|
}
|
|
464
466
|
}
|
|
465
467
|
if (this.featuresBeingModified_.getLength() === 0) {
|
|
@@ -818,10 +820,11 @@ class Modify extends PointerInteraction {
|
|
|
818
820
|
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
|
|
819
821
|
* @param {Array<Feature>} features The features being modified.
|
|
820
822
|
* @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
|
|
823
|
+
* @param {boolean} existing The vertex represents an existing vertex.
|
|
821
824
|
* @return {Feature} Vertex feature.
|
|
822
825
|
* @private
|
|
823
826
|
*/
|
|
824
|
-
createOrUpdateVertexFeature_(coordinates, features, geometries) {
|
|
827
|
+
createOrUpdateVertexFeature_(coordinates, features, geometries, existing) {
|
|
825
828
|
let vertexFeature = this.vertexFeature_;
|
|
826
829
|
if (!vertexFeature) {
|
|
827
830
|
vertexFeature = new Feature(new Point(coordinates));
|
|
@@ -833,6 +836,7 @@ class Modify extends PointerInteraction {
|
|
|
833
836
|
}
|
|
834
837
|
vertexFeature.set('features', features);
|
|
835
838
|
vertexFeature.set('geometries', geometries);
|
|
839
|
+
vertexFeature.set('existing', existing);
|
|
836
840
|
return vertexFeature;
|
|
837
841
|
}
|
|
838
842
|
|
|
@@ -874,6 +878,102 @@ class Modify extends PointerInteraction {
|
|
|
874
878
|
return super.handleEvent(mapBrowserEvent) && !handled;
|
|
875
879
|
}
|
|
876
880
|
|
|
881
|
+
findInsertVerticesAndUpdateDragSegments_(pixelCoordinate) {
|
|
882
|
+
this.handlePointerAtPixel_(pixelCoordinate);
|
|
883
|
+
this.dragSegments_.length = 0;
|
|
884
|
+
this.featuresBeingModified_ = null;
|
|
885
|
+
const vertexFeature = this.vertexFeature_;
|
|
886
|
+
if (!vertexFeature) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
const projection = this.getMap().getView().getProjection();
|
|
891
|
+
const insertVertices = [];
|
|
892
|
+
const vertex = vertexFeature.getGeometry().getCoordinates();
|
|
893
|
+
const vertexExtent = boundingExtent([vertex]);
|
|
894
|
+
const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
|
|
895
|
+
const componentSegments = {};
|
|
896
|
+
segmentDataMatches.sort(compareIndexes);
|
|
897
|
+
for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
|
|
898
|
+
const segmentDataMatch = segmentDataMatches[i];
|
|
899
|
+
const segment = segmentDataMatch.segment;
|
|
900
|
+
let uid = getUid(segmentDataMatch.geometry);
|
|
901
|
+
const depth = segmentDataMatch.depth;
|
|
902
|
+
if (depth) {
|
|
903
|
+
uid += '-' + depth.join('-'); // separate feature components
|
|
904
|
+
}
|
|
905
|
+
if (!componentSegments[uid]) {
|
|
906
|
+
componentSegments[uid] = new Array(2);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (
|
|
910
|
+
segmentDataMatch.geometry.getType() === 'Circle' &&
|
|
911
|
+
segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX
|
|
912
|
+
) {
|
|
913
|
+
const closestVertex = closestOnSegmentData(
|
|
914
|
+
pixelCoordinate,
|
|
915
|
+
segmentDataMatch,
|
|
916
|
+
projection,
|
|
917
|
+
);
|
|
918
|
+
if (
|
|
919
|
+
coordinatesEqual(closestVertex, vertex) &&
|
|
920
|
+
!componentSegments[uid][0]
|
|
921
|
+
) {
|
|
922
|
+
this.dragSegments_.push([segmentDataMatch, 0]);
|
|
923
|
+
componentSegments[uid][0] = segmentDataMatch;
|
|
924
|
+
}
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
if (coordinatesEqual(segment[0], vertex) && !componentSegments[uid][0]) {
|
|
929
|
+
this.dragSegments_.push([segmentDataMatch, 0]);
|
|
930
|
+
componentSegments[uid][0] = segmentDataMatch;
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (coordinatesEqual(segment[1], vertex) && !componentSegments[uid][1]) {
|
|
935
|
+
if (
|
|
936
|
+
componentSegments[uid][0] &&
|
|
937
|
+
componentSegments[uid][0].index === 0
|
|
938
|
+
) {
|
|
939
|
+
let coordinates = segmentDataMatch.geometry.getCoordinates();
|
|
940
|
+
switch (segmentDataMatch.geometry.getType()) {
|
|
941
|
+
// prevent dragging closed linestrings by the connecting node
|
|
942
|
+
case 'LineString':
|
|
943
|
+
case 'MultiLineString':
|
|
944
|
+
continue;
|
|
945
|
+
// if dragging the first vertex of a polygon, ensure the other segment
|
|
946
|
+
// belongs to the closing vertex of the linear ring
|
|
947
|
+
case 'MultiPolygon':
|
|
948
|
+
coordinates = coordinates[depth[1]];
|
|
949
|
+
/* falls through */
|
|
950
|
+
case 'Polygon':
|
|
951
|
+
if (segmentDataMatch.index !== coordinates[depth[0]].length - 2) {
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
break;
|
|
955
|
+
default:
|
|
956
|
+
// pass
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
this.dragSegments_.push([segmentDataMatch, 1]);
|
|
961
|
+
componentSegments[uid][1] = segmentDataMatch;
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
if (
|
|
966
|
+
getUid(segment) in this.vertexSegments_ &&
|
|
967
|
+
!componentSegments[uid][0] &&
|
|
968
|
+
!componentSegments[uid][1]
|
|
969
|
+
) {
|
|
970
|
+
insertVertices.push(segmentDataMatch);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
return insertVertices;
|
|
975
|
+
}
|
|
976
|
+
|
|
877
977
|
/**
|
|
878
978
|
* Handle pointer drag events.
|
|
879
979
|
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
@@ -881,7 +981,10 @@ class Modify extends PointerInteraction {
|
|
|
881
981
|
*/
|
|
882
982
|
handleDragEvent(evt) {
|
|
883
983
|
this.ignoreNextSingleClick_ = false;
|
|
884
|
-
this.willModifyFeatures_(
|
|
984
|
+
this.willModifyFeatures_(
|
|
985
|
+
evt,
|
|
986
|
+
this.dragSegments_.map(([segment]) => segment),
|
|
987
|
+
);
|
|
885
988
|
|
|
886
989
|
const vertex = [
|
|
887
990
|
evt.coordinate[0] + this.delta_[0],
|
|
@@ -942,23 +1045,26 @@ class Modify extends PointerInteraction {
|
|
|
942
1045
|
segment[index] = vertex;
|
|
943
1046
|
break;
|
|
944
1047
|
case 'Circle':
|
|
1048
|
+
const circle = /** @type {import("../geom/Circle.js").default} */ (
|
|
1049
|
+
geometry
|
|
1050
|
+
);
|
|
945
1051
|
segment[0] = vertex;
|
|
946
1052
|
segment[1] = vertex;
|
|
947
1053
|
if (segmentData.index === CIRCLE_CENTER_INDEX) {
|
|
948
1054
|
this.changingFeature_ = true;
|
|
949
|
-
|
|
1055
|
+
circle.setCenter(vertex);
|
|
950
1056
|
this.changingFeature_ = false;
|
|
951
1057
|
} else {
|
|
952
1058
|
// We're dragging the circle's circumference:
|
|
953
1059
|
this.changingFeature_ = true;
|
|
954
1060
|
const projection = evt.map.getView().getProjection();
|
|
955
1061
|
let radius = coordinateDistance(
|
|
956
|
-
fromUserCoordinate(
|
|
1062
|
+
fromUserCoordinate(circle.getCenter(), projection),
|
|
957
1063
|
fromUserCoordinate(vertex, projection),
|
|
958
1064
|
);
|
|
959
1065
|
const userProjection = getUserProjection();
|
|
960
1066
|
if (userProjection) {
|
|
961
|
-
const circleGeometry =
|
|
1067
|
+
const circleGeometry = circle
|
|
962
1068
|
.clone()
|
|
963
1069
|
.transform(userProjection, projection);
|
|
964
1070
|
circleGeometry.setRadius(radius);
|
|
@@ -966,7 +1072,7 @@ class Modify extends PointerInteraction {
|
|
|
966
1072
|
.transform(projection, userProjection)
|
|
967
1073
|
.getRadius();
|
|
968
1074
|
}
|
|
969
|
-
|
|
1075
|
+
circle.setRadius(radius);
|
|
970
1076
|
this.changingFeature_ = false;
|
|
971
1077
|
}
|
|
972
1078
|
break;
|
|
@@ -978,7 +1084,7 @@ class Modify extends PointerInteraction {
|
|
|
978
1084
|
this.setGeometryCoordinates_(geometry, coordinates);
|
|
979
1085
|
}
|
|
980
1086
|
}
|
|
981
|
-
this.createOrUpdateVertexFeature_(vertex, features, geometries);
|
|
1087
|
+
this.createOrUpdateVertexFeature_(vertex, features, geometries, true);
|
|
982
1088
|
}
|
|
983
1089
|
|
|
984
1090
|
/**
|
|
@@ -992,113 +1098,21 @@ class Modify extends PointerInteraction {
|
|
|
992
1098
|
return false;
|
|
993
1099
|
}
|
|
994
1100
|
const pixelCoordinate = evt.coordinate;
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this.featuresBeingModified_ = null;
|
|
998
|
-
const vertexFeature = this.vertexFeature_;
|
|
999
|
-
if (vertexFeature) {
|
|
1000
|
-
const projection = evt.map.getView().getProjection();
|
|
1001
|
-
const insertVertices = [];
|
|
1002
|
-
const vertex = vertexFeature.getGeometry().getCoordinates();
|
|
1003
|
-
const vertexExtent = boundingExtent([vertex]);
|
|
1004
|
-
const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
|
|
1005
|
-
const componentSegments = {};
|
|
1006
|
-
segmentDataMatches.sort(compareIndexes);
|
|
1007
|
-
for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
|
|
1008
|
-
const segmentDataMatch = segmentDataMatches[i];
|
|
1009
|
-
const segment = segmentDataMatch.segment;
|
|
1010
|
-
let uid = getUid(segmentDataMatch.geometry);
|
|
1011
|
-
const depth = segmentDataMatch.depth;
|
|
1012
|
-
if (depth) {
|
|
1013
|
-
uid += '-' + depth.join('-'); // separate feature components
|
|
1014
|
-
}
|
|
1015
|
-
if (!componentSegments[uid]) {
|
|
1016
|
-
componentSegments[uid] = new Array(2);
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
if (
|
|
1020
|
-
segmentDataMatch.geometry.getType() === 'Circle' &&
|
|
1021
|
-
segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX
|
|
1022
|
-
) {
|
|
1023
|
-
const closestVertex = closestOnSegmentData(
|
|
1024
|
-
pixelCoordinate,
|
|
1025
|
-
segmentDataMatch,
|
|
1026
|
-
projection,
|
|
1027
|
-
);
|
|
1028
|
-
if (
|
|
1029
|
-
coordinatesEqual(closestVertex, vertex) &&
|
|
1030
|
-
!componentSegments[uid][0]
|
|
1031
|
-
) {
|
|
1032
|
-
this.dragSegments_.push([segmentDataMatch, 0]);
|
|
1033
|
-
componentSegments[uid][0] = segmentDataMatch;
|
|
1034
|
-
}
|
|
1035
|
-
continue;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
if (
|
|
1039
|
-
coordinatesEqual(segment[0], vertex) &&
|
|
1040
|
-
!componentSegments[uid][0]
|
|
1041
|
-
) {
|
|
1042
|
-
this.dragSegments_.push([segmentDataMatch, 0]);
|
|
1043
|
-
componentSegments[uid][0] = segmentDataMatch;
|
|
1044
|
-
continue;
|
|
1045
|
-
}
|
|
1101
|
+
const insertVertices =
|
|
1102
|
+
this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
|
|
1046
1103
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
!componentSegments[uid][1]
|
|
1050
|
-
) {
|
|
1051
|
-
if (
|
|
1052
|
-
componentSegments[uid][0] &&
|
|
1053
|
-
componentSegments[uid][0].index === 0
|
|
1054
|
-
) {
|
|
1055
|
-
let coordinates = segmentDataMatch.geometry.getCoordinates();
|
|
1056
|
-
switch (segmentDataMatch.geometry.getType()) {
|
|
1057
|
-
// prevent dragging closed linestrings by the connecting node
|
|
1058
|
-
case 'LineString':
|
|
1059
|
-
case 'MultiLineString':
|
|
1060
|
-
continue;
|
|
1061
|
-
// if dragging the first vertex of a polygon, ensure the other segment
|
|
1062
|
-
// belongs to the closing vertex of the linear ring
|
|
1063
|
-
case 'MultiPolygon':
|
|
1064
|
-
coordinates = coordinates[depth[1]];
|
|
1065
|
-
/* falls through */
|
|
1066
|
-
case 'Polygon':
|
|
1067
|
-
if (
|
|
1068
|
-
segmentDataMatch.index !==
|
|
1069
|
-
coordinates[depth[0]].length - 2
|
|
1070
|
-
) {
|
|
1071
|
-
continue;
|
|
1072
|
-
}
|
|
1073
|
-
break;
|
|
1074
|
-
default:
|
|
1075
|
-
// pass
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1104
|
+
if (insertVertices?.length && this.insertVertexCondition_(evt)) {
|
|
1105
|
+
this.willModifyFeatures_(evt, insertVertices);
|
|
1078
1106
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1107
|
+
if (this.vertexFeature_) {
|
|
1108
|
+
const vertex = this.vertexFeature_.getGeometry().getCoordinates();
|
|
1109
|
+
for (let j = insertVertices.length - 1; j >= 0; --j) {
|
|
1110
|
+
this.insertVertex_(insertVertices[j], vertex);
|
|
1082
1111
|
}
|
|
1083
|
-
|
|
1084
|
-
if (
|
|
1085
|
-
getUid(segment) in this.vertexSegments_ &&
|
|
1086
|
-
!componentSegments[uid][0] &&
|
|
1087
|
-
!componentSegments[uid][1] &&
|
|
1088
|
-
this.insertVertexCondition_(evt)
|
|
1089
|
-
) {
|
|
1090
|
-
insertVertices.push(segmentDataMatch);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
if (insertVertices.length) {
|
|
1095
|
-
this.willModifyFeatures_(evt, [insertVertices]);
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
for (let j = insertVertices.length - 1; j >= 0; --j) {
|
|
1099
|
-
this.insertVertex_(insertVertices[j], vertex);
|
|
1112
|
+
this.ignoreNextSingleClick_ = true;
|
|
1100
1113
|
}
|
|
1101
1114
|
}
|
|
1115
|
+
|
|
1102
1116
|
return !!this.vertexFeature_;
|
|
1103
1117
|
}
|
|
1104
1118
|
|
|
@@ -1113,8 +1127,11 @@ class Modify extends PointerInteraction {
|
|
|
1113
1127
|
const segmentData = this.dragSegments_[i][0];
|
|
1114
1128
|
const geometry = segmentData.geometry;
|
|
1115
1129
|
if (geometry.getType() === 'Circle') {
|
|
1130
|
+
const circle = /** @type {import("../geom/Circle.js").default} */ (
|
|
1131
|
+
geometry
|
|
1132
|
+
);
|
|
1116
1133
|
// Update a circle object in the R* bush:
|
|
1117
|
-
const coordinates =
|
|
1134
|
+
const coordinates = circle.getCenter();
|
|
1118
1135
|
const centerSegmentData = segmentData.featureSegments[0];
|
|
1119
1136
|
const circumferenceSegmentData = segmentData.featureSegments[1];
|
|
1120
1137
|
centerSegmentData.segment[0] = coordinates;
|
|
@@ -1122,7 +1139,8 @@ class Modify extends PointerInteraction {
|
|
|
1122
1139
|
circumferenceSegmentData.segment[0] = coordinates;
|
|
1123
1140
|
circumferenceSegmentData.segment[1] = coordinates;
|
|
1124
1141
|
this.rBush_.update(createExtent(coordinates), centerSegmentData);
|
|
1125
|
-
|
|
1142
|
+
/** @type {import("../geom/Circle.js").default | import("../geom/Polygon.js").default} */
|
|
1143
|
+
let circleGeometry = circle;
|
|
1126
1144
|
const userProjection = getUserProjection();
|
|
1127
1145
|
if (userProjection) {
|
|
1128
1146
|
const projection = evt.map.getView().getProjection();
|
|
@@ -1161,17 +1179,16 @@ class Modify extends PointerInteraction {
|
|
|
1161
1179
|
*/
|
|
1162
1180
|
handlePointerMove_(evt) {
|
|
1163
1181
|
this.lastPixel_ = evt.pixel;
|
|
1164
|
-
this.handlePointerAtPixel_(evt.
|
|
1182
|
+
this.handlePointerAtPixel_(evt.coordinate);
|
|
1165
1183
|
}
|
|
1166
1184
|
|
|
1167
1185
|
/**
|
|
1168
|
-
* @param {import("../
|
|
1169
|
-
* @param {import("../Map.js").default} map Map.
|
|
1170
|
-
* @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate.
|
|
1186
|
+
* @param {import("../coordinate.js").Coordinate} pixelCoordinate The pixel Coordinate.
|
|
1171
1187
|
* @private
|
|
1172
1188
|
*/
|
|
1173
|
-
handlePointerAtPixel_(
|
|
1174
|
-
const
|
|
1189
|
+
handlePointerAtPixel_(pixelCoordinate) {
|
|
1190
|
+
const map = this.getMap();
|
|
1191
|
+
const pixel = map.getPixelFromCoordinate(pixelCoordinate);
|
|
1175
1192
|
const projection = map.getView().getProjection();
|
|
1176
1193
|
const sortByDistance = function (a, b) {
|
|
1177
1194
|
return (
|
|
@@ -1256,6 +1273,7 @@ class Modify extends PointerInteraction {
|
|
|
1256
1273
|
vertex,
|
|
1257
1274
|
[node.feature],
|
|
1258
1275
|
[node.geometry],
|
|
1276
|
+
this.snappedToVertex_,
|
|
1259
1277
|
);
|
|
1260
1278
|
} else {
|
|
1261
1279
|
const pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
|
@@ -1274,6 +1292,7 @@ class Modify extends PointerInteraction {
|
|
|
1274
1292
|
vertex,
|
|
1275
1293
|
[node.feature],
|
|
1276
1294
|
[node.geometry],
|
|
1295
|
+
this.snappedToVertex_,
|
|
1277
1296
|
);
|
|
1278
1297
|
const geometries = {};
|
|
1279
1298
|
geometries[getUid(node.geometry)] = true;
|
|
@@ -1309,6 +1328,7 @@ class Modify extends PointerInteraction {
|
|
|
1309
1328
|
/**
|
|
1310
1329
|
* @param {SegmentData} segmentData Segment data.
|
|
1311
1330
|
* @param {import("../coordinate.js").Coordinate} vertex Vertex.
|
|
1331
|
+
* @return {boolean} A vertex was inserted.
|
|
1312
1332
|
* @private
|
|
1313
1333
|
*/
|
|
1314
1334
|
insertVertex_(segmentData, vertex) {
|
|
@@ -1341,7 +1361,7 @@ class Modify extends PointerInteraction {
|
|
|
1341
1361
|
coordinates.splice(index + 1, 0, vertex);
|
|
1342
1362
|
break;
|
|
1343
1363
|
default:
|
|
1344
|
-
return;
|
|
1364
|
+
return false;
|
|
1345
1365
|
}
|
|
1346
1366
|
|
|
1347
1367
|
this.setGeometryCoordinates_(geometry, coordinates);
|
|
@@ -1372,21 +1392,86 @@ class Modify extends PointerInteraction {
|
|
|
1372
1392
|
|
|
1373
1393
|
rTree.insert(boundingExtent(newSegmentData2.segment), newSegmentData2);
|
|
1374
1394
|
this.dragSegments_.push([newSegmentData2, 0]);
|
|
1375
|
-
|
|
1395
|
+
return true;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
updatePointer_(coordinate) {
|
|
1399
|
+
if (coordinate) {
|
|
1400
|
+
this.findInsertVerticesAndUpdateDragSegments_(coordinate);
|
|
1401
|
+
}
|
|
1402
|
+
return this.vertexFeature_?.getGeometry().getCoordinates();
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* Get the current pointer position.
|
|
1407
|
+
* @return {import("../coordinate.js").Coordinate | null} The current pointer coordinate.
|
|
1408
|
+
*/
|
|
1409
|
+
getPoint() {
|
|
1410
|
+
const coordinate = this.vertexFeature_?.getGeometry().getCoordinates();
|
|
1411
|
+
if (!coordinate) {
|
|
1412
|
+
return null;
|
|
1413
|
+
}
|
|
1414
|
+
return toUserCoordinate(
|
|
1415
|
+
coordinate,
|
|
1416
|
+
this.getMap().getView().getProjection(),
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Check if a point can be removed from the current linestring or polygon at the current
|
|
1422
|
+
* pointer position.
|
|
1423
|
+
* @return {boolean} A point can be deleted at the current pointer position.
|
|
1424
|
+
* @api
|
|
1425
|
+
*/
|
|
1426
|
+
canRemovePoint() {
|
|
1427
|
+
if (!this.vertexFeature_) {
|
|
1428
|
+
return false;
|
|
1429
|
+
}
|
|
1430
|
+
if (
|
|
1431
|
+
this.vertexFeature_
|
|
1432
|
+
.get('geometries')
|
|
1433
|
+
.every(
|
|
1434
|
+
(geometry) =>
|
|
1435
|
+
geometry.getType() === 'Circle' ||
|
|
1436
|
+
geometry.getType().endsWith('Point'),
|
|
1437
|
+
)
|
|
1438
|
+
) {
|
|
1439
|
+
return false;
|
|
1440
|
+
}
|
|
1441
|
+
const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
|
|
1442
|
+
const segments = this.rBush_.getInExtent(boundingExtent([coordinate]));
|
|
1443
|
+
return segments.some(
|
|
1444
|
+
({segment}) =>
|
|
1445
|
+
coordinatesEqual(segment[0], coordinate) ||
|
|
1446
|
+
coordinatesEqual(segment[1], coordinate),
|
|
1447
|
+
);
|
|
1376
1448
|
}
|
|
1377
1449
|
|
|
1378
1450
|
/**
|
|
1379
|
-
* Removes the vertex currently being pointed.
|
|
1451
|
+
* Removes the vertex currently being pointed from the current linestring or polygon.
|
|
1452
|
+
* @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
|
|
1453
|
+
* will be set to the provided coordinate. If not, the current pointer coordinate will be used.
|
|
1380
1454
|
* @return {boolean} True when a vertex was removed.
|
|
1381
1455
|
* @api
|
|
1382
1456
|
*/
|
|
1383
|
-
removePoint() {
|
|
1457
|
+
removePoint(coordinate) {
|
|
1458
|
+
if (coordinate) {
|
|
1459
|
+
coordinate = fromUserCoordinate(
|
|
1460
|
+
coordinate,
|
|
1461
|
+
this.getMap().getView().getProjection(),
|
|
1462
|
+
);
|
|
1463
|
+
this.updatePointer_(coordinate);
|
|
1464
|
+
}
|
|
1384
1465
|
if (
|
|
1385
|
-
this.lastPointerEvent_
|
|
1386
|
-
this.lastPointerEvent_
|
|
1466
|
+
!this.lastPointerEvent_ ||
|
|
1467
|
+
(this.lastPointerEvent_ &&
|
|
1468
|
+
this.lastPointerEvent_.type != MapBrowserEventType.POINTERDRAG)
|
|
1387
1469
|
) {
|
|
1388
1470
|
const evt = this.lastPointerEvent_;
|
|
1389
|
-
this.willModifyFeatures_(
|
|
1471
|
+
this.willModifyFeatures_(
|
|
1472
|
+
evt,
|
|
1473
|
+
this.dragSegments_.map(([segment]) => segment),
|
|
1474
|
+
);
|
|
1390
1475
|
const removed = this.removeVertex_();
|
|
1391
1476
|
if (this.featuresBeingModified_) {
|
|
1392
1477
|
this.dispatchEvent(
|
|
@@ -1524,6 +1609,61 @@ class Modify extends PointerInteraction {
|
|
|
1524
1609
|
return deleted;
|
|
1525
1610
|
}
|
|
1526
1611
|
|
|
1612
|
+
/**
|
|
1613
|
+
* Check if a point can be inserted to the current linestring or polygon at the current
|
|
1614
|
+
* pointer position.
|
|
1615
|
+
* @return {boolean} A point can be inserted at the current pointer position.
|
|
1616
|
+
* @api
|
|
1617
|
+
*/
|
|
1618
|
+
canInsertPoint() {
|
|
1619
|
+
if (!this.vertexFeature_) {
|
|
1620
|
+
return false;
|
|
1621
|
+
}
|
|
1622
|
+
if (
|
|
1623
|
+
this.vertexFeature_
|
|
1624
|
+
.get('geometries')
|
|
1625
|
+
.every(
|
|
1626
|
+
(geometry) =>
|
|
1627
|
+
geometry.getType() === 'Circle' ||
|
|
1628
|
+
geometry.getType().endsWith('Point'),
|
|
1629
|
+
)
|
|
1630
|
+
) {
|
|
1631
|
+
return false;
|
|
1632
|
+
}
|
|
1633
|
+
const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
|
|
1634
|
+
const segments = this.rBush_.getInExtent(boundingExtent([coordinate]));
|
|
1635
|
+
return segments.some(
|
|
1636
|
+
({segment}) =>
|
|
1637
|
+
!(
|
|
1638
|
+
coordinatesEqual(segment[0], coordinate) ||
|
|
1639
|
+
coordinatesEqual(segment[1], coordinate)
|
|
1640
|
+
),
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
/**
|
|
1645
|
+
* Inserts the vertex currently being pointed to the current linestring or polygon.
|
|
1646
|
+
* @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
|
|
1647
|
+
* will be set to the provided coordinate. If not, the current pointer coordinate will be used.
|
|
1648
|
+
* @return {boolean} A vertex was inserted.
|
|
1649
|
+
* @api
|
|
1650
|
+
*/
|
|
1651
|
+
insertPoint(coordinate) {
|
|
1652
|
+
const pixelCoordinate = coordinate
|
|
1653
|
+
? fromUserCoordinate(coordinate, this.getMap().getView().getProjection())
|
|
1654
|
+
: this.vertexFeature_?.getGeometry().getCoordinates();
|
|
1655
|
+
if (!pixelCoordinate) {
|
|
1656
|
+
return false;
|
|
1657
|
+
}
|
|
1658
|
+
const insertVertices =
|
|
1659
|
+
this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
|
|
1660
|
+
return insertVertices.reduce(
|
|
1661
|
+
(prev, segmentData) =>
|
|
1662
|
+
prev || this.insertVertex_(segmentData, pixelCoordinate),
|
|
1663
|
+
false,
|
|
1664
|
+
);
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1527
1667
|
/**
|
|
1528
1668
|
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
1529
1669
|
* @param {Array} coordinates Coordinates.
|
package/package.json
CHANGED
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
* @return {TileRepresentationLookup} A new tile representation lookup.
|
|
11
11
|
*/
|
|
12
12
|
export function newTileRepresentationLookup(): TileRepresentationLookup;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @param {import("../../source/Tile.js").default} source The source.
|
|
15
|
+
* @param {import('../../tilecoord.js').TileCoord} tileCoord The tile coordinate.
|
|
16
|
+
* @return {string} The cache key.
|
|
17
|
+
*/
|
|
18
|
+
export function getCacheKey(source: import("../../source/Tile.js").default, tileCoord: import("../../tilecoord.js").TileCoord): string;
|
|
14
19
|
export namespace Uniforms {
|
|
15
20
|
let TILE_TRANSFORM: string;
|
|
16
21
|
let TRANSITION_ALPHA: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayerBase.d.ts","sourceRoot":"","sources":["TileLayerBase.js"],"names":[],"mappings":"AAkDA;;GAEG;AACH;;;;GAIG;AAEH;;GAEG;AACH,+CAFY,wBAAwB,CAInC;AA0DD,
|
|
1
|
+
{"version":3,"file":"TileLayerBase.d.ts","sourceRoot":"","sources":["TileLayerBase.js"],"names":[],"mappings":"AAkDA;;GAEG;AACH;;;;GAIG;AAEH;;GAEG;AACH,+CAFY,wBAAwB,CAInC;AA0DD;;;;GAIG;AACH,oCAJW,OAAO,sBAAsB,EAAE,OAAO,aACtC,OAAO,oBAAoB,EAAE,SAAS,GACrC,MAAM,CAIjB;;;;;;;;;;;;;;yCA9EY,OAAO,uCAAuC,EAAE,OAAO,CAAC,OAAO,eAAe,EAAE,OAAO,CAAC;;;;;aAIvF,GAAG,CAAC,MAAM,CAAC;;;;wBACX;YAAO,MAAM,GAAE,GAAG,CAAC,0BAA0B,CAAC;KAAC;;;;;;;;;;;;;;;;;;;4BAoFhD,mDAAyC;AATtD;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;;;GAOG;AACH,yCAL6B,SAAS,SAAxB,aAAc,EACmB,QAAQ,SAA1C,OAAQ,eAAe,EAAE,OAAQ,EACmC,kBAAkB,SAAtF,OAAQ,uCAAuC,EAAE,OAAO,CAAC,QAAQ,CAAE;IAI9E;;;OAGG;IACH,uBAHW,SAAS,WACT,OAAO,EA+DjB;IAvDC;;;OAGG;IACH,gBAFU,OAAO,CAEU;IAE3B;;;;OAIG;IACH,uBAAuC;IAEvC;;;OAGG;IACH,oBAHU,KAAK,CAAC,MAAM,CAAC,CAGK;IAE5B;;;OAGG;IACH,uBAA+C;IAE/C;;;OAGG;IACH,uBAA8C;IAE9C;;;OAGG;IACH,kBAAuB;IAGvB;;;OAGG;IACH,mCAHU,OAAO,2BAA2B,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAGnB;IAEtD;;;OAGG;IACH,sBAFU,OAAO,cAAc,EAAE,UAAU,GAAC,IAAI,CAE1B;IAEtB;;;OAGG;IACH,4BAAoC;IAGtC;;;OAGG;IACH,wBAHW,OAAO,QAOjB;IA4BD;;;;;OAKG;IACH,4CAJW,OAAO,uCAAuC,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAClF,kBAAkB,CAK7B;IAED;;;;;;OAMG;IACH,yBANW,OAAO,cAAc,EAAE,UAAU,UACjC,OAAO,iBAAiB,EAAE,MAAM,YAChC,MAAM,4BACN,wBAAwB,WACxB,MAAM,QAqHhB;IAED;;;;OAIG;IACH,wCAJW,OAAO,cAAc,EAAE,UAAU,kBACjC,OAAO,QAKjB;IAED;;;;OAIG;IACH,4CAJW,OAAO,cAAc,EAAE,UAAU,GAChC,OAAO,CAKlB;IAED;;;;;;;;;;;;;OAaG;IACH,yCAbW,kBAAkB,iBAClB,OAAO,oBAAoB,EAAE,SAAS,cACtC,OAAO,cAAc,EAAE,UAAU,gBACjC,OAAO,iBAAiB,EAAE,MAAM,kBAChC,MAAM,YACN,OAAO,eAAe,EAAE,IAAI,cAC5B,OAAO,qBAAqB,EAAE,UAAU,cACxC,OAAO,iBAAiB,EAAE,MAAM,SAChC,MAAM,UACN,MAAM,SACN,MAAM,QAeb;IAEJ;;;;;;OAMG;IACH,6CANW,kBAAkB,SAClB,MAAM,UACN,OAAO,iBAAiB,EAAE,MAAM,SAChC,MAAM,QAG0C;IAE3D,iIAuEC;IAED;;;;;OAKG;IACH,iCAJW,OAAO,cAAc,EAAE,UAAU,GAChC,WAAW,CA6MtB;IAED;;;OAGG;IACH,qCAHW,OAAO,cAAc,EAAE,UAAU,QAK3C;IAED;;;;;;;;;;OAUG;IACH,sBAsCC;CAkCF;+BA1yB8B,YAAY"}
|
|
@@ -120,8 +120,13 @@ function getRenderExtent(frameState, extent) {
|
|
|
120
120
|
return extent;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @param {import("../../source/Tile.js").default} source The source.
|
|
125
|
+
* @param {import('../../tilecoord.js').TileCoord} tileCoord The tile coordinate.
|
|
126
|
+
* @return {string} The cache key.
|
|
127
|
+
*/
|
|
123
128
|
export function getCacheKey(source, tileCoord) {
|
|
124
|
-
return `${source.getKey()},${getTileCoordKey(tileCoord)}`;
|
|
129
|
+
return `${source.getKey()},${source.getRevision()},${getTileCoordKey(tileCoord)}`;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
/**
|