@deck.gl-community/editable-layers 9.0.0-alpha.1 → 9.0.2

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 (279) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +2 -81
  3. package/dist/constants.js +4 -1
  4. package/dist/edit-modes/composite-mode.d.ts +1 -1
  5. package/dist/edit-modes/composite-mode.js +4 -1
  6. package/dist/edit-modes/draw-90degree-polygon-mode.d.ts +1 -1
  7. package/dist/edit-modes/draw-90degree-polygon-mode.js +29 -24
  8. package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +1 -1
  9. package/dist/edit-modes/draw-circle-by-diameter-mode.js +7 -4
  10. package/dist/edit-modes/draw-circle-from-center-mode.d.ts +1 -1
  11. package/dist/edit-modes/draw-circle-from-center-mode.js +7 -4
  12. package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +1 -1
  13. package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +3 -0
  14. package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +1 -1
  15. package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +3 -0
  16. package/dist/edit-modes/draw-line-string-mode.d.ts +1 -1
  17. package/dist/edit-modes/draw-line-string-mode.js +19 -16
  18. package/dist/edit-modes/draw-point-mode.d.ts +1 -1
  19. package/dist/edit-modes/draw-point-mode.js +7 -4
  20. package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +1 -1
  21. package/dist/edit-modes/draw-polygon-by-dragging-mode.js +10 -5
  22. package/dist/edit-modes/draw-polygon-mode.d.ts +1 -1
  23. package/dist/edit-modes/draw-polygon-mode.js +20 -16
  24. package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +1 -1
  25. package/dist/edit-modes/draw-rectangle-from-center-mode.js +3 -0
  26. package/dist/edit-modes/draw-rectangle-mode.d.ts +1 -1
  27. package/dist/edit-modes/draw-rectangle-mode.js +3 -0
  28. package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +1 -1
  29. package/dist/edit-modes/draw-rectangle-using-three-points-mode.js +8 -5
  30. package/dist/edit-modes/draw-square-from-center-mode.d.ts +1 -1
  31. package/dist/edit-modes/draw-square-from-center-mode.js +3 -0
  32. package/dist/edit-modes/draw-square-mode.d.ts +1 -1
  33. package/dist/edit-modes/draw-square-mode.js +3 -0
  34. package/dist/edit-modes/duplicate-mode.d.ts +1 -1
  35. package/dist/edit-modes/duplicate-mode.js +3 -0
  36. package/dist/edit-modes/edit-mode.js +3 -1
  37. package/dist/edit-modes/elevation-mode.d.ts +2 -2
  38. package/dist/edit-modes/elevation-mode.js +8 -5
  39. package/dist/edit-modes/extend-line-string-mode.d.ts +1 -1
  40. package/dist/edit-modes/extend-line-string-mode.js +9 -6
  41. package/dist/edit-modes/extrude-mode.d.ts +1 -1
  42. package/dist/edit-modes/extrude-mode.js +10 -7
  43. package/dist/edit-modes/geojson-edit-mode.d.ts +1 -1
  44. package/dist/edit-modes/geojson-edit-mode.js +18 -15
  45. package/dist/edit-modes/immutable-feature-collection.d.ts +2 -1
  46. package/dist/edit-modes/immutable-feature-collection.js +25 -20
  47. package/dist/edit-modes/measure-angle-mode.d.ts +1 -1
  48. package/dist/edit-modes/measure-angle-mode.js +8 -8
  49. package/dist/edit-modes/measure-area-mode.d.ts +1 -1
  50. package/dist/edit-modes/measure-area-mode.js +7 -5
  51. package/dist/edit-modes/measure-distance-mode.d.ts +1 -1
  52. package/dist/edit-modes/measure-distance-mode.js +17 -14
  53. package/dist/edit-modes/modify-mode.d.ts +1 -1
  54. package/dist/edit-modes/modify-mode.js +17 -14
  55. package/dist/edit-modes/resize-circle-mode.d.ts +2 -2
  56. package/dist/edit-modes/resize-circle-mode.js +3 -1
  57. package/dist/edit-modes/rotate-mode.d.ts +1 -1
  58. package/dist/edit-modes/rotate-mode.js +8 -5
  59. package/dist/edit-modes/scale-mode.d.ts +1 -1
  60. package/dist/edit-modes/scale-mode.js +8 -5
  61. package/dist/edit-modes/snappable-mode.d.ts +1 -1
  62. package/dist/edit-modes/snappable-mode.js +8 -5
  63. package/dist/edit-modes/split-polygon-mode.d.ts +1 -1
  64. package/dist/edit-modes/split-polygon-mode.js +12 -9
  65. package/dist/edit-modes/three-click-polygon-mode.d.ts +1 -1
  66. package/dist/edit-modes/three-click-polygon-mode.js +9 -6
  67. package/dist/edit-modes/transform-mode.d.ts +1 -1
  68. package/dist/edit-modes/transform-mode.js +4 -1
  69. package/dist/edit-modes/translate-mode.d.ts +1 -1
  70. package/dist/edit-modes/translate-mode.js +7 -4
  71. package/dist/edit-modes/two-click-polygon-mode.d.ts +1 -1
  72. package/dist/edit-modes/two-click-polygon-mode.js +9 -6
  73. package/dist/edit-modes/types.d.ts +1 -1
  74. package/dist/edit-modes/types.js +3 -0
  75. package/dist/edit-modes/utils.d.ts +1 -1
  76. package/dist/edit-modes/utils.js +21 -19
  77. package/dist/edit-modes/view-mode.js +3 -0
  78. package/dist/editable-layers/editable-geojson-layer.d.ts +4 -4
  79. package/dist/editable-layers/editable-geojson-layer.js +27 -26
  80. package/dist/editable-layers/editable-h3-cluster-layer.d.ts +2 -2
  81. package/dist/editable-layers/editable-h3-cluster-layer.js +6 -3
  82. package/dist/editable-layers/editable-layer.d.ts +5 -5
  83. package/dist/editable-layers/editable-layer.js +18 -15
  84. package/dist/editable-layers/editable-path-layer.d.ts +1 -1
  85. package/dist/editable-layers/editable-path-layer.js +10 -7
  86. package/dist/editable-layers/elevated-edit-handle-layer.d.ts +1 -1
  87. package/dist/editable-layers/elevated-edit-handle-layer.js +6 -3
  88. package/dist/editable-layers/junction-scatterplot-layer.d.ts +2 -2
  89. package/dist/editable-layers/junction-scatterplot-layer.js +10 -7
  90. package/dist/editable-layers/selection-layer.d.ts +1 -1
  91. package/dist/editable-layers/selection-layer.js +5 -2
  92. package/dist/index.cjs +65 -537
  93. package/dist/index.cjs.map +4 -4
  94. package/dist/index.d.ts +19 -20
  95. package/dist/index.js +20 -18
  96. package/dist/lib/constants.js +3 -0
  97. package/dist/lib/deck-renderer/deck-cache.d.ts +1 -1
  98. package/dist/lib/deck-renderer/deck-cache.js +1 -1
  99. package/dist/lib/deck-renderer/deck-drawer.d.ts +2 -3
  100. package/dist/lib/deck-renderer/deck-drawer.js +12 -12
  101. package/dist/lib/feature.d.ts +4 -4
  102. package/dist/lib/feature.js +4 -1
  103. package/dist/lib/layer-mouse-event.d.ts +2 -2
  104. package/dist/lib/layer-mouse-event.js +4 -1
  105. package/dist/lib/layers/junctions-layer.d.ts +4 -4
  106. package/dist/lib/layers/junctions-layer.js +10 -7
  107. package/dist/lib/layers/segments-layer.d.ts +4 -4
  108. package/dist/lib/layers/segments-layer.js +11 -8
  109. package/dist/lib/layers/texts-layer.d.ts +3 -3
  110. package/dist/lib/layers/texts-layer.js +8 -5
  111. package/dist/lib/math.d.ts +1 -1
  112. package/dist/lib/math.js +3 -0
  113. package/dist/lib/{nebula.d.ts → nebula-core.d.ts} +2 -2
  114. package/dist/lib/{nebula.js → nebula-core.js} +7 -4
  115. package/dist/lib/nebula-layer.d.ts +2 -2
  116. package/dist/lib/nebula-layer.js +4 -1
  117. package/dist/lib/style.js +5 -2
  118. package/dist/mode-handlers/composite-mode-handler.d.ts +1 -1
  119. package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts +1 -1
  120. package/dist/mode-handlers/draw-90degree-polygon-handler.js +13 -10
  121. package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +3 -0
  122. package/dist/mode-handlers/draw-circle-from-center-handler.js +3 -0
  123. package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +3 -0
  124. package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +5 -2
  125. package/dist/mode-handlers/draw-line-string-handler.js +7 -4
  126. package/dist/mode-handlers/draw-point-handler.js +4 -1
  127. package/dist/mode-handlers/draw-polygon-handler.d.ts +1 -1
  128. package/dist/mode-handlers/draw-polygon-handler.js +10 -7
  129. package/dist/mode-handlers/draw-rectangle-handler.js +3 -0
  130. package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +11 -8
  131. package/dist/mode-handlers/duplicate-handler.js +3 -0
  132. package/dist/mode-handlers/elevation-handler.d.ts +2 -2
  133. package/dist/mode-handlers/elevation-handler.js +8 -5
  134. package/dist/mode-handlers/extrude-handler.js +10 -7
  135. package/dist/mode-handlers/mode-handler.d.ts +1 -1
  136. package/dist/mode-handlers/mode-handler.js +17 -14
  137. package/dist/mode-handlers/modify-handler.d.ts +2 -2
  138. package/dist/mode-handlers/modify-handler.js +18 -15
  139. package/dist/mode-handlers/rotate-handler.d.ts +1 -1
  140. package/dist/mode-handlers/rotate-handler.js +4 -1
  141. package/dist/mode-handlers/scale-handler.d.ts +1 -1
  142. package/dist/mode-handlers/scale-handler.js +5 -2
  143. package/dist/mode-handlers/snappable-handler.d.ts +1 -1
  144. package/dist/mode-handlers/snappable-handler.js +6 -3
  145. package/dist/mode-handlers/split-polygon-handler.js +11 -8
  146. package/dist/mode-handlers/three-click-polygon-handler.js +3 -0
  147. package/dist/mode-handlers/translate-handler.d.ts +1 -1
  148. package/dist/mode-handlers/translate-handler.js +4 -1
  149. package/dist/mode-handlers/two-click-polygon-handler.js +3 -0
  150. package/dist/mode-handlers/view-handler.d.ts +1 -1
  151. package/dist/mode-handlers/view-handler.js +3 -0
  152. package/dist/shaderlib/color/color.d.ts +7 -6
  153. package/dist/shaderlib/color/color.js +7 -4
  154. package/dist/shaderlib/utils/utils.d.ts +2 -2
  155. package/dist/shaderlib/utils/utils.js +5 -2
  156. package/dist/{curve-utils.js → utils/curve-utils.js} +7 -4
  157. package/dist/{geojson-types.d.ts → utils/geojson-types.d.ts} +2 -25
  158. package/dist/utils/geojson-types.js +4 -0
  159. package/dist/{memoize.d.ts → utils/memoize.d.ts} +1 -1
  160. package/dist/{memoize.js → utils/memoize.js} +4 -1
  161. package/dist/{translateFromCenter.js → utils/translate-from-center.js} +4 -1
  162. package/dist/utils/types.js +4 -0
  163. package/dist/{utils.js → utils/utils.js} +8 -6
  164. package/package.json +10 -10
  165. package/src/constants.ts +5 -1
  166. package/src/edit-modes/composite-mode.ts +9 -5
  167. package/src/edit-modes/draw-90degree-polygon-mode.ts +38 -34
  168. package/src/edit-modes/draw-circle-by-diameter-mode.ts +16 -12
  169. package/src/edit-modes/draw-circle-from-center-mode.ts +15 -11
  170. package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +8 -4
  171. package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +9 -5
  172. package/src/edit-modes/draw-line-string-mode.ts +29 -25
  173. package/src/edit-modes/draw-point-mode.ts +13 -9
  174. package/src/edit-modes/draw-polygon-by-dragging-mode.ts +16 -16
  175. package/src/edit-modes/draw-polygon-mode.ts +28 -23
  176. package/src/edit-modes/draw-rectangle-from-center-mode.ts +6 -2
  177. package/src/edit-modes/draw-rectangle-mode.ts +6 -2
  178. package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +12 -8
  179. package/src/edit-modes/draw-square-from-center-mode.ts +7 -3
  180. package/src/edit-modes/draw-square-mode.ts +7 -3
  181. package/src/edit-modes/duplicate-mode.ts +7 -3
  182. package/src/edit-modes/edit-mode.ts +5 -1
  183. package/src/edit-modes/elevation-mode.ts +13 -9
  184. package/src/edit-modes/extend-line-string-mode.ts +16 -12
  185. package/src/edit-modes/extrude-mode.ts +22 -18
  186. package/src/edit-modes/geojson-edit-mode.ts +37 -33
  187. package/src/edit-modes/immutable-feature-collection.ts +28 -22
  188. package/src/edit-modes/measure-angle-mode.ts +66 -59
  189. package/src/edit-modes/measure-area-mode.ts +13 -10
  190. package/src/edit-modes/measure-distance-mode.ts +37 -33
  191. package/src/edit-modes/modify-mode.ts +36 -32
  192. package/src/edit-modes/resize-circle-mode.ts +8 -5
  193. package/src/edit-modes/rotate-mode.ts +22 -18
  194. package/src/edit-modes/scale-mode.ts +29 -23
  195. package/src/edit-modes/snappable-mode.ts +19 -15
  196. package/src/edit-modes/split-polygon-mode.ts +25 -21
  197. package/src/edit-modes/three-click-polygon-mode.ts +15 -11
  198. package/src/edit-modes/transform-mode.ts +15 -11
  199. package/src/edit-modes/translate-mode.ts +15 -11
  200. package/src/edit-modes/two-click-polygon-mode.ts +15 -11
  201. package/src/edit-modes/types.ts +5 -1
  202. package/src/edit-modes/utils.ts +33 -30
  203. package/src/edit-modes/view-mode.ts +5 -1
  204. package/src/editable-layers/editable-geojson-layer.ts +44 -41
  205. package/src/editable-layers/editable-h3-cluster-layer.ts +17 -14
  206. package/src/editable-layers/editable-layer.ts +42 -32
  207. package/src/editable-layers/editable-path-layer.ts +12 -8
  208. package/src/editable-layers/elevated-edit-handle-layer.ts +11 -7
  209. package/src/editable-layers/junction-scatterplot-layer.ts +15 -11
  210. package/src/editable-layers/selection-layer.ts +11 -7
  211. package/src/index.ts +68 -65
  212. package/src/lib/constants.ts +4 -0
  213. package/src/lib/deck-renderer/deck-cache.ts +1 -1
  214. package/src/lib/deck-renderer/deck-drawer.ts +28 -28
  215. package/src/lib/feature.ts +7 -3
  216. package/src/lib/layer-mouse-event.ts +7 -6
  217. package/src/lib/layers/junctions-layer.ts +14 -10
  218. package/src/lib/layers/segments-layer.ts +24 -20
  219. package/src/lib/layers/texts-layer.ts +18 -14
  220. package/src/lib/math.ts +5 -1
  221. package/src/lib/{nebula.ts → nebula-core.ts} +8 -4
  222. package/src/lib/nebula-layer.ts +9 -5
  223. package/src/lib/style.ts +6 -2
  224. package/src/mode-handlers/composite-mode-handler.ts +6 -6
  225. package/src/mode-handlers/draw-90degree-polygon-handler.ts +22 -18
  226. package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +10 -6
  227. package/src/mode-handlers/draw-circle-from-center-handler.ts +10 -6
  228. package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +9 -5
  229. package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +12 -8
  230. package/src/mode-handlers/draw-line-string-handler.ts +12 -8
  231. package/src/mode-handlers/draw-point-handler.ts +9 -5
  232. package/src/mode-handlers/draw-polygon-handler.ts +16 -12
  233. package/src/mode-handlers/draw-rectangle-handler.ts +8 -4
  234. package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +17 -13
  235. package/src/mode-handlers/duplicate-handler.ts +8 -4
  236. package/src/mode-handlers/elevation-handler.ts +14 -10
  237. package/src/mode-handlers/extrude-handler.ts +15 -11
  238. package/src/mode-handlers/mode-handler.ts +26 -28
  239. package/src/mode-handlers/modify-handler.ts +29 -25
  240. package/src/mode-handlers/rotate-handler.ts +13 -17
  241. package/src/mode-handlers/scale-handler.ts +13 -13
  242. package/src/mode-handlers/snappable-handler.ts +28 -24
  243. package/src/mode-handlers/split-polygon-handler.ts +22 -18
  244. package/src/mode-handlers/three-click-polygon-handler.ts +6 -2
  245. package/src/mode-handlers/translate-handler.ts +12 -8
  246. package/src/mode-handlers/two-click-polygon-handler.ts +6 -2
  247. package/src/mode-handlers/view-handler.ts +7 -3
  248. package/src/shaderlib/color/color.ts +10 -5
  249. package/src/shaderlib/utils/utils.ts +6 -2
  250. package/src/{curve-utils.ts → utils/curve-utils.ts} +11 -7
  251. package/src/{geojson-types.ts → utils/geojson-types.ts} +16 -31
  252. package/src/{memoize.ts → utils/memoize.ts} +5 -1
  253. package/src/{translateFromCenter.ts → utils/translate-from-center.ts} +8 -4
  254. package/src/{types.ts → utils/types.ts} +4 -0
  255. package/src/{utils.ts → utils/utils.ts} +14 -11
  256. package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.d.ts +0 -4
  257. package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.js +0 -55
  258. package/dist/editable-layers/path-marker-layer/create-path-markers.d.ts +0 -16
  259. package/dist/editable-layers/path-marker-layer/create-path-markers.js +0 -75
  260. package/dist/editable-layers/path-marker-layer/path-marker-layer.d.ts +0 -40
  261. package/dist/editable-layers/path-marker-layer/path-marker-layer.js +0 -121
  262. package/dist/editable-layers/path-marker-layer/polyline.d.ts +0 -18
  263. package/dist/editable-layers/path-marker-layer/polyline.js +0 -37
  264. package/dist/editable-layers/path-outline-layer/path-outline-layer.d.ts +0 -26
  265. package/dist/editable-layers/path-outline-layer/path-outline-layer.js +0 -106
  266. package/dist/geojson-types.js +0 -2
  267. package/dist/shaderlib/outline/outline.d.ts +0 -8
  268. package/dist/shaderlib/outline/outline.js +0 -97
  269. package/dist/types.js +0 -1
  270. package/src/editable-layers/path-marker-layer/arrow-2d-geometry.ts +0 -61
  271. package/src/editable-layers/path-marker-layer/create-path-markers.ts +0 -107
  272. package/src/editable-layers/path-marker-layer/path-marker-layer.ts +0 -179
  273. package/src/editable-layers/path-marker-layer/polyline.ts +0 -40
  274. package/src/editable-layers/path-outline-layer/path-outline-layer.ts +0 -147
  275. package/src/shaderlib/outline/outline.ts +0 -101
  276. /package/dist/{curve-utils.d.ts → utils/curve-utils.d.ts} +0 -0
  277. /package/dist/{translateFromCenter.d.ts → utils/translate-from-center.d.ts} +0 -0
  278. /package/dist/{types.d.ts → utils/types.d.ts} +0 -0
  279. /package/dist/{utils.d.ts → utils/utils.d.ts} +0 -0
