ofs-object 0.1.7 → 0.1.8
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/index.d.ts +70 -1
- package/dist/ofs-object.cjs +109 -109
- package/dist/ofs-object.js +144 -72
- package/docs/API.md +15 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -363,6 +363,11 @@ export declare abstract class BaseGLAdapter implements IMapAdapter {
|
|
|
363
363
|
* is left without our handlers after destroy().
|
|
364
364
|
*/
|
|
365
365
|
protected listen(event: string, handler: (e: any) => void): void;
|
|
366
|
+
/**
|
|
367
|
+
* Data features under a map event: rendered features within 6 px, falling back to a spatial point
|
|
368
|
+
* query when nothing rendered matched. Click and double-click both use it.
|
|
369
|
+
*/
|
|
370
|
+
private featuresAtEvent;
|
|
366
371
|
protected setupMapEventListeners(): void;
|
|
367
372
|
/** undefined = not worked out yet for the current style */
|
|
368
373
|
private styleFontCache;
|
|
@@ -1219,6 +1224,16 @@ export declare interface DrawEvents {
|
|
|
1219
1224
|
'draw:otrack-change': {
|
|
1220
1225
|
enabled: boolean;
|
|
1221
1226
|
};
|
|
1227
|
+
/** Grips started editing a feature - by any route, including switching from another feature */
|
|
1228
|
+
'edit:start': {
|
|
1229
|
+
layerId: string;
|
|
1230
|
+
featureId: string | number;
|
|
1231
|
+
};
|
|
1232
|
+
/** Grips stopped editing a feature */
|
|
1233
|
+
'edit:end': {
|
|
1234
|
+
layerId: string;
|
|
1235
|
+
featureId: string | number;
|
|
1236
|
+
};
|
|
1222
1237
|
'selection:draw-complete': {
|
|
1223
1238
|
mode: 'select-box' | 'select-polygon';
|
|
1224
1239
|
selectionPolygon: Feature<Polygon>;
|
|
@@ -1684,6 +1699,9 @@ export declare interface GripHandle {
|
|
|
1684
1699
|
partIndex?: number;
|
|
1685
1700
|
}
|
|
1686
1701
|
|
|
1702
|
+
/** Decides which features Grips may edit; see OFSDrawTools.setEditFilter */
|
|
1703
|
+
export declare type GripsEditFilter = (layerId: string, featureId: string | number) => boolean;
|
|
1704
|
+
|
|
1687
1705
|
export declare interface GripsEditorEvents {
|
|
1688
1706
|
'grip:select': {
|
|
1689
1707
|
handle: GripHandle;
|
|
@@ -1701,6 +1719,16 @@ export declare interface GripsEditorEvents {
|
|
|
1701
1719
|
index: number;
|
|
1702
1720
|
};
|
|
1703
1721
|
'grip:clear': void;
|
|
1722
|
+
/** Grips started editing a feature (also when switching from one feature to another) */
|
|
1723
|
+
'edit:start': {
|
|
1724
|
+
layerId: string;
|
|
1725
|
+
featureId: string | number;
|
|
1726
|
+
};
|
|
1727
|
+
/** Grips stopped editing a feature */
|
|
1728
|
+
'edit:end': {
|
|
1729
|
+
layerId: string;
|
|
1730
|
+
featureId: string | number;
|
|
1731
|
+
};
|
|
1704
1732
|
}
|
|
1705
1733
|
|
|
1706
1734
|
/** A curve with no bend worth drawing is just a polyline and needs no metadata */
|
|
@@ -2354,6 +2382,11 @@ export declare interface MapClickEvent {
|
|
|
2354
2382
|
geometry: any;
|
|
2355
2383
|
}>;
|
|
2356
2384
|
originalEvent: MouseEvent;
|
|
2385
|
+
/**
|
|
2386
|
+
* Stop the map's own handling of this event - for a double-click, the zoom. Present on events
|
|
2387
|
+
* from the GL adapters (MapLibre / Mapbox `MapMouseEvent.preventDefault`).
|
|
2388
|
+
*/
|
|
2389
|
+
preventDefault?: () => void;
|
|
2357
2390
|
}
|
|
2358
2391
|
|
|
2359
2392
|
/**
|
|
@@ -3194,6 +3227,8 @@ export declare class OFSDrawTools extends TypedEventEmitter<DrawEvents> {
|
|
|
3194
3227
|
/** How far stored geometry may sag from the curves it samples */
|
|
3195
3228
|
private sagToleranceMeters;
|
|
3196
3229
|
private targetLayerId;
|
|
3230
|
+
/** Which features Grips may edit (null = any) - see setEditFilter */
|
|
3231
|
+
private editFilter;
|
|
3197
3232
|
private tempSourceId;
|
|
3198
3233
|
private unsubClick;
|
|
3199
3234
|
private unsubDblClick;
|
|
@@ -3208,6 +3243,7 @@ export declare class OFSDrawTools extends TypedEventEmitter<DrawEvents> {
|
|
|
3208
3243
|
private justFinishedDrag;
|
|
3209
3244
|
private handleKeyDown;
|
|
3210
3245
|
constructor(dataSource: OFSDataSource, mapAdapter: IMapAdapter);
|
|
3246
|
+
private dataUnsubscribers;
|
|
3211
3247
|
setOrtho(enabled: boolean): void;
|
|
3212
3248
|
toggleOrtho(): boolean;
|
|
3213
3249
|
/**
|
|
@@ -3437,6 +3473,28 @@ export declare class OFSDrawTools extends TypedEventEmitter<DrawEvents> {
|
|
|
3437
3473
|
* Stop interactive Grips editing
|
|
3438
3474
|
*/
|
|
3439
3475
|
stopEdit(): void;
|
|
3476
|
+
/**
|
|
3477
|
+
* Limit which features Grips may edit, e.g. only the selected features of the active layer:
|
|
3478
|
+
*
|
|
3479
|
+
* ```ts
|
|
3480
|
+
* draw.setEditFilter((layerId, id) =>
|
|
3481
|
+
* layerId === ds.getActiveLayerId() && ds.getSelectedFeatureIds(layerId).includes(id));
|
|
3482
|
+
* ```
|
|
3483
|
+
* Applies to every way into Grips: startEdit, clicking in modify mode (a rejected feature counts as
|
|
3484
|
+
* empty space), double-click to edit, the hover cursor, the `grips` command and a box selection
|
|
3485
|
+
* that lands on one feature. It limits Grips only - move, rotate, offset and the other commands
|
|
3486
|
+
* are not affected.
|
|
3487
|
+
*
|
|
3488
|
+
* An edit in progress is ended when the filter stops allowing it: when a new filter is set, and
|
|
3489
|
+
* when the selection or the active layer changes. If the filter depends on other application state,
|
|
3490
|
+
* call `stopEdit()` (or set the filter again) when that changes. `null` = any feature.
|
|
3491
|
+
*/
|
|
3492
|
+
setEditFilter(filter: ((layerId: string, featureId: string | number) => boolean) | null): void;
|
|
3493
|
+
/** End the current edit when the edit filter no longer allows it */
|
|
3494
|
+
private enforceEditFilter;
|
|
3495
|
+
private isSelected;
|
|
3496
|
+
/** Whether Grips may edit this feature under the current edit filter */
|
|
3497
|
+
canEdit(layerId: string, featureId: string | number): boolean;
|
|
3440
3498
|
/**
|
|
3441
3499
|
* Check if geometry editing is currently active
|
|
3442
3500
|
*/
|
|
@@ -3755,6 +3813,7 @@ export declare class OFSGripsEditor extends TypedEventEmitter<GripsEditorEvents>
|
|
|
3755
3813
|
private currentSnapResult;
|
|
3756
3814
|
private sourceId;
|
|
3757
3815
|
private activeFeatureId;
|
|
3816
|
+
private editFilter;
|
|
3758
3817
|
private activeLayerId;
|
|
3759
3818
|
private activeGrip;
|
|
3760
3819
|
private isDragging;
|
|
@@ -3774,7 +3833,17 @@ export declare class OFSGripsEditor extends TypedEventEmitter<GripsEditorEvents>
|
|
|
3774
3833
|
/**
|
|
3775
3834
|
* Start editing a feature's geometry with grips
|
|
3776
3835
|
*/
|
|
3777
|
-
|
|
3836
|
+
/**
|
|
3837
|
+
* Which features may be edited (null = any). Checked here, in the one method every way into
|
|
3838
|
+
* editing goes through - clicking, double-clicking, startEdit, the `grips` command, a box selection
|
|
3839
|
+
* that lands on one feature - so a new way in cannot forget it.
|
|
3840
|
+
*/
|
|
3841
|
+
setEditFilter(filter: GripsEditFilter | null): void;
|
|
3842
|
+
/**
|
|
3843
|
+
* Start editing a feature. Returns false when it cannot be edited: it does not exist, its geometry
|
|
3844
|
+
* type has no grips, or the edit filter rejects it.
|
|
3845
|
+
*/
|
|
3846
|
+
editFeature(layerId: string, featureId: string | number): boolean;
|
|
3778
3847
|
/**
|
|
3779
3848
|
* Stop editing and clear grips
|
|
3780
3849
|
*/
|