terra-draw 1.3.0 → 1.4.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/common.d.ts +2 -0
- package/dist/modes/base.mode.d.ts +1 -0
- package/dist/modes/polygon/polygon.mode.d.ts +8 -0
- package/dist/modes/select/behaviors/coordinate-point.behavior.d.ts +16 -0
- package/dist/modes/select/behaviors/coordinate-point.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.d.ts +3 -1
- package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +6 -2
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +3 -1
- package/dist/modes/select/behaviors/midpoint.behavior.d.ts +4 -2
- package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +3 -1
- package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +3 -1
- package/dist/modes/select/select.mode.d.ts +4 -0
- package/dist/store/store.d.ts +2 -1
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/common.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare abstract class TerraDrawBaseDrawMode<Styling extends CustomStylin
|
|
|
42
42
|
protected setStopped(): void;
|
|
43
43
|
register(config: TerraDrawModeRegisterConfig): void;
|
|
44
44
|
validateFeature(feature: unknown): ReturnType<Validation>;
|
|
45
|
+
afterFeatureAdded(feature: GeoJSONStoreFeatures): void;
|
|
45
46
|
private performFeatureValidation;
|
|
46
47
|
protected validateModeFeature(feature: unknown, modeValidationFn: (feature: GeoJSONStoreFeatures) => ReturnType<Validation>): ReturnType<Validation>;
|
|
47
48
|
abstract start(): void;
|
|
@@ -24,6 +24,10 @@ type PolygonStyling = {
|
|
|
24
24
|
editedPointColor: HexColorStyling;
|
|
25
25
|
editedPointOutlineWidth: NumericStyling;
|
|
26
26
|
editedPointOutlineColor: HexColorStyling;
|
|
27
|
+
coordinatePointWidth: NumericStyling;
|
|
28
|
+
coordinatePointColor: HexColorStyling;
|
|
29
|
+
coordinatePointOutlineWidth: NumericStyling;
|
|
30
|
+
coordinatePointOutlineColor: HexColorStyling;
|
|
27
31
|
};
|
|
28
32
|
interface Cursors {
|
|
29
33
|
start?: Cursor;
|
|
@@ -48,6 +52,7 @@ interface TerraDrawPolygonModeOptions<T extends CustomStyling> extends BaseModeO
|
|
|
48
52
|
keyEvents?: TerraDrawPolygonModeKeyEvents | null;
|
|
49
53
|
cursors?: Cursors;
|
|
50
54
|
editable?: boolean;
|
|
55
|
+
showCoordinatePoints?: boolean;
|
|
51
56
|
}
|
|
52
57
|
export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonStyling> {
|
|
53
58
|
mode: "polygon";
|
|
@@ -56,6 +61,7 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
|
|
|
56
61
|
private keyEvents;
|
|
57
62
|
private cursors;
|
|
58
63
|
private mouseMove;
|
|
64
|
+
private showCoordinatePoints;
|
|
59
65
|
private snapping;
|
|
60
66
|
private snappedPointId;
|
|
61
67
|
private editable;
|
|
@@ -64,6 +70,7 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
|
|
|
64
70
|
private editedSnapType;
|
|
65
71
|
private editedInsertIndex;
|
|
66
72
|
private editedPointId;
|
|
73
|
+
private coordinatePoints;
|
|
67
74
|
private lineSnapping;
|
|
68
75
|
private coordinateSnapping;
|
|
69
76
|
private pixelDistance;
|
|
@@ -100,6 +107,7 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
|
|
|
100
107
|
cleanUp(): void;
|
|
101
108
|
/** @internal */
|
|
102
109
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
110
|
+
afterFeatureAdded(feature: GeoJSONStoreFeatures): void;
|
|
103
111
|
validateFeature(feature: unknown): StoreValidation;
|
|
104
112
|
}
|
|
105
113
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Point, Position } from "geojson";
|
|
2
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
+
import { FeatureId } from "../../../store/store";
|
|
4
|
+
export declare class CoordinatePointBehavior extends TerraDrawModeBehavior {
|
|
5
|
+
constructor(config: BehaviorConfig);
|
|
6
|
+
createOrUpdate(featureId: FeatureId): void;
|
|
7
|
+
deletePointsByFeatureIds(features: FeatureId[]): void;
|
|
8
|
+
getUpdated(featureId: FeatureId, updatedCoordinates: Position[]): {
|
|
9
|
+
id: FeatureId;
|
|
10
|
+
geometry: Point;
|
|
11
|
+
}[] | undefined;
|
|
12
|
+
private createPoints;
|
|
13
|
+
private setFeatureCoordinatePoints;
|
|
14
|
+
private deleteCoordinatePoints;
|
|
15
|
+
private deleteIfPresent;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,13 +4,15 @@ import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
5
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
6
6
|
import { FeatureId } from "../../../store/store";
|
|
7
|
+
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
|
|
7
8
|
export type ResizeOptions = "center" | "opposite" | "center-fixed" | "opposite-fixed";
|
|
8
9
|
export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior {
|
|
9
10
|
readonly config: BehaviorConfig;
|
|
10
11
|
private readonly pixelDistance;
|
|
11
12
|
private readonly selectionPoints;
|
|
12
13
|
private readonly midPoints;
|
|
13
|
-
|
|
14
|
+
private readonly coordinatePoints;
|
|
15
|
+
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior);
|
|
14
16
|
private minimumScale;
|
|
15
17
|
private draggedCoordinate;
|
|
16
18
|
private boundingBoxMaps;
|
|
@@ -4,16 +4,20 @@ import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
5
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
6
6
|
import { FeatureId } from "../../../store/store";
|
|
7
|
+
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
|
|
8
|
+
import { CoordinateSnappingBehavior } from "../../coordinate-snapping.behavior";
|
|
7
9
|
export declare class DragCoordinateBehavior extends TerraDrawModeBehavior {
|
|
8
10
|
readonly config: BehaviorConfig;
|
|
9
11
|
private readonly pixelDistance;
|
|
10
12
|
private readonly selectionPoints;
|
|
11
13
|
private readonly midPoints;
|
|
12
|
-
|
|
14
|
+
private readonly coordinatePoints;
|
|
15
|
+
private readonly coordinateSnapping;
|
|
16
|
+
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior, coordinateSnapping: CoordinateSnappingBehavior);
|
|
13
17
|
private draggedCoordinate;
|
|
14
18
|
private getClosestCoordinate;
|
|
15
19
|
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
|
|
16
|
-
drag(event: TerraDrawMouseEvent, allowSelfIntersection: boolean, validateFeature
|
|
20
|
+
drag(event: TerraDrawMouseEvent, allowSelfIntersection: boolean, validateFeature: Validation, snapping: boolean): boolean;
|
|
17
21
|
isDragging(): boolean;
|
|
18
22
|
startDragging(id: FeatureId, index: number): void;
|
|
19
23
|
stopDragging(): void;
|
|
@@ -4,12 +4,14 @@ import { FeatureAtPointerEventBehavior } from "./feature-at-pointer-event.behavi
|
|
|
4
4
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
5
5
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
6
6
|
import { FeatureId } from "../../../store/store";
|
|
7
|
+
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
|
|
7
8
|
export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
|
|
8
9
|
readonly config: BehaviorConfig;
|
|
9
10
|
private readonly featuresAtCursorEvent;
|
|
10
11
|
private readonly selectionPoints;
|
|
11
12
|
private readonly midPoints;
|
|
12
|
-
|
|
13
|
+
private readonly coordinatePoints;
|
|
14
|
+
constructor(config: BehaviorConfig, featuresAtCursorEvent: FeatureAtPointerEventBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior);
|
|
13
15
|
private draggedFeatureId;
|
|
14
16
|
private dragPosition;
|
|
15
17
|
startDragging(event: TerraDrawMouseEvent, id: FeatureId): void;
|
|
@@ -2,14 +2,16 @@ import { Point, Position } from "geojson";
|
|
|
2
2
|
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
3
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
4
4
|
import { FeatureId } from "../../../store/store";
|
|
5
|
+
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
|
|
5
6
|
export declare class MidPointBehavior extends TerraDrawModeBehavior {
|
|
6
7
|
readonly config: BehaviorConfig;
|
|
7
8
|
private readonly selectionPointBehavior;
|
|
8
|
-
|
|
9
|
+
private readonly coordinatePointBehavior;
|
|
10
|
+
constructor(config: BehaviorConfig, selectionPointBehavior: SelectionPointBehavior, coordinatePointBehavior: CoordinatePointBehavior);
|
|
9
11
|
private _midPoints;
|
|
10
12
|
get ids(): string[];
|
|
11
13
|
set ids(_: string[]);
|
|
12
|
-
insert(midPointId:
|
|
14
|
+
insert(featureId: FeatureId, midPointId: FeatureId, coordinatePrecision: number): void;
|
|
13
15
|
create(selectedCoords: Position[], featureId: FeatureId, coordinatePrecision: number): void;
|
|
14
16
|
delete(): void;
|
|
15
17
|
getUpdated(updatedCoordinates: Position[]): {
|
|
@@ -3,11 +3,13 @@ import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
|
3
3
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
5
|
import { FeatureId } from "../../../store/store";
|
|
6
|
+
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
|
|
6
7
|
export declare class RotateFeatureBehavior extends TerraDrawModeBehavior {
|
|
7
8
|
readonly config: BehaviorConfig;
|
|
8
9
|
private readonly selectionPoints;
|
|
9
10
|
private readonly midPoints;
|
|
10
|
-
|
|
11
|
+
private readonly coordinatePoints;
|
|
12
|
+
constructor(config: BehaviorConfig, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior);
|
|
11
13
|
private lastBearing;
|
|
12
14
|
reset(): void;
|
|
13
15
|
rotate(event: TerraDrawMouseEvent, selectedId: FeatureId, validateFeature?: Validation): false | undefined;
|
|
@@ -3,11 +3,13 @@ import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
|
3
3
|
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
4
4
|
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
5
|
import { FeatureId } from "../../../store/store";
|
|
6
|
+
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
|
|
6
7
|
export declare class ScaleFeatureBehavior extends TerraDrawModeBehavior {
|
|
7
8
|
readonly config: BehaviorConfig;
|
|
8
9
|
private readonly selectionPoints;
|
|
9
10
|
private readonly midPoints;
|
|
10
|
-
|
|
11
|
+
private readonly coordinatePoints;
|
|
12
|
+
constructor(config: BehaviorConfig, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior);
|
|
11
13
|
private lastDistance;
|
|
12
14
|
reset(): void;
|
|
13
15
|
scale(event: TerraDrawMouseEvent, selectedId: FeatureId, validateFeature?: Validation): false | undefined;
|
|
@@ -17,6 +17,7 @@ type ModeFlags = {
|
|
|
17
17
|
scaleable?: boolean;
|
|
18
18
|
selfIntersectable?: boolean;
|
|
19
19
|
coordinates?: {
|
|
20
|
+
snappable?: boolean;
|
|
20
21
|
midpoints?: boolean | {
|
|
21
22
|
draggable?: boolean;
|
|
22
23
|
};
|
|
@@ -74,6 +75,7 @@ export declare class TerraDrawSelectMode extends TerraDrawBaseSelectMode<Selecti
|
|
|
74
75
|
private validations;
|
|
75
76
|
private selectionPoints;
|
|
76
77
|
private midPoints;
|
|
78
|
+
private coordinateSnap;
|
|
77
79
|
private featuresAtMouseEvent;
|
|
78
80
|
private pixelDistance;
|
|
79
81
|
private clickBoundingBox;
|
|
@@ -82,8 +84,10 @@ export declare class TerraDrawSelectMode extends TerraDrawBaseSelectMode<Selecti
|
|
|
82
84
|
private rotateFeature;
|
|
83
85
|
private scaleFeature;
|
|
84
86
|
private dragCoordinateResizeFeature;
|
|
87
|
+
private coordinatePoints;
|
|
85
88
|
constructor(options?: TerraDrawSelectModeOptions<SelectionStyling>);
|
|
86
89
|
updateOptions(options?: TerraDrawSelectModeOptions<SelectionStyling>): void;
|
|
90
|
+
private createOrUpdateCoordinatePoint;
|
|
87
91
|
selectFeature(featureId: FeatureId): void;
|
|
88
92
|
setSelecting(): void;
|
|
89
93
|
registerBehaviors(config: BehaviorConfig): void;
|
package/dist/store/store.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class GeoJSONStore<Id extends FeatureId = FeatureId> {
|
|
|
37
37
|
private clone;
|
|
38
38
|
getId(): FeatureId;
|
|
39
39
|
has(id: FeatureId): boolean;
|
|
40
|
-
load(data: GeoJSONStoreFeatures[], featureValidation?: (feature: unknown, tracked?: boolean) => StoreValidation): StoreValidation[];
|
|
40
|
+
load(data: GeoJSONStoreFeatures[], featureValidation?: (feature: unknown, tracked?: boolean) => StoreValidation, afterFeatureAdded?: (feature: GeoJSONStoreFeatures) => void): StoreValidation[];
|
|
41
41
|
search(bbox: BBoxPolygon, filter?: (feature: GeoJSONStoreFeatures) => boolean): GeoJSONStoreFeatures[];
|
|
42
42
|
registerOnChange(onChange: StoreChangeHandler): void;
|
|
43
43
|
getGeometryCopy<T extends GeoJSONStoreGeometries>(id: FeatureId): T;
|
|
@@ -58,6 +58,7 @@ export declare class GeoJSONStore<Id extends FeatureId = FeatureId> {
|
|
|
58
58
|
delete(ids: FeatureId[]): void;
|
|
59
59
|
copy(id: FeatureId): GeoJSONStoreFeatures;
|
|
60
60
|
copyAll(): GeoJSONStoreFeatures[];
|
|
61
|
+
copyAllWhere(equals: (properties: JSONObject) => boolean): GeoJSONStoreFeatures[];
|
|
61
62
|
clear(): void;
|
|
62
63
|
size(): number;
|
|
63
64
|
}
|