terra-draw 1.0.0-beta.9 → 1.1.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/.versionrc.cjs +9 -0
- package/README.md +12 -26
- package/dist/common/adapter-listener.spec.d.ts +1 -0
- package/dist/{adapters/common → common}/base.adapter.d.ts +1 -1
- package/dist/common.d.ts +8 -5
- package/dist/extend.d.ts +4 -3
- package/dist/geometry/boolean/is-valid-coordinate.spec.d.ts +1 -0
- package/dist/geometry/boolean/point-in-polygon.spec.d.ts +1 -0
- package/dist/geometry/boolean/self-intersects.spec.d.ts +1 -0
- package/dist/geometry/calculate-relative-angle.d.ts +2 -10
- package/dist/geometry/calculate-relative-angle.spec.d.ts +1 -0
- package/dist/geometry/centroid.spec.d.ts +1 -0
- package/dist/geometry/clockwise.d.ts +2 -10
- package/dist/geometry/clockwise.spec.d.ts +1 -0
- package/dist/geometry/coordinates-identical.spec.d.ts +1 -0
- package/dist/geometry/determine-halfplane.d.ts +2 -10
- package/dist/geometry/determine-halfplane.spec.d.ts +1 -0
- package/dist/geometry/get-coordinates-as-points.spec.d.ts +1 -0
- package/dist/geometry/get-midpoint.spec.d.ts +1 -0
- package/dist/geometry/limit-decimal-precision.spec.d.ts +1 -0
- package/dist/geometry/measure/bearing.d.ts +2 -7
- package/dist/geometry/measure/bearing.spec.d.ts +1 -0
- package/dist/geometry/measure/desination.spec.d.ts +1 -0
- package/dist/geometry/measure/destination.d.ts +2 -7
- package/dist/geometry/measure/haversine-distance.spec.d.ts +1 -0
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +2 -10
- package/dist/geometry/measure/pixel-distance-to-line.spec.d.ts +1 -0
- package/dist/geometry/measure/pixel-distance.d.ts +2 -7
- package/dist/geometry/measure/pixel-distance.spec.d.ts +1 -0
- package/dist/geometry/measure/rhumb-bearing.spec.d.ts +1 -0
- package/dist/geometry/measure/rhumb-destination.spec.d.ts +1 -0
- package/dist/geometry/measure/rhumb-distance.spec.d.ts +1 -0
- package/dist/geometry/point-on-line.d.ts +6 -0
- package/dist/geometry/point-on-line.spec.d.ts +1 -0
- package/dist/geometry/project/web-mercator.d.ts +2 -4
- package/dist/geometry/project/web-mercator.spec.d.ts +1 -0
- package/dist/geometry/shape/create-bbox.spec.d.ts +1 -0
- package/dist/geometry/shape/create-circle.spec.d.ts +1 -0
- package/dist/geometry/shape/great-circle-coordinates.spec.d.ts +1 -0
- package/dist/geometry/shape/web-mercator-distortion.spec.d.ts +1 -0
- package/dist/geometry/transform/rotate.spec.d.ts +1 -0
- package/dist/geometry/transform/scale.spec.d.ts +1 -0
- package/dist/geometry/web-mercator-centroid.d.ts +2 -4
- package/dist/geometry/web-mercator-centroid.spec.d.ts +1 -0
- package/dist/geometry/web-mercator-point-on-line.d.ts +12 -0
- package/dist/geometry/web-mercator-point-on-line.spec.d.ts +1 -0
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +0 -1
- package/dist/modes/angled-rectangle/angled-rectangle.mode.spec.d.ts +1 -0
- package/dist/modes/circle/circle.mode.spec.d.ts +1 -0
- package/dist/modes/click-bounding-box.behavior.spec.d.ts +1 -0
- package/dist/modes/coordinate-snapping.behavior.d.ts +21 -0
- package/dist/modes/coordinate-snapping.behavior.spec.d.ts +1 -0
- package/dist/modes/freehand/freehand.mode.spec.d.ts +1 -0
- package/dist/modes/insert-coordinates.behavior.spec.d.ts +1 -0
- package/dist/modes/{snapping.behavior.d.ts → line-snapping.behavior.d.ts} +8 -3
- package/dist/modes/line-snapping.behavior.spec.d.ts +1 -0
- package/dist/modes/linestring/linestring.mode.d.ts +14 -3
- package/dist/modes/linestring/linestring.mode.spec.d.ts +1 -0
- package/dist/modes/pixel-distance.behavior.spec.d.ts +1 -0
- package/dist/modes/point/point.mode.d.ts +16 -4
- package/dist/modes/point/point.mode.spec.d.ts +1 -0
- package/dist/modes/polygon/behaviors/closing-points.behavior.spec.d.ts +1 -0
- package/dist/modes/polygon/polygon.mode.d.ts +32 -6
- package/dist/modes/polygon/polygon.mode.spec.d.ts +1 -0
- package/dist/modes/rectangle/rectangle.mode.spec.d.ts +1 -0
- package/dist/modes/render/render.mode.spec.d.ts +1 -0
- package/dist/modes/sector/sector.mode.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-coordinate.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-feature.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/feature-at-pointer-event.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/midpoint.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/rotate-feature.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/scale-feature.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/selection-point.behavior.spec.d.ts +1 -0
- package/dist/modes/select/select.mode.spec.d.ts +1 -0
- package/dist/modes/sensor/sensor.mode.spec.d.ts +1 -0
- package/dist/modes/static/static.mode.spec.d.ts +1 -0
- package/dist/store/spatial-index/quickselect.spec.d.ts +1 -0
- package/dist/store/spatial-index/rbush.spec.d.ts +1 -0
- package/dist/store/spatial-index/spatial-index.spec.d.ts +1 -0
- package/dist/store/store-validation.spec.d.ts +1 -0
- package/dist/store/store.spec.d.ts +1 -0
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +9 -46
- package/dist/terra-draw.extensions.spec.d.ts +28 -0
- 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.spec.d.ts +1 -0
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/dist/test/create-store-features.d.ts +6 -0
- package/dist/test/mock-behavior-config.d.ts +2 -0
- package/dist/test/mock-cursor-event.d.ts +6 -0
- package/dist/test/mock-features.d.ts +4 -0
- package/dist/test/mock-keyboard-event.d.ts +5 -0
- package/dist/test/mock-mode-config.d.ts +21 -0
- package/dist/util/geom.spec.d.ts +1 -0
- package/dist/util/id.spec.d.ts +1 -0
- package/dist/util/styling.spec.d.ts +1 -0
- package/dist/validations/linestring.validation.spec.d.ts +1 -0
- package/dist/validations/max-size.validation.spec.d.ts +1 -0
- package/dist/validations/min-size.validation.spec.d.ts +1 -0
- package/dist/validations/not-self-intersecting.validation.spec.d.ts +1 -0
- package/dist/validations/point.validation.spec.d.ts +1 -0
- package/dist/validations/polygon.validation.spec.d.ts +1 -0
- package/jest.nocheck.config.ts +5 -14
- package/package.json +8 -119
- package/tsconfig.json +6 -25
- package/.devcontainer/Dockerfile +0 -8
- package/.devcontainer/devcontainer.json +0 -27
- package/.devcontainer/post-create.sh +0 -16
- package/LICENSE +0 -8
- package/dist/adapters/arcgis-maps-sdk.adapter.d.ts +0 -106
- package/dist/adapters/google-maps.adapter.d.ts +0 -90
- package/dist/adapters/leaflet.adapter.d.ts +0 -99
- package/dist/adapters/mapbox-gl.adapter.d.ts +0 -90
- package/dist/adapters/maplibre-gl.adapter.d.ts +0 -72
- package/dist/adapters/openlayers.adapter.d.ts +0 -121
- package/e2e/README.md +0 -29
- package/e2e/package-lock.json +0 -4275
- package/e2e/package.json +0 -26
- package/e2e/playwright.config.ts +0 -77
- package/e2e/public/favicon.ico +0 -0
- package/e2e/public/index.html +0 -55
- package/e2e/tests/leaflet.spec.ts +0 -1040
- package/e2e/tests/setup.ts +0 -208
- package/e2e/webpack.config.js +0 -36
- package/eslint.config.js +0 -31
- /package/dist/{adapters/common → common}/adapter-listener.d.ts +0 -0
package/.versionrc.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const packageJsonPath = path.resolve(__dirname, `package.json`);
|
|
3
|
+
const packageName = require(packageJsonPath).name
|
|
4
|
+
console.log(`✔ Package: ${packageName}`)
|
|
5
|
+
|
|
6
|
+
const changelogPath = path.resolve(__dirname, "/CHANGELOG.md")
|
|
7
|
+
const releaseConfig = require('../../release')
|
|
8
|
+
|
|
9
|
+
module.exports = releaseConfig(packageName, packageJsonPath, changelogPath)
|
package/README.md
CHANGED
|
@@ -13,37 +13,23 @@ Frictionless map drawing across mapping libraries.
|
|
|
13
13
|
|
|
14
14
|
Terra Draw centralizes map drawing logic and provides a host of out-of-the-box drawing modes that work across different JavaScript mapping libraries. It also allows you to bring your own modes!
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
### Supported Mapping Libraries
|
|
17
17
|
|
|
18
|
+
Terra Draw works with your mapping library of choice via adapters. Please pick the adapter for the mapping library you are working with:
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- [Mapbox GL JS](https://www.mapbox.com/mapbox-gljs) v2
|
|
26
|
-
- [MapLibre](https://maplibre.org/maplibre-gl-js/docs/) v2/v3
|
|
27
|
-
- [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/overview) v3
|
|
28
|
-
- [ArcGIS JavaScript SDK](https://developers.arcgis.com/javascript/latest/) v4 (MapView)
|
|
20
|
+
* [terra-draw-maplibre-gl-js-adapter](https://www.npmjs.com/package/terra-draw-maplibre-gl-js-adapter)
|
|
21
|
+
* [terra-draw-leaflet-adapter](https://www.npmjs.com/package/terra-draw-leaflet-adapter)
|
|
22
|
+
* [terra-draw-google-maps-adapter](https://www.npmjs.com/package/terra-draw-googl-emaps-adapter)
|
|
23
|
+
* [terra-draw-mapbox-gl-js-adapter](https://www.npmjs.com/package/terra-draw-mapbox-gl-js-adapter)
|
|
24
|
+
* [terra-draw-google-maps-adapter](https://www.npmjs.com/package/terra-draw-google-maps-adapter)
|
|
25
|
+
* [terra-draw-arcgis-adapter](https://www.npmjs.com/package/terra-draw-arcgis-adapter)
|
|
29
26
|
|
|
30
27
|
### Getting Started
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* For development, please see the [the development documentation](./guides/7.DEVELOPMENT.md)
|
|
37
|
-
* For guidance on contributing, please see the [the contributing documentation](./guides/7.DEVELOPMENT.md#contributing)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Project Website
|
|
41
|
-
|
|
42
|
-
You can check out the official Terra Draw website at [terradraw.io](https://www.terradraw.io). If you are interested in contributing to the website please see [this repository](https://www.github.com/JamesLMilner/terra-draw-website).
|
|
43
|
-
|
|
44
|
-
### Contact
|
|
45
|
-
|
|
46
|
-
Email: [contact@terradraw.io](mailto:contact@terradraw.io)
|
|
29
|
+
* [Getting started guide](https://github.com/JamesLMilner/terra-draw/blob/main/guides/1.GETTING_STARTED.md)
|
|
30
|
+
* [API Docs](https://terradraw.io/#/api)
|
|
31
|
+
* [Repository](https://www.github.com/JamesLMilner/terra-draw)
|
|
32
|
+
* [Website](https://www.terradraw.io)
|
|
47
33
|
|
|
48
34
|
### License
|
|
49
35
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction, GetLngLatFromEvent, TerraDrawAdapter } from "
|
|
1
|
+
import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction, GetLngLatFromEvent, TerraDrawAdapter } from "../common";
|
|
2
2
|
import { AdapterListener } from "./adapter-listener";
|
|
3
3
|
type BasePointerListener = (event: PointerEvent) => void;
|
|
4
4
|
type BaseKeyboardListener = (event: KeyboardEvent) => void;
|
package/dist/common.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export interface TerraDrawAdapterStyling {
|
|
|
15
15
|
lineStringColor: HexColor;
|
|
16
16
|
zIndex: number;
|
|
17
17
|
}
|
|
18
|
+
export type CartesianPoint = {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
18
22
|
export interface TerraDrawMouseEvent {
|
|
19
23
|
lng: number;
|
|
20
24
|
lat: number;
|
|
@@ -30,10 +34,7 @@ export interface TerraDrawKeyboardEvent {
|
|
|
30
34
|
}
|
|
31
35
|
export type Cursor = Parameters<SetCursor>[0];
|
|
32
36
|
export type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer" | "wait" | "move") => void;
|
|
33
|
-
export type Project = (lng: number, lat: number) =>
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
};
|
|
37
|
+
export type Project = (lng: number, lat: number) => CartesianPoint;
|
|
37
38
|
export type Unproject = (x: number, y: number) => {
|
|
38
39
|
lat: number;
|
|
39
40
|
lng: number;
|
|
@@ -112,7 +113,9 @@ export declare const SELECT_PROPERTIES: {
|
|
|
112
113
|
readonly MID_POINT: "midPoint";
|
|
113
114
|
readonly SELECTION_POINT: "selectionPoint";
|
|
114
115
|
};
|
|
115
|
-
export declare const
|
|
116
|
+
export declare const COMMON_PROPERTIES: {
|
|
117
|
+
EDITED: string;
|
|
116
118
|
CLOSING_POINT: string;
|
|
119
|
+
SNAPPING_POINT: string;
|
|
117
120
|
};
|
|
118
121
|
export {};
|
package/dist/extend.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { TerraDrawBaseAdapter, BaseAdapterConfig } from "./
|
|
2
|
-
import { HexColorStyling, NumericStyling, TerraDrawCallbacks } from "./common";
|
|
1
|
+
import { TerraDrawBaseAdapter, BaseAdapterConfig } from "./common/base.adapter";
|
|
2
|
+
import { HexColorStyling, NumericStyling, SELECT_PROPERTIES, TerraDrawCallbacks } from "./common";
|
|
3
3
|
import { BaseModeOptions, TerraDrawBaseDrawMode } from "./modes/base.mode";
|
|
4
|
-
|
|
4
|
+
import { FeatureId, GeoJSONStore } from "./store/store";
|
|
5
|
+
export { GeoJSONStore, TerraDrawBaseDrawMode, TerraDrawBaseAdapter, BaseAdapterConfig, NumericStyling, HexColorStyling, BaseModeOptions, TerraDrawCallbacks, FeatureId, SELECT_PROPERTIES, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CartesianPoint } from "../common";
|
|
1
2
|
/**
|
|
2
3
|
* Calculate the relative angle between two lines
|
|
3
4
|
* @param A The first point of the first line
|
|
@@ -5,13 +6,4 @@
|
|
|
5
6
|
* @param C The second point of the second line
|
|
6
7
|
* @returns The relative angle between the two lines
|
|
7
8
|
*/
|
|
8
|
-
export declare function calculateRelativeAngle(A:
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
}, B: {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
}, C: {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
}): number;
|
|
9
|
+
export declare function calculateRelativeAngle(A: CartesianPoint, B: CartesianPoint, C: CartesianPoint): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
y: number;
|
|
4
|
-
}, secondCoord: {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
}, thirdCoord: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
}): boolean;
|
|
1
|
+
import { CartesianPoint } from "../common";
|
|
2
|
+
export declare function isClockwiseWebMercator(center: CartesianPoint, secondCoord: CartesianPoint, thirdCoord: CartesianPoint): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
y: number;
|
|
4
|
-
}, lineStart: {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
}, lineEnd: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
}): string;
|
|
1
|
+
import { CartesianPoint } from "../common";
|
|
2
|
+
export declare function determineHalfPlane(point: CartesianPoint, lineStart: CartesianPoint, lineEnd: CartesianPoint): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Position } from "geojson";
|
|
2
|
+
import { CartesianPoint } from "../../common";
|
|
2
3
|
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;
|
|
4
|
+
export declare function webMercatorBearing({ x: x1, y: y1 }: CartesianPoint, { x: x2, y: y2 }: CartesianPoint): number;
|
|
10
5
|
export declare function normalizeBearing(bearing: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Position } from "geojson";
|
|
2
|
+
import { CartesianPoint } from "../../common";
|
|
2
3
|
export declare function destination(origin: Position, distance: number, bearing: number): Position;
|
|
3
|
-
export declare function webMercatorDestination({ x, y }:
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
}, distance: number, bearing: number): {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
};
|
|
4
|
+
export declare function webMercatorDestination({ x, y }: CartesianPoint, distance: number, bearing: number): CartesianPoint;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
y: number;
|
|
4
|
-
}, linePointOne: {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
}, linePointTwo: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
}) => number;
|
|
1
|
+
import { CartesianPoint } from "../../common";
|
|
2
|
+
export declare const pixelDistanceToLine: (point: CartesianPoint, linePointOne: CartesianPoint, linePointTwo: CartesianPoint) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
y: number;
|
|
4
|
-
}, pointTwo: {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
}) => number;
|
|
1
|
+
import { CartesianPoint } from "../../common";
|
|
2
|
+
export declare const cartesianDistance: (pointOne: CartesianPoint, pointTwo: CartesianPoint) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { CartesianPoint } from "../../common";
|
|
1
2
|
/**
|
|
2
3
|
* Convert longitude and latitude to web mercator x and y
|
|
3
4
|
* @param lng
|
|
4
5
|
* @param lat
|
|
5
6
|
* @returns - web mercator x and y
|
|
6
7
|
*/
|
|
7
|
-
export declare const lngLatToWebMercatorXY: (lng: number, lat: number) =>
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
};
|
|
8
|
+
export declare const lngLatToWebMercatorXY: (lng: number, lat: number) => CartesianPoint;
|
|
11
9
|
/**
|
|
12
10
|
* Convert web mercator x and y to longitude and latitude
|
|
13
11
|
* @param x - web mercator x
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
+
import { CartesianPoint } from "../common";
|
|
2
3
|
/**
|
|
3
4
|
* Calculates the centroid of a GeoJSON Polygon or LineString in Web Mercator
|
|
4
5
|
|
|
5
6
|
* @param {Feature<Polygon | LineString>} feature - The GeoJSON Feature containing either a Polygon or LineString
|
|
6
7
|
* @returns {{ x: number, y: number }} The centroid of the polygon or line string in Web Mercator coordinates.
|
|
7
8
|
*/
|
|
8
|
-
export declare function webMercatorCentroid(feature: Feature<Polygon | LineString>):
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
};
|
|
9
|
+
export declare function webMercatorCentroid(feature: Feature<Polygon | LineString>): CartesianPoint;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Position } from "geojson";
|
|
2
|
+
/**
|
|
3
|
+
* Takes two points and finds the closest point on the line between them to a third point.
|
|
4
|
+
* @param lines
|
|
5
|
+
* @param inputCoordinate
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function webMercatorNearestPointOnLine(inputCoordinate: Position, lines: [Position, Position][]): {
|
|
9
|
+
coordinate: Position;
|
|
10
|
+
lineIndex: number;
|
|
11
|
+
distance: number;
|
|
12
|
+
} | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -16,7 +16,6 @@ interface Cursors {
|
|
|
16
16
|
close?: Cursor;
|
|
17
17
|
}
|
|
18
18
|
interface TerraDrawPolygonModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
19
|
-
snapping?: boolean;
|
|
20
19
|
pointerDistance?: number;
|
|
21
20
|
keyEvents?: TerraDrawPolygonModeKeyEvents | null;
|
|
22
21
|
cursors?: Cursors;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
+
import { TerraDrawMouseEvent } from "../common";
|
|
3
|
+
import { Feature, Position } from "geojson";
|
|
4
|
+
import { ClickBoundingBoxBehavior } from "./click-bounding-box.behavior";
|
|
5
|
+
import { FeatureId } from "../store/store";
|
|
6
|
+
import { PixelDistanceBehavior } from "./pixel-distance.behavior";
|
|
7
|
+
export declare class CoordinateSnappingBehavior extends TerraDrawModeBehavior {
|
|
8
|
+
readonly config: BehaviorConfig;
|
|
9
|
+
private readonly pixelDistance;
|
|
10
|
+
private readonly clickBoundingBox;
|
|
11
|
+
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, clickBoundingBox: ClickBoundingBoxBehavior);
|
|
12
|
+
/** Returns the nearest snappable coordinate - on first click there is no currentId so no need to provide */
|
|
13
|
+
getSnappableCoordinateFirstClick: (event: TerraDrawMouseEvent) => Position | undefined;
|
|
14
|
+
getSnappableCoordinate: (event: TerraDrawMouseEvent, currentFeatureId: FeatureId) => Position | undefined;
|
|
15
|
+
getSnappable(event: TerraDrawMouseEvent, filter?: (feature: Feature) => boolean): {
|
|
16
|
+
coordinate: undefined | Position;
|
|
17
|
+
minDist: number;
|
|
18
|
+
featureId: undefined | FeatureId;
|
|
19
|
+
featureCoordinateIndex: undefined | number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
2
|
import { TerraDrawMouseEvent } from "../common";
|
|
3
|
-
import { Position } from "geojson";
|
|
3
|
+
import { Feature, Position } from "geojson";
|
|
4
4
|
import { ClickBoundingBoxBehavior } from "./click-bounding-box.behavior";
|
|
5
5
|
import { FeatureId } from "../store/store";
|
|
6
6
|
import { PixelDistanceBehavior } from "./pixel-distance.behavior";
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class LineSnappingBehavior extends TerraDrawModeBehavior {
|
|
8
8
|
readonly config: BehaviorConfig;
|
|
9
9
|
private readonly pixelDistance;
|
|
10
10
|
private readonly clickBoundingBox;
|
|
@@ -12,5 +12,10 @@ export declare class SnappingBehavior extends TerraDrawModeBehavior {
|
|
|
12
12
|
/** Returns the nearest snappable coordinate - on first click there is no currentId so no need to provide */
|
|
13
13
|
getSnappableCoordinateFirstClick: (event: TerraDrawMouseEvent) => Position | undefined;
|
|
14
14
|
getSnappableCoordinate: (event: TerraDrawMouseEvent, currentFeatureId: FeatureId) => Position | undefined;
|
|
15
|
-
|
|
15
|
+
getSnappable(event: TerraDrawMouseEvent, filter?: (feature: Feature) => boolean): {
|
|
16
|
+
coordinate: undefined | Position;
|
|
17
|
+
minDistance: number;
|
|
18
|
+
featureId: undefined | FeatureId;
|
|
19
|
+
featureCoordinateIndex: undefined | number;
|
|
20
|
+
};
|
|
16
21
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
|
+
import { Position } from "geojson";
|
|
2
3
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
4
|
import { BehaviorConfig } from "../base.behavior";
|
|
4
5
|
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
@@ -13,6 +14,10 @@ type LineStringStyling = {
|
|
|
13
14
|
closingPointWidth: NumericStyling;
|
|
14
15
|
closingPointOutlineColor: HexColorStyling;
|
|
15
16
|
closingPointOutlineWidth: NumericStyling;
|
|
17
|
+
snappingPointColor: HexColorStyling;
|
|
18
|
+
snappingPointWidth: NumericStyling;
|
|
19
|
+
snappingPointOutlineColor: HexColorStyling;
|
|
20
|
+
snappingPointOutlineWidth: NumericStyling;
|
|
16
21
|
};
|
|
17
22
|
interface Cursors {
|
|
18
23
|
start?: Cursor;
|
|
@@ -22,8 +27,12 @@ interface InertCoordinates {
|
|
|
22
27
|
strategy: "amount";
|
|
23
28
|
value: number;
|
|
24
29
|
}
|
|
30
|
+
interface Snapping {
|
|
31
|
+
toCoordinate?: boolean;
|
|
32
|
+
toCustom?: (event: TerraDrawMouseEvent) => Position | undefined;
|
|
33
|
+
}
|
|
25
34
|
interface TerraDrawLineStringModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
26
|
-
snapping?:
|
|
35
|
+
snapping?: Snapping;
|
|
27
36
|
pointerDistance?: number;
|
|
28
37
|
keyEvents?: TerraDrawLineStringModeKeyEvents | null;
|
|
29
38
|
cursors?: Cursors;
|
|
@@ -35,12 +44,13 @@ export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineS
|
|
|
35
44
|
private currentId;
|
|
36
45
|
private closingPointId;
|
|
37
46
|
private keyEvents;
|
|
38
|
-
private
|
|
47
|
+
private snapping;
|
|
39
48
|
private cursors;
|
|
40
49
|
private mouseMove;
|
|
41
50
|
private insertCoordinates;
|
|
42
51
|
private lastCommitedCoordinates;
|
|
43
|
-
private
|
|
52
|
+
private snappedPointId;
|
|
53
|
+
private coordinateSnapping;
|
|
44
54
|
private insertPoint;
|
|
45
55
|
constructor(options?: TerraDrawLineStringModeOptions<LineStringStyling>);
|
|
46
56
|
private close;
|
|
@@ -74,5 +84,6 @@ export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineS
|
|
|
74
84
|
/** @internal */
|
|
75
85
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
76
86
|
validateFeature(feature: unknown): StoreValidation;
|
|
87
|
+
private snapCoordinate;
|
|
77
88
|
}
|
|
78
89
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, NumericStyling, HexColorStyling, Cursor } from "../../common";
|
|
2
2
|
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
3
3
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
+
import { BehaviorConfig } from "../base.behavior";
|
|
4
5
|
type PointModeStyling = {
|
|
5
6
|
pointWidth: NumericStyling;
|
|
6
7
|
pointColor: HexColorStyling;
|
|
7
8
|
pointOutlineColor: HexColorStyling;
|
|
8
9
|
pointOutlineWidth: NumericStyling;
|
|
10
|
+
editedPointColor: HexColorStyling;
|
|
11
|
+
editedPointWidth: NumericStyling;
|
|
12
|
+
editedPointOutlineColor: HexColorStyling;
|
|
13
|
+
editedPointOutlineWidth: NumericStyling;
|
|
9
14
|
};
|
|
10
15
|
interface Cursors {
|
|
11
16
|
create?: Cursor;
|
|
17
|
+
dragStart?: Cursor;
|
|
18
|
+
dragEnd?: Cursor;
|
|
12
19
|
}
|
|
13
20
|
interface TerraDrawPointModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
14
21
|
cursors?: Cursors;
|
|
22
|
+
editable?: boolean;
|
|
15
23
|
}
|
|
16
24
|
export declare class TerraDrawPointMode extends TerraDrawBaseDrawMode<PointModeStyling> {
|
|
17
25
|
mode: string;
|
|
18
26
|
private cursors;
|
|
27
|
+
private editable;
|
|
28
|
+
private editedFeatureId;
|
|
29
|
+
private pixelDistance;
|
|
30
|
+
private clickBoundingBox;
|
|
19
31
|
constructor(options?: TerraDrawPointModeOptions<PointModeStyling>);
|
|
20
32
|
/** @internal */
|
|
21
33
|
start(): void;
|
|
@@ -31,12 +43,12 @@ export declare class TerraDrawPointMode extends TerraDrawBaseDrawMode<PointModeS
|
|
|
31
43
|
onKeyUp(): void;
|
|
32
44
|
/** @internal */
|
|
33
45
|
cleanUp(): void;
|
|
46
|
+
onDragStart(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
34
47
|
/** @internal */
|
|
35
|
-
|
|
48
|
+
onDrag(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
36
49
|
/** @internal */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
onDragEnd(): void;
|
|
50
|
+
onDragEnd(_: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
51
|
+
registerBehaviors(config: BehaviorConfig): void;
|
|
40
52
|
/** @internal */
|
|
41
53
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
42
54
|
validateFeature(feature: unknown): StoreValidation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|