terra-draw 1.0.0-beta.8 → 1.0.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.
Files changed (153) hide show
  1. package/.versionrc.cjs +9 -0
  2. package/README.md +4 -47
  3. package/dist/common/adapter-listener.spec.d.ts +1 -0
  4. package/dist/{adapters/common → common}/base.adapter.d.ts +1 -1
  5. package/dist/common.d.ts +11 -6
  6. package/dist/extend.d.ts +4 -3
  7. package/dist/geometry/boolean/is-valid-coordinate.spec.d.ts +1 -0
  8. package/dist/geometry/boolean/point-in-polygon.spec.d.ts +1 -0
  9. package/dist/geometry/boolean/self-intersects.spec.d.ts +1 -0
  10. package/dist/geometry/calculate-relative-angle.d.ts +2 -10
  11. package/dist/geometry/calculate-relative-angle.spec.d.ts +1 -0
  12. package/dist/geometry/centroid.spec.d.ts +1 -0
  13. package/dist/geometry/clockwise.d.ts +2 -10
  14. package/dist/geometry/clockwise.spec.d.ts +1 -0
  15. package/dist/geometry/coordinates-identical.spec.d.ts +1 -0
  16. package/dist/geometry/determine-halfplane.d.ts +2 -10
  17. package/dist/geometry/determine-halfplane.spec.d.ts +1 -0
  18. package/dist/geometry/get-coordinates-as-points.spec.d.ts +1 -0
  19. package/dist/geometry/get-midpoint.spec.d.ts +1 -0
  20. package/dist/geometry/limit-decimal-precision.spec.d.ts +1 -0
  21. package/dist/geometry/measure/bearing.d.ts +2 -7
  22. package/dist/geometry/measure/bearing.spec.d.ts +1 -0
  23. package/dist/geometry/measure/desination.spec.d.ts +1 -0
  24. package/dist/geometry/measure/destination.d.ts +2 -7
  25. package/dist/geometry/measure/haversine-distance.spec.d.ts +1 -0
  26. package/dist/geometry/measure/pixel-distance-to-line.d.ts +2 -10
  27. package/dist/geometry/measure/pixel-distance-to-line.spec.d.ts +1 -0
  28. package/dist/geometry/measure/pixel-distance.d.ts +2 -7
  29. package/dist/geometry/measure/pixel-distance.spec.d.ts +1 -0
  30. package/dist/geometry/measure/rhumb-bearing.spec.d.ts +1 -0
  31. package/dist/geometry/measure/rhumb-destination.spec.d.ts +1 -0
  32. package/dist/geometry/measure/rhumb-distance.spec.d.ts +1 -0
  33. package/dist/geometry/point-on-line.d.ts +5 -0
  34. package/dist/geometry/point-on-line.spec.d.ts +1 -0
  35. package/dist/geometry/project/web-mercator.d.ts +2 -4
  36. package/dist/geometry/project/web-mercator.spec.d.ts +1 -0
  37. package/dist/geometry/shape/create-bbox.spec.d.ts +1 -0
  38. package/dist/geometry/shape/create-circle.spec.d.ts +1 -0
  39. package/dist/geometry/shape/great-circle-coordinates.spec.d.ts +1 -0
  40. package/dist/geometry/shape/web-mercator-distortion.spec.d.ts +1 -0
  41. package/dist/geometry/transform/rotate.spec.d.ts +1 -0
  42. package/dist/geometry/transform/scale.spec.d.ts +1 -0
  43. package/dist/geometry/web-mercator-centroid.d.ts +2 -4
  44. package/dist/geometry/web-mercator-centroid.spec.d.ts +1 -0
  45. package/dist/geometry/web-mercator-point-on-line.d.ts +11 -0
  46. package/dist/geometry/web-mercator-point-on-line.spec.d.ts +1 -0
  47. package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +2 -3
  48. package/dist/modes/angled-rectangle/angled-rectangle.mode.spec.d.ts +1 -0
  49. package/dist/modes/base.mode.d.ts +3 -1
  50. package/dist/modes/circle/circle.mode.d.ts +3 -2
  51. package/dist/modes/circle/circle.mode.spec.d.ts +1 -0
  52. package/dist/modes/click-bounding-box.behavior.spec.d.ts +1 -0
  53. package/dist/modes/coordinate-snapping.behavior.d.ts +16 -0
  54. package/dist/modes/coordinate-snapping.behavior.spec.d.ts +1 -0
  55. package/dist/modes/freehand/freehand.mode.d.ts +8 -2
  56. package/dist/modes/freehand/freehand.mode.spec.d.ts +1 -0
  57. package/dist/modes/insert-coordinates.behavior.spec.d.ts +1 -0
  58. package/dist/modes/{snapping.behavior.d.ts → line-snapping.behavior.d.ts} +1 -1
  59. package/dist/modes/line-snapping.behavior.spec.d.ts +1 -0
  60. package/dist/modes/linestring/linestring.mode.d.ts +16 -5
  61. package/dist/modes/linestring/linestring.mode.spec.d.ts +1 -0
  62. package/dist/modes/pixel-distance.behavior.spec.d.ts +1 -0
  63. package/dist/modes/point/point.mode.d.ts +2 -2
  64. package/dist/modes/point/point.mode.spec.d.ts +1 -0
  65. package/dist/modes/polygon/behaviors/closing-points.behavior.spec.d.ts +1 -0
  66. package/dist/modes/polygon/polygon.mode.d.ts +17 -4
  67. package/dist/modes/polygon/polygon.mode.spec.d.ts +1 -0
  68. package/dist/modes/rectangle/rectangle.mode.d.ts +2 -2
  69. package/dist/modes/rectangle/rectangle.mode.spec.d.ts +1 -0
  70. package/dist/modes/render/render.mode.d.ts +2 -1
  71. package/dist/modes/render/render.mode.spec.d.ts +1 -0
  72. package/dist/modes/sector/sector.mode.d.ts +2 -2
  73. package/dist/modes/sector/sector.mode.spec.d.ts +1 -0
  74. package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.spec.d.ts +1 -0
  75. package/dist/modes/select/behaviors/drag-coordinate.behavior.spec.d.ts +1 -0
  76. package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +2 -2
  77. package/dist/modes/select/behaviors/drag-feature.behavior.spec.d.ts +1 -0
  78. package/dist/modes/select/behaviors/feature-at-pointer-event.behavior.spec.d.ts +1 -0
  79. package/dist/modes/select/behaviors/midpoint.behavior.spec.d.ts +1 -0
  80. package/dist/modes/select/behaviors/rotate-feature.behavior.spec.d.ts +1 -0
  81. package/dist/modes/select/behaviors/scale-feature.behavior.spec.d.ts +1 -0
  82. package/dist/modes/select/behaviors/selection-point.behavior.spec.d.ts +1 -0
  83. package/dist/modes/select/select.mode.spec.d.ts +1 -0
  84. package/dist/modes/sensor/sensor.mode.d.ts +2 -2
  85. package/dist/modes/sensor/sensor.mode.spec.d.ts +1 -0
  86. package/dist/modes/static/static.mode.spec.d.ts +1 -0
  87. package/dist/store/spatial-index/quickselect.spec.d.ts +1 -0
  88. package/dist/store/spatial-index/rbush.spec.d.ts +1 -0
  89. package/dist/store/spatial-index/spatial-index.spec.d.ts +1 -0
  90. package/dist/store/store-feature-validation.d.ts +8 -2
  91. package/dist/store/store-validation.spec.d.ts +1 -0
  92. package/dist/store/store.d.ts +5 -1
  93. package/dist/store/store.spec.d.ts +1 -0
  94. package/dist/terra-draw.cjs +1 -1
  95. package/dist/terra-draw.cjs.map +1 -1
  96. package/dist/terra-draw.d.ts +13 -14
  97. package/dist/terra-draw.extensions.spec.d.ts +28 -0
  98. package/dist/terra-draw.modern.js +1 -1
  99. package/dist/terra-draw.modern.js.map +1 -1
  100. package/dist/terra-draw.module.js +1 -1
  101. package/dist/terra-draw.module.js.map +1 -1
  102. package/dist/terra-draw.spec.d.ts +1 -0
  103. package/dist/terra-draw.umd.js +1 -1
  104. package/dist/terra-draw.umd.js.map +1 -1
  105. package/dist/test/create-store-features.d.ts +6 -0
  106. package/dist/test/jest.matchers.d.ts +1 -0
  107. package/dist/test/mock-behavior-config.d.ts +2 -0
  108. package/dist/test/mock-callbacks.d.ts +2 -0
  109. package/dist/test/mock-cursor-event.d.ts +6 -0
  110. package/dist/test/mock-features.d.ts +4 -0
  111. package/dist/test/mock-keyboard-event.d.ts +5 -0
  112. package/dist/test/mock-mode-config.d.ts +21 -0
  113. package/dist/test/mock-pointer-event.d.ts +1 -0
  114. package/dist/util/geom.spec.d.ts +1 -0
  115. package/dist/util/id.spec.d.ts +1 -0
  116. package/dist/util/styling.spec.d.ts +1 -0
  117. package/dist/validation-reasons.d.ts +13 -0
  118. package/dist/validations/common-validations.d.ts +2 -0
  119. package/dist/validations/linestring.validation.d.ts +4 -1
  120. package/dist/validations/linestring.validation.spec.d.ts +1 -0
  121. package/dist/validations/max-size.validation.d.ts +3 -1
  122. package/dist/validations/max-size.validation.spec.d.ts +1 -0
  123. package/dist/validations/min-size.validation.d.ts +3 -1
  124. package/dist/validations/min-size.validation.spec.d.ts +1 -0
  125. package/dist/validations/not-self-intersecting.validation.d.ts +4 -1
  126. package/dist/validations/not-self-intersecting.validation.spec.d.ts +1 -0
  127. package/dist/validations/point.validation.d.ts +4 -1
  128. package/dist/validations/point.validation.spec.d.ts +1 -0
  129. package/dist/validations/polygon.validation.d.ts +8 -2
  130. package/dist/validations/polygon.validation.spec.d.ts +1 -0
  131. package/jest.nocheck.config.ts +5 -14
  132. package/package.json +12 -137
  133. package/tsconfig.json +6 -25
  134. package/.devcontainer/Dockerfile +0 -8
  135. package/.devcontainer/devcontainer.json +0 -27
  136. package/.devcontainer/post-create.sh +0 -16
  137. package/LICENSE +0 -8
  138. package/dist/adapters/arcgis-maps-sdk.adapter.d.ts +0 -106
  139. package/dist/adapters/google-maps.adapter.d.ts +0 -90
  140. package/dist/adapters/leaflet.adapter.d.ts +0 -99
  141. package/dist/adapters/mapbox-gl.adapter.d.ts +0 -90
  142. package/dist/adapters/maplibre-gl.adapter.d.ts +0 -72
  143. package/dist/adapters/openlayers.adapter.d.ts +0 -121
  144. package/e2e/README.md +0 -29
  145. package/e2e/package-lock.json +0 -4274
  146. package/e2e/package.json +0 -26
  147. package/e2e/playwright.config.ts +0 -77
  148. package/e2e/public/favicon.ico +0 -0
  149. package/e2e/public/index.html +0 -55
  150. package/e2e/tests/leaflet.spec.ts +0 -1040
  151. package/e2e/tests/setup.ts +0 -208
  152. package/e2e/webpack.config.js +0 -36
  153. /package/dist/{adapters/common → common}/adapter-listener.d.ts +0 -0
