terra-draw 0.0.1-alpha.69 → 0.0.1-alpha.70
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/geometry/get-midpoints.d.ts +9 -3
- package/dist/geometry/measure/bearing.d.ts +7 -0
- package/dist/geometry/midpoint-coordinate.d.ts +1 -0
- package/dist/geometry/transform/rotate.d.ts +8 -1
- package/dist/geometry/transform/scale.d.ts +7 -0
- package/dist/geometry/web-mercator-centroid.d.ts +11 -0
- package/dist/modes/base.behavior.d.ts +4 -2
- package/dist/modes/base.mode.d.ts +3 -1
- package/dist/modes/circle/circle.mode.d.ts +0 -1
- package/dist/modes/linestring/linestring.mode.d.ts +1 -3
- package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.d.ts +2 -2
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +19 -19
- 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/e2e/tests/leaflet.spec.ts +167 -153
- package/e2e/tests/setup.ts +12 -3
- package/package.json +3 -3
- package/dist/geometry/web-mercator-center.d.ts +0 -5
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Point, Position } from "geojson";
|
|
2
|
-
import { Project, Unproject } from "../common";
|
|
2
|
+
import { Project, Projection, Unproject } from "../common";
|
|
3
3
|
import { JSONObject } from "../store/store";
|
|
4
|
-
export declare function getMidPointCoordinates(featureCoords
|
|
5
|
-
|
|
4
|
+
export declare function getMidPointCoordinates({ featureCoords, precision, unproject, project, projection, }: {
|
|
5
|
+
featureCoords: Position[];
|
|
6
|
+
precision: number;
|
|
7
|
+
project: Project;
|
|
8
|
+
unproject: Unproject;
|
|
9
|
+
projection: Projection;
|
|
10
|
+
}): Position[];
|
|
11
|
+
export declare function getMidPoints(selectedCoords: Position[], properties: (index: number) => JSONObject, precision: number, project: Project, unproject: Unproject, projection: Projection): {
|
|
6
12
|
geometry: Point;
|
|
7
13
|
properties: JSONObject;
|
|
8
14
|
}[];
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { Position } from "geojson";
|
|
2
2
|
export declare function bearing(start: Position, end: Position): number;
|
|
3
|
+
export declare function webMercatorBearing({ x: x1, y: y1 }: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}, { x: x2, y: y2 }: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}): number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Position } from "geojson";
|
|
2
2
|
import { Project, Unproject } from "../common";
|
|
3
3
|
export declare function midpointCoordinate(coordinates1: Position, coordinates2: Position, precision: number, project: Project, unproject: Unproject): number[];
|
|
4
|
+
export declare function geodesicMidpointCoordinate(coordinates1: Position, coordinates2: Position, precision: number): number[];
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
-
export declare function transformRotate(
|
|
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
1
|
import { Feature, LineString, Polygon, Position } from "geojson";
|
|
2
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,4 +1,4 @@
|
|
|
1
|
-
import { Project, Unproject } from "../common";
|
|
1
|
+
import { Project, Projection, Unproject } from "../common";
|
|
2
2
|
import { GeoJSONStore } from "../store/store";
|
|
3
3
|
export type BehaviorConfig = {
|
|
4
4
|
store: GeoJSONStore;
|
|
@@ -7,6 +7,7 @@ export type BehaviorConfig = {
|
|
|
7
7
|
unproject: Unproject;
|
|
8
8
|
pointerDistance: number;
|
|
9
9
|
coordinatePrecision: number;
|
|
10
|
+
projection: Projection;
|
|
10
11
|
};
|
|
11
12
|
export declare class TerraDrawModeBehavior {
|
|
12
13
|
protected store: GeoJSONStore;
|
|
@@ -15,5 +16,6 @@ export declare class TerraDrawModeBehavior {
|
|
|
15
16
|
protected unproject: Unproject;
|
|
16
17
|
protected pointerDistance: number;
|
|
17
18
|
protected coordinatePrecision: number;
|
|
18
|
-
|
|
19
|
+
protected projection: Projection;
|
|
20
|
+
constructor({ store, mode, project, unproject, pointerDistance, coordinatePrecision, projection, }: BehaviorConfig);
|
|
19
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
-
import { HexColor, OnFinishContext, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation } from "../common";
|
|
2
|
+
import { HexColor, OnFinishContext, Projection, 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 {
|
|
@@ -12,6 +12,7 @@ export type BaseModeOptions<T extends CustomStyling> = {
|
|
|
12
12
|
styles?: Partial<T>;
|
|
13
13
|
pointerDistance?: number;
|
|
14
14
|
validation?: Validation;
|
|
15
|
+
projection?: Projection;
|
|
15
16
|
};
|
|
16
17
|
export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
17
18
|
protected _state: TerraDrawModeState;
|
|
@@ -31,6 +32,7 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
|
31
32
|
protected project: TerraDrawModeRegisterConfig["project"];
|
|
32
33
|
protected setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
33
34
|
protected registerBehaviors(behaviorConfig: BehaviorConfig): void;
|
|
35
|
+
protected projection: Projection;
|
|
34
36
|
constructor(options?: BaseModeOptions<T>);
|
|
35
37
|
type: ModeTypes;
|
|
36
38
|
mode: string;
|
|
@@ -22,7 +22,6 @@ interface TerraDrawCircleModeOptions<T extends CustomStyling> extends BaseModeOp
|
|
|
22
22
|
}
|
|
23
23
|
export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePolygonStyling> {
|
|
24
24
|
mode: string;
|
|
25
|
-
private projection;
|
|
26
25
|
private center;
|
|
27
26
|
private clickCount;
|
|
28
27
|
private currentCircleId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } 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";
|
|
@@ -28,11 +28,9 @@ interface TerraDrawLineStringModeOptions<T extends CustomStyling> extends BaseMo
|
|
|
28
28
|
keyEvents?: TerraDrawLineStringModeKeyEvents | null;
|
|
29
29
|
cursors?: Cursors;
|
|
30
30
|
insertCoordinates?: InertCoordinates;
|
|
31
|
-
projection?: Projection;
|
|
32
31
|
}
|
|
33
32
|
export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineStringStyling> {
|
|
34
33
|
mode: string;
|
|
35
|
-
private projection;
|
|
36
34
|
private currentCoordinate;
|
|
37
35
|
private currentId;
|
|
38
36
|
private closingPointId;
|
|
@@ -4,7 +4,7 @@ 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
|
-
export type ResizeOptions = "center
|
|
7
|
+
export type ResizeOptions = "center" | "opposite" | "center-fixed" | "opposite-fixed";
|
|
8
8
|
export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior {
|
|
9
9
|
readonly config: BehaviorConfig;
|
|
10
10
|
private readonly pixelDistance;
|
|
@@ -55,7 +55,7 @@ export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior
|
|
|
55
55
|
/**
|
|
56
56
|
* Resizes the feature based on the cursor event
|
|
57
57
|
* @param event - cursor event
|
|
58
|
-
* @param resizeOption - the resize option, either "center
|
|
58
|
+
* @param resizeOption - the resize option, either "center" or "opposite"
|
|
59
59
|
* @returns - true is resize was successful, false otherwise
|
|
60
60
|
*/
|
|
61
61
|
drag(event: TerraDrawMouseEvent, resizeOption: ResizeOptions, validateFeature?: Validation): boolean;
|