@@ -1,16 +1,20 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
2
6
  import turfDifference from '@turf/difference';
3
7
  import turfBuffer from '@turf/buffer';
4
8
  import lineIntersect from '@turf/line-intersect';
5
- import { lineString } from '@turf/helpers';
9
+ import {lineString} from '@turf/helpers';
6
10
  import turfBearing from '@turf/bearing';
7
11
  import turfDistance from '@turf/distance';
8
12
  import turfDestination from '@turf/destination';
9
13
  import turfPolygonToLine from '@turf/polygon-to-line';
10
- import nearestPointOnLine, { NearestPointOnLine } from '@turf/nearest-point-on-line';
11
- import { generatePointsParallelToLinePoints } from '../utils';
12
- import { EditAction, ModeHandler } from './mode-handler';
13
- import { ClickEvent, PointerMoveEvent } from '../edit-modes/types';
14
+ import nearestPointOnLine, {NearestPointOnLine} from '@turf/nearest-point-on-line';
15
+ import {generatePointsParallelToLinePoints} from '../utils/utils';
16
+ import {EditAction, ModeHandler} from './mode-handler';
17
+ import {ClickEvent, PointerMoveEvent} from '../edit-modes/types';
14
18
 
15
19
  // TODO edit-modes: delete handlers once EditMode fully implemented
