terra-draw 0.0.1-alpha.6 → 0.0.1-alpha.61
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 +21 -0
- package/.devcontainer/post-create.sh +16 -0
- package/README.md +30 -6
- package/dist/adapters/arcgis-maps-sdk.adapter.d.ts +105 -0
- package/dist/adapters/common/adapter-listener.d.ts +22 -0
- package/dist/adapters/common/base.adapter.d.ts +59 -0
- package/dist/adapters/google-maps.adapter.d.ts +90 -39
- package/dist/adapters/leaflet.adapter.d.ts +97 -33
- package/dist/adapters/mapbox-gl.adapter.d.ts +89 -37
- package/dist/adapters/maplibre-gl.adapter.d.ts +71 -0
- package/dist/adapters/openlayers.adapter.d.ts +118 -0
- package/dist/common.d.ts +103 -98
- package/dist/geometry/boolean/is-valid-coordinate.d.ts +4 -0
- package/dist/geometry/boolean/is-valid-linestring-feature.d.ts +2 -0
- package/dist/geometry/boolean/is-valid-point.d.ts +2 -0
- package/dist/geometry/boolean/is-valid-polygon-feature.d.ts +3 -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 +8 -7
- package/dist/geometry/helpers.d.ts +4 -4
- package/dist/geometry/limit-decimal-precision.d.ts +1 -1
- 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/midpoint-coordinate.d.ts +3 -2
- package/dist/geometry/shape/create-bbox.d.ts +10 -0
- package/dist/geometry/shape/create-circle.d.ts +7 -7
- package/dist/geometry/shape/great-circle-line.d.ts +12 -0
- package/dist/geometry/transform/rotate.d.ts +2 -2
- package/dist/geometry/transform/scale.d.ts +2 -2
- package/dist/modes/base.behavior.d.ts +19 -19
- package/dist/modes/base.mode.d.ts +62 -33
- package/dist/modes/circle/circle.mode.d.ts +55 -35
- package/dist/modes/click-bounding-box.behavior.d.ts +6 -7
- package/dist/modes/freehand/freehand.mode.d.ts +63 -37
- package/dist/modes/great-circle-snapping.behavior.d.ts +14 -0
- package/dist/modes/greatcircle/great-circle.mode.d.ts +64 -0
- package/dist/modes/linestring/linestring.mode.d.ts +67 -40
- 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 +70 -49
- 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 +28 -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 +117 -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 +220 -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/e2e/README.md +29 -0
- package/e2e/package-lock.json +4249 -0
- package/e2e/package.json +26 -0
- package/e2e/playwright.config.ts +77 -0
- package/e2e/public/index.html +53 -0
- package/e2e/src/index.ts +165 -0
- package/e2e/tests/leaflet.spec.ts +413 -0
- package/e2e/tests/setup.ts +164 -0
- package/e2e/webpack.config.js +36 -0
- package/jest.nocheck.config.ts +17 -0
- package/package.json +157 -87
- package/readme.gif +0 -0
- package/tsconfig.json +17 -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,37 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import mapboxgl from "mapbox-gl";
|
|
3
|
-
import {
|
|
4
|
-
export declare class TerraDrawMapboxGLAdapter
|
|
5
|
-
constructor(config: {
|
|
6
|
-
map: mapboxgl.Map;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
1
|
+
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
|
|
2
|
+
import mapboxgl from "mapbox-gl";
|
|
3
|
+
import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
|
|
4
|
+
export declare class TerraDrawMapboxGLAdapter extends TerraDrawBaseAdapter {
|
|
5
|
+
constructor(config: {
|
|
6
|
+
map: mapboxgl.Map;
|
|
7
|
+
} & BaseAdapterConfig);
|
|
8
|
+
private _nextRender;
|
|
9
|
+
private _map;
|
|
10
|
+
private _container;
|
|
11
|
+
private _rendered;
|
|
12
|
+
/**
|
|
13
|
+
* Clears the map of rendered layers and sources
|
|
14
|
+
* @returns void
|
|
15
|
+
* */
|
|
16
|
+
private clearLayers;
|
|
17
|
+
private _addGeoJSONSource;
|
|
18
|
+
private _addFillLayer;
|
|
19
|
+
private _addFillOutlineLayer;
|
|
20
|
+
private _addLineLayer;
|
|
21
|
+
private _addPointLayer;
|
|
22
|
+
private _addLayer;
|
|
23
|
+
private _addGeoJSONLayer;
|
|
24
|
+
private _setGeoJSONLayerData;
|
|
25
|
+
private getEmptyGeometries;
|
|
26
|
+
private changedIds;
|
|
27
|
+
private updateChangedIds;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
30
|
+
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
31
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
|
|
32
|
+
*/
|
|
33
|
+
getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
34
|
+
lng: number;
|
|
35
|
+
lat: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
*Retrieves the HTML element of the Mapbox element that handles interaction events
|
|
39
|
+
* @returns The HTMLElement representing the map container.
|
|
40
|
+
*/
|
|
41
|
+
getMapEventElement(): HTMLCanvasElement;
|
|
42
|
+
/**
|
|
43
|
+
* Enables or disables the draggable functionality of the map.
|
|
44
|
+
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
45
|
+
*/
|
|
46
|
+
setDraggability(enabled: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
* Converts longitude and latitude coordinates to pixel coordinates in the map container.
|
|
49
|
+
* @param lng The longitude coordinate to project.
|
|
50
|
+
* @param lat The latitude coordinate to project.
|
|
51
|
+
* @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
|
|
52
|
+
*/
|
|
53
|
+
project(lng: number, lat: number): {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Converts pixel coordinates in the map container to longitude and latitude coordinates.
|
|
59
|
+
* @param x The x-coordinate in the map container to unproject.
|
|
60
|
+
* @param y The y-coordinate in the map container to unproject.
|
|
61
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
|
|
62
|
+
*/
|
|
63
|
+
unproject(x: number, y: number): {
|
|
64
|
+
lng: number;
|
|
65
|
+
lat: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Sets the cursor style for the map container.
|
|
69
|
+
* @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
|
|
70
|
+
*/
|
|
71
|
+
setCursor(cursor: Parameters<SetCursor>[0]): void;
|
|
72
|
+
/**
|
|
73
|
+
* Enables or disables the double-click to zoom functionality on the map.
|
|
74
|
+
* @param enabled Set to true to enable double-click to zoom, or false to disable it.
|
|
75
|
+
*/
|
|
76
|
+
setDoubleClickToZoom(enabled: boolean): void;
|
|
77
|
+
/**
|
|
78
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
79
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
80
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
81
|
+
*/
|
|
82
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
83
|
+
/**
|
|
84
|
+
* Clears the map and store of all rendered data layers
|
|
85
|
+
* @returns void
|
|
86
|
+
* */
|
|
87
|
+
clear(): void;
|
|
88
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
89
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
|
|
2
|
+
import { Map } from "maplibre-gl";
|
|
3
|
+
import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
|
|
4
|
+
export declare class TerraDrawMapLibreGLAdapter extends TerraDrawBaseAdapter {
|
|
5
|
+
private mapboxglAdapter;
|
|
6
|
+
constructor(config: {
|
|
7
|
+
map: Map;
|
|
8
|
+
} & BaseAdapterConfig);
|
|
9
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
10
|
+
unregister(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
13
|
+
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
14
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
|
|
15
|
+
*/
|
|
16
|
+
getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
17
|
+
lng: number;
|
|
18
|
+
lat: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the HTML element of the MapLibre element that handles interaction events
|
|
22
|
+
* @returns The HTMLElement representing the map container.
|
|
23
|
+
*/
|
|
24
|
+
getMapEventElement(): HTMLCanvasElement;
|
|
25
|
+
/**
|
|
26
|
+
* Enables or disables the draggable functionality of the map.
|
|
27
|
+
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
28
|
+
*/
|
|
29
|
+
setDraggability(enabled: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* Converts longitude and latitude coordinates to pixel coordinates in the map container.
|
|
32
|
+
* @param lng The longitude coordinate to project.
|
|
33
|
+
* @param lat The latitude coordinate to project.
|
|
34
|
+
* @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
|
|
35
|
+
*/
|
|
36
|
+
project(lng: number, lat: number): {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Converts pixel coordinates in the map container to longitude and latitude coordinates.
|
|
42
|
+
* @param x The x-coordinate in the map container to unproject.
|
|
43
|
+
* @param y The y-coordinate in the map container to unproject.
|
|
44
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
|
|
45
|
+
*/
|
|
46
|
+
unproject(x: number, y: number): {
|
|
47
|
+
lng: number;
|
|
48
|
+
lat: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Sets the cursor style for the map container.
|
|
52
|
+
* @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
|
|
53
|
+
*/
|
|
54
|
+
setCursor(style: Parameters<SetCursor>[0]): void;
|
|
55
|
+
/**
|
|
56
|
+
* Enables or disables the double-click to zoom functionality on the map.
|
|
57
|
+
* @param enabled Set to true to enable double-click to zoom, or false to disable it.
|
|
58
|
+
*/
|
|
59
|
+
setDoubleClickToZoom(enabled: boolean): void;
|
|
60
|
+
/**
|
|
61
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
62
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
63
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
64
|
+
*/
|
|
65
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
66
|
+
/**
|
|
67
|
+
* Clears the map and store of all rendered data layers
|
|
68
|
+
* @returns void
|
|
69
|
+
* */
|
|
70
|
+
clear(): void;
|
|
71
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
|
|
2
|
+
import CircleGeom from "ol/geom/Circle";
|
|
3
|
+
import Feature from "ol/Feature";
|
|
4
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
5
|
+
import Map from "ol/Map";
|
|
6
|
+
import Circle from "ol/style/Circle";
|
|
7
|
+
import Stroke from "ol/style/Stroke";
|
|
8
|
+
import Style from "ol/style/Style";
|
|
9
|
+
import VectorSource from "ol/source/Vector";
|
|
10
|
+
import VectorLayer from "ol/layer/Vector";
|
|
11
|
+
import { toLonLat } from "ol/proj";
|
|
12
|
+
import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
|
|
13
|
+
type InjectableOL = {
|
|
14
|
+
Circle: typeof CircleGeom;
|
|
15
|
+
Feature: typeof Feature;
|
|
16
|
+
GeoJSON: typeof GeoJSON;
|
|
17
|
+
Style: typeof Style;
|
|
18
|
+
CircleStyle: typeof Circle;
|
|
19
|
+
VectorLayer: typeof VectorLayer;
|
|
20
|
+
VectorSource: typeof VectorSource;
|
|
21
|
+
Stroke: typeof Stroke;
|
|
22
|
+
toLonLat: typeof toLonLat;
|
|
23
|
+
};
|
|
24
|
+
export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
|
|
25
|
+
constructor(config: {
|
|
26
|
+
map: Map;
|
|
27
|
+
lib: InjectableOL;
|
|
28
|
+
} & BaseAdapterConfig);
|
|
29
|
+
private stylingFunction;
|
|
30
|
+
private _lib;
|
|
31
|
+
private _map;
|
|
32
|
+
private _container;
|
|
33
|
+
private _projection;
|
|
34
|
+
private _vectorSource;
|
|
35
|
+
private _geoJSONReader;
|
|
36
|
+
/**
|
|
37
|
+
* Converts a hexideciaml color to RGB
|
|
38
|
+
* @param hex a string of the hexidecimal string
|
|
39
|
+
* @returns an object to red green and blue (RGB) color
|
|
40
|
+
*/
|
|
41
|
+
private hexToRGB;
|
|
42
|
+
/**
|
|
43
|
+
* Converts a hexideciaml color to RGB
|
|
44
|
+
* @param feature
|
|
45
|
+
* @param styling
|
|
46
|
+
* @returns an object to red green and blue (RGB) color
|
|
47
|
+
*/
|
|
48
|
+
private getStyles;
|
|
49
|
+
/**
|
|
50
|
+
* Clears the layers created by the adapter
|
|
51
|
+
* @returns void
|
|
52
|
+
* */
|
|
53
|
+
private clearLayers;
|
|
54
|
+
private addFeature;
|
|
55
|
+
private removeFeature;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
58
|
+
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
59
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
|
|
60
|
+
*/
|
|
61
|
+
getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
62
|
+
lng: number;
|
|
63
|
+
lat: number;
|
|
64
|
+
} | null;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the HTML element of the OpenLayers element that handles interaction events
|
|
67
|
+
* @returns The HTMLElement representing the map container.
|
|
68
|
+
*/
|
|
69
|
+
getMapEventElement(): HTMLCanvasElement;
|
|
70
|
+
/**
|
|
71
|
+
* Enables or disables the draggable functionality of the map.
|
|
72
|
+
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
73
|
+
*/
|
|
74
|
+
setDraggability(enabled: boolean): void;
|
|
75
|
+
/**
|
|
76
|
+
* Converts longitude and latitude coordinates to pixel coordinates in the map container.
|
|
77
|
+
* @param lng The longitude coordinate to project.
|
|
78
|
+
* @param lat The latitude coordinate to project.
|
|
79
|
+
* @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
|
|
80
|
+
*/
|
|
81
|
+
project(lng: number, lat: number): {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Converts pixel coordinates in the map container to longitude and latitude coordinates.
|
|
87
|
+
* @param x The x-coordinate in the map container to unproject.
|
|
88
|
+
* @param y The y-coordinate in the map container to unproject.
|
|
89
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
|
|
90
|
+
*/
|
|
91
|
+
unproject(x: number, y: number): {
|
|
92
|
+
lng: number;
|
|
93
|
+
lat: number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Sets the cursor style for the map container.
|
|
97
|
+
* @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
|
|
98
|
+
*/
|
|
99
|
+
setCursor(cursor: Parameters<SetCursor>[0]): void;
|
|
100
|
+
/**
|
|
101
|
+
* Enables or disables the double-click to zoom functionality on the map.
|
|
102
|
+
* @param enabled Set to true to enable double-click to zoom, or false to disable it.
|
|
103
|
+
*/
|
|
104
|
+
setDoubleClickToZoom(enabled: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
107
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
108
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
109
|
+
*/
|
|
110
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
111
|
+
/**
|
|
112
|
+
* Clears the map and store of all rendered data layers
|
|
113
|
+
* @returns void
|
|
114
|
+
* */
|
|
115
|
+
clear(): void;
|
|
116
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
package/dist/common.d.ts
CHANGED
|
@@ -1,98 +1,103 @@
|
|
|
1
|
-
import { StoreChangeHandler, GeoJSONStore, GeoJSONStoreFeatures } from "./store/store";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
onKeyUp: (event: TerraDrawKeyboardEvent) => void;
|
|
65
|
-
onKeyDown: (event: TerraDrawKeyboardEvent) => void;
|
|
66
|
-
onClick: (event: TerraDrawMouseEvent) => void;
|
|
67
|
-
onMouseMove: (event: TerraDrawMouseEvent) => void;
|
|
68
|
-
onDragStart: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
|
|
69
|
-
onDrag: (event: TerraDrawMouseEvent) => void;
|
|
70
|
-
onDragEnd: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
import { StoreChangeHandler, GeoJSONStore, GeoJSONStoreFeatures, FeatureId } from "./store/store";
|
|
2
|
+
export type HexColor = `#${string}`;
|
|
3
|
+
export type HexColorStyling = HexColor | ((feature: GeoJSONStoreFeatures) => HexColor);
|
|
4
|
+
export type NumericStyling = number | ((feature: GeoJSONStoreFeatures) => number);
|
|
5
|
+
export interface TerraDrawAdapterStyling {
|
|
6
|
+
pointColor: HexColor;
|
|
7
|
+
pointWidth: number;
|
|
8
|
+
pointOutlineColor: HexColor;
|
|
9
|
+
pointOutlineWidth: number;
|
|
10
|
+
polygonFillColor: HexColor;
|
|
11
|
+
polygonFillOpacity: number;
|
|
12
|
+
polygonOutlineColor: HexColor;
|
|
13
|
+
polygonOutlineWidth: number;
|
|
14
|
+
lineStringWidth: number;
|
|
15
|
+
lineStringColor: HexColor;
|
|
16
|
+
zIndex: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TerraDrawMouseEvent {
|
|
19
|
+
lng: number;
|
|
20
|
+
lat: number;
|
|
21
|
+
containerX: number;
|
|
22
|
+
containerY: number;
|
|
23
|
+
button: "neither" | "left" | "middle" | "right";
|
|
24
|
+
heldKeys: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface TerraDrawKeyboardEvent {
|
|
27
|
+
key: string;
|
|
28
|
+
heldKeys: string[];
|
|
29
|
+
preventDefault: () => void;
|
|
30
|
+
}
|
|
31
|
+
export type Required<T> = {
|
|
32
|
+
[P in keyof T]-?: T[P];
|
|
33
|
+
};
|
|
34
|
+
export type Cursor = Parameters<SetCursor>[0];
|
|
35
|
+
export type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer" | "wait" | "move") => void;
|
|
36
|
+
export type Project = (lng: number, lat: number) => {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
export type Unproject = (x: number, y: number) => {
|
|
41
|
+
lat: number;
|
|
42
|
+
lng: number;
|
|
43
|
+
};
|
|
44
|
+
export type GetLngLatFromEvent = (event: PointerEvent | MouseEvent) => {
|
|
45
|
+
lng: number;
|
|
46
|
+
lat: number;
|
|
47
|
+
} | null;
|
|
48
|
+
export interface TerraDrawModeRegisterConfig {
|
|
49
|
+
mode: string;
|
|
50
|
+
store: GeoJSONStore;
|
|
51
|
+
setDoubleClickToZoom: (enabled: boolean) => void;
|
|
52
|
+
setCursor: SetCursor;
|
|
53
|
+
onChange: StoreChangeHandler;
|
|
54
|
+
onSelect: (selectedId: string) => void;
|
|
55
|
+
onDeselect: (deselectedId: string) => void;
|
|
56
|
+
onFinish: (finishedId: string) => void;
|
|
57
|
+
project: Project;
|
|
58
|
+
unproject: Unproject;
|
|
59
|
+
coordinatePrecision: number;
|
|
60
|
+
}
|
|
61
|
+
export type TerraDrawModeState = "unregistered" | "registered" | "started" | "drawing" | "selecting" | "stopped";
|
|
62
|
+
export interface TerraDrawCallbacks {
|
|
63
|
+
getState: () => TerraDrawModeState;
|
|
64
|
+
onKeyUp: (event: TerraDrawKeyboardEvent) => void;
|
|
65
|
+
onKeyDown: (event: TerraDrawKeyboardEvent) => void;
|
|
66
|
+
onClick: (event: TerraDrawMouseEvent) => void;
|
|
67
|
+
onMouseMove: (event: TerraDrawMouseEvent) => void;
|
|
68
|
+
onDragStart: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
|
|
69
|
+
onDrag: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
|
|
70
|
+
onDragEnd: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
|
|
71
|
+
onClear: () => void;
|
|
72
|
+
onReady?(): void;
|
|
73
|
+
}
|
|
74
|
+
export interface TerraDrawChanges {
|
|
75
|
+
created: GeoJSONStoreFeatures[];
|
|
76
|
+
updated: GeoJSONStoreFeatures[];
|
|
77
|
+
unchanged: GeoJSONStoreFeatures[];
|
|
78
|
+
deletedIds: FeatureId[];
|
|
79
|
+
}
|
|
80
|
+
export type TerraDrawStylingFunction = {
|
|
81
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
82
|
+
};
|
|
83
|
+
export interface TerraDrawAdapter {
|
|
84
|
+
project: Project;
|
|
85
|
+
unproject: Unproject;
|
|
86
|
+
setCursor: SetCursor;
|
|
87
|
+
getLngLatFromEvent: GetLngLatFromEvent;
|
|
88
|
+
setDoubleClickToZoom: (enabled: boolean) => void;
|
|
89
|
+
getMapEventElement: () => HTMLElement;
|
|
90
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
91
|
+
unregister(): void;
|
|
92
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
93
|
+
clear(): void;
|
|
94
|
+
getCoordinatePrecision(): number;
|
|
95
|
+
}
|
|
96
|
+
export declare const SELECT_PROPERTIES: {
|
|
97
|
+
readonly SELECTED: "selected";
|
|
98
|
+
readonly MID_POINT: "midPoint";
|
|
99
|
+
readonly SELECTION_POINT: "selectionPoint";
|
|
100
|
+
};
|
|
101
|
+
export declare const POLYGON_PROPERTIES: {
|
|
102
|
+
CLOSING_POINT: string;
|
|
103
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function validLatitude(lat: number): boolean;
|
|
2
|
+
export declare function validLongitude(lng: number): boolean;
|
|
3
|
+
export declare function coordinateIsValid(coordinate: unknown[], coordinatePrecision: number): boolean;
|
|
4
|
+
export declare function getDecimalPlaces(value: number): number;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GeoJSONStoreFeatures } from "../../terra-draw";
|
|
2
|
+
export declare function isValidPolygonFeature(feature: GeoJSONStoreFeatures, coordinatePrecision: number): boolean;
|
|
3
|
+
export declare function isValidNonIntersectingPolygonFeature(feature: GeoJSONStoreFeatures, coordinatePrecision: number): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Position } from "geojson";
|
|
2
|
-
export declare function pointInPolygon(point: Position, rings: Position[][]): boolean;
|
|
1
|
+
import { Position } from "geojson";
|
|
2
|
+
export declare function pointInPolygon(point: Position, rings: Position[][]): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
-
export declare function selfIntersects(feature: Feature<Polygon> | Feature<LineString>): boolean;
|
|
1
|
+
import { Feature, LineString, Polygon } from "geojson";
|
|
2
|
+
export declare function selfIntersects(feature: Feature<Polygon> | Feature<LineString>): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Feature, LineString, Polygon, Position } from "geojson";
|
|
2
|
-
export declare function centroid(geojson: Feature<Polygon | LineString>): Position;
|
|
1
|
+
import { Feature, LineString, Polygon, Position } from "geojson";
|
|
2
|
+
export declare function centroid(geojson: Feature<Polygon | LineString>): Position;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Position } from "geojson";
|
|
2
|
-
export declare function coordinatesIdentical(coordinate: Position, coordinateTwo: Position): boolean;
|
|
1
|
+
import { Position } from "geojson";
|
|
2
|
+
export declare function coordinatesIdentical(coordinate: Position, coordinateTwo: Position): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Point, Position } from "geojson";
|
|
2
|
-
import { JSONObject } from "../store/store";
|
|
3
|
-
export declare function getCoordinatesAsPoints(selectedCoords: Position[], geometryType: "Polygon" | "LineString", properties: (index: number) => JSONObject): {
|
|
4
|
-
geometry: Point;
|
|
5
|
-
properties: JSONObject;
|
|
6
|
-
}[];
|
|
1
|
+
import { Point, Position } from "geojson";
|
|
2
|
+
import { JSONObject } from "../store/store";
|
|
3
|
+
export declare function getCoordinatesAsPoints(selectedCoords: Position[], geometryType: "Polygon" | "LineString", properties: (index: number) => JSONObject): {
|
|
4
|
+
geometry: Point;
|
|
5
|
+
properties: JSONObject;
|
|
6
|
+
}[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Point, Position } from "geojson";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Point, Position } from "geojson";
|
|
2
|
+
import { Project, Unproject } from "../common";
|
|
3
|
+
import { JSONObject } from "../store/store";
|
|
4
|
+
export declare function getMidPointCoordinates(featureCoords: Position[], precision: number, project: Project, unproject: Unproject): Position[];
|
|
5
|
+
export declare function getMidPoints(selectedCoords: Position[], properties: (index: number) => JSONObject, precision: number, project: Project, unproject: Unproject): {
|
|
6
|
+
geometry: Point;
|
|
7
|
+
properties: JSONObject;
|
|
8
|
+
}[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const earthRadius = 6371008.8;
|
|
2
|
-
export declare function degreesToRadians(degrees: number): number;
|
|
3
|
-
export declare function lengthToRadians(distance: number): number;
|
|
4
|
-
export declare function radiansToDegrees(radians: number): number;
|
|
1
|
+
export declare const earthRadius = 6371008.8;
|
|
2
|
+
export declare function degreesToRadians(degrees: number): number;
|
|
3
|
+
export declare function lengthToRadians(distance: number): number;
|
|
4
|
+
export declare function radiansToDegrees(radians: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function limitPrecision(num: number, decimalLimit?: number): number;
|
|
1
|
+
export declare function limitPrecision(num: number, decimalLimit?: number): number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Position } from "geojson";
|
|
2
|
-
export declare function haversineDistanceKilometers(pointOne: Position, pointTwo: Position): number;
|
|
1
|
+
import { Position } from "geojson";
|
|
2
|
+
export declare function haversineDistanceKilometers(pointOne: Position, pointTwo: Position): number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const pixelDistanceToLine: (point: {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
}, linePointOne: {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
}, linePointTwo: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
}) => number;
|
|
1
|
+
export declare const pixelDistanceToLine: (point: {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}, linePointOne: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}, linePointTwo: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}) => number;
|