terra-draw 0.0.1-alpha.9 → 1.0.0-beta.1
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/.devcontainer/Dockerfile +8 -0
- package/.devcontainer/devcontainer.json +27 -0
- package/.devcontainer/post-create.sh +16 -0
- package/README.md +23 -13
- package/dist/adapters/arcgis-maps-sdk.adapter.d.ts +106 -0
- package/dist/adapters/google-maps.adapter.d.ts +90 -39
- package/dist/adapters/leaflet.adapter.d.ts +99 -33
- package/dist/adapters/mapbox-gl.adapter.d.ts +91 -37
- package/dist/adapters/maplibre-gl.adapter.d.ts +72 -0
- package/dist/adapters/openlayers.adapter.d.ts +120 -0
- package/dist/common.d.ts +118 -98
- package/dist/geometry/boolean/is-valid-coordinate.d.ts +4 -0
- package/dist/geometry/boolean/point-in-polygon.d.ts +2 -2
- package/dist/geometry/boolean/self-intersects.d.ts +2 -2
- package/dist/geometry/calculate-relative-angle.d.ts +17 -0
- package/dist/geometry/centroid.d.ts +2 -2
- package/dist/geometry/coordinates-identical.d.ts +2 -2
- package/dist/geometry/determine-halfplane.d.ts +10 -0
- package/dist/geometry/get-coordinates-as-points.d.ts +6 -6
- package/dist/geometry/get-midpoints.d.ts +14 -7
- package/dist/geometry/helpers.d.ts +4 -4
- package/dist/geometry/limit-decimal-precision.d.ts +1 -1
- package/dist/geometry/measure/area.d.ts +2 -0
- package/dist/geometry/measure/bearing.d.ts +9 -0
- package/dist/geometry/measure/destination.d.ts +9 -0
- package/dist/geometry/measure/haversine-distance.d.ts +2 -2
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +10 -10
- package/dist/geometry/measure/pixel-distance.d.ts +7 -7
- package/dist/geometry/measure/rhumb-bearing.d.ts +2 -2
- package/dist/geometry/measure/rhumb-destination.d.ts +2 -2
- package/dist/geometry/measure/rhumb-distance.d.ts +2 -2
- package/dist/geometry/measure/slice-along.d.ts +2 -0
- package/dist/geometry/midpoint-coordinate.d.ts +4 -2
- package/dist/geometry/project/web-mercator.d.ts +20 -0
- package/dist/geometry/shape/create-bbox.d.ts +10 -0
- package/dist/geometry/shape/create-circle.d.ts +13 -7
- package/dist/geometry/shape/great-circle-coordinates.d.ts +2 -0
- package/dist/geometry/shape/web-mercator-distortion.d.ts +2 -0
- package/dist/geometry/transform/rotate.d.ts +9 -2
- package/dist/geometry/transform/scale.d.ts +9 -2
- package/dist/geometry/web-mercator-centroid.d.ts +11 -0
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +62 -0
- package/dist/modes/base.behavior.d.ts +21 -19
- package/dist/modes/base.mode.d.ts +66 -33
- package/dist/modes/circle/circle.mode.d.ts +66 -37
- package/dist/modes/click-bounding-box.behavior.d.ts +6 -7
- package/dist/modes/freehand/freehand.mode.d.ts +63 -43
- package/dist/modes/insert-coordinates.behavior.d.ts +9 -0
- package/dist/modes/linestring/linestring.mode.d.ts +78 -47
- package/dist/modes/pixel-distance.behavior.d.ts +7 -7
- package/dist/modes/point/point.mode.d.ts +44 -26
- package/dist/modes/polygon/behaviors/closing-points.behavior.d.ts +19 -19
- package/dist/modes/polygon/polygon.mode.d.ts +69 -51
- package/dist/modes/rectangle/rectangle.mode.d.ts +55 -0
- package/dist/modes/render/render.mode.d.ts +52 -23
- package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.d.ts +62 -0
- package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +20 -13
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +20 -17
- package/dist/modes/select/behaviors/{features-at-mouse-event.behavior.d.ts → feature-at-pointer-event.behavior.d.ts} +15 -15
- package/dist/modes/select/behaviors/midpoint.behavior.d.ts +19 -18
- package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +14 -13
- package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +14 -13
- package/dist/modes/select/behaviors/selection-point.behavior.d.ts +19 -18
- package/dist/modes/select/select.mode.d.ts +119 -78
- package/dist/modes/snapping.behavior.d.ts +16 -13
- package/dist/modes/static/static.mode.d.ts +32 -30
- package/dist/store/spatial-index/quickselect.d.ts +2 -2
- package/dist/store/spatial-index/rbush.d.ts +35 -35
- package/dist/store/spatial-index/spatial-index.d.ts +18 -18
- package/dist/store/store-feature-validation.d.ts +16 -0
- package/dist/store/store.d.ts +59 -48
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +223 -48
- 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/dist/util/geoms.d.ts +3 -3
- package/dist/util/id.d.ts +1 -1
- package/dist/util/styling.d.ts +2 -2
- package/dist/validations/linestring.validation.d.ts +2 -0
- package/dist/validations/max-size.validation.d.ts +2 -0
- package/dist/validations/min-size.validation.d.ts +2 -0
- package/dist/validations/not-self-intersecting.validation.d.ts +2 -0
- package/dist/validations/point.validation.d.ts +2 -0
- package/dist/validations/polygon.validation.d.ts +3 -0
- package/e2e/README.md +29 -0
- package/e2e/package-lock.json +4274 -0
- package/e2e/package.json +26 -0
- package/e2e/playwright.config.ts +77 -0
- package/e2e/public/favicon.ico +0 -0
- package/e2e/public/index.html +53 -0
- package/e2e/tests/leaflet.spec.ts +739 -0
- package/e2e/tests/setup.ts +198 -0
- package/e2e/webpack.config.js +36 -0
- package/jest.nocheck.config.ts +17 -0
- package/package.json +158 -87
- package/readme.gif +0 -0
- package/tsconfig.json +25 -12
- package/CODE_OF_CONDUCT.md +0 -36
- package/CONTRIBUTING.md +0 -17
- package/DEVELOPMENT.md +0 -77
- package/dist/bundle.js +0 -6
- package/dist/bundle.js.LICENSE.txt +0 -4
- package/dist/geometry/create-circle.d.ts +0 -6
- package/dist/geometry/get-pixel-distance-to-line.d.ts +0 -10
- package/dist/geometry/get-pixel-distance.d.ts +0 -7
- package/dist/geometry/haversine-distance.d.ts +0 -1
- package/dist/geometry/point-in-polygon.d.ts +0 -1
- package/dist/geometry/self-intersects.d.ts +0 -2
- package/dist/modes/circle.mode.d.ts +0 -18
- package/dist/modes/freehand.mode.d.ts +0 -20
- package/dist/modes/line-string.mode.d.ts +0 -21
- package/dist/modes/point.mode.d.ts +0 -14
- package/dist/modes/polygon/behaviors/start-end-point.behavior.d.ts +0 -11
- package/dist/modes/polygon.mode.d.ts +0 -21
- package/dist/modes/select.mode.d.ts +0 -21
- package/dist/modes/static.mode.d.ts +0 -10
- package/jest.config.ts +0 -27
|
@@ -1,47 +1,78 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent,
|
|
2
|
-
import { TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
-
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
5
|
-
|
|
6
|
-
cancel: KeyboardEvent["key"];
|
|
7
|
-
finish: KeyboardEvent["key"];
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
lineStringWidth:
|
|
11
|
-
lineStringColor:
|
|
12
|
-
closingPointColor:
|
|
13
|
-
closingPointWidth:
|
|
14
|
-
closingPointOutlineColor:
|
|
15
|
-
closingPointOutlineWidth:
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
|
+
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
+
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
+
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
5
|
+
type TerraDrawLineStringModeKeyEvents = {
|
|
6
|
+
cancel: KeyboardEvent["key"] | null;
|
|
7
|
+
finish: KeyboardEvent["key"] | null;
|
|
8
|
+
};
|
|
9
|
+
type LineStringStyling = {
|
|
10
|
+
lineStringWidth: NumericStyling;
|
|
11
|
+
lineStringColor: HexColorStyling;
|
|
12
|
+
closingPointColor: HexColorStyling;
|
|
13
|
+
closingPointWidth: NumericStyling;
|
|
14
|
+
closingPointOutlineColor: HexColorStyling;
|
|
15
|
+
closingPointOutlineWidth: NumericStyling;
|
|
16
|
+
};
|
|
17
|
+
interface Cursors {
|
|
18
|
+
start?: Cursor;
|
|
19
|
+
close?: Cursor;
|
|
20
|
+
}
|
|
21
|
+
interface InertCoordinates {
|
|
22
|
+
strategy: "amount";
|
|
23
|
+
value: number;
|
|
24
|
+
}
|
|
25
|
+
interface TerraDrawLineStringModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
26
|
+
snapping?: boolean;
|
|
27
|
+
pointerDistance?: number;
|
|
28
|
+
keyEvents?: TerraDrawLineStringModeKeyEvents | null;
|
|
29
|
+
cursors?: Cursors;
|
|
30
|
+
insertCoordinates?: InertCoordinates;
|
|
31
|
+
}
|
|
32
|
+
export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineStringStyling> {
|
|
33
|
+
mode: string;
|
|
34
|
+
private currentCoordinate;
|
|
35
|
+
private currentId;
|
|
36
|
+
private closingPointId;
|
|
37
|
+
private keyEvents;
|
|
38
|
+
private snappingEnabled;
|
|
39
|
+
private cursors;
|
|
40
|
+
private mouseMove;
|
|
41
|
+
private insertCoordinates;
|
|
42
|
+
private lastCommitedCoordinates;
|
|
43
|
+
private snapping;
|
|
44
|
+
private insertPoint;
|
|
45
|
+
constructor(options?: TerraDrawLineStringModeOptions<LineStringStyling>);
|
|
46
|
+
private close;
|
|
47
|
+
private updateGeometries;
|
|
48
|
+
private generateInsertCoordinates;
|
|
49
|
+
private createLine;
|
|
50
|
+
private firstUpdateToLine;
|
|
51
|
+
private updateToLine;
|
|
52
|
+
/** @internal */
|
|
53
|
+
registerBehaviors(config: BehaviorConfig): void;
|
|
54
|
+
/** @internal */
|
|
55
|
+
start(): void;
|
|
56
|
+
/** @internal */
|
|
57
|
+
stop(): void;
|
|
58
|
+
/** @internal */
|
|
59
|
+
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
60
|
+
/** @internal */
|
|
61
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
62
|
+
/** @internal */
|
|
63
|
+
onKeyDown(): void;
|
|
64
|
+
/** @internal */
|
|
65
|
+
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
66
|
+
/** @internal */
|
|
67
|
+
onDragStart(): void;
|
|
68
|
+
/** @internal */
|
|
69
|
+
onDrag(): void;
|
|
70
|
+
/** @internal */
|
|
71
|
+
onDragEnd(): void;
|
|
72
|
+
/** @internal */
|
|
73
|
+
cleanUp(): void;
|
|
74
|
+
/** @internal */
|
|
75
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
76
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
-
import { TerraDrawMouseEvent } from "../common";
|
|
3
|
-
import { Position } from "geojson";
|
|
4
|
-
export declare class PixelDistanceBehavior extends TerraDrawModeBehavior {
|
|
5
|
-
constructor(config: BehaviorConfig);
|
|
6
|
-
measure(clickEvent: TerraDrawMouseEvent, secondCoordinate: Position): number;
|
|
7
|
-
}
|
|
1
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
+
import { TerraDrawMouseEvent } from "../common";
|
|
3
|
+
import { Position } from "geojson";
|
|
4
|
+
export declare class PixelDistanceBehavior extends TerraDrawModeBehavior {
|
|
5
|
+
constructor(config: BehaviorConfig);
|
|
6
|
+
measure(clickEvent: TerraDrawMouseEvent, secondCoordinate: Position): number;
|
|
7
|
+
}
|
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling,
|
|
2
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
-
import { TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
-
|
|
5
|
-
pointWidth:
|
|
6
|
-
pointColor:
|
|
7
|
-
pointOutlineColor:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, NumericStyling, HexColorStyling, Cursor } from "../../common";
|
|
2
|
+
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
+
type PointModeStyling = {
|
|
5
|
+
pointWidth: NumericStyling;
|
|
6
|
+
pointColor: HexColorStyling;
|
|
7
|
+
pointOutlineColor: HexColorStyling;
|
|
8
|
+
pointOutlineWidth: NumericStyling;
|
|
9
|
+
};
|
|
10
|
+
interface Cursors {
|
|
11
|
+
create?: Cursor;
|
|
12
|
+
}
|
|
13
|
+
interface TerraDrawPointModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
14
|
+
cursors?: Cursors;
|
|
15
|
+
}
|
|
16
|
+
export declare class TerraDrawPointMode extends TerraDrawBaseDrawMode<PointModeStyling> {
|
|
17
|
+
mode: string;
|
|
18
|
+
private cursors;
|
|
19
|
+
constructor(options?: TerraDrawPointModeOptions<PointModeStyling>);
|
|
20
|
+
/** @internal */
|
|
21
|
+
start(): void;
|
|
22
|
+
/** @internal */
|
|
23
|
+
stop(): void;
|
|
24
|
+
/** @internal */
|
|
25
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
26
|
+
/** @internal */
|
|
27
|
+
onMouseMove(): void;
|
|
28
|
+
/** @internal */
|
|
29
|
+
onKeyDown(): void;
|
|
30
|
+
/** @internal */
|
|
31
|
+
onKeyUp(): void;
|
|
32
|
+
/** @internal */
|
|
33
|
+
cleanUp(): void;
|
|
34
|
+
/** @internal */
|
|
35
|
+
onDragStart(): void;
|
|
36
|
+
/** @internal */
|
|
37
|
+
onDrag(): void;
|
|
38
|
+
/** @internal */
|
|
39
|
+
onDragEnd(): void;
|
|
40
|
+
/** @internal */
|
|
41
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
42
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Position } from "geojson";
|
|
2
|
-
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
-
import { TerraDrawMouseEvent } from "../../../common";
|
|
4
|
-
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
5
|
-
export declare class ClosingPointsBehavior extends TerraDrawModeBehavior {
|
|
6
|
-
readonly config: BehaviorConfig;
|
|
7
|
-
private readonly pixelDistance;
|
|
8
|
-
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior);
|
|
9
|
-
private _startEndPoints;
|
|
10
|
-
get ids(): string[];
|
|
11
|
-
set ids(_: string[]);
|
|
12
|
-
create(selectedCoords: Position[], mode: string): void;
|
|
13
|
-
delete(): void;
|
|
14
|
-
update(updatedCoordinates: Position[]): void;
|
|
15
|
-
isClosingPoint(event: TerraDrawMouseEvent): {
|
|
16
|
-
isClosing: boolean;
|
|
17
|
-
isPreviousClosing: boolean;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
1
|
+
import { Position } from "geojson";
|
|
2
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
+
import { TerraDrawMouseEvent } from "../../../common";
|
|
4
|
+
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
5
|
+
export declare class ClosingPointsBehavior extends TerraDrawModeBehavior {
|
|
6
|
+
readonly config: BehaviorConfig;
|
|
7
|
+
private readonly pixelDistance;
|
|
8
|
+
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior);
|
|
9
|
+
private _startEndPoints;
|
|
10
|
+
get ids(): string[];
|
|
11
|
+
set ids(_: string[]);
|
|
12
|
+
create(selectedCoords: Position[], mode: string): void;
|
|
13
|
+
delete(): void;
|
|
14
|
+
update(updatedCoordinates: Position[]): void;
|
|
15
|
+
isClosingPoint(event: TerraDrawMouseEvent): {
|
|
16
|
+
isClosing: boolean;
|
|
17
|
+
isPreviousClosing: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,51 +1,69 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent,
|
|
2
|
-
import { TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
-
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
5
|
-
|
|
6
|
-
cancel
|
|
7
|
-
finish
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
fillColor:
|
|
11
|
-
outlineColor:
|
|
12
|
-
outlineWidth:
|
|
13
|
-
fillOpacity:
|
|
14
|
-
closingPointWidth:
|
|
15
|
-
closingPointColor:
|
|
16
|
-
closingPointOutlineWidth:
|
|
17
|
-
closingPointOutlineColor:
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
|
+
import { TerraDrawBaseDrawMode, BaseModeOptions, CustomStyling } from "../base.mode";
|
|
3
|
+
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
+
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
5
|
+
type TerraDrawPolygonModeKeyEvents = {
|
|
6
|
+
cancel?: KeyboardEvent["key"] | null;
|
|
7
|
+
finish?: KeyboardEvent["key"] | null;
|
|
8
|
+
};
|
|
9
|
+
type PolygonStyling = {
|
|
10
|
+
fillColor: HexColorStyling;
|
|
11
|
+
outlineColor: HexColorStyling;
|
|
12
|
+
outlineWidth: NumericStyling;
|
|
13
|
+
fillOpacity: NumericStyling;
|
|
14
|
+
closingPointWidth: NumericStyling;
|
|
15
|
+
closingPointColor: HexColorStyling;
|
|
16
|
+
closingPointOutlineWidth: NumericStyling;
|
|
17
|
+
closingPointOutlineColor: HexColorStyling;
|
|
18
|
+
};
|
|
19
|
+
interface Cursors {
|
|
20
|
+
start?: Cursor;
|
|
21
|
+
close?: Cursor;
|
|
22
|
+
}
|
|
23
|
+
interface TerraDrawPolygonModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
24
|
+
snapping?: boolean;
|
|
25
|
+
pointerDistance?: number;
|
|
26
|
+
keyEvents?: TerraDrawPolygonModeKeyEvents | null;
|
|
27
|
+
cursors?: Cursors;
|
|
28
|
+
}
|
|
29
|
+
export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonStyling> {
|
|
30
|
+
mode: string;
|
|
31
|
+
private currentCoordinate;
|
|
32
|
+
private currentId;
|
|
33
|
+
private keyEvents;
|
|
34
|
+
private snappingEnabled;
|
|
35
|
+
private snapping;
|
|
36
|
+
private pixelDistance;
|
|
37
|
+
private closingPoints;
|
|
38
|
+
private cursors;
|
|
39
|
+
private mouseMove;
|
|
40
|
+
constructor(options?: TerraDrawPolygonModeOptions<PolygonStyling>);
|
|
41
|
+
private close;
|
|
42
|
+
/** @internal */
|
|
43
|
+
registerBehaviors(config: BehaviorConfig): void;
|
|
44
|
+
/** @internal */
|
|
45
|
+
start(): void;
|
|
46
|
+
/** @internal */
|
|
47
|
+
stop(): void;
|
|
48
|
+
/** @internal */
|
|
49
|
+
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
50
|
+
private updatePolygonGeometry;
|
|
51
|
+
/** @internal */
|
|
52
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
53
|
+
/** @internal */
|
|
54
|
+
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
55
|
+
/** @internal */
|
|
56
|
+
onKeyDown(): void;
|
|
57
|
+
/** @internal */
|
|
58
|
+
onDragStart(): void;
|
|
59
|
+
/** @internal */
|
|
60
|
+
onDrag(): void;
|
|
61
|
+
/** @internal */
|
|
62
|
+
onDragEnd(): void;
|
|
63
|
+
/** @internal */
|
|
64
|
+
cleanUp(): void;
|
|
65
|
+
/** @internal */
|
|
66
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
67
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
|
+
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
+
type TerraDrawRectangleModeKeyEvents = {
|
|
5
|
+
cancel: KeyboardEvent["key"] | null;
|
|
6
|
+
finish: KeyboardEvent["key"] | null;
|
|
7
|
+
};
|
|
8
|
+
type RectanglePolygonStyling = {
|
|
9
|
+
fillColor: HexColorStyling;
|
|
10
|
+
outlineColor: HexColorStyling;
|
|
11
|
+
outlineWidth: NumericStyling;
|
|
12
|
+
fillOpacity: NumericStyling;
|
|
13
|
+
};
|
|
14
|
+
interface Cursors {
|
|
15
|
+
start?: Cursor;
|
|
16
|
+
}
|
|
17
|
+
interface TerraDrawRectangleModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
18
|
+
keyEvents?: TerraDrawRectangleModeKeyEvents | null;
|
|
19
|
+
cursors?: Cursors;
|
|
20
|
+
}
|
|
21
|
+
export declare class TerraDrawRectangleMode extends TerraDrawBaseDrawMode<RectanglePolygonStyling> {
|
|
22
|
+
mode: string;
|
|
23
|
+
private center;
|
|
24
|
+
private clickCount;
|
|
25
|
+
private currentRectangleId;
|
|
26
|
+
private keyEvents;
|
|
27
|
+
private cursors;
|
|
28
|
+
constructor(options?: TerraDrawRectangleModeOptions<RectanglePolygonStyling>);
|
|
29
|
+
private updateRectangle;
|
|
30
|
+
private close;
|
|
31
|
+
/** @internal */
|
|
32
|
+
start(): void;
|
|
33
|
+
/** @internal */
|
|
34
|
+
stop(): void;
|
|
35
|
+
/** @internal */
|
|
36
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
37
|
+
/** @internal */
|
|
38
|
+
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
39
|
+
/** @internal */
|
|
40
|
+
onKeyDown(): void;
|
|
41
|
+
/** @internal */
|
|
42
|
+
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
43
|
+
/** @internal */
|
|
44
|
+
onDragStart(): void;
|
|
45
|
+
/** @internal */
|
|
46
|
+
onDrag(): void;
|
|
47
|
+
/** @internal */
|
|
48
|
+
onDragEnd(): void;
|
|
49
|
+
/** @internal */
|
|
50
|
+
cleanUp(): void;
|
|
51
|
+
/** @internal */
|
|
52
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
53
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -1,23 +1,52 @@
|
|
|
1
|
-
import { TerraDrawAdapterStyling } from "../../common";
|
|
2
|
-
import { TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
-
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { HexColorStyling, NumericStyling, TerraDrawAdapterStyling } from "../../common";
|
|
2
|
+
import { BaseModeOptions, CustomStyling, ModeTypes, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
+
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
+
import { GeoJSONStoreFeatures } from "../../terra-draw";
|
|
5
|
+
type RenderModeStyling = {
|
|
6
|
+
pointColor: HexColorStyling;
|
|
7
|
+
pointWidth: NumericStyling;
|
|
8
|
+
pointOutlineColor: HexColorStyling;
|
|
9
|
+
pointOutlineWidth: NumericStyling;
|
|
10
|
+
polygonFillColor: HexColorStyling;
|
|
11
|
+
polygonFillOpacity: NumericStyling;
|
|
12
|
+
polygonOutlineColor: HexColorStyling;
|
|
13
|
+
polygonOutlineWidth: NumericStyling;
|
|
14
|
+
lineStringWidth: NumericStyling;
|
|
15
|
+
lineStringColor: HexColorStyling;
|
|
16
|
+
zIndex: NumericStyling;
|
|
17
|
+
};
|
|
18
|
+
interface TerraDrawRenderModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
19
|
+
modeName: string;
|
|
20
|
+
styles: Partial<T>;
|
|
21
|
+
}
|
|
22
|
+
export declare class TerraDrawRenderMode extends TerraDrawBaseDrawMode<RenderModeStyling> {
|
|
23
|
+
type: ModeTypes;
|
|
24
|
+
mode: string;
|
|
25
|
+
constructor(options: TerraDrawRenderModeOptions<RenderModeStyling>);
|
|
26
|
+
/** @internal */
|
|
27
|
+
registerBehaviors(behaviorConfig: BehaviorConfig): void;
|
|
28
|
+
/** @internal */
|
|
29
|
+
start(): void;
|
|
30
|
+
/** @internal */
|
|
31
|
+
stop(): void;
|
|
32
|
+
/** @internal */
|
|
33
|
+
onKeyUp(): void;
|
|
34
|
+
/** @internal */
|
|
35
|
+
onKeyDown(): void;
|
|
36
|
+
/** @internal */
|
|
37
|
+
onClick(): void;
|
|
38
|
+
/** @internal */
|
|
39
|
+
onDragStart(): void;
|
|
40
|
+
/** @internal */
|
|
41
|
+
onDrag(): void;
|
|
42
|
+
/** @internal */
|
|
43
|
+
onDragEnd(): void;
|
|
44
|
+
/** @internal */
|
|
45
|
+
onMouseMove(): void;
|
|
46
|
+
/** @internal */
|
|
47
|
+
cleanUp(): void;
|
|
48
|
+
/** @internal */
|
|
49
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
50
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { TerraDrawMouseEvent, Validation } from "../../../common";
|
|
2
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
+
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
4
|
+
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
|
+
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
6
|
+
import { FeatureId } from "../../../store/store";
|
|
7
|
+
export type ResizeOptions = "center" | "opposite" | "center-fixed" | "opposite-fixed";
|
|
8
|
+
export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior {
|
|
9
|
+
readonly config: BehaviorConfig;
|
|
10
|
+
private readonly pixelDistance;
|
|
11
|
+
private readonly selectionPoints;
|
|
12
|
+
private readonly midPoints;
|
|
13
|
+
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
14
|
+
private minimumScale;
|
|
15
|
+
private draggedCoordinate;
|
|
16
|
+
private boundingBoxMaps;
|
|
17
|
+
private getClosestCoordinate;
|
|
18
|
+
private isValidDragWebMercator;
|
|
19
|
+
private getSelectedFeatureDataWebMercator;
|
|
20
|
+
private centerWebMercatorDrag;
|
|
21
|
+
private centerFixedWebMercatorDrag;
|
|
22
|
+
private scaleFixedWebMercator;
|
|
23
|
+
private oppositeFixedWebMercatorDrag;
|
|
24
|
+
private oppositeWebMercatorDrag;
|
|
25
|
+
private scaleWebMercator;
|
|
26
|
+
private getFeature;
|
|
27
|
+
private getNormalisedCoordinates;
|
|
28
|
+
private validateScale;
|
|
29
|
+
private performWebMercatorScale;
|
|
30
|
+
private getBBoxWebMercator;
|
|
31
|
+
private getIndexesWebMercator;
|
|
32
|
+
/**
|
|
33
|
+
* @returns - true if the feature is being dragged (resized), false otherwise
|
|
34
|
+
*/
|
|
35
|
+
isDragging(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Starts the resizing of the feature
|
|
38
|
+
* @param id - feature id of the feature that is being dragged
|
|
39
|
+
* @param index - index of the coordinate that is being dragged
|
|
40
|
+
* @returns - void
|
|
41
|
+
*/
|
|
42
|
+
startDragging(id: FeatureId, index: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Stops the resizing of the feature
|
|
45
|
+
* @returns - void *
|
|
46
|
+
*/
|
|
47
|
+
stopDragging(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the index of the coordinate that is going to be dragged
|
|
50
|
+
* @param event - cursor event
|
|
51
|
+
* @param selectedId - feature id of the feature that is selected
|
|
52
|
+
* @returns - the index to be dragged
|
|
53
|
+
*/
|
|
54
|
+
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
|
|
55
|
+
/**
|
|
56
|
+
* Resizes the feature based on the cursor event
|
|
57
|
+
* @param event - cursor event
|
|
58
|
+
* @param resizeOption - the resize option, either "center" or "opposite"
|
|
59
|
+
* @returns - true is resize was successful, false otherwise
|
|
60
|
+
*/
|
|
61
|
+
drag(event: TerraDrawMouseEvent, resizeOption: ResizeOptions, validateFeature?: Validation): boolean;
|
|
62
|
+
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent } from "../../../common";
|
|
2
|
-
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
-
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
4
|
-
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
|
-
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, Validation } from "../../../common";
|
|
2
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
+
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
|
|
4
|
+
import { MidPointBehavior } from "./midpoint.behavior";
|
|
5
|
+
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
6
|
+
import { FeatureId } from "../../../store/store";
|
|
7
|
+
export declare class DragCoordinateBehavior extends TerraDrawModeBehavior {
|
|
8
|
+
readonly config: BehaviorConfig;
|
|
9
|
+
private readonly pixelDistance;
|
|
10
|
+
private readonly selectionPoints;
|
|
11
|
+
private readonly midPoints;
|
|
12
|
+
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
13
|
+
private draggedCoordinate;
|
|
14
|
+
private getClosestCoordinate;
|
|
15
|
+
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
|
|
16
|
+
drag(event: TerraDrawMouseEvent, allowSelfIntersection: boolean, validateFeature?: Validation): boolean;
|
|
17
|
+
isDragging(): boolean;
|
|
18
|
+
startDragging(id: FeatureId, index: number): void;
|
|
19
|
+
stopDragging(): void;
|
|
20
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent } from "../../../common";
|
|
2
|
-
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
|
|
8
|
-
readonly config: BehaviorConfig;
|
|
9
|
-
private readonly featuresAtMouseEvent;
|
|
10
|
-
private readonly selectionPoints;
|
|
11
|
-
private readonly midPoints;
|
|
12
|
-
constructor(config: BehaviorConfig, featuresAtMouseEvent:
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, Validation } from "../../../common";
|
|
2
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
+
import { FeatureAtPointerEventBehavior } from "./feature-at-pointer-event.behavior";
|
|
4
|
+
import { SelectionPointBehavior } from "./selection-point.behavior";
|
|
5
|
+
import { MidPointBehavior } from "./midpoint.behavior";
|
|
6
|
+
import { FeatureId } from "../../../store/store";
|
|
7
|
+
export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
|
|
8
|
+
readonly config: BehaviorConfig;
|
|
9
|
+
private readonly featuresAtMouseEvent;
|
|
10
|
+
private readonly selectionPoints;
|
|
11
|
+
private readonly midPoints;
|
|
12
|
+
constructor(config: BehaviorConfig, featuresAtMouseEvent: FeatureAtPointerEventBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
13
|
+
private draggedFeatureId;
|
|
14
|
+
private dragPosition;
|
|
15
|
+
startDragging(event: TerraDrawMouseEvent, id: FeatureId): void;
|
|
16
|
+
stopDragging(): void;
|
|
17
|
+
isDragging(): boolean;
|
|
18
|
+
canDrag(event: TerraDrawMouseEvent, selectedId: FeatureId): boolean;
|
|
19
|
+
drag(event: TerraDrawMouseEvent, validateFeature?: Validation): false | undefined;
|
|
20
|
+
}
|