16
20
  export class SplitPolygonHandler extends ModeHandler {
@@ -42,9 +46,9 @@ export class SplitPolygonHandler extends ModeHandler {
42
46
  if (closestPoint) {
43
47
  // closest point is used as 90degree entry to the polygon
44
48
  const lastBearing = turfBearing(firstPoint, closestPoint);
45
- const currentDistance = turfDistance(firstPoint, mapCoords, { units: 'meters' });
49
+ const currentDistance = turfDistance(firstPoint, mapCoords, {units: 'meters'});
46
50
  return turfDestination(firstPoint, currentDistance, lastBearing, {
47
- units: 'meters',
51
+ units: 'meters'
48
52
  }).geometry.coordinates;
49
53
  }
50
54
  return mapCoords;
@@ -65,7 +69,7 @@ export class SplitPolygonHandler extends ModeHandler {
65
69
  handleClick(event: ClickEvent): EditAction | null | undefined {
66
70
  super.handleClick({
67
71
  ...event,
68
- mapCoords: this.calculateMapCoords(this.getClickSequence(), event.mapCoords),
72
+ mapCoords: this.calculateMapCoords(this.getClickSequence(), event.mapCoords)
69
73
  });
70
74
  const editAction: EditAction | null | undefined = null;
71
75
  const tentativeFeature = this.getTentativeFeature();
@@ -80,7 +84,7 @@ export class SplitPolygonHandler extends ModeHandler {
80
84
  }
81
85
  const pt = {
82
86
  type: 'Point',
83
- coordinates: clickSequence[clickSequence.length - 1],
87
+ coordinates: clickSequence[clickSequence.length - 1]
84
88
  };
85
89
  // @ts-expect-error turf type diff
86
90
  const isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry);
@@ -98,12 +102,12 @@ export class SplitPolygonHandler extends ModeHandler {
98
102
  return editAction;
99
103
  }
100
104
 
101
- handlePointerMove({ mapCoords }: PointerMoveEvent): {
105
+ handlePointerMove({mapCoords}: PointerMoveEvent): {
102
106
  editAction: EditAction | null | undefined;
103
107
  cancelMapPan: boolean;
104
108
  } {
105
109
  const clickSequence = this.getClickSequence();
106
- const result = { editAction: null, cancelMapPan: false };
110
+ const result = {editAction: null, cancelMapPan: false};
107
111
 
108
112
  if (clickSequence.length === 0) {
109
113
  // nothing to do yet
@@ -114,8 +118,8 @@ export class SplitPolygonHandler extends ModeHandler {
114
118
  type: 'Feature',
115
119
  geometry: {
116
120
  type: 'LineString',
117
- coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords)],
118
- },
121
+ coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords)]
122
+ }
119
123
  });
