terra-draw 0.0.1-alpha.8 → 1.0.0-beta.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/.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/centroid.d.ts +2 -2
- package/dist/geometry/coordinates-identical.d.ts +2 -2
- 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 +2 -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/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 -39
- 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 +222 -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 +52 -0
- package/e2e/tests/leaflet.spec.ts +657 -0
- package/e2e/tests/setup.ts +181 -0
- package/e2e/webpack.config.js +36 -0
- package/jest.nocheck.config.ts +17 -0
- package/package.json +159 -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,2 +1,9 @@
|
|
|
1
|
-
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
-
export declare function transformRotate(
|
|
1
|
+
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
+
export declare function transformRotate(feature: Feature<Polygon | LineString>, angle: number): Feature<Polygon | LineString, import("geojson").GeoJsonProperties>;
|
|
3
|
+
/**
|
|
4
|
+
* Rotate a GeoJSON Polygon geometry in web mercator
|
|
5
|
+
* @param polygon - GeoJSON Polygon geometry
|
|
6
|
+
* @param angle - rotation angle in degrees
|
|
7
|
+
* @returns - rotated GeoJSON Polygon geometry
|
|
8
|
+
*/
|
|
9
|
+
export declare const transformRotateWebMercator: (feature: Feature<Polygon> | Feature<LineString>, angle: number) => Feature<Polygon, import("geojson").GeoJsonProperties> | Feature<LineString, import("geojson").GeoJsonProperties>;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
-
export declare function transformScale(feature: Feature<Polygon | LineString>, factor: number): Feature<Polygon | LineString, import("geojson").GeoJsonProperties>;
|
|
1
|
+
import { Feature, LineString, Polygon, Position } from "geojson";
|
|
2
|
+
export declare function transformScale(feature: Feature<Polygon | LineString>, factor: number, origin: Position, axis?: "x" | "y" | "xy"): Feature<Polygon | LineString, import("geojson").GeoJsonProperties>;
|
|
3
|
+
/**
|
|
4
|
+
* Scale a GeoJSON Polygon geometry in web mercator
|
|
5
|
+
* @param polygon - GeoJSON Polygon geometry
|
|
6
|
+
* @param scale - scaling factor
|
|
7
|
+
* @returns - scaled GeoJSON Polygon geometry
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformScaleWebMercator(feature: Feature<Polygon | LineString>, factor: number, origin: Position): Feature<Polygon | LineString>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the centroid of a GeoJSON Polygon or LineString in Web Mercator
|
|
4
|
+
|
|
5
|
+
* @param {Feature<Polygon | LineString>} feature - The GeoJSON Feature containing either a Polygon or LineString
|
|
6
|
+
* @returns {{ x: number, y: number }} The centroid of the polygon or line string in Web Mercator coordinates.
|
|
7
|
+
*/
|
|
8
|
+
export declare function webMercatorCentroid(feature: Feature<Polygon | LineString>): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { Project, Unproject } from "../common";
|
|
2
|
-
import { GeoJSONStore } from "../store/store";
|
|
3
|
-
export
|
|
4
|
-
store: GeoJSONStore;
|
|
5
|
-
mode: string;
|
|
6
|
-
project: Project;
|
|
7
|
-
unproject: Unproject;
|
|
8
|
-
pointerDistance: number;
|
|
9
|
-
coordinatePrecision: number;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
protected
|
|
14
|
-
protected
|
|
15
|
-
protected
|
|
16
|
-
protected
|
|
17
|
-
protected
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { Project, Projection, Unproject } from "../common";
|
|
2
|
+
import { GeoJSONStore } from "../store/store";
|
|
3
|
+
export type BehaviorConfig = {
|
|
4
|
+
store: GeoJSONStore;
|
|
5
|
+
mode: string;
|
|
6
|
+
project: Project;
|
|
7
|
+
unproject: Unproject;
|
|
8
|
+
pointerDistance: number;
|
|
9
|
+
coordinatePrecision: number;
|
|
10
|
+
projection: Projection;
|
|
11
|
+
};
|
|
12
|
+
export declare class TerraDrawModeBehavior {
|
|
13
|
+
protected store: GeoJSONStore;
|
|
14
|
+
protected mode: string;
|
|
15
|
+
protected project: Project;
|
|
16
|
+
protected unproject: Unproject;
|
|
17
|
+
protected pointerDistance: number;
|
|
18
|
+
protected coordinatePrecision: number;
|
|
19
|
+
protected projection: Projection;
|
|
20
|
+
constructor({ store, mode, project, unproject, pointerDistance, coordinatePrecision, projection, }: BehaviorConfig);
|
|
21
|
+
}
|
|
@@ -1,33 +1,66 @@
|
|
|
1
|
-
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
-
import { TerraDrawModeRegisterConfig, TerraDrawModeState } from "../common";
|
|
3
|
-
import { GeoJSONStore, GeoJSONStoreFeatures } from "../store/store";
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
protected
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
protected
|
|
27
|
-
protected
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
+
import { HexColor, OnFinishContext, Projection, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation } from "../common";
|
|
3
|
+
import { FeatureId, GeoJSONStore, GeoJSONStoreFeatures, StoreChangeHandler } from "../store/store";
|
|
4
|
+
export type CustomStyling = Record<string, string | number | ((feature: GeoJSONStoreFeatures) => HexColor) | ((feature: GeoJSONStoreFeatures) => number)>;
|
|
5
|
+
export declare enum ModeTypes {
|
|
6
|
+
Drawing = "drawing",
|
|
7
|
+
Select = "select",
|
|
8
|
+
Static = "static",
|
|
9
|
+
Render = "render"
|
|
10
|
+
}
|
|
11
|
+
export type BaseModeOptions<T extends CustomStyling> = {
|
|
12
|
+
styles?: Partial<T>;
|
|
13
|
+
pointerDistance?: number;
|
|
14
|
+
validation?: Validation;
|
|
15
|
+
projection?: Projection;
|
|
16
|
+
};
|
|
17
|
+
export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
18
|
+
protected _state: TerraDrawModeState;
|
|
19
|
+
get state(): TerraDrawModeState;
|
|
20
|
+
set state(_: TerraDrawModeState);
|
|
21
|
+
protected _styles: Partial<T>;
|
|
22
|
+
get styles(): Partial<T>;
|
|
23
|
+
set styles(styling: Partial<T>);
|
|
24
|
+
protected behaviors: TerraDrawModeBehavior[];
|
|
25
|
+
protected validate: Validation | undefined;
|
|
26
|
+
protected pointerDistance: number;
|
|
27
|
+
protected coordinatePrecision: number;
|
|
28
|
+
protected onStyleChange: StoreChangeHandler;
|
|
29
|
+
protected store: GeoJSONStore;
|
|
30
|
+
protected setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
31
|
+
protected unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
32
|
+
protected project: TerraDrawModeRegisterConfig["project"];
|
|
33
|
+
protected setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
34
|
+
protected registerBehaviors(behaviorConfig: BehaviorConfig): void;
|
|
35
|
+
protected projection: Projection;
|
|
36
|
+
constructor(options?: BaseModeOptions<T>);
|
|
37
|
+
type: ModeTypes;
|
|
38
|
+
mode: string;
|
|
39
|
+
protected setDrawing(): void;
|
|
40
|
+
protected setStarted(): void;
|
|
41
|
+
protected setStopped(): void;
|
|
42
|
+
register(config: TerraDrawModeRegisterConfig): void;
|
|
43
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
44
|
+
abstract start(): void;
|
|
45
|
+
abstract stop(): void;
|
|
46
|
+
abstract cleanUp(): void;
|
|
47
|
+
abstract styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
48
|
+
onFinish(finishedId: FeatureId, context: OnFinishContext): void;
|
|
49
|
+
onDeselect(deselectedId: FeatureId): void;
|
|
50
|
+
onSelect(selectedId: FeatureId): void;
|
|
51
|
+
onKeyDown(event: TerraDrawKeyboardEvent): void;
|
|
52
|
+
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
53
|
+
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
54
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
55
|
+
onDragStart(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
56
|
+
onDrag(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
57
|
+
onDragEnd(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
58
|
+
protected getHexColorStylingValue(value: HexColor | ((feature: GeoJSONStoreFeatures) => HexColor) | undefined, defaultValue: HexColor, feature: GeoJSONStoreFeatures): HexColor;
|
|
59
|
+
protected getNumericStylingValue(value: number | ((feature: GeoJSONStoreFeatures) => number) | undefined, defaultValue: number, feature: GeoJSONStoreFeatures): number;
|
|
60
|
+
private getStylingValue;
|
|
61
|
+
}
|
|
62
|
+
export declare abstract class TerraDrawBaseSelectMode<T extends CustomStyling> extends TerraDrawBaseDrawMode<T> {
|
|
63
|
+
type: ModeTypes;
|
|
64
|
+
abstract selectFeature(featureId: FeatureId): void;
|
|
65
|
+
abstract deselectFeature(featureId: FeatureId): void;
|
|
66
|
+
}
|
|
@@ -1,37 +1,66 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent,
|
|
2
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
-
import { TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
-
|
|
5
|
-
cancel: KeyboardEvent["key"];
|
|
6
|
-
finish: KeyboardEvent["key"];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
fillColor:
|
|
10
|
-
outlineColor:
|
|
11
|
-
outlineWidth:
|
|
12
|
-
fillOpacity:
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, Projection } from "../../common";
|
|
2
|
+
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
+
type TerraDrawCircleModeKeyEvents = {
|
|
5
|
+
cancel: KeyboardEvent["key"] | null;
|
|
6
|
+
finish: KeyboardEvent["key"] | null;
|
|
7
|
+
};
|
|
8
|
+
type CirclePolygonStyling = {
|
|
9
|
+
fillColor: HexColorStyling;
|
|
10
|
+
outlineColor: HexColorStyling;
|
|
11
|
+
outlineWidth: NumericStyling;
|
|
12
|
+
fillOpacity: NumericStyling;
|
|
13
|
+
};
|
|
14
|
+
interface Cursors {
|
|
15
|
+
start?: Cursor;
|
|
16
|
+
}
|
|
17
|
+
interface TerraDrawCircleModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
18
|
+
keyEvents?: TerraDrawCircleModeKeyEvents | null;
|
|
19
|
+
cursors?: Cursors;
|
|
20
|
+
startingRadiusKilometers?: number;
|
|
21
|
+
projection?: Projection;
|
|
22
|
+
}
|
|
23
|
+
export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePolygonStyling> {
|
|
24
|
+
mode: string;
|
|
25
|
+
private center;
|
|
26
|
+
private clickCount;
|
|
27
|
+
private currentCircleId;
|
|
28
|
+
private keyEvents;
|
|
29
|
+
private cursors;
|
|
30
|
+
private startingRadiusKilometers;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new circle mode instance
|
|
33
|
+
* @param options - Options to customize the behavior of the circle mode
|
|
34
|
+
* @param options.keyEvents - Key events to cancel or finish the mode
|
|
35
|
+
* @param options.cursors - Cursors to use for the mode
|
|
36
|
+
* @param options.styles - Custom styling for the circle
|
|
37
|
+
* @param options.pointerDistance - Distance in pixels to consider a pointer close to a vertex
|
|
38
|
+
*/
|
|
39
|
+
constructor(options?: TerraDrawCircleModeOptions<CirclePolygonStyling>);
|
|
40
|
+
private close;
|
|
41
|
+
/** @internal */
|
|
42
|
+
start(): void;
|
|
43
|
+
/** @internal */
|
|
44
|
+
stop(): void;
|
|
45
|
+
/** @internal */
|
|
46
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
47
|
+
/** @internal */
|
|
48
|
+
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
49
|
+
/** @internal */
|
|
50
|
+
onKeyDown(): void;
|
|
51
|
+
/** @internal */
|
|
52
|
+
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
53
|
+
/** @internal */
|
|
54
|
+
onDragStart(): void;
|
|
55
|
+
/** @internal */
|
|
56
|
+
onDrag(): void;
|
|
57
|
+
/** @internal */
|
|
58
|
+
onDragEnd(): void;
|
|
59
|
+
/** @internal */
|
|
60
|
+
cleanUp(): void;
|
|
61
|
+
/** @internal */
|
|
62
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
63
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
64
|
+
private updateCircle;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
+
import { TerraDrawMouseEvent } from "../common";
|
|
3
|
+
export declare class ClickBoundingBoxBehavior extends TerraDrawModeBehavior {
|
|
4
|
+
constructor(config: BehaviorConfig);
|
|
5
|
+
create(event: TerraDrawMouseEvent): import("geojson").Feature<import("geojson").Polygon, import("geojson").GeoJsonProperties>;
|
|
6
|
+
}
|
|
@@ -1,39 +1,63 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent,
|
|
2
|
-
import { TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
4
|
-
|
|
5
|
-
cancel: KeyboardEvent["key"];
|
|
6
|
-
finish: KeyboardEvent["key"];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
fillColor:
|
|
10
|
-
outlineColor:
|
|
11
|
-
outlineWidth:
|
|
12
|
-
fillOpacity:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
|
+
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
+
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
4
|
+
type TerraDrawFreehandModeKeyEvents = {
|
|
5
|
+
cancel: KeyboardEvent["key"] | null;
|
|
6
|
+
finish: KeyboardEvent["key"] | null;
|
|
7
|
+
};
|
|
8
|
+
type FreehandPolygonStyling = {
|
|
9
|
+
fillColor: HexColorStyling;
|
|
10
|
+
outlineColor: HexColorStyling;
|
|
11
|
+
outlineWidth: NumericStyling;
|
|
12
|
+
fillOpacity: NumericStyling;
|
|
13
|
+
closingPointColor: HexColorStyling;
|
|
14
|
+
closingPointWidth: NumericStyling;
|
|
15
|
+
closingPointOutlineColor: HexColorStyling;
|
|
16
|
+
closingPointOutlineWidth: NumericStyling;
|
|
17
|
+
};
|
|
18
|
+
interface Cursors {
|
|
19
|
+
start?: Cursor;
|
|
20
|
+
close?: Cursor;
|
|
21
|
+
}
|
|
22
|
+
interface TerraDrawFreehandModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
23
|
+
minDistance?: number;
|
|
24
|
+
preventPointsNearClose?: boolean;
|
|
25
|
+
keyEvents?: TerraDrawFreehandModeKeyEvents | null;
|
|
26
|
+
cursors?: Cursors;
|
|
27
|
+
}
|
|
28
|
+
export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<FreehandPolygonStyling> {
|
|
29
|
+
mode: string;
|
|
30
|
+
private startingClick;
|
|
31
|
+
private currentId;
|
|
32
|
+
private closingPointId;
|
|
33
|
+
private minDistance;
|
|
34
|
+
private keyEvents;
|
|
35
|
+
private cursors;
|
|
36
|
+
private preventPointsNearClose;
|
|
37
|
+
constructor(options?: TerraDrawFreehandModeOptions<FreehandPolygonStyling>);
|
|
38
|
+
private close;
|
|
39
|
+
/** @internal */
|
|
40
|
+
start(): void;
|
|
41
|
+
/** @internal */
|
|
42
|
+
stop(): void;
|
|
43
|
+
/** @internal */
|
|
44
|
+
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
45
|
+
/** @internal */
|
|
46
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
47
|
+
/** @internal */
|
|
48
|
+
onKeyDown(): void;
|
|
49
|
+
/** @internal */
|
|
50
|
+
onKeyUp(event: TerraDrawKeyboardEvent): void;
|
|
51
|
+
/** @internal */
|
|
52
|
+
onDragStart(): void;
|
|
53
|
+
/** @internal */
|
|
54
|
+
onDrag(): void;
|
|
55
|
+
/** @internal */
|
|
56
|
+
onDragEnd(): void;
|
|
57
|
+
/** @internal */
|
|
58
|
+
cleanUp(): void;
|
|
59
|
+
/** @internal */
|
|
60
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
61
|
+
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
+
import { Position } from "geojson";
|
|
3
|
+
export declare class InsertCoordinatesBehavior extends TerraDrawModeBehavior {
|
|
4
|
+
readonly config: BehaviorConfig;
|
|
5
|
+
constructor(config: BehaviorConfig);
|
|
6
|
+
generateInsertionCoordinates(coordinateOne: Position, coordinateTwo: Position, segmentLength: number): Position[];
|
|
7
|
+
generateInsertionGeodesicCoordinates(coordinateOne: Position, coordinateTwo: Position, segmentLength: number): Position[];
|
|
8
|
+
private limitCoordinates;
|
|
9
|
+
}
|
|
@@ -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 {};
|