|
7 | 7 | * @property {Array<Array<number>>} segment Segment. |
8 | 8 | * @property {Array<SegmentData>} [featureSegments] FeatureSegments. |
9 | 9 | */ |
| 10 | +/** |
| 11 | + * @typedef {[SegmentData, number]} DragSegment |
| 12 | + */ |
10 | 13 | /** |
11 | 14 | * @typedef {Object} Options |
12 | 15 | * @property {import("../events/condition.js").Condition} [condition] A function that |
|
29 | 32 | * Style used for the modification point or vertex. For linestrings and polygons, this will |
30 | 33 | * be the affected vertex, for circles a point along the circle, and for points the actual |
31 | 34 | * point. If not configured, the default edit style is used (see {@link module:ol/style/Style~Style}). |
32 | | - * When using a style function, the point feature passed to the function will have a `features` |
| 35 | + * When using a style function, the point feature passed to the function will have an `existing` property - |
| 36 | + * indicating whether there is an existing vertex underneath or not, a `features` |
33 | 37 | * property - an array whose entries are the features that are being modified, and a `geometries` |
34 | 38 | * property - an array whose entries are the geometries that are being modified. Both arrays are |
35 | 39 | * in the same order. The `geometries` are only useful when modifying geometry collections, where |
@@ -103,6 +107,7 @@ export type SegmentData = { |
103 | 107 | */ |
104 | 108 | featureSegments?: SegmentData[] | undefined; |
105 | 109 | }; |
| 110 | +export type DragSegment = [SegmentData, number]; |
106 | 111 | export type Options = { |
107 | 112 | /** |
108 | 113 | * A function that |
@@ -136,7 +141,8 @@ export type Options = { |
136 | 141 | * Style used for the modification point or vertex. For linestrings and polygons, this will |
137 | 142 | * be the affected vertex, for circles a point along the circle, and for points the actual |
138 | 143 | * point. If not configured, the default edit style is used (see {@link module :ol/style/Style~Style}). |
139 | | - * When using a style function, the point feature passed to the function will have a `features` |
| 144 | + * When using a style function, the point feature passed to the function will have an `existing` property - |
| 145 | + * indicating whether there is an existing vertex underneath or not, a `features` |
140 | 146 | * property - an array whose entries are the features that are being modified, and a `geometries` |
141 | 147 | * property - an array whose entries are the geometries that are being modified. Both arrays are |
142 | 148 | * in the same order. The `geometries` are only useful when modifying geometry collections, where |
@@ -307,7 +313,7 @@ declare class Modify extends PointerInteraction { |
307 | 313 | */ |
308 | 314 | private changingFeature_; |
309 | 315 | /** |
310 | | - * @type {Array} |
| 316 | + * @type {Array<DragSegment>} |
311 | 317 | * @private |
312 | 318 | */ |
313 | 319 | private dragSegments_; |
@@ -360,7 +366,7 @@ declare class Modify extends PointerInteraction { |
360 | 366 | private addFeature_; |
361 | 367 | /** |
362 | 368 | * @param {import("../MapBrowserEvent.js").default} evt Map browser event. |
363 | | - * @param {Array<Array<SegmentData>>} segments The segments subject to modification. |
| 369 | + * @param {Array<SegmentData>} segments The segments subject to modification. |
364 | 370 | * @private |
365 | 371 | */ |
366 | 372 | private willModifyFeatures_; |
@@ -471,40 +477,71 @@ declare class Modify extends PointerInteraction { |
471 | 477 | * @param {import("../coordinate.js").Coordinate} coordinates Coordinates. |
472 | 478 | * @param {Array<Feature>} features The features being modified. |
473 | 479 | * @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified. |
| 480 | + * @param {boolean} existing The vertex represents an existing vertex. |
474 | 481 | * @return {Feature} Vertex feature. |
475 | 482 | * @private |
476 | 483 | */ |
477 | 484 | private createOrUpdateVertexFeature_; |
| 485 | + findInsertVerticesAndUpdateDragSegments_(pixelCoordinate: any): SegmentData[] | undefined; |
478 | 486 | /** |
479 | 487 | * @param {import("../MapBrowserEvent.js").default} evt Event. |
480 | 488 | * @private |
481 | 489 | */ |
482 | 490 | private handlePointerMove_; |
483 | 491 | /** |
484 | | - * @param {import("../pixel.js").Pixel} pixel Pixel |
485 | | - * @param {import("../Map.js").default} map Map. |
486 | | - * @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate. |
| 492 | + * @param {import("../coordinate.js").Coordinate} pixelCoordinate The pixel Coordinate. |
487 | 493 | * @private |
488 | 494 | */ |
489 | 495 | private handlePointerAtPixel_; |
490 | 496 | /** |
491 | 497 | * @param {SegmentData} segmentData Segment data. |
492 | 498 | * @param {import("../coordinate.js").Coordinate} vertex Vertex. |
| 499 | + * @return {boolean} A vertex was inserted. |
493 | 500 | * @private |
494 | 501 | */ |
495 | 502 | private insertVertex_; |
| 503 | + updatePointer_(coordinate: any): import("../coordinate.js").Coordinate; |
| 504 | + /** |
| 505 | + * Get the current pointer position. |
| 506 | + * @return {import("../coordinate.js").Coordinate | null} The current pointer coordinate. |
| 507 | + */ |
| 508 | + getPoint(): import("../coordinate.js").Coordinate | null; |
| 509 | + /** |
| 510 | + * Check if a point can be removed from the current linestring or polygon at the current |
| 511 | + * pointer position. |
| 512 | + * @return {boolean} A point can be deleted at the current pointer position. |
| 513 | + * @api |
| 514 | + */ |
| 515 | + canRemovePoint(): boolean; |
496 | 516 | /** |
497 | | - * Removes the vertex currently being pointed. |
| 517 | + * Removes the vertex currently being pointed from the current linestring or polygon. |
| 518 | + * @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer |
| 519 | + * will be set to the provided coordinate. If not, the current pointer coordinate will be used. |
498 | 520 | * @return {boolean} True when a vertex was removed. |
499 | 521 | * @api |
500 | 522 | */ |
501 | | - removePoint(): boolean; |
| 523 | + removePoint(coordinate?: import("../coordinate.js").Coordinate | undefined): boolean; |
502 | 524 | /** |
503 | 525 | * Removes a vertex from all matching features. |
504 | 526 | * @return {boolean} True when a vertex was removed. |
505 | 527 | * @private |
506 | 528 | */ |
507 | 529 | private removeVertex_; |
| 530 | + /** |
| 531 | + * Check if a point can be inserted to the current linestring or polygon at the current |
| 532 | + * pointer position. |
| 533 | + * @return {boolean} A point can be inserted at the current pointer position. |
| 534 | + * @api |
| 535 | + */ |
| 536 | + canInsertPoint(): boolean; |
| 537 | + /** |
| 538 | + * Inserts the vertex currently being pointed to the current linestring or polygon. |
| 539 | + * @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer |
| 540 | + * will be set to the provided coordinate. If not, the current pointer coordinate will be used. |
| 541 | + * @return {boolean} A vertex was inserted. |
| 542 | + * @api |
| 543 | + */ |
| 544 | + insertPoint(coordinate?: import("../coordinate.js").Coordinate | undefined): boolean; |
508 | 545 | /** |
509 | 546 | * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry. |
510 | 547 | * @param {Array} coordinates Coordinates. |
|
0 commit comments