120
124
 
121
125
  return result;
@@ -128,13 +132,13 @@ export class SplitPolygonHandler extends ModeHandler {
128
132
  const modeConfig = this.getModeConfig() || {};
129
133
 
130
134
  // Default gap in between the polygon
131
- let { gap = 0.1, units = 'centimeters' } = modeConfig;
135
+ let {gap = 0.1, units = 'centimeters'} = modeConfig;
132
136
  if (gap === 0) {
133
137
  gap = 0.1;
134
138
  units = 'centimeters';
135
139
  }
136
140
  // @ts-expect-error turf type diff
137
- const buffer = turfBuffer(tentativeFeature, gap, { units });
141
+ const buffer = turfBuffer(tentativeFeature, gap, {units});
138
142
  // @ts-expect-error turf type diff
139
143
  const updatedGeometry = turfDifference(selectedGeometry, buffer);
140
144
  this._setTentativeFeature(null);
@@ -144,7 +148,7 @@ export class SplitPolygonHandler extends ModeHandler {
144
148
  return null;
145
149
  }
146
150
 
147
- const { type, coordinates } = updatedGeometry.geometry;
151
+ const {type, coordinates} = updatedGeometry.geometry;
148
152
  let updatedCoordinates: any[] = []; // TODO
149
153
  if (type === 'Polygon') {
150
154
  // Update the coordinates as per Multipolygon
@@ -162,14 +166,14 @@ export class SplitPolygonHandler extends ModeHandler {
162
166
  // Update the type to Mulitpolygon
163
167
  const updatedData = this.getImmutableFeatureCollection().replaceGeometry(featureIndex, {
164
168
  type: 'MultiPolygon',
165
- coordinates: updatedCoordinates,
169
+ coordinates: updatedCoordinates
166
170
  });
167
171
 
168
172
  const editAction: EditAction = {
169
173
  updatedData: updatedData.getObject(),
170
174
  editType: 'split',
171
175
  featureIndexes: [featureIndex],
172
- editContext: null,
176
+ editContext: null
173
177
  };
174
178
 
175
179
  return editAction;
@@ -1,5 +1,9 @@
1
- import { ClickEvent } from '../edit-modes/types';
2
- import { ModeHandler, EditAction } from './mode-handler';
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {ClickEvent} from '../edit-modes/types';
6
+ import {ModeHandler, EditAction} from './mode-handler';
3
7
 
4
8
  // TODO edit-modes: delete handlers once EditMode fully implemented
5
9
  export class ThreeClickPolygonHandler extends ModeHandler {
@@ -1,10 +1,14 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import turfBearing from '@turf/bearing';
2
6
  import turfDistance from '@turf/distance';
3
7
  import turfTransformTranslate from '@turf/transform-translate';
4
- import { point } from '@turf/helpers';
5
- import { FeatureCollection, Position } from '../geojson-types';
6
- import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
7
- import { EditAction, ModeHandler } from './mode-handler';
8
+ import {point} from '@turf/helpers';
9
+ import {FeatureCollection, Position} from '../utils/geojson-types';
10
+ import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
11
+ import {EditAction, ModeHandler} from './mode-handler';
8
12
 
9
13
  // TODO edit-modes: delete handlers once EditMode fully implemented
10
14
  export class TranslateHandler extends ModeHandler {
@@ -22,7 +26,7 @@ export class TranslateHandler extends ModeHandler {
22
26
 
23
27
  if (!this._isTranslatable || !event.pointerDownMapCoords) {
24
28
  // Nothing to do
25
- return { editAction: null, cancelMapPan: false };
29
+ return {editAction: null, cancelMapPan: false};
26
30
  }
27
31
 
28
32
  if (event.isDragging && this._geometryBeforeTranslate) {
@@ -34,7 +38,7 @@ export class TranslateHandler extends ModeHandler {
34
38
  );
35
39
  }
36
40
 
37
- return { editAction, cancelMapPan: true };
41
+ return {editAction, cancelMapPan: true};
38
42
  }
39
43
 
40
44
  handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined {
@@ -62,7 +66,7 @@ export class TranslateHandler extends ModeHandler {
62
66
  return editAction;
63
67
  }
64
68
 
65
- getCursor({ isDragging }: { isDragging: boolean }): string {
69
+ getCursor({isDragging}: {isDragging: boolean}): string {
66
70
  if (this._isTranslatable) {
67
71
  return 'move';
68
72
  }
@@ -104,7 +108,7 @@ export class TranslateHandler extends ModeHandler {
104
108
  updatedData: updatedData.getObject(),
105
109
  editType,
106
110
  featureIndexes: selectedIndexes,
107
- editContext: null,
111
+ editContext: null
108
112
  };
109
113
  }
110
114
  }
@@ -1,5 +1,9 @@
1
- import { ClickEvent } from '../edit-modes/types';
2
- import { ModeHandler, EditAction } from './mode-handler';
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {ClickEvent} from '../edit-modes/types';
6
+ import {ModeHandler, EditAction} from './mode-handler';
3
7
 
4
8
  // TODO edit-modes: delete handlers once EditMode fully implemented
5
9
  export class TwoClickPolygonHandler extends ModeHandler {
@@ -1,9 +1,13 @@
1
- import { Position } from '../geojson-types';
2
- import { EditHandle, ModeHandler } from './mode-handler';
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {Position} from '../utils/geojson-types';
6
+ import {EditHandle, ModeHandler} from './mode-handler';
3
7
 
4
8
  // TODO edit-modes: delete handlers once EditMode fully implemented
5
9
  export class ViewHandler extends ModeHandler {
6
- getCursor({ isDragging }: { isDragging: boolean }): string {
10
+ getCursor({isDragging}: {isDragging: boolean}): string {
7
11
  return isDragging ? 'grabbing' : 'grab';
8
12
  }
9
13
 
@@ -1,10 +1,14 @@
1
- // TODO - this module is a WIP
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {ShaderModule} from '@luma.gl/shadertools';
2
6
 
3
7
  /* eslint-disable camelcase */
4
8
  const INITIAL_STATE: Record<string, number> = {
5
9
  color_uOpacity: 1.0,
6
10
  color_uDesaturate: 0.0,
7
- color_uBrightness: 1.0,
11
+ color_uBrightness: 1.0
8
12
  };
9
13
 
10
14
  function getUniforms(opts = INITIAL_STATE) {
@@ -48,9 +52,10 @@ vec4 color_filterColor(vec4 color) {
48
52
  }
49
53
  `;
50
54
 
51
- export default {
55
+ /** Shader module that implements desaturation. @note still WIP */
56
+ export const color = {
52
57
  name: 'color',
53
58
  vs,
54
59
  fs,
55
- getUniforms,
56
- };
60
+ getUniforms
61
+ } as const satisfies ShaderModule;
@@ -1,3 +1,7 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // TODO - this module is a WIP
2
6
 
3
7
  /* eslint-disable camelcase */
@@ -25,9 +29,9 @@ vec2 project_clipspace_to_projective_uv(vec4 position) {
25
29
 
26
30
  const fs = vs;
27
31
 
28
- export default {
32
+ export const utils = {
29
33
  name: 'outline',
30
34
  vs,
31
35
  fs,
32
- getUniforms,
36
+ getUniforms
33
37
  };
@@ -1,7 +1,11 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import hermite from 'cubic-hermite-spline';
2
6
  import turfDistance from '@turf/distance';
3
- import { lineString } from '@turf/helpers';
4
- import type { Feature, MultiLineString, LineString, Position } from '@turf/helpers';
7
+ import {lineString} from '@turf/helpers';
8
+ import type {Feature, MultiLineString, LineString, Position} from '@turf/helpers';
5
9
 
6
10
  const INTERPOLATION_INTERVAL = 0.005;
7
11
  const INTERPOLATION_THRESHOLD = 0.001;
@@ -21,7 +25,7 @@ export function generateCurveFromControlPoints(
21
25
  let prev: Position[] | null = null;
22
26
  let totalDistance = 0;
23
27
 
24
- const { coordinates: coords } = line.geometry;
28
+ const {coordinates: coords} = line.geometry;
25
29
 
26
30
  for (let i = 0; i < coords.length; i++) {
27
31
  const cur = coords[i];
@@ -37,14 +41,14 @@ export function generateCurveFromControlPoints(
37
41
  const tangents: number[][] = [];
38
42
 
39
43
  // first tangent
40
- // @ts-ignore
44
+ // @ts-expect-error TODO
41
45
  tangents.push(calculateSingleTangent(coords[0], coords[1], knots[1] - knots[0]));
42
46
 
43
47
  // second to before last
44
48
  for (let i = 1; i < coords.length - 1; i++) {
45
- // @ts-ignore
49
+ // @ts-expect-error TODO
46
50
  const A = calculateSingleTangent(coords[i], coords[i + 1], knots[i + 1] - knots[i]);
47
- // @ts-ignore
51
+ // @ts-expect-error TODO
48
52
  const B = calculateSingleTangent(coords[i - 1], coords[i], knots[i] - knots[i - 1]);
49
53
  const x = (A[0] + B[0]) / 2.0;
50
54
  const y = (A[1] + B[1]) / 2.0;
@@ -54,7 +58,7 @@ export function generateCurveFromControlPoints(
54
58
  // last tangent
55
59
  const last = coords.length - 1;
56
60
  tangents.push(
57
- // @ts-ignore
61
+ // @ts-expect-error TODO
58
62
  calculateSingleTangent(coords[last - 1], coords[last], knots[last] - knots[last - 1])
59
63
  );
60
64
 
@@ -1,6 +1,21 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // Geometry types
2
6
 
3
- export type Position = [number, number] | [number, number, number];
7
+ import type {
8
+ Point,
9
+ LineString,
10
+ Polygon,
11
+ MultiPoint,
12
+ MultiLineString,
13
+ MultiPolygon,
14
+ Position
15
+ } from 'geojson';
16
+
17
+ export {Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Position};
18
+
4
19
  export type PointCoordinates = Position;
5
20
  export type LineStringCoordinates = Position[];
6
21
  export type PolygonCoordinates = Position[][];
@@ -16,36 +31,6 @@ export type AnyCoordinates =
16
31
  | MultiLineStringCoordinates
17
32
  | MultiPolygonCoordinates;
18
33
 
19
- export type Point = {
20
- type: 'Point';
21
- coordinates: PointCoordinates;
22
- };
23
-
24
- export type LineString = {
25
- type: 'LineString';
26
- coordinates: LineStringCoordinates;
27
- };
28
-
29
- export type Polygon = {
30
- type: 'Polygon';
31
- coordinates: PolygonCoordinates;
32
- };
33
-
34
- export type MultiPoint = {
35
- type: 'MultiPoint';
36
- coordinates: MultiPointCoordinates;
37
- };
38
-
39
- export type MultiLineString = {
40
- type: 'MultiLineString';
41
- coordinates: MultiLineStringCoordinates;
42
- };
43
-
44
- export type MultiPolygon = {
45
- type: 'MultiPolygon';
46
- coordinates: MultiPolygonCoordinates;
47
- };
48
-
49
34
  export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
50
35
 
51
36
  export type Polygonal = Polygon | MultiPolygon;
@@ -1,3 +1,7 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // port from @deck.gl/core
2
6
  function isEqual(a: any, b: any) {
3
7
  if (a === b) {
@@ -26,7 +30,7 @@ function isEqual(a: any, b: any) {
26
30
  * https://en.wikipedia.org/wiki/Memoization
27
31
  * @param {function} compute - the function to be memoized
28
32
  */
29
- export default function memoize(compute: Function) {
33
+ export function memoize(compute: Function) {
30
34
  let cachedArgs = {};
31
35
  let cachedResult;
32
36
 
@@ -1,3 +1,7 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import turfCenter from '@turf/center';
2
6
  import turfRhumbBearing from '@turf/rhumb-bearing';
3
7
  import turfRhumbDistance from '@turf/rhumb-distance';
@@ -5,10 +9,10 @@ import turfRhumbDestination from '@turf/rhumb-destination';
5
9
  import type {
6
10
  Position as TurfPosition,
7
11
  Feature as TurfFeature,
8
- Geometry as TurfGeometry,
12
+ Geometry as TurfGeometry
9
13
  } from '@turf/helpers';
10
- import { mapCoords } from './edit-modes/utils';
11
- import type { AnyCoordinates, Position } from './';
14
+ import {mapCoords} from '../edit-modes/utils';
15
+ import type {AnyCoordinates, Position} from './geojson-types';
12
16
 
13
17
  // This function takes feature's center, moves it,
14
18
  // and builds new feature around it keeping the proportions
@@ -38,7 +42,7 @@ export function translateFromCenter(
38
42
  distance,
39
43
  direction
40
44
  ).geometry.coordinates;
41
- return movedPosition as Position;
45
+ return movedPosition;
42
46
  }
43
47
  );
44
48
 
@@ -1,3 +1,7 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  export type LayerMouseEventResult = {
2
6
  eventConsumed?: boolean;
3
7
  eventSoftConsumed?: boolean;
@@ -1,14 +1,18 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import destination from '@turf/destination';
2
6
  import bearing from '@turf/bearing';
3
7
  import pointToLineDistance from '@turf/point-to-line-distance';
4
- import { point } from '@turf/helpers';
8
+ import {point} from '@turf/helpers';
5
9
  import WebMercatorViewport from 'viewport-mercator-project';
6
- import { FeatureOf, FeatureWithProps, LineString, Point, Position } from './geojson-types';
7
- import { Viewport } from './types';
10
+ import {FeatureOf, FeatureWithProps, LineString, Point, Position} from './geojson-types';
11
+ import {Viewport} from './types';
8
12
 
9
13
  // TODO edit-modes: delete and use edit-modes/utils instead
10
14
 
11
- export type NearestPointType = FeatureWithProps<Point, { dist: number; index: number }>;
15
+ export type NearestPointType = FeatureWithProps<Point, {dist: number; index: number}>;
12
16
 
13
17
  export function toDeckColor(
14
18
  color?: [number, number, number, number] | number,
@@ -69,7 +73,7 @@ export function generatePointsParallelToLinePoints(
69
73
  ): Position[] {
70
74
  const lineString: LineString = {
71
75
  type: 'LineString',
72
- coordinates: [p1, p2],
76
+ coordinates: [p1, p2]
73
77
  };
74
78
  const pt = point(mapCoords);
75
79
  const ddistance = pointToLineDistance(pt, lineString);
@@ -140,11 +144,11 @@ export function nearestPointOnProjectedLine(
140
144
  minPointInfo = {
141
145
  index,
142
146
  x0: (B * (B * x - A * y) - A * C) / div,
143
- y0: (A * (-B * x + A * y) - B * C) / div,
147
+ y0: (A * (-B * x + A * y) - B * C) / div
144
148
  };
145
149
  }
146
150
  });
147
- const { index, x0, y0 } = minPointInfo as any;
151
+ const {index, x0, y0} = minPointInfo as any;
148
152
  const [x1, y1, z1 = 0] = projectedCoords[index - 1];
149
153
  const [x2, y2, z2 = 0] = projectedCoords[index];
150
154
 
@@ -158,14 +162,13 @@ export function nearestPointOnProjectedLine(
158
162
  type: 'Feature',
159
163
  geometry: {
160
164
  type: 'Point',
161
- // @ts-expect-error Position type diff
162
- coordinates: wmViewport.unproject([x0, y0, z0]),
165
+ coordinates: wmViewport.unproject([x0, y0, z0])
163
166
  },
164
167
  properties: {
165
168
  // TODO: calculate the distance in proper units
166
169
  dist: minDistance,
167
- index: index - 1,
168
- },
170
+ index: index - 1
171
+ }
169
172
  };
170
173
  }
171
174
 
@@ -1,4 +0,0 @@
1
- import { Geometry } from '@luma.gl/engine';
2
- export default class Arrow2DGeometry extends Geometry {
3
- constructor(opts?: {});
4
- }
@@ -1,55 +0,0 @@
1
- import { Geometry } from '@luma.gl/engine';
2
- export default class Arrow2DGeometry extends Geometry {
3
- constructor(opts = {}) {
4
- super(Object.assign({}, opts, {
5
- attributes: getArrowAttributes(opts),
6
- topology: 'triangle-list'
7
- }));
8
- }
9
- }
10
- function getArrowAttributes({ length = 1, headSize = 0.2, tailWidth = 0.05, tailStart = 0.05 }) {
11
- const texCoords = [
12
- // HEAD
13
- 0.5,
14
- 1.0,
15
- 0,
16
- 0.5 - headSize / 2,
17
- 1.0 - headSize,
18
- 0,
19
- 0.5 + headSize / 2,
20
- 1.0 - headSize,
21
- 0,
22
- 0.5 - tailWidth / 2,
23
- tailStart,
24
- 0,
25
- 0.5 + tailWidth / 2,
26
- 1.0 - headSize,
27
- 0,
28
- 0.5 + tailWidth / 2,
29
- tailStart,
30
- 0,
31
- 0.5 - tailWidth / 2,
32
- tailStart,
33
- 0,
34
- 0.5 - tailWidth / 2,
35
- 1.0 - headSize,
36
- 0,
37
- 0.5 + tailWidth / 2,
38
- 1.0 - headSize,
39
- 0,
40
- ];
41
- const normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1];
42
- // Center and scale
43
- const positions = new Array(texCoords.length);
44
- for (let i = 0; i < texCoords.length / 3; i++) {
45
- const i3 = i * 3;
46
- positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length;
47
- positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length;
48
- positions[i3 + 2] = 0;
49
- }
50
- return {
51
- positions: { size: 3, value: new Float32Array(positions) },
52
- normals: { size: 3, value: new Float32Array(normals) },
53
- texCoords: { size: 2, value: new Float32Array(texCoords) },
54
- };
55
- }
@@ -1,16 +0,0 @@
1
- import { Position } from '../../geojson-types';
2
- import { Color } from '../../types';
3
- export interface PathMarker {
4
- position: Position;
5
- angle: number;
6
- color: Color;
7
- object: unknown;
8
- }
9
- export default function createPathMarkers({ data, getPath, getDirection, getColor, getMarkerPercentages, projectFlat, }: {
10
- data: any;
11
- getPath?: (x: any, context: any) => any;
12
- getDirection?: (x: any) => any;
13
- getColor?: (x: any) => number[];
14
- getMarkerPercentages?: (x: any, info: any) => number[];
15
- projectFlat: any;
16
- }): PathMarker[];
@@ -1,75 +0,0 @@
1
- import { Vector2 } from '@math.gl/core';
2
- function getLineLength(vPoints) {
3
- // calculate total length
4
- let lineLength = 0;
5
- for (let i = 0; i < vPoints.length - 1; i++) {
6
- lineLength += vPoints[i].distance(vPoints[i + 1]);
7
- }
8
- return lineLength;
9
- }
10
- const DEFAULT_COLOR = [0, 0, 0, 255];
11
- const DEFAULT_DIRECTION = { forward: true, backward: false };
12
- export default function createPathMarkers({ data, getPath = (x, context) => x.path, getDirection = (x) => x.direction, getColor = (x) => DEFAULT_COLOR, getMarkerPercentages = (x, info) => [0.5], projectFlat, }) {
13
- const markers = [];
14
- for (const object of data) {
15
- const path = getPath(object, null);
16
- const direction = getDirection(object) || DEFAULT_DIRECTION;
17
- const color = getColor(object);
18
- const vPoints = path.map((p) => new Vector2(p));
19
- const vPointsReverse = vPoints.slice(0).reverse();
20
- // calculate total length
21
- const lineLength = getLineLength(vPoints);
22
- // Ask for where to put markers
23
- const percentages = getMarkerPercentages(object, { lineLength });
24
- // Create the markers
25
- for (const percentage of percentages) {
26
- if (direction.forward) {
27
- const marker = createMarkerAlongPath({
28
- path: vPoints,
29
- percentage,
30
- lineLength,
31
- color,
32
- object,
33
- projectFlat,
34
- });
35
- markers.push(marker);
36
- }
37
- if (direction.backward) {
38
- const marker = createMarkerAlongPath({
39
- path: vPointsReverse,
40
- percentage,
41
- lineLength,
42
- color,
43
- object,
44
- projectFlat,
45
- });
46
- markers.push(marker);
47
- }
48
- }
49
- }
50
- return markers;
51
- }
52
- function createMarkerAlongPath({ path, percentage, lineLength, color, object, projectFlat }) {
53
- const distanceAlong = lineLength * percentage;
54
- let currentDistance = 0;
55
- let previousDistance = 0;
56
- let i = 0;
57
- for (i = 0; i < path.length - 1; i++) {
58
- currentDistance += path[i].distance(path[i + 1]);
59
- if (currentDistance > distanceAlong) {
60
- break;
61
- }
62
- previousDistance = currentDistance;
63
- }
64
- // If reached the end of the loop without exiting early,
65
- // undo the final increment to avoid a null-pointer exception
66
- if (i === path.length - 1) {
67
- i -= 1;
68
- }
69
- const vDirection = path[i + 1].clone().subtract(path[i]).normalize();
70
- const along = distanceAlong - previousDistance;
71
- const vCenter = vDirection.clone().multiply(new Vector2(along, along)).add(path[i]);
72
- const vDirection2 = new Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i]));
73
- const angle = (vDirection2.verticalAngle() * 180) / Math.PI;
74
- return { position: [vCenter.x, vCenter.y, 0], angle, color, object };
75
- }