terra-draw 0.0.1-alpha.67 → 0.0.1-alpha.69
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/adapters/google-maps.adapter.d.ts +0 -1
- package/dist/common.d.ts +14 -2
- package/dist/geometry/measure/bearing.d.ts +2 -0
- package/dist/geometry/measure/destination.d.ts +2 -0
- package/dist/geometry/measure/slice-along.d.ts +2 -0
- package/dist/geometry/shape/create-bbox.d.ts +1 -1
- package/dist/geometry/shape/create-circle.d.ts +6 -0
- package/dist/geometry/shape/great-circle-coordinates.d.ts +2 -0
- package/dist/geometry/shape/web-mercator-distortion.d.ts +2 -0
- package/dist/modes/base.mode.d.ts +4 -2
- package/dist/modes/circle/circle.mode.d.ts +6 -5
- package/dist/modes/insert-coordinates.behavior.d.ts +9 -0
- package/dist/modes/linestring/linestring.mode.d.ts +16 -3
- package/dist/modes/polygon/polygon.mode.d.ts +1 -2
- package/dist/modes/static/static.mode.d.ts +5 -5
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +6 -6
- 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/validations/linestring.validation.d.ts +2 -0
- package/dist/validations/max-size.validation.d.ts +2 -2
- package/dist/validations/min-size.validation.d.ts +2 -2
- 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/package-lock.json +231 -206
- package/e2e/package.json +9 -9
- package/e2e/public/favicon.ico +0 -0
- package/e2e/public/index.html +0 -1
- package/e2e/tests/leaflet.spec.ts +276 -46
- package/e2e/tests/setup.ts +18 -10
- package/package.json +33 -32
- package/tsconfig.json +9 -1
- package/dist/geometry/boolean/is-valid-linestring-feature.d.ts +0 -2
- package/dist/geometry/boolean/is-valid-point.d.ts +0 -2
- package/dist/geometry/boolean/is-valid-polygon-feature.d.ts +0 -3
- package/dist/geometry/shape/great-circle-line.d.ts +0 -12
- package/dist/modes/great-circle-snapping.behavior.d.ts +0 -14
- package/dist/modes/greatcircle/great-circle.mode.d.ts +0 -64
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="google.maps" />
|
|
2
1
|
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
|
|
3
2
|
import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
|
|
4
3
|
export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
|
package/dist/common.d.ts
CHANGED
|
@@ -45,6 +45,11 @@ export type GetLngLatFromEvent = (event: PointerEvent | MouseEvent) => {
|
|
|
45
45
|
lng: number;
|
|
46
46
|
lat: number;
|
|
47
47
|
} | null;
|
|
48
|
+
export type Projection = "web-mercator" | "globe";
|
|
49
|
+
export type OnFinishContext = {
|
|
50
|
+
mode: string;
|
|
51
|
+
action: string;
|
|
52
|
+
};
|
|
48
53
|
export interface TerraDrawModeRegisterConfig {
|
|
49
54
|
mode: string;
|
|
50
55
|
store: GeoJSONStore;
|
|
@@ -53,12 +58,19 @@ export interface TerraDrawModeRegisterConfig {
|
|
|
53
58
|
onChange: StoreChangeHandler;
|
|
54
59
|
onSelect: (selectedId: string) => void;
|
|
55
60
|
onDeselect: (deselectedId: string) => void;
|
|
56
|
-
onFinish: (finishedId: string) => void;
|
|
61
|
+
onFinish: (finishedId: string, context: OnFinishContext) => void;
|
|
57
62
|
project: Project;
|
|
58
63
|
unproject: Unproject;
|
|
59
64
|
coordinatePrecision: number;
|
|
60
65
|
}
|
|
61
|
-
|
|
66
|
+
export declare enum UpdateTypes {
|
|
67
|
+
Commit = "commit",
|
|
68
|
+
Provisional = "provisional",
|
|
69
|
+
Finish = "finish"
|
|
70
|
+
}
|
|
71
|
+
type ValidationContext = Pick<TerraDrawModeRegisterConfig, "project" | "unproject" | "coordinatePrecision"> & {
|
|
72
|
+
updateType: UpdateTypes;
|
|
73
|
+
};
|
|
62
74
|
export type Validation = (feature: GeoJSONStoreFeatures, context: ValidationContext) => boolean;
|
|
63
75
|
export type TerraDrawModeState = "unregistered" | "registered" | "started" | "drawing" | "selecting" | "stopped";
|
|
64
76
|
export interface TerraDrawCallbacks {
|
|
@@ -5,3 +5,9 @@ export declare function circle(options: {
|
|
|
5
5
|
coordinatePrecision: number;
|
|
6
6
|
steps?: number;
|
|
7
7
|
}): Feature<Polygon>;
|
|
8
|
+
export declare function circleWebMercator(options: {
|
|
9
|
+
center: Position;
|
|
10
|
+
radiusKilometers: number;
|
|
11
|
+
coordinatePrecision: number;
|
|
12
|
+
steps?: number;
|
|
13
|
+
}): GeoJSON.Feature<GeoJSON.Polygon>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
-
import { HexColor, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent } from "../common";
|
|
2
|
+
import { HexColor, OnFinishContext, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation } from "../common";
|
|
3
3
|
import { FeatureId, GeoJSONStore, GeoJSONStoreFeatures, StoreChangeHandler } from "../store/store";
|
|
4
4
|
export type CustomStyling = Record<string, string | number | ((feature: GeoJSONStoreFeatures) => HexColor) | ((feature: GeoJSONStoreFeatures) => number)>;
|
|
5
5
|
export declare enum ModeTypes {
|
|
@@ -11,6 +11,7 @@ export declare enum ModeTypes {
|
|
|
11
11
|
export type BaseModeOptions<T extends CustomStyling> = {
|
|
12
12
|
styles?: Partial<T>;
|
|
13
13
|
pointerDistance?: number;
|
|
14
|
+
validation?: Validation;
|
|
14
15
|
};
|
|
15
16
|
export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
16
17
|
protected _state: TerraDrawModeState;
|
|
@@ -20,6 +21,7 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
|
20
21
|
get styles(): Partial<T>;
|
|
21
22
|
set styles(styling: Partial<T>);
|
|
22
23
|
protected behaviors: TerraDrawModeBehavior[];
|
|
24
|
+
protected validate: Validation | undefined;
|
|
23
25
|
protected pointerDistance: number;
|
|
24
26
|
protected coordinatePrecision: number;
|
|
25
27
|
protected onStyleChange: StoreChangeHandler;
|
|
@@ -41,7 +43,7 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
|
41
43
|
abstract stop(): void;
|
|
42
44
|
abstract cleanUp(): void;
|
|
43
45
|
abstract styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
44
|
-
onFinish(finishedId: FeatureId): void;
|
|
46
|
+
onFinish(finishedId: FeatureId, context: OnFinishContext): void;
|
|
45
47
|
onDeselect(deselectedId: FeatureId): void;
|
|
46
48
|
onSelect(selectedId: FeatureId): void;
|
|
47
49
|
onKeyDown(event: TerraDrawKeyboardEvent): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, Projection } from "../../common";
|
|
2
2
|
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
3
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
4
|
type TerraDrawCircleModeKeyEvents = {
|
|
@@ -17,22 +17,23 @@ interface Cursors {
|
|
|
17
17
|
interface TerraDrawCircleModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
18
18
|
keyEvents?: TerraDrawCircleModeKeyEvents | null;
|
|
19
19
|
cursors?: Cursors;
|
|
20
|
-
|
|
20
|
+
startingRadiusKilometers?: number;
|
|
21
|
+
projection?: Projection;
|
|
21
22
|
}
|
|
22
23
|
export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePolygonStyling> {
|
|
23
24
|
mode: string;
|
|
25
|
+
private projection;
|
|
24
26
|
private center;
|
|
25
27
|
private clickCount;
|
|
26
28
|
private currentCircleId;
|
|
27
29
|
private keyEvents;
|
|
28
30
|
private cursors;
|
|
29
|
-
private
|
|
31
|
+
private startingRadiusKilometers;
|
|
30
32
|
/**
|
|
31
33
|
* Create a new circle mode instance
|
|
32
34
|
* @param options - Options to customize the behavior of the circle mode
|
|
33
35
|
* @param options.keyEvents - Key events to cancel or finish the mode
|
|
34
36
|
* @param options.cursors - Cursors to use for the mode
|
|
35
|
-
* @param options.minimumRadiusKilometers - Minimum radius for the circle
|
|
36
37
|
* @param options.styles - Custom styling for the circle
|
|
37
38
|
* @param options.pointerDistance - Distance in pixels to consider a pointer close to a vertex
|
|
38
39
|
*/
|
|
@@ -61,6 +62,6 @@ export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePol
|
|
|
61
62
|
/** @internal */
|
|
62
63
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
63
64
|
validateFeature(feature: unknown): feature is GeoJSONStoreFeatures;
|
|
64
|
-
private
|
|
65
|
+
private updateCircle;
|
|
65
66
|
}
|
|
66
67
|
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,4 +1,4 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, Projection } from "../../common";
|
|
2
2
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
3
|
import { BehaviorConfig } from "../base.behavior";
|
|
4
4
|
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
@@ -18,26 +18,39 @@ interface Cursors {
|
|
|
18
18
|
start?: Cursor;
|
|
19
19
|
close?: Cursor;
|
|
20
20
|
}
|
|
21
|
+
interface InertCoordinates {
|
|
22
|
+
strategy: "amount";
|
|
23
|
+
value: number;
|
|
24
|
+
}
|
|
21
25
|
interface TerraDrawLineStringModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
22
26
|
snapping?: boolean;
|
|
23
|
-
allowSelfIntersections?: boolean;
|
|
24
27
|
pointerDistance?: number;
|
|
25
28
|
keyEvents?: TerraDrawLineStringModeKeyEvents | null;
|
|
26
29
|
cursors?: Cursors;
|
|
30
|
+
insertCoordinates?: InertCoordinates;
|
|
31
|
+
projection?: Projection;
|
|
27
32
|
}
|
|
28
33
|
export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineStringStyling> {
|
|
29
34
|
mode: string;
|
|
35
|
+
private projection;
|
|
30
36
|
private currentCoordinate;
|
|
31
37
|
private currentId;
|
|
32
38
|
private closingPointId;
|
|
33
|
-
private allowSelfIntersections;
|
|
34
39
|
private keyEvents;
|
|
35
40
|
private snappingEnabled;
|
|
36
41
|
private cursors;
|
|
37
42
|
private mouseMove;
|
|
43
|
+
private insertCoordinates;
|
|
44
|
+
private lastCommitedCoordinates;
|
|
38
45
|
private snapping;
|
|
46
|
+
private insertPoint;
|
|
39
47
|
constructor(options?: TerraDrawLineStringModeOptions<LineStringStyling>);
|
|
40
48
|
private close;
|
|
49
|
+
private updateGeometries;
|
|
50
|
+
private generateInsertCoordinates;
|
|
51
|
+
private createLine;
|
|
52
|
+
private firstUpdateToLine;
|
|
53
|
+
private updateToLine;
|
|
41
54
|
/** @internal */
|
|
42
55
|
registerBehaviors(config: BehaviorConfig): void;
|
|
43
56
|
/** @internal */
|
|
@@ -21,7 +21,6 @@ interface Cursors {
|
|
|
21
21
|
close?: Cursor;
|
|
22
22
|
}
|
|
23
23
|
interface TerraDrawPolygonModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
24
|
-
allowSelfIntersections?: boolean;
|
|
25
24
|
snapping?: boolean;
|
|
26
25
|
pointerDistance?: number;
|
|
27
26
|
keyEvents?: TerraDrawPolygonModeKeyEvents | null;
|
|
@@ -31,7 +30,6 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
|
|
|
31
30
|
mode: string;
|
|
32
31
|
private currentCoordinate;
|
|
33
32
|
private currentId;
|
|
34
|
-
private allowSelfIntersections;
|
|
35
33
|
private keyEvents;
|
|
36
34
|
private snappingEnabled;
|
|
37
35
|
private snapping;
|
|
@@ -49,6 +47,7 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
|
|
|
49
47
|
stop(): void;
|
|
50
48
|
/** @internal */
|
|
51
49
|
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
50
|
+
private updatePolygonGeometry;
|
|
52
51
|
/** @internal */
|
|
53
52
|
onClick(event: TerraDrawMouseEvent): void;
|
|
54
53
|
/** @internal */
|
|
@@ -16,16 +16,16 @@ export declare class TerraDrawStaticMode extends TerraDrawBaseDrawMode<StaticMod
|
|
|
16
16
|
onMouseMove(): void;
|
|
17
17
|
cleanUp(): void;
|
|
18
18
|
styleFeature(): {
|
|
19
|
-
pointColor:
|
|
19
|
+
pointColor: import("../../common").HexColor;
|
|
20
20
|
pointWidth: number;
|
|
21
|
-
pointOutlineColor:
|
|
21
|
+
pointOutlineColor: import("../../common").HexColor;
|
|
22
22
|
pointOutlineWidth: number;
|
|
23
|
-
polygonFillColor:
|
|
23
|
+
polygonFillColor: import("../../common").HexColor;
|
|
24
24
|
polygonFillOpacity: number;
|
|
25
|
-
polygonOutlineColor:
|
|
25
|
+
polygonOutlineColor: import("../../common").HexColor;
|
|
26
26
|
polygonOutlineWidth: number;
|
|
27
27
|
lineStringWidth: number;
|
|
28
|
-
lineStringColor:
|
|
28
|
+
lineStringColor: import("../../common").HexColor;
|
|
29
29
|
zIndex: number;
|
|
30
30
|
};
|
|
31
31
|
}
|