@@ -1,90 +0,0 @@
1
- import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
2
- import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
3
- export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
4
- constructor(config: {
5
- lib: typeof google.maps;
6
- map: google.maps.Map;
7
- } & BaseAdapterConfig);
8
- private _cursor;
9
- private _cursorStyleSheet;
10
- private _lib;
11
- private _map;
12
- private _overlay;
13
- private _clickEventListener;
14
- private _mouseMoveEventListener;
15
- private get _layers();
16
- /**
17
- * Generates an SVG path string for a circle with the given center coordinates and radius.
18
- * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484
19
- * @param cx The x-coordinate of the circle's center.
20
- * @param cy The y-coordinate of the circle's center.
21
- * @param r The radius of the circle.
22
- * @returns The SVG path string representing the circle.
23
- */
24
- private circlePath;
25
- register(callbacks: TerraDrawCallbacks): void;
26
- unregister(): void;
27
- /**
28
- * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
29
- * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
30
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
31
- */
32
- getLngLatFromEvent(event: PointerEvent | MouseEvent): {
33
- lng: number;
34
- lat: number;
35
- } | null;
36
- /**
37
- * Retrieves the HTML element of the Google Map element that handles interaction events
38
- * @returns The HTMLElement representing the map container.
39
- */
40
- getMapEventElement(): HTMLDivElement;
41
- /**
42
- * Converts longitude and latitude coordinates to pixel coordinates in the map container.
43
- * @param lng The longitude coordinate to project.
44
- * @param lat The latitude coordinate to project.
45
- * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
46
- */
47
- project(lng: number, lat: number): {
48
- x: number;
49
- y: number;
50
- };
51
- /**
52
- * Converts pixel coordinates in the map container to longitude and latitude coordinates.
53
- * @param x The x-coordinate in the map container to unproject.
54
- * @param y The y-coordinate in the map container to unproject.
55
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
56
- */
57
- unproject(x: number, y: number): {
58
- lng: number;
59
- lat: number;
60
- };
61
- /**
62
- * Sets the cursor style for the map container.
63
- * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
64
- */
65
- setCursor(cursor: Parameters<SetCursor>[0]): void;
66
- /**
67
- * Enables or disables the double-click to zoom functionality on the map.
68
- * @param enabled Set to true to enable double-click to zoom, or false to disable it.
69
- */
70
- setDoubleClickToZoom(enabled: boolean): void;
71
- /**
72
- * Enables or disables the draggable functionality of the map.
73
- * @param enabled Set to true to enable map dragging, or false to disable it.
74
- */
75
- setDraggability(enabled: boolean): void;
76
- private renderedFeatureIds;
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
- private clearLayers;
84
- /**
85
- * Clears the map and store of all rendered data layers
86
- * @returns void
87
- * */
88
- clear(): void;
89
- getCoordinatePrecision(): number;
90
- }
@@ -1,99 +0,0 @@
1
- import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
2
- import L from "leaflet";
3
- import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
4
- export declare class TerraDrawLeafletAdapter extends TerraDrawBaseAdapter {
5
- constructor(config: {
6
- lib: typeof L;
7
- map: L.Map;
8
- } & BaseAdapterConfig);
9
- private _lib;
10
- private _map;
11
- private _panes;
12
- private _container;
13
- private _layers;
14
- /**
15
- * Creates a pane and its associated style sheet
16
- * @param pane - The pane name
17
- * @param zIndex - The zIndex value for the pane
18
- * @returns The created style element
19
- */
20
- private createPaneStyleSheet;
21
- /**
22
- * Clears the panes created by the adapter
23
- * @returns void
24
- * */
25
- private clearPanes;
26
- /**
27
- * Clears the leaflet layers created by the adapter
28
- * @returns void
29
- * */
30
- private clearLayers;
31
- /**
32
- * Styles a GeoJSON layer based on the styling function
33
- * @param styling - The styling function
34
- * */
35
- private styleGeoJSONLayer;
36
- /**
37
- * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
38
- * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
39
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
40
- */
41
- getLngLatFromEvent(event: PointerEvent | MouseEvent): {
42
- lng: number;
43
- lat: number;
44
- } | null;
45
- /**
46
- * Retrieves the HTML element of the Leaflet element that handles interaction events
47
- * @returns The HTMLElement representing the map container.
48
- */
49
- getMapEventElement(): HTMLElement;
50
- /**
51
- * Enables or disables the draggable functionality of the map.
52
- * @param enabled Set to true to enable map dragging, or false to disable it.
53
- */
54
- setDraggability(enabled: boolean): void;
55
- /**
56
- * Converts longitude and latitude coordinates to pixel coordinates in the map container.
57
- * @param lng The longitude coordinate to project.
58
- * @param lat The latitude coordinate to project.
59
- * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
60
- */
61
- project(lng: number, lat: number): {
62
- x: number;
63
- y: number;
64
- };
65
- /**
66
- * Converts pixel coordinates in the map container to longitude and latitude coordinates.
67
- * @param x The x-coordinate in the map container to unproject.
68
- * @param y The y-coordinate in the map container to unproject.
69
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
70
- */
71
- unproject(x: number, y: number): {
72
- lng: number;
73
- lat: number;
74
- };
75
- /**
76
- * Sets the cursor style for the map container.
77
- * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
78
- */
79
- setCursor(cursor: Parameters<SetCursor>[0]): void;
80
- /**
81
- * Enables or disables the double-click to zoom functionality on the map.
82
- * @param enabled Set to true to enable double-click to zoom, or false to disable it.
83
- */
84
- setDoubleClickToZoom(enabled: boolean): void;
85
- /**
86
- * Renders GeoJSON features on the map using the provided styling configuration.
87
- * @param changes An object containing arrays of created, updated, and unchanged features to render.
88
- * @param styling An object mapping draw modes to feature styling functions
89
- */
90
- render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
91
- /**
92
- * Clears the map and store of all rendered data layers
93
- * @returns void
94
- * */
95
- clear(): void;
96
- register(callbacks: TerraDrawCallbacks): void;
97
- getCoordinatePrecision(): number;
98
- unregister(): void;
99
- }
@@ -1,90 +0,0 @@
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 changedIds;
26
- private updateChangedIds;
27
- /**
28
- * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
29
- * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
30
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
31
- */
32
- getLngLatFromEvent(event: PointerEvent | MouseEvent): {
33
- lng: number;
34
- lat: number;
35
- };
36
- /**
37
- *Retrieves the HTML element of the Mapbox element that handles interaction events
38
- * @returns The HTMLElement representing the map container.
39
- */
40
- getMapEventElement(): HTMLCanvasElement;
41
- /**
42
- * Enables or disables the draggable functionality of the map.
43
- * @param enabled Set to true to enable map dragging, or false to disable it.
44
- */
45
- setDraggability(enabled: boolean): void;
46
- /**
47
- * Converts longitude and latitude coordinates to pixel coordinates in the map container.
48
- * @param lng The longitude coordinate to project.
49
- * @param lat The latitude coordinate to project.
50
- * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
51
- */
52
- project(lng: number, lat: number): {
53
- x: number;
54
- y: number;
55
- };
56
- /**
57
- * Converts pixel coordinates in the map container to longitude and latitude coordinates.
58
- * @param x The x-coordinate in the map container to unproject.
59
- * @param y The y-coordinate in the map container to unproject.
60
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
61
- */
62
- unproject(x: number, y: number): {
63
- lng: number;
64
- lat: number;
65
- };
66
- /**
67
- * Sets the cursor style for the map container.
68
- * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
69
- */
70
- setCursor(cursor: Parameters<SetCursor>[0]): void;
71
- /**
72
- * Enables or disables the double-click to zoom functionality on the map.
73
- * @param enabled Set to true to enable double-click to zoom, or false to disable it.
74
- */
75
- setDoubleClickToZoom(enabled: boolean): void;
76
- /**
77
- * Renders GeoJSON features on the map using the provided styling configuration.
78
- * @param changes An object containing arrays of created, updated, and unchanged features to render.
79
- * @param styling An object mapping draw modes to feature styling functions
80
- */
81
- render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
82
- /**
83
- * Clears the map and store of all rendered data layers
84
- * @returns void
85
- * */
86
- clear(): void;
87
- getCoordinatePrecision(): number;
88
- unregister(): void;
89
- register(callbacks: TerraDrawCallbacks): void;
90
- }
@@ -1,72 +0,0 @@
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
- getCoordinatePrecision(): number;
12
- /**
13
- * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
14
- * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
15
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
16
- */
17
- getLngLatFromEvent(event: PointerEvent | MouseEvent): {
18
- lng: number;
19
- lat: number;
20
- };
21
- /**
22
- * Retrieves the HTML element of the MapLibre element that handles interaction events
23
- * @returns The HTMLElement representing the map container.
24
- */
25
- getMapEventElement(): HTMLCanvasElement;
26
- /**
27
- * Enables or disables the draggable functionality of the map.
28
- * @param enabled Set to true to enable map dragging, or false to disable it.
29
- */
30
- setDraggability(enabled: boolean): void;
31
- /**
32
- * Converts longitude and latitude coordinates to pixel coordinates in the map container.
33
- * @param lng The longitude coordinate to project.
34
- * @param lat The latitude coordinate to project.
35
- * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
36
- */
37
- project(lng: number, lat: number): {
38
- x: number;
39
- y: number;
40
- };
41
- /**
42
- * Converts pixel coordinates in the map container to longitude and latitude coordinates.
43
- * @param x The x-coordinate in the map container to unproject.
44
- * @param y The y-coordinate in the map container to unproject.
45
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
46
- */
47
- unproject(x: number, y: number): {
48
- lng: number;
49
- lat: number;
50
- };
51
- /**
52
- * Sets the cursor style for the map container.
53
- * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
54
- */
55
- setCursor(style: Parameters<SetCursor>[0]): void;
56
- /**
57
- * Enables or disables the double-click to zoom functionality on the map.
58
- * @param enabled Set to true to enable double-click to zoom, or false to disable it.
59
- */
60
- setDoubleClickToZoom(enabled: boolean): void;
61
- /**
62
- * Renders GeoJSON features on the map using the provided styling configuration.
63
- * @param changes An object containing arrays of created, updated, and unchanged features to render.
64
- * @param styling An object mapping draw modes to feature styling functions
65
- */
66
- render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
67
- /**
68
- * Clears the map and store of all rendered data layers
69
- * @returns void
70
- * */
71
- clear(): void;
72
- }
@@ -1,121 +0,0 @@
1
- import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
2
- import Feature from "ol/Feature";
3
- import GeoJSON from "ol/format/GeoJSON";
4
- import Map from "ol/Map";
5
- import Circle from "ol/style/Circle";
6
- import Fill from "ol/style/Fill";
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 { getUserProjection } from "ol/proj";
12
- import { BaseAdapterConfig, TerraDrawBaseAdapter } from "./common/base.adapter";
13
- export type InjectableOL = {
14
- Fill: typeof Fill;
15
- Feature: typeof Feature;
16
- GeoJSON: typeof GeoJSON;
17
- Style: typeof Style;
18
- Circle: typeof Circle;
19
- VectorLayer: typeof VectorLayer;
20
- VectorSource: typeof VectorSource;
21
- Stroke: typeof Stroke;
22
- getUserProjection: typeof getUserProjection;
23
- };
24
- export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
25
- constructor(config: {
26
- map: Map;
27
- lib: InjectableOL;
28
- zIndex?: number;
29
- } & BaseAdapterConfig);
30
- private stylingFunction;
31
- private _lib;
32
- private _map;
33
- private _container;
34
- private _projection;
35
- private _vectorSource;
36
- private _geoJSONReader;
37
- /**
38
- * Converts a hexideciaml color to RGB
39
- * @param hex a string of the hexidecimal string
40
- * @returns an object to red green and blue (RGB) color
41
- */
42
- private hexToRGB;
43
- private getStyles;
44
- /**
45
- * Clears the layers created by the adapter
46
- * @returns void
47
- * */
48
- private clearLayers;
49
- private addFeature;
50
- private removeFeature;
51
- /**
52
- * Sorts an array of DOM elements based on their order in the document, from earliest to latest.
53
- * @param elements - An array of `HTMLElement` objects to be sorted.
54
- * @returns A new array of `HTMLElement` objects sorted by their document order.
55
- */
56
- private sortElementsByDOMOrder;
57
- /**
58
- * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
59
- * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
60
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
61
- */
62
- getLngLatFromEvent(event: PointerEvent | MouseEvent): {
63
- lng: number;
64
- lat: number;
65
- } | null;
66
- /**
67
- * Retrieves the HTML element of the OpenLayers element that handles interaction events
68
- * @returns The HTMLElement representing the map container.
69
- */
70
- getMapEventElement(): HTMLCanvasElement;
71
- /**
72
- * Enables or disables the draggable functionality of the map.
73
- * @param enabled Set to true to enable map dragging, or false to disable it.
74
- */
75
- setDraggability(enabled: boolean): void;
76
- /**
77
- * Converts longitude and latitude coordinates to pixel coordinates in the map container.
78
- * @param lng The longitude coordinate to project.
79
- * @param lat The latitude coordinate to project.
80
- * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
81
- */
82
- project(lng: number, lat: number): {
83
- x: number;
84
- y: number;
85
- };
86
- /**
87
- * Converts pixel coordinates in the map container to longitude and latitude coordinates.
88
- * @param x The x-coordinate in the map container to unproject.
89
- * @param y The y-coordinate in the map container to unproject.
90
- * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
91
- */
92
- unproject(x: number, y: number): {
93
- lng: number;
94
- lat: number;
95
- };
96
- /**
97
- * Sets the cursor style for the map container.
98
- * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
99
- */
100
- setCursor(cursor: Parameters<SetCursor>[0]): void;
101
- /**
102
- * Enables or disables the double-click to zoom functionality on the map.
103
- * @param enabled Set to true to enable double-click to zoom, or false to disable it.
104
- */
105
- setDoubleClickToZoom(enabled: boolean): void;
106
- /**
107
- * Renders GeoJSON features on the map using the provided styling configuration.
108
- * @param changes An object containing arrays of created, updated, and unchanged features to render.
109
- * @param styling An object mapping draw modes to feature styling functions
110
- */
111
- render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
112
- /**
113
- * Clears the map and store of all rendered data layers
114
- * @returns void
115
- * */
116
- clear(): void;
117
- private registeredLayerHandlers;
118
- register(callbacks: TerraDrawCallbacks): void;
119
- getCoordinatePrecision(): number;
120
- unregister(): void;
121
- }
package/e2e/README.md DELETED
@@ -1,29 +0,0 @@
1
- # E2E Testing with Playwright
2
-
3
- We provide a basic end-to-end (E2E) test suite via Playwright, testing against the Leaflet Adapter. The test suite aims to emulate how an end user would interact with and use Terra Draw. Here we can attempt to catch bugs earlier in the pipeline and ensure that new behaviours in the future adhere to a given specification.
4
-
5
- ## Installation
6
-
7
- Installation can be down via npm like so:
8
-
9
- ```shell
10
- npm install
11
- ```
12
-
13
- ## Running
14
-
15
- You can run the tests headless (i.e. no opening of Chromimum) like so:
16
-
17
- ```shell
18
- npm run test
19
- ```
20
-
21
- Or you can run them headed (i.e. Chromimum will open and you will see the tests run) like so:
22
-
23
- ```shell
24
- npm run test:headed
25
- ```
26
-
27
- ## Tests
28
-
29
- Tests are located in the `tests` folder. You will see the `leaflet.spec.ts` file, this is where the tests are kept for the E2E tests written for the Leaflet Adapter. There are also some convienence methods written in the `setup.ts` file which can be leveraged to write tests more easily.