maplibre-gl-geo-editor 0.2.0 → 0.3.0
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/types/index.d.ts +1420 -0
- package/dist/types/react.d.ts +2014 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1,1421 @@
|
|
|
1
|
+
import { Feature } from 'geojson';
|
|
2
|
+
import { FeatureCollection } from 'geojson';
|
|
3
|
+
import { GeoJsonProperties } from 'geojson';
|
|
4
|
+
import { Geometry } from 'geojson';
|
|
5
|
+
import { IControl } from 'maplibre-gl';
|
|
6
|
+
import { LineString } from 'geojson';
|
|
7
|
+
import { Map as Map_2 } from 'maplibre-gl';
|
|
8
|
+
import { MapMouseEvent } from 'maplibre-gl';
|
|
9
|
+
import { MapTouchEvent } from 'maplibre-gl';
|
|
10
|
+
import { MultiPolygon } from 'geojson';
|
|
11
|
+
import { Point } from 'geojson';
|
|
12
|
+
import { Polygon } from 'geojson';
|
|
13
|
+
import { Position } from 'geojson';
|
|
14
|
+
import * as turf from '@turf/turf';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Add feature to selection
|
|
18
|
+
*/
|
|
19
|
+
export declare function addToSelection(selection: SelectedFeature[], feature: Feature, layerId?: string): SelectedFeature[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Advanced edit modes (our implementations)
|
|
23
|
+
*/
|
|
24
|
+
export declare const ADVANCED_EDIT_MODES: EditMode[];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Calculate the bearing between two points in degrees
|
|
28
|
+
*/
|
|
29
|
+
export declare function bearingBetweenPoints(point1: Position, point2: Position): number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Calculate the area of a polygon in square meters
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateArea(feature: Feature<Polygon | MultiPolygon>): number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Calculate the length of a line in kilometers
|
|
38
|
+
*/
|
|
39
|
+
export declare function calculateLength(feature: Feature<LineString>): number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Calculate the scale factor between two bounding boxes
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateScaleFactor(originalBBox: [number, number, number, number], newBBox: [number, number, number, number]): number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Check if features can be merged (union)
|
|
48
|
+
* At least 2 polygons that overlap or touch
|
|
49
|
+
*/
|
|
50
|
+
export declare function canMergeFeatures(features: Feature[]): {
|
|
51
|
+
canMerge: boolean;
|
|
52
|
+
reason?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Check if features can be used for difference operation
|
|
57
|
+
*/
|
|
58
|
+
export declare function canSubtractFeatures(features: Feature[]): {
|
|
59
|
+
canSubtract: boolean;
|
|
60
|
+
reason?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Clamp a value between min and max
|
|
65
|
+
*/
|
|
66
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Deep clone a feature
|
|
70
|
+
*/
|
|
71
|
+
export declare function cloneFeature<T extends Feature>(feature: T): T;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Check if polygon1 contains polygon2
|
|
75
|
+
*/
|
|
76
|
+
export declare function contains(container: Feature<Polygon | MultiPolygon>, contained: Feature<Polygon | MultiPolygon>): boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Handles copy/paste operations for features
|
|
80
|
+
*/
|
|
81
|
+
export declare class CopyFeature {
|
|
82
|
+
private options;
|
|
83
|
+
constructor(options?: CopyOptions);
|
|
84
|
+
/**
|
|
85
|
+
* Copy a single feature with optional offset
|
|
86
|
+
*/
|
|
87
|
+
copy(feature: Feature, offset?: [number, number]): Feature;
|
|
88
|
+
/**
|
|
89
|
+
* Copy multiple features maintaining relative positions
|
|
90
|
+
*/
|
|
91
|
+
copyMultiple(features: Feature[], offset?: [number, number]): Feature[];
|
|
92
|
+
/**
|
|
93
|
+
* Copy features to a specific location (centered on the location)
|
|
94
|
+
*/
|
|
95
|
+
copyToLocation(features: Feature[], targetCenter: [number, number]): Feature[];
|
|
96
|
+
/**
|
|
97
|
+
* Update the default offset
|
|
98
|
+
*/
|
|
99
|
+
setOffset(offset: [number, number]): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get the current offset
|
|
102
|
+
*/
|
|
103
|
+
getOffset(): [number, number];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export declare interface CopyOptions {
|
|
107
|
+
/** Offset in [lng, lat] degrees for pasted features */
|
|
108
|
+
offset?: [number, number];
|
|
109
|
+
/** Generate new IDs for copied features */
|
|
110
|
+
generateNewIds?: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Create a feature collection
|
|
115
|
+
*/
|
|
116
|
+
export declare function createFeatureCollection<T extends Feature>(features: T[]): FeatureCollection;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Create a line from coordinates
|
|
120
|
+
*/
|
|
121
|
+
export declare function createLine(coordinates: Position[], properties?: Record<string, unknown>): Feature<LineString>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Create a point from coordinates
|
|
125
|
+
*/
|
|
126
|
+
export declare function createPoint(coordinates: Position, properties?: Record<string, unknown>): Feature<Point>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Create a polygon from coordinates
|
|
130
|
+
*/
|
|
131
|
+
export declare function createPolygon(coordinates: Position[][], properties?: Record<string, unknown>): Feature<Polygon>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* CSS class prefix for the plugin
|
|
135
|
+
*/
|
|
136
|
+
export declare const CSS_PREFIX = "geo-editor";
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Default draw modes available in the toolbar
|
|
140
|
+
*/
|
|
141
|
+
export declare const DEFAULT_DRAW_MODES: DrawMode[];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Default edit modes available in the toolbar
|
|
145
|
+
*/
|
|
146
|
+
export declare const DEFAULT_EDIT_MODES: EditMode[];
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Default file modes
|
|
150
|
+
*/
|
|
151
|
+
export declare const DEFAULT_FILE_MODES: FileMode[];
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Default options for GeoEditor
|
|
155
|
+
*/
|
|
156
|
+
export declare const DEFAULT_OPTIONS: GeoEditorOptionsRequired;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Convert degrees to radians
|
|
160
|
+
*/
|
|
161
|
+
export declare function degreesToRadians(degrees: number): number;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Handles polygon difference/subtraction operations
|
|
165
|
+
*/
|
|
166
|
+
export declare class DifferenceFeature {
|
|
167
|
+
/**
|
|
168
|
+
* Subtract one or more polygons from a base polygon
|
|
169
|
+
*/
|
|
170
|
+
difference(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>[], options?: DifferenceOptions): DifferenceResult;
|
|
171
|
+
/**
|
|
172
|
+
* Check if subtraction can be performed
|
|
173
|
+
*/
|
|
174
|
+
canSubtract(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>): {
|
|
175
|
+
canSubtract: boolean;
|
|
176
|
+
overlap: boolean;
|
|
177
|
+
reason?: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Get the area that would be removed
|
|
181
|
+
*/
|
|
182
|
+
getSubtractedArea(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>): number | null;
|
|
183
|
+
/**
|
|
184
|
+
* Preview the result without applying
|
|
185
|
+
*/
|
|
186
|
+
preview(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>[]): Feature<Polygon | MultiPolygon> | null;
|
|
187
|
+
/**
|
|
188
|
+
* Create a hole in a polygon at a specific location
|
|
189
|
+
*/
|
|
190
|
+
createHole(polygon: Feature<Polygon>, hole: Feature<Polygon>): Feature<Polygon | MultiPolygon> | null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export declare interface DifferenceOptions {
|
|
194
|
+
/** Properties to use for the result feature */
|
|
195
|
+
properties?: GeoJsonProperties;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export declare interface DifferenceResult {
|
|
199
|
+
/** Resulting feature after subtraction */
|
|
200
|
+
result: Feature<Polygon | MultiPolygon> | null;
|
|
201
|
+
/** Base feature */
|
|
202
|
+
base: Feature<Polygon | MultiPolygon>;
|
|
203
|
+
/** Features that were subtracted */
|
|
204
|
+
subtracted: Feature<Polygon | MultiPolygon>[];
|
|
205
|
+
/** Whether the operation was successful */
|
|
206
|
+
success: boolean;
|
|
207
|
+
/** Error message if operation failed */
|
|
208
|
+
error?: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Calculate the distance between two points in kilometers
|
|
213
|
+
*/
|
|
214
|
+
export declare function distanceBetweenPoints(point1: Position, point2: Position): number;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Available draw modes.
|
|
218
|
+
* Note: 'freehand' is implemented as a custom feature (not dependent on Geoman Pro).
|
|
219
|
+
*/
|
|
220
|
+
export declare type DrawMode = 'marker' | 'circle' | 'circle_marker' | 'ellipse' | 'text_marker' | 'line' | 'rectangle' | 'polygon' | 'freehand';
|
|
221
|
+
|
|
222
|
+
export declare type EditMode = 'drag' | 'change' | 'rotate' | 'cut' | 'delete' | 'select' | 'scale' | 'copy' | 'split' | 'union' | 'difference' | 'simplify' | 'lasso';
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Ensure a feature has an ID
|
|
226
|
+
*/
|
|
227
|
+
export declare function ensureFeatureId(feature: Feature): Feature;
|
|
228
|
+
|
|
229
|
+
export declare type FileMode = 'open' | 'save';
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Filter features by geometry type
|
|
233
|
+
*/
|
|
234
|
+
export declare function filterByGeometryType(features: Feature[], types: string[]): Feature[];
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Convert SelectedFeature array to Feature array
|
|
238
|
+
*/
|
|
239
|
+
export declare function fromSelectedFeatures(selected: SelectedFeature[]): Feature[];
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Generate a unique ID for a feature
|
|
243
|
+
*/
|
|
244
|
+
export declare function generateFeatureId(): string;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* GeoEditor - Advanced geometry editing control for MapLibre GL
|
|
248
|
+
* Extends the free Geoman control with advanced features
|
|
249
|
+
*/
|
|
250
|
+
export declare class GeoEditor implements IControl {
|
|
251
|
+
private map;
|
|
252
|
+
private geoman;
|
|
253
|
+
private container;
|
|
254
|
+
private options;
|
|
255
|
+
private state;
|
|
256
|
+
private copyFeature;
|
|
257
|
+
private simplifyFeature;
|
|
258
|
+
private unionFeature;
|
|
259
|
+
private differenceFeature;
|
|
260
|
+
private scaleFeature;
|
|
261
|
+
private lassoFeature;
|
|
262
|
+
private splitFeature;
|
|
263
|
+
private freehandFeature;
|
|
264
|
+
private boundKeyHandler;
|
|
265
|
+
private boundClickHandler;
|
|
266
|
+
private boundScaleMouseDown;
|
|
267
|
+
private boundScaleMouseMove;
|
|
268
|
+
private boundScaleMouseUp;
|
|
269
|
+
private isSelectMode;
|
|
270
|
+
private pendingOperation;
|
|
271
|
+
private snappingEnabled;
|
|
272
|
+
private lastCreatedFeature;
|
|
273
|
+
private lastEditedFeature;
|
|
274
|
+
private lastDeletedFeature;
|
|
275
|
+
private lastDeletedFeatureId;
|
|
276
|
+
private isScaling;
|
|
277
|
+
private scaleTargetFeature;
|
|
278
|
+
private scaleTargetGeomanData;
|
|
279
|
+
private scaleStartFeature;
|
|
280
|
+
private scaleDragPanEnabled;
|
|
281
|
+
private isMultiDragging;
|
|
282
|
+
private multiDragStartPoint;
|
|
283
|
+
private multiDragOriginalFeatures;
|
|
284
|
+
private multiDragGeomanData;
|
|
285
|
+
private multiDragPanEnabled;
|
|
286
|
+
private boundMultiDragMouseDown;
|
|
287
|
+
private boundMultiDragMouseMove;
|
|
288
|
+
private boundMultiDragMouseUp;
|
|
289
|
+
private toolbar;
|
|
290
|
+
private fileInput;
|
|
291
|
+
private propertiesPopup;
|
|
292
|
+
constructor(options?: GeoEditorOptions);
|
|
293
|
+
/**
|
|
294
|
+
* Called when the control is added to the map
|
|
295
|
+
*/
|
|
296
|
+
onAdd(map: Map_2): HTMLElement;
|
|
297
|
+
/**
|
|
298
|
+
* Called when the control is removed from the map
|
|
299
|
+
*/
|
|
300
|
+
onRemove(): void;
|
|
301
|
+
/**
|
|
302
|
+
* Set the Geoman instance for integration
|
|
303
|
+
*/
|
|
304
|
+
setGeoman(geoman: GeomanInstance): void;
|
|
305
|
+
/**
|
|
306
|
+
* Hide the geoman control toolbar
|
|
307
|
+
*/
|
|
308
|
+
private hideGeomanControl;
|
|
309
|
+
/**
|
|
310
|
+
* Setup click handler for feature selection
|
|
311
|
+
*/
|
|
312
|
+
private setupSelectionHandler;
|
|
313
|
+
/**
|
|
314
|
+
* Find a feature at a given point
|
|
315
|
+
*/
|
|
316
|
+
private findFeatureAtPoint;
|
|
317
|
+
/**
|
|
318
|
+
* Find a feature at the mouse event using Geoman's hit test
|
|
319
|
+
*/
|
|
320
|
+
private findFeatureByMouseEvent;
|
|
321
|
+
/**
|
|
322
|
+
* Find geoman data for a feature by searching
|
|
323
|
+
*/
|
|
324
|
+
private findGeomanDataForFeature;
|
|
325
|
+
private getGeomanIdFromFeature;
|
|
326
|
+
private getGeomanFeature;
|
|
327
|
+
/**
|
|
328
|
+
* Remove selection handler
|
|
329
|
+
*/
|
|
330
|
+
private removeSelectionHandler;
|
|
331
|
+
/**
|
|
332
|
+
* Setup mouse handlers for scale mode
|
|
333
|
+
*/
|
|
334
|
+
private setupScaleHandler;
|
|
335
|
+
/**
|
|
336
|
+
* Remove scale handlers
|
|
337
|
+
*/
|
|
338
|
+
private removeScaleHandler;
|
|
339
|
+
/**
|
|
340
|
+
* Setup mouse handlers for multi-drag when multiple features are selected
|
|
341
|
+
*/
|
|
342
|
+
private setupMultiDragHandler;
|
|
343
|
+
private removeMultiDragHandler;
|
|
344
|
+
private disableMultiDragPan;
|
|
345
|
+
private restoreMultiDragPan;
|
|
346
|
+
private getScaleHandleFromEvent;
|
|
347
|
+
private disableScaleDragPan;
|
|
348
|
+
private restoreScaleDragPan;
|
|
349
|
+
private applyScaledFeature;
|
|
350
|
+
private bringScaleHandlesToFront;
|
|
351
|
+
private logSelectedFeatureCollection;
|
|
352
|
+
private extractFeatureFromEvent;
|
|
353
|
+
/**
|
|
354
|
+
* Toggle feature in selection
|
|
355
|
+
*/
|
|
356
|
+
private toggleFeatureSelection;
|
|
357
|
+
/**
|
|
358
|
+
* Enable select mode
|
|
359
|
+
*/
|
|
360
|
+
enableSelectMode(): void;
|
|
361
|
+
/**
|
|
362
|
+
* Disable select mode
|
|
363
|
+
*/
|
|
364
|
+
disableSelectMode(): void;
|
|
365
|
+
/**
|
|
366
|
+
* Get the current state
|
|
367
|
+
*/
|
|
368
|
+
getState(): GeoEditorState;
|
|
369
|
+
/**
|
|
370
|
+
* Get selected features
|
|
371
|
+
*/
|
|
372
|
+
getSelectedFeatures(): Feature[];
|
|
373
|
+
getSelectedFeatureCollection(): FeatureCollection;
|
|
374
|
+
/**
|
|
375
|
+
* Get all features from the map
|
|
376
|
+
*/
|
|
377
|
+
getFeatures(): FeatureCollection;
|
|
378
|
+
getAllFeatureCollection(): FeatureCollection;
|
|
379
|
+
getLastCreatedFeature(): Feature | null;
|
|
380
|
+
getLastEditedFeature(): Feature | null;
|
|
381
|
+
getLastDeletedFeature(): Feature | null;
|
|
382
|
+
getLastDeletedFeatureId(): string | null;
|
|
383
|
+
/**
|
|
384
|
+
* Enable a draw mode
|
|
385
|
+
*/
|
|
386
|
+
enableDrawMode(mode: DrawMode): void;
|
|
387
|
+
/**
|
|
388
|
+
* Enable freehand drawing mode (custom implementation)
|
|
389
|
+
*/
|
|
390
|
+
private enableFreehandMode;
|
|
391
|
+
/**
|
|
392
|
+
* Disable freehand drawing mode
|
|
393
|
+
*/
|
|
394
|
+
private disableFreehandMode;
|
|
395
|
+
/**
|
|
396
|
+
* Enable an edit mode
|
|
397
|
+
*/
|
|
398
|
+
enableEditMode(mode: EditMode): void;
|
|
399
|
+
/**
|
|
400
|
+
* Disable all modes
|
|
401
|
+
*/
|
|
402
|
+
disableAllModes(): void;
|
|
403
|
+
/**
|
|
404
|
+
* Enable an advanced edit mode
|
|
405
|
+
*/
|
|
406
|
+
private enableAdvancedEditMode;
|
|
407
|
+
/**
|
|
408
|
+
* Enable union mode (interactive polygon selection)
|
|
409
|
+
*/
|
|
410
|
+
private enableUnionMode;
|
|
411
|
+
/**
|
|
412
|
+
* Enable difference mode (interactive polygon selection)
|
|
413
|
+
*/
|
|
414
|
+
private enableDifferenceMode;
|
|
415
|
+
/**
|
|
416
|
+
* Execute the pending operation (union/difference)
|
|
417
|
+
*/
|
|
418
|
+
executePendingOperation(): void;
|
|
419
|
+
/**
|
|
420
|
+
* Cancel pending operation
|
|
421
|
+
*/
|
|
422
|
+
cancelPendingOperation(): void;
|
|
423
|
+
/**
|
|
424
|
+
* Setup selection highlight layer
|
|
425
|
+
*/
|
|
426
|
+
private setupSelectionHighlight;
|
|
427
|
+
/**
|
|
428
|
+
* Update selection highlight on the map
|
|
429
|
+
*/
|
|
430
|
+
private updateSelectionHighlight;
|
|
431
|
+
/**
|
|
432
|
+
* Select features
|
|
433
|
+
*/
|
|
434
|
+
selectFeatures(features: Feature[], geomanDataList?: GeomanFeatureData[]): void;
|
|
435
|
+
/**
|
|
436
|
+
* Add feature to selection
|
|
437
|
+
*/
|
|
438
|
+
addToSelection(feature: Feature, geomanData?: GeomanFeatureData): void;
|
|
439
|
+
/**
|
|
440
|
+
* Remove feature from selection
|
|
441
|
+
*/
|
|
442
|
+
removeFromSelection(featureId: string): void;
|
|
443
|
+
/**
|
|
444
|
+
* Clear selection
|
|
445
|
+
*/
|
|
446
|
+
clearSelection(): void;
|
|
447
|
+
/**
|
|
448
|
+
* Show popup with feature properties
|
|
449
|
+
*/
|
|
450
|
+
private showFeaturePropertiesPopup;
|
|
451
|
+
/**
|
|
452
|
+
* Hide feature properties popup
|
|
453
|
+
*/
|
|
454
|
+
private hideFeaturePropertiesPopup;
|
|
455
|
+
/**
|
|
456
|
+
* Format feature properties as HTML table
|
|
457
|
+
*/
|
|
458
|
+
private formatPropertiesHtml;
|
|
459
|
+
/**
|
|
460
|
+
* Escape HTML special characters
|
|
461
|
+
*/
|
|
462
|
+
private escapeHtml;
|
|
463
|
+
/**
|
|
464
|
+
* Enable scale mode
|
|
465
|
+
*/
|
|
466
|
+
private enableScaleMode;
|
|
467
|
+
/**
|
|
468
|
+
* Enable copy mode
|
|
469
|
+
*/
|
|
470
|
+
private enableCopyMode;
|
|
471
|
+
/**
|
|
472
|
+
* Enable split mode
|
|
473
|
+
*/
|
|
474
|
+
private enableSplitMode;
|
|
475
|
+
/**
|
|
476
|
+
* Enable lasso selection mode
|
|
477
|
+
*/
|
|
478
|
+
private enableLassoMode;
|
|
479
|
+
/**
|
|
480
|
+
* Execute union on selected polygons
|
|
481
|
+
*/
|
|
482
|
+
private executeUnion;
|
|
483
|
+
/**
|
|
484
|
+
* Execute difference on selected polygons
|
|
485
|
+
*/
|
|
486
|
+
private executeDifference;
|
|
487
|
+
/**
|
|
488
|
+
* Execute simplify on selected features
|
|
489
|
+
*/
|
|
490
|
+
private executeSimplify;
|
|
491
|
+
private getSimplifyResult;
|
|
492
|
+
/**
|
|
493
|
+
* Copy selected features to clipboard
|
|
494
|
+
*/
|
|
495
|
+
copySelectedFeatures(): void;
|
|
496
|
+
/**
|
|
497
|
+
* Paste features from clipboard
|
|
498
|
+
*/
|
|
499
|
+
pasteFeatures(): void;
|
|
500
|
+
/**
|
|
501
|
+
* Delete a feature by ID
|
|
502
|
+
*/
|
|
503
|
+
private deleteFeatureById;
|
|
504
|
+
/**
|
|
505
|
+
* Delete selected features
|
|
506
|
+
*/
|
|
507
|
+
deleteSelectedFeatures(): void;
|
|
508
|
+
private deleteGeomanFeatureData;
|
|
509
|
+
private deleteGeomanFeatures;
|
|
510
|
+
private clearGeomanTemporaryFeatures;
|
|
511
|
+
private handleSplitResult;
|
|
512
|
+
private handleUnionResult;
|
|
513
|
+
private handleDifferenceResult;
|
|
514
|
+
private applySimplifyResult;
|
|
515
|
+
private handleLassoResult;
|
|
516
|
+
/**
|
|
517
|
+
* Create the toolbar UI
|
|
518
|
+
*/
|
|
519
|
+
private createToolbar;
|
|
520
|
+
/**
|
|
521
|
+
* Create the collapse/expand button
|
|
522
|
+
*/
|
|
523
|
+
private createCollapseButton;
|
|
524
|
+
/**
|
|
525
|
+
* Toggle toolbar collapsed state
|
|
526
|
+
*/
|
|
527
|
+
toggleCollapse(): void;
|
|
528
|
+
/**
|
|
529
|
+
* Check if toolbar is collapsed
|
|
530
|
+
*/
|
|
531
|
+
isCollapsed(): boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Set toolbar collapsed state
|
|
534
|
+
*/
|
|
535
|
+
setCollapsed(collapsed: boolean): void;
|
|
536
|
+
/**
|
|
537
|
+
* Create helper tools group (snapping toggle)
|
|
538
|
+
*/
|
|
539
|
+
private createHelperToolsGroup;
|
|
540
|
+
private createResetToolsGroup;
|
|
541
|
+
/**
|
|
542
|
+
* Create file tools group (open/save GeoJSON)
|
|
543
|
+
*/
|
|
544
|
+
private createFileToolsGroup;
|
|
545
|
+
/**
|
|
546
|
+
* Setup hidden file input for file dialog
|
|
547
|
+
*/
|
|
548
|
+
private setupFileInput;
|
|
549
|
+
/**
|
|
550
|
+
* Open file dialog to select GeoJSON file
|
|
551
|
+
*/
|
|
552
|
+
openFileDialog(): void;
|
|
553
|
+
/**
|
|
554
|
+
* Handle file selection from file dialog
|
|
555
|
+
*/
|
|
556
|
+
private handleFileSelect;
|
|
557
|
+
/**
|
|
558
|
+
* Load GeoJSON data into the editor
|
|
559
|
+
* @param geoJson - FeatureCollection or Feature to load
|
|
560
|
+
* @param filename - Optional filename for logging
|
|
561
|
+
* @returns Result of the load operation
|
|
562
|
+
*/
|
|
563
|
+
loadGeoJson(geoJson: FeatureCollection | Feature, filename?: string): GeoJsonLoadResult;
|
|
564
|
+
/**
|
|
565
|
+
* Fit the map bounds to show all features in a FeatureCollection
|
|
566
|
+
*/
|
|
567
|
+
private fitBoundsToFeatures;
|
|
568
|
+
/**
|
|
569
|
+
* Check if a bounding box is valid
|
|
570
|
+
*/
|
|
571
|
+
private isValidBBox;
|
|
572
|
+
/**
|
|
573
|
+
* Fit the map to show all current features
|
|
574
|
+
*/
|
|
575
|
+
fitToAllFeatures(): void;
|
|
576
|
+
/**
|
|
577
|
+
* Save current features as GeoJSON file download
|
|
578
|
+
* @param filename - Optional filename for download
|
|
579
|
+
* @returns Result of the save operation
|
|
580
|
+
*/
|
|
581
|
+
saveGeoJson(filename?: string): GeoJsonSaveResult;
|
|
582
|
+
/**
|
|
583
|
+
* Toggle snapping on/off (independent of other modes)
|
|
584
|
+
* Note: Snapping functionality requires Geoman Pro. In the free version,
|
|
585
|
+
* this toggle tracks state but does not enable actual vertex snapping.
|
|
586
|
+
*/
|
|
587
|
+
toggleSnapping(): void;
|
|
588
|
+
/**
|
|
589
|
+
* Check if snapping is enabled
|
|
590
|
+
*/
|
|
591
|
+
isSnappingEnabled(): boolean;
|
|
592
|
+
/**
|
|
593
|
+
* Set snapping state
|
|
594
|
+
*/
|
|
595
|
+
setSnapping(enabled: boolean): void;
|
|
596
|
+
private applySnappingState;
|
|
597
|
+
/**
|
|
598
|
+
* Create a tool group
|
|
599
|
+
*/
|
|
600
|
+
private createToolGroup;
|
|
601
|
+
/**
|
|
602
|
+
* Create a tool button
|
|
603
|
+
*/
|
|
604
|
+
private createToolButton;
|
|
605
|
+
/**
|
|
606
|
+
* Update toolbar button states
|
|
607
|
+
*/
|
|
608
|
+
private updateToolbarState;
|
|
609
|
+
/**
|
|
610
|
+
* Get human-readable label for a mode
|
|
611
|
+
*/
|
|
612
|
+
private getModeLabel;
|
|
613
|
+
/**
|
|
614
|
+
* Get SVG icon for a mode
|
|
615
|
+
*/
|
|
616
|
+
private getModeIcon;
|
|
617
|
+
private setupKeyboardShortcuts;
|
|
618
|
+
private removeKeyboardShortcuts;
|
|
619
|
+
private setupGeomanEvents;
|
|
620
|
+
private emitEvent;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export declare interface GeoEditorEventMap {
|
|
624
|
+
'gm:scale': {
|
|
625
|
+
feature: Feature;
|
|
626
|
+
scaleFactor: number;
|
|
627
|
+
};
|
|
628
|
+
'gm:scalestart': {
|
|
629
|
+
feature: Feature;
|
|
630
|
+
};
|
|
631
|
+
'gm:scaleend': {
|
|
632
|
+
feature: Feature;
|
|
633
|
+
scaleFactor: number;
|
|
634
|
+
};
|
|
635
|
+
'gm:copy': {
|
|
636
|
+
features: Feature[];
|
|
637
|
+
};
|
|
638
|
+
'gm:paste': {
|
|
639
|
+
features: Feature[];
|
|
640
|
+
};
|
|
641
|
+
'gm:split': SplitResult;
|
|
642
|
+
'gm:union': UnionResult;
|
|
643
|
+
'gm:difference': DifferenceResult;
|
|
644
|
+
'gm:simplify': SimplifyResult;
|
|
645
|
+
'gm:lassostart': Record<string, never>;
|
|
646
|
+
'gm:lassoend': LassoResult;
|
|
647
|
+
'gm:selectionchange': {
|
|
648
|
+
features: Feature[];
|
|
649
|
+
};
|
|
650
|
+
'gm:modechange': {
|
|
651
|
+
mode: DrawMode | EditMode | null;
|
|
652
|
+
};
|
|
653
|
+
'gm:geojsonload': GeoJsonLoadResult;
|
|
654
|
+
'gm:geojsonsave': GeoJsonSaveResult;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export declare type GeoEditorEventType = keyof GeoEditorEventMap;
|
|
658
|
+
|
|
659
|
+
export declare interface GeoEditorOptions {
|
|
660
|
+
/** Position of the control on the map */
|
|
661
|
+
position?: ToolbarPosition;
|
|
662
|
+
/** Whether the toolbar starts collapsed */
|
|
663
|
+
collapsed?: boolean;
|
|
664
|
+
/** Draw modes to enable */
|
|
665
|
+
drawModes?: DrawMode[];
|
|
666
|
+
/** Edit modes to enable */
|
|
667
|
+
editModes?: EditMode[];
|
|
668
|
+
/** Helper modes to enable */
|
|
669
|
+
helperModes?: HelperMode[];
|
|
670
|
+
/** Toolbar orientation */
|
|
671
|
+
toolbarOrientation?: ToolbarOrientation;
|
|
672
|
+
/** Show text labels on toolbar buttons */
|
|
673
|
+
showLabels?: boolean;
|
|
674
|
+
/** Default tolerance for line simplification */
|
|
675
|
+
simplifyTolerance?: number;
|
|
676
|
+
/** Enable snapping by default */
|
|
677
|
+
snappingEnabled?: boolean;
|
|
678
|
+
/** Enable measurements by default */
|
|
679
|
+
measurementsEnabled?: boolean;
|
|
680
|
+
/** Hide the geoman control (use GeoEditor toolbar instead) */
|
|
681
|
+
hideGeomanControl?: boolean;
|
|
682
|
+
/** Callback when a feature is created */
|
|
683
|
+
onFeatureCreate?: (feature: Feature) => void;
|
|
684
|
+
/** Callback when a feature is edited */
|
|
685
|
+
onFeatureEdit?: (feature: Feature, oldFeature: Feature) => void;
|
|
686
|
+
/** Callback when a feature is deleted */
|
|
687
|
+
onFeatureDelete?: (featureId: string) => void;
|
|
688
|
+
/** Callback when selection changes */
|
|
689
|
+
onSelectionChange?: (features: Feature[]) => void;
|
|
690
|
+
/** Callback when mode changes */
|
|
691
|
+
onModeChange?: (mode: DrawMode | EditMode | null) => void;
|
|
692
|
+
/** File modes to enable (default: ['open', 'save']) */
|
|
693
|
+
fileModes?: FileMode[];
|
|
694
|
+
/** Default filename for saving GeoJSON (default: 'features.geojson') */
|
|
695
|
+
saveFilename?: string;
|
|
696
|
+
/** Callback when GeoJSON is loaded */
|
|
697
|
+
onGeoJsonLoad?: (result: GeoJsonLoadResult) => void;
|
|
698
|
+
/** Callback when GeoJSON is saved */
|
|
699
|
+
onGeoJsonSave?: (result: GeoJsonSaveResult) => void;
|
|
700
|
+
/** Show feature properties in a popup when selected (default: false) */
|
|
701
|
+
showFeatureProperties?: boolean;
|
|
702
|
+
/** Auto-fit map bounds when GeoJSON is loaded (default: true) */
|
|
703
|
+
fitBoundsOnLoad?: boolean;
|
|
704
|
+
/** Number of columns for button layout in vertical orientation (default: 1) */
|
|
705
|
+
columns?: number;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
declare type GeoEditorOptionsRequired = Required<GeoEditorOptions>;
|
|
709
|
+
|
|
710
|
+
export declare interface GeoEditorState {
|
|
711
|
+
/** Currently active draw mode */
|
|
712
|
+
activeDrawMode: DrawMode | null;
|
|
713
|
+
/** Currently active edit mode */
|
|
714
|
+
activeEditMode: EditMode | null;
|
|
715
|
+
/** Currently selected features */
|
|
716
|
+
selectedFeatures: SelectedFeature[];
|
|
717
|
+
/** Whether currently drawing */
|
|
718
|
+
isDrawing: boolean;
|
|
719
|
+
/** Whether currently editing */
|
|
720
|
+
isEditing: boolean;
|
|
721
|
+
/** Features in clipboard for copy/paste */
|
|
722
|
+
clipboard: Feature[];
|
|
723
|
+
/** Whether toolbar is collapsed */
|
|
724
|
+
collapsed: boolean;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
export declare interface GeoJsonLoadResult {
|
|
728
|
+
/** Successfully loaded features */
|
|
729
|
+
features: Feature[];
|
|
730
|
+
/** Number of features loaded */
|
|
731
|
+
count: number;
|
|
732
|
+
/** Original filename */
|
|
733
|
+
filename: string;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
export declare interface GeoJsonSaveResult {
|
|
737
|
+
/** The saved FeatureCollection */
|
|
738
|
+
featureCollection: FeatureCollection;
|
|
739
|
+
/** Number of features saved */
|
|
740
|
+
count: number;
|
|
741
|
+
/** Filename used for download */
|
|
742
|
+
filename: string;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
declare interface GeomanEventParameters {
|
|
746
|
+
type: string;
|
|
747
|
+
feature?: Feature;
|
|
748
|
+
shape?: string;
|
|
749
|
+
[key: string]: any;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
declare interface GeomanFeatureData {
|
|
753
|
+
id: string | number;
|
|
754
|
+
shape: string;
|
|
755
|
+
geoJson?: Feature;
|
|
756
|
+
getGeoJson?: () => Feature;
|
|
757
|
+
updateGeometry?: (geometry: Geometry) => void;
|
|
758
|
+
updateGeoJsonGeometry?: (geometry: Geometry) => void;
|
|
759
|
+
temporary?: boolean;
|
|
760
|
+
delete: () => void;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
export declare interface GeomanFeaturesAPI {
|
|
764
|
+
getAll: () => FeatureCollection;
|
|
765
|
+
get: (sourceName: string, featureId: string) => GeomanFeatureData | null;
|
|
766
|
+
forEach: (callback: (feature: GeomanFeatureData) => void) => void;
|
|
767
|
+
tmpForEach?: (callback: (feature: GeomanFeatureData) => void) => void;
|
|
768
|
+
has: (sourceName: string, featureId: string) => boolean;
|
|
769
|
+
delete: (featureData: GeomanFeatureData) => void;
|
|
770
|
+
deleteAll: () => void;
|
|
771
|
+
importGeoJson: (geoJson: FeatureCollection, options?: {
|
|
772
|
+
overwrite?: boolean;
|
|
773
|
+
}) => {
|
|
774
|
+
success: number;
|
|
775
|
+
failed: number;
|
|
776
|
+
};
|
|
777
|
+
importGeoJsonFeature: (feature: Feature) => GeomanFeatureData | null;
|
|
778
|
+
getFeatureByMouseEvent: (options: {
|
|
779
|
+
event: MapMouseEvent | MapTouchEvent;
|
|
780
|
+
sourceNames?: string[];
|
|
781
|
+
}) => GeomanFeatureData | null;
|
|
782
|
+
getFeaturesByScreenBounds: (options: {
|
|
783
|
+
bounds: [[number, number], [number, number]];
|
|
784
|
+
sourceNames?: string[];
|
|
785
|
+
}) => GeomanFeatureData[];
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
export declare interface GeomanInstance {
|
|
789
|
+
enableDraw: (shape: DrawMode) => void;
|
|
790
|
+
disableDraw: () => void;
|
|
791
|
+
toggleDraw: (shape: DrawMode) => void;
|
|
792
|
+
drawEnabled: (shape?: DrawMode) => boolean;
|
|
793
|
+
enableMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
|
|
794
|
+
disableMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
|
|
795
|
+
toggleMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
|
|
796
|
+
isModeEnabled: (modeType: 'draw' | 'edit' | 'helper', mode: string) => boolean;
|
|
797
|
+
enableGlobalEditMode: () => void;
|
|
798
|
+
disableGlobalEditMode: () => void;
|
|
799
|
+
toggleGlobalEditMode: () => void;
|
|
800
|
+
globalEditModeEnabled: () => boolean;
|
|
801
|
+
enableGlobalDragMode: () => void;
|
|
802
|
+
disableGlobalDragMode: () => void;
|
|
803
|
+
toggleGlobalDragMode: () => void;
|
|
804
|
+
globalDragModeEnabled: () => boolean;
|
|
805
|
+
enableGlobalRotateMode: () => void;
|
|
806
|
+
disableGlobalRotateMode: () => void;
|
|
807
|
+
toggleGlobalRotateMode: () => void;
|
|
808
|
+
globalRotateModeEnabled: () => boolean;
|
|
809
|
+
enableGlobalCutMode: () => void;
|
|
810
|
+
disableGlobalCutMode: () => void;
|
|
811
|
+
toggleGlobalCutMode: () => void;
|
|
812
|
+
globalCutModeEnabled: () => boolean;
|
|
813
|
+
enableGlobalRemovalMode: () => void;
|
|
814
|
+
disableGlobalRemovalMode: () => void;
|
|
815
|
+
toggleGlobalRemovalMode: () => void;
|
|
816
|
+
globalRemovalModeEnabled: () => boolean;
|
|
817
|
+
disableAllModes: () => void;
|
|
818
|
+
addControls: (controlsElement?: HTMLElement) => Promise<void>;
|
|
819
|
+
removeControls: () => void;
|
|
820
|
+
setGlobalEventsListener: (callback?: (parameters: GeomanEventParameters) => void) => void;
|
|
821
|
+
features: GeomanFeaturesAPI;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Get bounding box of a feature
|
|
826
|
+
*/
|
|
827
|
+
export declare function getBBox(feature: Feature): [number, number, number, number];
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Get the bounding box center of a feature
|
|
831
|
+
*/
|
|
832
|
+
export declare function getBBoxCenter(feature: Feature): Position;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Get the bounding box corners as coordinates
|
|
836
|
+
*/
|
|
837
|
+
export declare function getBBoxCorners(feature: Feature): Position[];
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Get the midpoints of the bounding box edges
|
|
841
|
+
*/
|
|
842
|
+
export declare function getBBoxMidpoints(feature: Feature): Position[];
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Get the center point of a feature
|
|
846
|
+
*/
|
|
847
|
+
export declare function getCenter(feature: Feature): Position;
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Get all coordinates from a feature
|
|
851
|
+
*/
|
|
852
|
+
export declare function getCoordAll(feature: Feature): Position[];
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Get the feature ID, generating one if it doesn't exist
|
|
856
|
+
*/
|
|
857
|
+
export declare function getFeatureId(feature: Feature): string;
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Get only polygon features from a collection
|
|
861
|
+
*/
|
|
862
|
+
export declare function getPolygonFeatures(features: Feature[]): Feature<Polygon>[];
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Get vertex count of a feature
|
|
866
|
+
*/
|
|
867
|
+
export declare function getVertexCount(feature: Feature): number;
|
|
868
|
+
|
|
869
|
+
export declare type HelperMode = 'snapping' | 'measurements';
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Check if two features intersect
|
|
873
|
+
*/
|
|
874
|
+
export declare function intersects(feature1: Feature, feature2: Feature): boolean;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Check if a feature is in the selection
|
|
878
|
+
*/
|
|
879
|
+
export declare function isFeatureSelected(feature: Feature, selection: SelectedFeature[]): boolean;
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Check if a feature is a line
|
|
883
|
+
*/
|
|
884
|
+
export declare function isLine(feature: Feature): feature is Feature<LineString>;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Check if a feature is a point
|
|
888
|
+
*/
|
|
889
|
+
export declare function isPoint(feature: Feature): feature is Feature<Point>;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Check if a feature is a polygon
|
|
893
|
+
*/
|
|
894
|
+
export declare function isPolygon(feature: Feature): feature is Feature<Polygon>;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Check if selection contains only polygons
|
|
898
|
+
*/
|
|
899
|
+
export declare function isPolygonOnlySelection(features: Feature[]): boolean;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Check if a feature has a valid geometry
|
|
903
|
+
*/
|
|
904
|
+
export declare function isValidGeometry(feature: Feature): boolean;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Check if a feature is within another feature
|
|
908
|
+
*/
|
|
909
|
+
export declare function isWithin(feature: Feature, container: Feature): boolean;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Handles lasso selection of features
|
|
913
|
+
*/
|
|
914
|
+
export declare class LassoFeature {
|
|
915
|
+
private map;
|
|
916
|
+
private isDrawing;
|
|
917
|
+
private points;
|
|
918
|
+
private options;
|
|
919
|
+
private onCompleteCallback;
|
|
920
|
+
private dragPanEnabled;
|
|
921
|
+
private boxZoomEnabled;
|
|
922
|
+
private doubleClickZoomEnabled;
|
|
923
|
+
private handleMouseDown;
|
|
924
|
+
private handleMouseMove;
|
|
925
|
+
private handleMouseUp;
|
|
926
|
+
constructor(options?: LassoOptions);
|
|
927
|
+
/**
|
|
928
|
+
* Initialize with map instance
|
|
929
|
+
*/
|
|
930
|
+
init(map: Map_2): void;
|
|
931
|
+
/**
|
|
932
|
+
* Enable lasso selection mode
|
|
933
|
+
*/
|
|
934
|
+
enable(onComplete?: (result: LassoResult) => void): void;
|
|
935
|
+
/**
|
|
936
|
+
* Disable lasso selection mode
|
|
937
|
+
*/
|
|
938
|
+
disable(): void;
|
|
939
|
+
/**
|
|
940
|
+
* Get features within the lasso polygon
|
|
941
|
+
*/
|
|
942
|
+
selectWithinLasso(lassoPolygon: Feature<Polygon>, features: Feature[]): Feature[];
|
|
943
|
+
/**
|
|
944
|
+
* Build polygon from drawn points
|
|
945
|
+
*/
|
|
946
|
+
buildLassoPolygon(): Feature<Polygon> | null;
|
|
947
|
+
/**
|
|
948
|
+
* Set selection mode
|
|
949
|
+
*/
|
|
950
|
+
setMode(mode: 'contains' | 'intersects'): void;
|
|
951
|
+
/**
|
|
952
|
+
* Check if lasso is currently active
|
|
953
|
+
*/
|
|
954
|
+
isActive(): boolean;
|
|
955
|
+
/**
|
|
956
|
+
* Setup map layers for lasso visualization
|
|
957
|
+
*/
|
|
958
|
+
private setupLassoLayers;
|
|
959
|
+
/**
|
|
960
|
+
* Attach mouse event listeners
|
|
961
|
+
*/
|
|
962
|
+
private attachEventListeners;
|
|
963
|
+
/**
|
|
964
|
+
* Remove event listeners
|
|
965
|
+
*/
|
|
966
|
+
private removeEventListeners;
|
|
967
|
+
/**
|
|
968
|
+
* Update the lasso visualization on the map
|
|
969
|
+
*/
|
|
970
|
+
private updateLassoVisualization;
|
|
971
|
+
/**
|
|
972
|
+
* Complete the lasso selection
|
|
973
|
+
*/
|
|
974
|
+
private completeLasso;
|
|
975
|
+
/**
|
|
976
|
+
* Clear the lasso visualization
|
|
977
|
+
*/
|
|
978
|
+
private clearLasso;
|
|
979
|
+
private disableMapInteractions;
|
|
980
|
+
private restoreMapInteractions;
|
|
981
|
+
/**
|
|
982
|
+
* Remove lasso layers from the map
|
|
983
|
+
*/
|
|
984
|
+
removeLayers(): void;
|
|
985
|
+
/**
|
|
986
|
+
* Cleanup resources
|
|
987
|
+
*/
|
|
988
|
+
destroy(): void;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
export declare interface LassoOptions {
|
|
992
|
+
/** Selection mode: 'contains' or 'intersects' */
|
|
993
|
+
mode?: 'contains' | 'intersects';
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
export declare interface LassoResult {
|
|
997
|
+
/** Features selected by the lasso */
|
|
998
|
+
selected: Feature[];
|
|
999
|
+
/** The lasso polygon used for selection */
|
|
1000
|
+
lasso: Feature<Polygon>;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Check if two polygons overlap
|
|
1005
|
+
*/
|
|
1006
|
+
export declare function overlaps(feature1: Feature<Polygon | MultiPolygon>, feature2: Feature<Polygon | MultiPolygon>): boolean;
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Convert polygon to line
|
|
1010
|
+
*/
|
|
1011
|
+
export declare function polygonToLine(polygon: Feature<Polygon | MultiPolygon>): ReturnType<typeof turf.polygonToLine>;
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Check if two positions are approximately equal
|
|
1015
|
+
*/
|
|
1016
|
+
export declare function positionsEqual(pos1: Position, pos2: Position, tolerance?: number): boolean;
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Convert radians to degrees
|
|
1020
|
+
*/
|
|
1021
|
+
export declare function radiansToDegrees(radians: number): number;
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Remove feature from selection
|
|
1025
|
+
*/
|
|
1026
|
+
export declare function removeFromSelection(selection: SelectedFeature[], featureId: string): SelectedFeature[];
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Round coordinates to a specified precision
|
|
1030
|
+
*/
|
|
1031
|
+
export declare function roundCoordinates(coordinates: Position, precision?: number): Position;
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Get centroid with fallback for invalid geometries
|
|
1035
|
+
*/
|
|
1036
|
+
export declare function safeCentroid(feature: Feature): Feature<Point>;
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Safe wrapper for turf.clone
|
|
1040
|
+
*/
|
|
1041
|
+
export declare function safeClone<T extends Feature>(feature: T): T;
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Safe wrapper for turf.difference
|
|
1045
|
+
*/
|
|
1046
|
+
export declare function safeDifference(polygon1: Feature<Polygon | MultiPolygon>, polygon2: Feature<Polygon | MultiPolygon>): Feature<Polygon | MultiPolygon> | null;
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Safe wrapper for turf.lineIntersect
|
|
1050
|
+
*/
|
|
1051
|
+
export declare function safeLineIntersect(line1: Feature<LineString>, line2: Feature<LineString>): FeatureCollection<Point>;
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Safe wrapper for turf.lineSplit
|
|
1055
|
+
*/
|
|
1056
|
+
export declare function safeLineSplit(line: Feature<LineString>, splitter: Feature<LineString>): FeatureCollection<LineString>;
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Safe wrapper for turf.transformScale
|
|
1060
|
+
*/
|
|
1061
|
+
export declare function safeScale(feature: Feature, factor: number, origin?: Position): Feature;
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Safe wrapper for turf.simplify
|
|
1065
|
+
*/
|
|
1066
|
+
export declare function safeSimplify<T extends Feature>(feature: T, options: {
|
|
1067
|
+
tolerance: number;
|
|
1068
|
+
highQuality?: boolean;
|
|
1069
|
+
}): T;
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Safe wrapper for turf.transformTranslate
|
|
1073
|
+
*/
|
|
1074
|
+
export declare function safeTranslate(feature: Feature, distance: number, direction: number): Feature;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Safe wrapper for turf.union that handles edge cases
|
|
1078
|
+
*/
|
|
1079
|
+
export declare function safeUnion(features: Feature<Polygon | MultiPolygon>[]): Feature<Polygon | MultiPolygon> | null;
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Handles interactive scaling of features
|
|
1083
|
+
*/
|
|
1084
|
+
export declare class ScaleFeature {
|
|
1085
|
+
private map;
|
|
1086
|
+
private options;
|
|
1087
|
+
private activeFeature;
|
|
1088
|
+
private originalFeature;
|
|
1089
|
+
private handles;
|
|
1090
|
+
private activeHandle;
|
|
1091
|
+
private startPoint;
|
|
1092
|
+
private onScaleCallback;
|
|
1093
|
+
constructor(options?: ScaleOptions);
|
|
1094
|
+
/**
|
|
1095
|
+
* Initialize with map instance
|
|
1096
|
+
*/
|
|
1097
|
+
init(map: Map_2): void;
|
|
1098
|
+
/**
|
|
1099
|
+
* Scale a feature by a given factor
|
|
1100
|
+
*/
|
|
1101
|
+
scale(feature: Feature, factor: number, origin?: Position): Feature;
|
|
1102
|
+
/**
|
|
1103
|
+
* Scale feature by dragging from a specific handle
|
|
1104
|
+
*/
|
|
1105
|
+
scaleFromHandle(feature: Feature, handlePosition: ScaleHandlePosition, startPoint: Position, currentPoint: Position): Feature;
|
|
1106
|
+
/**
|
|
1107
|
+
* Create scale handles for a feature
|
|
1108
|
+
*/
|
|
1109
|
+
createHandles(feature: Feature): ScaleHandle[];
|
|
1110
|
+
/**
|
|
1111
|
+
* Start scaling operation
|
|
1112
|
+
*/
|
|
1113
|
+
startScale(feature: Feature, handlePosition: ScaleHandlePosition, startPoint: Position, onScale?: (feature: Feature, factor: number) => void): void;
|
|
1114
|
+
/**
|
|
1115
|
+
* Show scale handles without starting a drag operation
|
|
1116
|
+
*/
|
|
1117
|
+
showHandlesForFeature(feature: Feature): void;
|
|
1118
|
+
/**
|
|
1119
|
+
* Update scaling during drag
|
|
1120
|
+
*/
|
|
1121
|
+
updateScale(currentPoint: Position): Feature | null;
|
|
1122
|
+
/**
|
|
1123
|
+
* End scaling operation
|
|
1124
|
+
*/
|
|
1125
|
+
endScale(): {
|
|
1126
|
+
feature: Feature;
|
|
1127
|
+
factor: number;
|
|
1128
|
+
} | null;
|
|
1129
|
+
/**
|
|
1130
|
+
* Cancel scaling operation
|
|
1131
|
+
*/
|
|
1132
|
+
cancelScale(): void;
|
|
1133
|
+
/**
|
|
1134
|
+
* Show scale handles on the map
|
|
1135
|
+
*/
|
|
1136
|
+
private showHandles;
|
|
1137
|
+
/**
|
|
1138
|
+
* Update handle positions after scaling
|
|
1139
|
+
*/
|
|
1140
|
+
private updateHandlePositions;
|
|
1141
|
+
/**
|
|
1142
|
+
* Hide scale handles from the map
|
|
1143
|
+
*/
|
|
1144
|
+
private hideHandles;
|
|
1145
|
+
/**
|
|
1146
|
+
* Calculate distance from a point to the center
|
|
1147
|
+
*/
|
|
1148
|
+
private distanceFromCenter;
|
|
1149
|
+
/**
|
|
1150
|
+
* Get the opposite corner for scaling origin
|
|
1151
|
+
*/
|
|
1152
|
+
private getOppositeCorner;
|
|
1153
|
+
/**
|
|
1154
|
+
* Get handle at a specific point
|
|
1155
|
+
*/
|
|
1156
|
+
getHandleAtPoint(point: Position, tolerance?: number): ScaleHandlePosition | null;
|
|
1157
|
+
/**
|
|
1158
|
+
* Cleanup resources
|
|
1159
|
+
*/
|
|
1160
|
+
destroy(): void;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
export declare interface ScaleHandle {
|
|
1164
|
+
position: ScaleHandlePosition;
|
|
1165
|
+
coordinates: [number, number];
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
export declare type ScaleHandlePosition = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
1169
|
+
|
|
1170
|
+
export declare interface ScaleOptions {
|
|
1171
|
+
/** Maintain aspect ratio during scaling */
|
|
1172
|
+
maintainAspectRatio?: boolean;
|
|
1173
|
+
/** Scale from center of feature */
|
|
1174
|
+
scaleFromCenter?: boolean;
|
|
1175
|
+
/** Minimum scale factor */
|
|
1176
|
+
minScale?: number;
|
|
1177
|
+
/** Maximum scale factor */
|
|
1178
|
+
maxScale?: number;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
export declare interface SelectedFeature {
|
|
1182
|
+
id: string;
|
|
1183
|
+
feature: Feature;
|
|
1184
|
+
layerId: string;
|
|
1185
|
+
/** Reference to geoman feature data for deletion */
|
|
1186
|
+
geomanData?: GeomanFeatureData;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Filter features that are within a lasso polygon
|
|
1191
|
+
*/
|
|
1192
|
+
export declare function selectFeaturesWithinLasso(features: Feature[], lasso: Feature<Polygon>, mode?: 'contains' | 'intersects'): Feature[];
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Handles line/polygon simplification using Douglas-Peucker algorithm
|
|
1196
|
+
*/
|
|
1197
|
+
export declare class SimplifyFeature {
|
|
1198
|
+
private defaultOptions;
|
|
1199
|
+
constructor(options?: Partial<SimplifyOptions>);
|
|
1200
|
+
/**
|
|
1201
|
+
* Simplify a geometry using Douglas-Peucker algorithm
|
|
1202
|
+
*/
|
|
1203
|
+
simplify<T extends Feature>(feature: T, options?: Partial<SimplifyOptions>): T;
|
|
1204
|
+
/**
|
|
1205
|
+
* Simplify and return detailed result with statistics
|
|
1206
|
+
*/
|
|
1207
|
+
simplifyWithStats(feature: Feature, options?: Partial<SimplifyOptions>): SimplifyResult;
|
|
1208
|
+
/**
|
|
1209
|
+
* Get simplification statistics without applying
|
|
1210
|
+
*/
|
|
1211
|
+
getSimplificationStats(feature: Feature, tolerance: number): {
|
|
1212
|
+
before: number;
|
|
1213
|
+
after: number;
|
|
1214
|
+
reduction: number;
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* Preview simplification at different tolerance levels
|
|
1218
|
+
*/
|
|
1219
|
+
previewTolerances(feature: Feature, tolerances: number[]): Map<number, SimplifyResult>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Get suggested tolerance values based on feature complexity
|
|
1222
|
+
*/
|
|
1223
|
+
getSuggestedTolerances(feature: Feature): number[];
|
|
1224
|
+
/**
|
|
1225
|
+
* Find optimal tolerance for a target vertex reduction
|
|
1226
|
+
*/
|
|
1227
|
+
findOptimalTolerance(feature: Feature, targetReduction: number): {
|
|
1228
|
+
tolerance: number;
|
|
1229
|
+
result: SimplifyResult;
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* Set default tolerance
|
|
1233
|
+
*/
|
|
1234
|
+
setDefaultTolerance(tolerance: number): void;
|
|
1235
|
+
/**
|
|
1236
|
+
* Get default tolerance
|
|
1237
|
+
*/
|
|
1238
|
+
getDefaultTolerance(): number;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export declare interface SimplifyOptions {
|
|
1242
|
+
/** Tolerance for simplification (in degrees) */
|
|
1243
|
+
tolerance: number;
|
|
1244
|
+
/** Use high quality simplification */
|
|
1245
|
+
highQuality?: boolean;
|
|
1246
|
+
/** Mutate original feature */
|
|
1247
|
+
mutate?: boolean;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
export declare interface SimplifyResult {
|
|
1251
|
+
/** Simplified feature */
|
|
1252
|
+
result: Feature;
|
|
1253
|
+
/** Original feature */
|
|
1254
|
+
original: Feature;
|
|
1255
|
+
/** Number of vertices before */
|
|
1256
|
+
verticesBefore: number;
|
|
1257
|
+
/** Number of vertices after */
|
|
1258
|
+
verticesAfter: number;
|
|
1259
|
+
/** Reduction percentage */
|
|
1260
|
+
reductionPercent: number;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Handles splitting of polygons and lines
|
|
1265
|
+
*/
|
|
1266
|
+
export declare class SplitFeature {
|
|
1267
|
+
private map;
|
|
1268
|
+
private isDrawing;
|
|
1269
|
+
private splitLinePoints;
|
|
1270
|
+
private targetFeature;
|
|
1271
|
+
private onCompleteCallback;
|
|
1272
|
+
private handleClick;
|
|
1273
|
+
private handleMouseMove;
|
|
1274
|
+
private handleDblClick;
|
|
1275
|
+
constructor();
|
|
1276
|
+
/**
|
|
1277
|
+
* Initialize with map instance
|
|
1278
|
+
*/
|
|
1279
|
+
init(map: Map_2): void;
|
|
1280
|
+
/**
|
|
1281
|
+
* Split a polygon with a line
|
|
1282
|
+
*/
|
|
1283
|
+
splitPolygon(polygon: Feature<Polygon>, splitter: Feature<LineString>, _options?: SplitOptions): SplitResult;
|
|
1284
|
+
/**
|
|
1285
|
+
* Split a line with a point or another line
|
|
1286
|
+
*/
|
|
1287
|
+
splitLine(line: Feature<LineString>, splitter: Feature<LineString>): SplitResult;
|
|
1288
|
+
/**
|
|
1289
|
+
* Start interactive split mode
|
|
1290
|
+
*/
|
|
1291
|
+
startSplit(feature: Feature<Polygon | LineString>, onComplete: (result: SplitResult) => void): void;
|
|
1292
|
+
/**
|
|
1293
|
+
* Cancel the split operation
|
|
1294
|
+
*/
|
|
1295
|
+
cancelSplit(): void;
|
|
1296
|
+
/**
|
|
1297
|
+
* Check if split mode is active
|
|
1298
|
+
*/
|
|
1299
|
+
isActive(): boolean;
|
|
1300
|
+
/**
|
|
1301
|
+
* Perform the actual polygon split
|
|
1302
|
+
*/
|
|
1303
|
+
private performPolygonSplit;
|
|
1304
|
+
/**
|
|
1305
|
+
* Clip a line to a bounding box
|
|
1306
|
+
*/
|
|
1307
|
+
private clipLineToBbox;
|
|
1308
|
+
/**
|
|
1309
|
+
* Setup layers for split line visualization
|
|
1310
|
+
*/
|
|
1311
|
+
private setupSplitLineLayers;
|
|
1312
|
+
/**
|
|
1313
|
+
* Attach event listeners for drawing the split line
|
|
1314
|
+
*/
|
|
1315
|
+
private attachEventListeners;
|
|
1316
|
+
/**
|
|
1317
|
+
* Remove event listeners
|
|
1318
|
+
*/
|
|
1319
|
+
private removeEventListeners;
|
|
1320
|
+
/**
|
|
1321
|
+
* Update the split line visualization
|
|
1322
|
+
*/
|
|
1323
|
+
private updateSplitLineVisualization;
|
|
1324
|
+
/**
|
|
1325
|
+
* Complete the split operation
|
|
1326
|
+
*/
|
|
1327
|
+
private completeSplit;
|
|
1328
|
+
/**
|
|
1329
|
+
* Cleanup after split operation
|
|
1330
|
+
*/
|
|
1331
|
+
private cleanup;
|
|
1332
|
+
/**
|
|
1333
|
+
* Clear the split line visualization
|
|
1334
|
+
*/
|
|
1335
|
+
private clearSplitLine;
|
|
1336
|
+
/**
|
|
1337
|
+
* Remove split line layers from the map
|
|
1338
|
+
*/
|
|
1339
|
+
removeLayers(): void;
|
|
1340
|
+
/**
|
|
1341
|
+
* Cleanup resources
|
|
1342
|
+
*/
|
|
1343
|
+
destroy(): void;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
export declare interface SplitOptions {
|
|
1347
|
+
/** Keep the original feature after splitting */
|
|
1348
|
+
keepOriginal?: boolean;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
export declare interface SplitResult {
|
|
1352
|
+
/** Original feature that was split */
|
|
1353
|
+
original: Feature<Polygon | LineString>;
|
|
1354
|
+
/** Resulting parts after splitting */
|
|
1355
|
+
parts: Feature[];
|
|
1356
|
+
/** Whether the operation was successful */
|
|
1357
|
+
success: boolean;
|
|
1358
|
+
/** Error message if operation failed */
|
|
1359
|
+
error?: string;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Toggle feature in selection
|
|
1364
|
+
*/
|
|
1365
|
+
export declare function toggleInSelection(selection: SelectedFeature[], feature: Feature, layerId?: string): SelectedFeature[];
|
|
1366
|
+
|
|
1367
|
+
export declare type ToolbarOrientation = 'vertical' | 'horizontal';
|
|
1368
|
+
|
|
1369
|
+
export declare type ToolbarPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Convert Feature array to SelectedFeature array
|
|
1373
|
+
*/
|
|
1374
|
+
export declare function toSelectedFeatures(features: Feature[], layerId?: string): SelectedFeature[];
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Handles polygon union/merge operations
|
|
1378
|
+
*/
|
|
1379
|
+
export declare class UnionFeature {
|
|
1380
|
+
/**
|
|
1381
|
+
* Merge multiple polygons into one
|
|
1382
|
+
*/
|
|
1383
|
+
union(features: Feature<Polygon | MultiPolygon>[], options?: UnionOptions): UnionResult;
|
|
1384
|
+
/**
|
|
1385
|
+
* Check if polygons can be merged
|
|
1386
|
+
*/
|
|
1387
|
+
canMerge(features: Feature<Polygon | MultiPolygon>[]): {
|
|
1388
|
+
canMerge: boolean;
|
|
1389
|
+
reason?: string;
|
|
1390
|
+
};
|
|
1391
|
+
/**
|
|
1392
|
+
* Check if any polygons overlap
|
|
1393
|
+
*/
|
|
1394
|
+
hasOverlap(features: Feature<Polygon | MultiPolygon>[]): boolean;
|
|
1395
|
+
/**
|
|
1396
|
+
* Get the combined area of all polygons
|
|
1397
|
+
*/
|
|
1398
|
+
getCombinedArea(features: Feature<Polygon | MultiPolygon>[]): number;
|
|
1399
|
+
/**
|
|
1400
|
+
* Get the area of the union result
|
|
1401
|
+
*/
|
|
1402
|
+
getUnionArea(features: Feature<Polygon | MultiPolygon>[]): number | null;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
export declare interface UnionOptions {
|
|
1406
|
+
/** Properties to use for the merged feature */
|
|
1407
|
+
properties?: GeoJsonProperties;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
export declare interface UnionResult {
|
|
1411
|
+
/** Resulting merged feature */
|
|
1412
|
+
result: Feature<Polygon | MultiPolygon> | null;
|
|
1413
|
+
/** Original features that were merged */
|
|
1414
|
+
originals: Feature<Polygon | MultiPolygon>[];
|
|
1415
|
+
/** Whether the operation was successful */
|
|
1416
|
+
success: boolean;
|
|
1417
|
+
/** Error message if operation failed */
|
|
1418
|
+
error?: string;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1
1421
|
export { }
|