@macrostrat/column-views 3.8.0 → 3.10.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 (173) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/dist/animated-age-window.cjs +51 -0
  3. package/dist/animated-age-window.cjs.map +1 -0
  4. package/dist/animated-age-window.d.ts +51 -0
  5. package/dist/animated-age-window.js +51 -0
  6. package/dist/animated-age-window.js.map +1 -0
  7. package/dist/column.cjs +11 -1
  8. package/dist/column.cjs.map +1 -1
  9. package/dist/column.d.ts +11 -0
  10. package/dist/column.js +11 -1
  11. package/dist/column.js.map +1 -1
  12. package/dist/correlation-chart/main.cjs +24 -12
  13. package/dist/correlation-chart/main.cjs.map +1 -1
  14. package/dist/correlation-chart/main.d.ts +8 -1
  15. package/dist/correlation-chart/main.js +24 -12
  16. package/dist/correlation-chart/main.js.map +1 -1
  17. package/dist/data-provider/store.cjs +17 -4
  18. package/dist/data-provider/store.cjs.map +1 -1
  19. package/dist/data-provider/store.d.ts +6 -1
  20. package/dist/data-provider/store.js +17 -4
  21. package/dist/data-provider/store.js.map +1 -1
  22. package/dist/index.cjs +17 -42
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +3 -1
  25. package/dist/index.js +3 -34
  26. package/dist/index.js.map +1 -1
  27. package/dist/prepare-units/composite-scale.cjs +94 -8
  28. package/dist/prepare-units/composite-scale.cjs.map +1 -1
  29. package/dist/prepare-units/composite-scale.d.ts +39 -0
  30. package/dist/prepare-units/composite-scale.js +96 -10
  31. package/dist/prepare-units/composite-scale.js.map +1 -1
  32. package/dist/prepare-units/helpers.cjs +0 -1
  33. package/dist/prepare-units/helpers.cjs.map +1 -1
  34. package/dist/prepare-units/helpers.js +0 -1
  35. package/dist/prepare-units/helpers.js.map +1 -1
  36. package/dist/prepare-units/index.cjs +33 -12
  37. package/dist/prepare-units/index.cjs.map +1 -1
  38. package/dist/prepare-units/index.js +34 -13
  39. package/dist/prepare-units/index.js.map +1 -1
  40. package/dist/prepare-units/types.cjs.map +1 -1
  41. package/dist/prepare-units/types.d.ts +13 -0
  42. package/dist/prepare-units/types.js.map +1 -1
  43. package/dist/section.cjs +4 -2
  44. package/dist/section.cjs.map +1 -1
  45. package/dist/section.d.ts +4 -1
  46. package/dist/section.js +4 -2
  47. package/dist/section.js.map +1 -1
  48. package/dist/units/boxes.cjs +22 -39
  49. package/dist/units/boxes.cjs.map +1 -1
  50. package/dist/units/boxes.js +24 -41
  51. package/dist/units/boxes.js.map +1 -1
  52. package/dist/units/composite.cjs +12 -12
  53. package/dist/units/composite.cjs.map +1 -1
  54. package/dist/units/composite.js +12 -12
  55. package/dist/units/composite.js.map +1 -1
  56. package/dist/units/index.cjs +7 -11
  57. package/dist/units/index.cjs.map +1 -1
  58. package/dist/units/index.d.ts +0 -1
  59. package/dist/units/index.js +4 -9
  60. package/dist/units/index.js.map +1 -1
  61. package/package.json +10 -31
  62. package/src/animated-age-window.ts +120 -0
  63. package/src/column.ts +24 -0
  64. package/src/correlation-chart/main.ts +30 -8
  65. package/src/data-provider/store.ts +21 -2
  66. package/src/index.ts +4 -1
  67. package/src/prepare-units/composite-scale.ts +210 -10
  68. package/src/prepare-units/helpers.ts +0 -2
  69. package/src/prepare-units/index.ts +68 -14
  70. package/src/prepare-units/types.ts +13 -0
  71. package/src/section.ts +6 -0
  72. package/src/units/boxes.ts +37 -56
  73. package/src/units/composite.ts +21 -12
  74. package/src/units/index.ts +9 -26
  75. package/dist/maps/column-correlation/core.cjs +0 -288
  76. package/dist/maps/column-correlation/core.cjs.map +0 -1
  77. package/dist/maps/column-correlation/core.d.ts +0 -9
  78. package/dist/maps/column-correlation/core.js +0 -286
  79. package/dist/maps/column-correlation/core.js.map +0 -1
  80. package/dist/maps/column-correlation/index.d.ts +0 -2
  81. package/dist/maps/column-correlation/state.cjs +0 -193
  82. package/dist/maps/column-correlation/state.cjs.map +0 -1
  83. package/dist/maps/column-correlation/state.d.ts +0 -62
  84. package/dist/maps/column-correlation/state.js +0 -190
  85. package/dist/maps/column-correlation/state.js.map +0 -1
  86. package/dist/maps/column-navigation/index.d.ts +0 -2
  87. package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
  88. package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
  89. package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
  90. package/dist/maps/column-navigation/mapbox/index.js +0 -213
  91. package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
  92. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
  93. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
  94. package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
  95. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
  96. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
  97. package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
  98. package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
  99. package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
  100. package/dist/maps/column-navigation/mapbox/state.js +0 -71
  101. package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
  102. package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
  103. package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
  104. package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
  105. package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
  106. package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
  107. package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
  108. package/dist/maps/column-navigation/svg/index.cjs +0 -94
  109. package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
  110. package/dist/maps/column-navigation/svg/index.d.ts +0 -9
  111. package/dist/maps/column-navigation/svg/index.js +0 -93
  112. package/dist/maps/column-navigation/svg/index.js.map +0 -1
  113. package/dist/maps/column-navigation/svg/layers.cjs +0 -177
  114. package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
  115. package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
  116. package/dist/maps/column-navigation/svg/layers.js +0 -174
  117. package/dist/maps/column-navigation/svg/layers.js.map +0 -1
  118. package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
  119. package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
  120. package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
  121. package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
  122. package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
  123. package/dist/maps/index.d.ts +0 -4
  124. package/dist/maps/inset-map/index.cjs +0 -71
  125. package/dist/maps/inset-map/index.cjs.map +0 -1
  126. package/dist/maps/inset-map/index.d.ts +0 -16
  127. package/dist/maps/inset-map/index.js +0 -69
  128. package/dist/maps/inset-map/index.js.map +0 -1
  129. package/dist/maps/layers/columns.cjs +0 -165
  130. package/dist/maps/layers/columns.cjs.map +0 -1
  131. package/dist/maps/layers/columns.d.ts +0 -28
  132. package/dist/maps/layers/columns.js +0 -165
  133. package/dist/maps/layers/columns.js.map +0 -1
  134. package/dist/maps/layers/index.d.ts +0 -2
  135. package/dist/maps/layers/units.cjs +0 -207
  136. package/dist/maps/layers/units.cjs.map +0 -1
  137. package/dist/maps/layers/units.d.ts +0 -14
  138. package/dist/maps/layers/units.js +0 -204
  139. package/dist/maps/layers/units.js.map +0 -1
  140. package/dist/units/colors.cjs +0 -115
  141. package/dist/units/colors.cjs.map +0 -1
  142. package/dist/units/colors.d.ts +0 -20
  143. package/dist/units/colors.js +0 -113
  144. package/dist/units/colors.js.map +0 -1
  145. package/dist/units/resolvers.cjs +0 -125
  146. package/dist/units/resolvers.cjs.map +0 -1
  147. package/dist/units/resolvers.d.ts +0 -8
  148. package/dist/units/resolvers.js +0 -125
  149. package/dist/units/resolvers.js.map +0 -1
  150. package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
  151. package/src/maps/column-correlation/core.ts +0 -342
  152. package/src/maps/column-correlation/index.ts +0 -2
  153. package/src/maps/column-correlation/state.ts +0 -315
  154. package/src/maps/column-navigation/index.ts +0 -2
  155. package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
  156. package/src/maps/column-navigation/mapbox/index.ts +0 -276
  157. package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
  158. package/src/maps/column-navigation/mapbox/state.ts +0 -119
  159. package/src/maps/column-navigation/svg/animated.ts +0 -78
  160. package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
  161. package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
  162. package/src/maps/column-navigation/svg/index.ts +0 -96
  163. package/src/maps/column-navigation/svg/layers.ts +0 -233
  164. package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
  165. package/src/maps/index.ts +0 -4
  166. package/src/maps/inset-map/index.ts +0 -87
  167. package/src/maps/inset-map/inset-map.stories.ts +0 -20
  168. package/src/maps/layers/columns.ts +0 -216
  169. package/src/maps/layers/index.ts +0 -2
  170. package/src/maps/layers/units.ts +0 -286
  171. package/src/maps/unit-map.stories.ts +0 -79
  172. package/src/units/colors.ts +0 -183
  173. package/src/units/resolvers.ts +0 -141
@@ -1,286 +0,0 @@
1
- import { useOverlayStyle, useMapStyleOperator, useMapClickHandler, useMapEaseTo } from "@macrostrat/mapbox-react";
2
- import { LngLatBounds } from "mapbox-gl";
3
- import h from "@macrostrat/hyper";
4
- import { useRef, useMemo } from "react";
5
- import { setGeoJSON, buildGeoJSONSource } from "@macrostrat/mapbox-utils";
6
- import { useCorrelationMapStore } from "./state.js";
7
- import { InsetMap } from "../inset-map/index.js";
8
- import { buildCrossSectionLayers } from "@macrostrat/map-styles";
9
- import { BaseColumnsLayer } from "../layers/columns.js";
10
- function ColumnCorrelationMap(props) {
11
- const { padding = 50, children, columnColor, projectID, ...rest } = props;
12
- return h(
13
- InsetMap,
14
- {
15
- ...rest,
16
- boxZoom: false,
17
- dragRotate: false
18
- },
19
- [
20
- h(ColumnsLayer, { color: columnColor }),
21
- h(SelectedColumnsLayer),
22
- h(MapClickHandler),
23
- h(ColumnInteractionHandler),
24
- h(HoveredColumnHighlight),
25
- h(ColumnZoomer, { padding }),
26
- h(SectionLine, { padding }),
27
- children
28
- ]
29
- );
30
- }
31
- function ColumnZoomer({ padding }) {
32
- const zoomColumn = useCorrelationMapStore((state) => state.zoomColumn);
33
- const zoomNonce = useCorrelationMapStore((state) => state.zoomNonce);
34
- const columns = useCorrelationMapStore((state) => state.columns);
35
- const bounds = useMemo(() => {
36
- if (zoomColumn == null || columns == null) return null;
37
- const col = columns.find((c) => c.properties?.col_id === zoomColumn);
38
- if (col?.geometry == null) return null;
39
- const b = new LngLatBounds();
40
- forEachCoordinate(col.geometry, (coord) => b.extend(coord));
41
- return b.isEmpty() ? null : b;
42
- }, [zoomColumn, zoomNonce, columns]);
43
- useMapEaseTo({ bounds, padding: padding * 2 });
44
- return null;
45
- }
46
- function forEachCoordinate(geometry, fn) {
47
- const walk = (coords) => {
48
- if (typeof coords[0] === "number") {
49
- fn(coords);
50
- } else {
51
- for (const c of coords) walk(c);
52
- }
53
- };
54
- if (geometry?.coordinates != null) walk(geometry.coordinates);
55
- }
56
- const columnLayers = ["columns-fill", "columns-points"];
57
- function MapClickHandler() {
58
- const onClickMap = useCorrelationMapStore((state) => state.onClickMap);
59
- useMapClickHandler(
60
- (e) => {
61
- onClickMap(e, { type: "Point", coordinates: e.lngLat.toArray() });
62
- },
63
- [onClickMap]
64
- );
65
- return null;
66
- }
67
- function ColumnInteractionHandler() {
68
- const toggleColumn = useCorrelationMapStore((state) => state.toggleColumn);
69
- const setHoveredColumn = useCorrelationMapStore(
70
- (state) => state.setHoveredColumn
71
- );
72
- const isManual = useCorrelationMapStore(
73
- (state) => state.selectionMode === "manual"
74
- );
75
- const hoveredRef = useRef(null);
76
- useMapStyleOperator(
77
- (map) => {
78
- if (!isManual) return;
79
- const onClick = (e) => {
80
- const colID = e.features?.[0]?.properties?.col_id;
81
- if (colID != null) toggleColumn(colID);
82
- };
83
- map.on("click", columnLayers, onClick);
84
- return () => map.off("click", columnLayers, onClick);
85
- },
86
- [isManual, toggleColumn]
87
- );
88
- useMapStyleOperator(
89
- (map) => {
90
- const clearHover = () => {
91
- if (hoveredRef.current != null) {
92
- map.setFeatureState(
93
- { source: "columns", id: hoveredRef.current },
94
- { hover: false }
95
- );
96
- hoveredRef.current = null;
97
- }
98
- };
99
- const onMove = (e) => {
100
- const f = e.features?.[0];
101
- if (f == null) return;
102
- if (hoveredRef.current !== f.id) {
103
- clearHover();
104
- map.setFeatureState({ source: "columns", id: f.id }, { hover: true });
105
- hoveredRef.current = f.id;
106
- }
107
- setHoveredColumn(f.properties?.col_id ?? null);
108
- map.getCanvas().style.cursor = "pointer";
109
- };
110
- const onLeave = () => {
111
- clearHover();
112
- setHoveredColumn(null);
113
- map.getCanvas().style.cursor = "";
114
- };
115
- map.on("mousemove", columnLayers, onMove);
116
- map.on("mouseleave", columnLayers, onLeave);
117
- return () => {
118
- map.off("mousemove", columnLayers, onMove);
119
- map.off("mouseleave", columnLayers, onLeave);
120
- clearHover();
121
- };
122
- },
123
- [setHoveredColumn]
124
- );
125
- return null;
126
- }
127
- function HoveredColumnHighlight() {
128
- const hoveredColumn = useCorrelationMapStore((state) => state.hoveredColumn);
129
- const columns = useCorrelationMapStore((state) => state.columns);
130
- const appliedRef = useRef(null);
131
- useMapStyleOperator(
132
- (map) => {
133
- if (appliedRef.current != null) {
134
- map.setFeatureState(
135
- { source: "columns", id: appliedRef.current },
136
- { highlighted: false }
137
- );
138
- appliedRef.current = null;
139
- }
140
- if (hoveredColumn == null || columns == null) return;
141
- const col = columns.find((c) => c.properties?.col_id === hoveredColumn);
142
- const id = col?.id ?? col?.properties?.col_id;
143
- if (id == null) return;
144
- map.setFeatureState({ source: "columns", id }, { highlighted: true });
145
- appliedRef.current = id;
146
- },
147
- [hoveredColumn, columns]
148
- );
149
- return null;
150
- }
151
- function SelectedColumnsLayer() {
152
- useOverlayStyle(() => selectedColumnsStyle, []);
153
- const focusedColumns = useCorrelationMapStore(
154
- (state) => state.focusedColumns
155
- );
156
- useMapStyleOperator(
157
- (map) => {
158
- let features = focusedColumns;
159
- const data = {
160
- type: "FeatureCollection",
161
- features
162
- };
163
- const columnCentroidLine = {
164
- type: "Feature",
165
- geometry: {
166
- type: "LineString",
167
- coordinates: features.map(
168
- (col) => col.properties.centroid.geometry.coordinates
169
- )
170
- },
171
- properties: {}
172
- };
173
- setGeoJSON(map, "selected-columns", data);
174
- setGeoJSON(map, "selected-column-centroids", {
175
- type: "FeatureCollection",
176
- features: [columnCentroidLine]
177
- });
178
- },
179
- [focusedColumns]
180
- );
181
- return null;
182
- }
183
- function ColumnsLayer({ enabled = true, color }) {
184
- const columns = useCorrelationMapStore((state) => state.columns);
185
- return h(BaseColumnsLayer, { enabled, color, columns });
186
- }
187
- const selectedColumnsStyle = {
188
- version: 8,
189
- sources: {
190
- "selected-columns": buildGeoJSONSource(),
191
- "selected-column-centroids": buildGeoJSONSource()
192
- },
193
- layers: [
194
- {
195
- id: "selected-columns-fill",
196
- type: "fill",
197
- source: "selected-columns",
198
- paint: {
199
- "fill-color": "rgba(255, 0, 0, 0.1)"
200
- }
201
- },
202
- {
203
- id: "selected-column-centroids-line",
204
- type: "line",
205
- source: "selected-column-centroids",
206
- paint: {
207
- "line-color": "rgba(255, 0, 0, 0.8)",
208
- "line-width": 2,
209
- "line-dasharray": [2, 2]
210
- }
211
- },
212
- {
213
- id: "selected-column-centroids-points",
214
- type: "circle",
215
- source: "selected-column-centroids",
216
- paint: {
217
- "circle-radius": 4,
218
- "circle-color": "rgba(255, 0, 0, 0.8)"
219
- }
220
- }
221
- ]
222
- };
223
- const lineOfSectionStyle = {
224
- version: 8,
225
- sources: {
226
- elevationMarker: buildGeoJSONSource(),
227
- crossSectionLine: buildGeoJSONSource(),
228
- crossSectionEndpoints: buildGeoJSONSource()
229
- },
230
- layers: buildCrossSectionLayers()
231
- };
232
- function SectionLine({ padding }) {
233
- useOverlayStyle(() => lineOfSectionStyle, []);
234
- const focusedLine = useCorrelationMapStore((state) => state.focusedLine);
235
- const focusedColumns = useCorrelationMapStore(
236
- (state) => state.focusedColumns
237
- );
238
- useMapStyleOperator(
239
- (map) => {
240
- if (focusedLine == null) {
241
- setGeoJSON(map, "crossSectionLine", emptyFeatureCollection);
242
- setGeoJSON(map, "crossSectionEndpoints", emptyFeatureCollection);
243
- return;
244
- }
245
- const data = {
246
- type: "FeatureCollection",
247
- features: [
248
- {
249
- type: "Feature",
250
- geometry: focusedLine,
251
- properties: { id: "focusedLine" }
252
- }
253
- ]
254
- };
255
- setGeoJSON(map, "crossSectionLine", data);
256
- setGeoJSON(map, "crossSectionEndpoints", {
257
- type: "FeatureCollection",
258
- features: focusedLine.coordinates.map((coord) => ({
259
- type: "Feature",
260
- geometry: { type: "Point", coordinates: coord },
261
- properties: {}
262
- }))
263
- });
264
- },
265
- [focusedLine]
266
- );
267
- const bounds = useMemo(() => {
268
- const coords = focusedLine != null && focusedLine.coordinates.length >= 2 ? focusedLine.coordinates : focusedColumns.map((c) => c.properties.centroid.geometry.coordinates);
269
- if (coords.length < 2) return null;
270
- const bounds2 = new LngLatBounds();
271
- for (const coord of coords) {
272
- bounds2.extend(coord);
273
- }
274
- return bounds2;
275
- }, [focusedLine, focusedColumns]);
276
- useMapEaseTo({ bounds, padding, trackResize: true });
277
- return null;
278
- }
279
- const emptyFeatureCollection = {
280
- type: "FeatureCollection",
281
- features: []
282
- };
283
- export {
284
- ColumnCorrelationMap
285
- };
286
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","sources":["../../../src/maps/column-correlation/core.ts"],"sourcesContent":["import {\n useMapClickHandler,\n useMapEaseTo,\n useMapStyleOperator,\n useOverlayStyle,\n} from \"@macrostrat/mapbox-react\";\nimport { LngLatBounds, Style } from \"mapbox-gl\";\nimport h from \"@macrostrat/hyper\";\nimport { Feature, FeatureCollection } from \"geojson\";\nimport { ReactNode, useMemo, useRef } from \"react\";\nimport { setGeoJSON, buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\n\nimport { useCorrelationMapStore } from \"./state\";\nimport { InsetMap, type InsetMapProps } from \"../inset-map\";\nimport { BaseColumnsLayer } from \"../layers\";\nimport { buildCrossSectionLayers } from \"@macrostrat/map-styles\";\n\nexport interface CorrelationMapProps extends InsetMapProps {\n padding?: number;\n children?: ReactNode;\n accessToken?: string;\n columnColor?: string;\n}\n\nexport function ColumnCorrelationMap(props: CorrelationMapProps) {\n const { padding = 50, children, columnColor, projectID, ...rest } = props;\n\n return h(\n InsetMap,\n {\n ...rest,\n boxZoom: false,\n dragRotate: false,\n },\n [\n h(ColumnsLayer, { color: columnColor }),\n h(SelectedColumnsLayer),\n h(MapClickHandler),\n h(ColumnInteractionHandler),\n h(HoveredColumnHighlight),\n h(ColumnZoomer, { padding }),\n h(SectionLine, { padding }),\n children,\n ],\n );\n}\n\nfunction ColumnZoomer({ padding }: { padding: number }) {\n /** Frame a single column when `zoomColumn` is set (e.g. header click). */\n const zoomColumn = useCorrelationMapStore((state) => state.zoomColumn);\n const zoomNonce = useCorrelationMapStore((state) => state.zoomNonce);\n const columns = useCorrelationMapStore((state) => state.columns);\n\n const bounds = useMemo(() => {\n if (zoomColumn == null || columns == null) return null;\n const col = columns.find((c) => c.properties?.col_id === zoomColumn);\n if (col?.geometry == null) return null;\n const b = new LngLatBounds();\n forEachCoordinate(col.geometry, (coord) => b.extend(coord as [number, number]));\n return b.isEmpty() ? null : b;\n // zoomNonce forces a fresh bounds object so repeat clicks re-frame\n }, [zoomColumn, zoomNonce, columns]);\n\n useMapEaseTo({ bounds, padding: padding * 2 });\n return null;\n}\n\nfunction forEachCoordinate(geometry: any, fn: (coord: number[]) => void) {\n const walk = (coords: any) => {\n if (typeof coords[0] === \"number\") {\n fn(coords);\n } else {\n for (const c of coords) walk(c);\n }\n };\n if (geometry?.coordinates != null) walk(geometry.coordinates);\n}\n\nconst columnLayers = [\"columns-fill\", \"columns-points\"];\n\nfunction MapClickHandler() {\n const onClickMap = useCorrelationMapStore((state) => state.onClickMap);\n\n useMapClickHandler(\n (e) => {\n onClickMap(e, { type: \"Point\", coordinates: e.lngLat.toArray() });\n },\n [onClickMap],\n );\n\n return null;\n}\n\nfunction ColumnInteractionHandler() {\n /** Per-column click (manual selection) and hover highlighting. */\n const toggleColumn = useCorrelationMapStore((state) => state.toggleColumn);\n const setHoveredColumn = useCorrelationMapStore(\n (state) => state.setHoveredColumn,\n );\n const isManual = useCorrelationMapStore(\n (state) => state.selectionMode === \"manual\",\n );\n const hoveredRef = useRef<number | string | null>(null);\n\n // Click a column to toggle it in/out of the selection (manual mode only)\n useMapStyleOperator(\n (map) => {\n if (!isManual) return;\n const onClick = (e) => {\n const colID = e.features?.[0]?.properties?.col_id;\n if (colID != null) toggleColumn(colID);\n };\n map.on(\"click\", columnLayers, onClick);\n return () => map.off(\"click\", columnLayers, onClick);\n },\n [isManual, toggleColumn],\n );\n\n // Hover highlighting (via the columns layer's `hover` feature-state)\n useMapStyleOperator(\n (map) => {\n const clearHover = () => {\n if (hoveredRef.current != null) {\n map.setFeatureState(\n { source: \"columns\", id: hoveredRef.current },\n { hover: false },\n );\n hoveredRef.current = null;\n }\n };\n const onMove = (e) => {\n const f = e.features?.[0];\n if (f == null) return;\n if (hoveredRef.current !== f.id) {\n clearHover();\n map.setFeatureState({ source: \"columns\", id: f.id }, { hover: true });\n hoveredRef.current = f.id;\n }\n setHoveredColumn(f.properties?.col_id ?? null);\n map.getCanvas().style.cursor = \"pointer\";\n };\n const onLeave = () => {\n clearHover();\n setHoveredColumn(null);\n map.getCanvas().style.cursor = \"\";\n };\n map.on(\"mousemove\", columnLayers, onMove);\n map.on(\"mouseleave\", columnLayers, onLeave);\n return () => {\n map.off(\"mousemove\", columnLayers, onMove);\n map.off(\"mouseleave\", columnLayers, onLeave);\n clearHover();\n };\n },\n [setHoveredColumn],\n );\n\n return null;\n}\n\nfunction HoveredColumnHighlight() {\n /** Reflects the store's `hoveredColumn` on the map (e.g. when a column is\n * hovered elsewhere in the UI) using the `highlighted` feature-state. */\n const hoveredColumn = useCorrelationMapStore((state) => state.hoveredColumn);\n const columns = useCorrelationMapStore((state) => state.columns);\n const appliedRef = useRef<number | string | null>(null);\n\n useMapStyleOperator(\n (map) => {\n if (appliedRef.current != null) {\n map.setFeatureState(\n { source: \"columns\", id: appliedRef.current },\n { highlighted: false },\n );\n appliedRef.current = null;\n }\n if (hoveredColumn == null || columns == null) return;\n const col = columns.find((c) => c.properties?.col_id === hoveredColumn);\n const id = (col as any)?.id ?? col?.properties?.col_id;\n if (id == null) return;\n map.setFeatureState({ source: \"columns\", id }, { highlighted: true });\n appliedRef.current = id;\n },\n [hoveredColumn, columns],\n );\n\n return null;\n}\n\nfunction SelectedColumnsLayer() {\n useOverlayStyle(() => selectedColumnsStyle, []);\n\n const focusedColumns = useCorrelationMapStore(\n (state) => state.focusedColumns,\n );\n\n useMapStyleOperator(\n (map) => {\n let features = focusedColumns;\n\n const data: FeatureCollection = {\n type: \"FeatureCollection\",\n features,\n };\n\n const columnCentroidLine: Feature = {\n type: \"Feature\",\n geometry: {\n type: \"LineString\",\n coordinates: features.map(\n (col) => col.properties.centroid.geometry.coordinates,\n ),\n },\n properties: {},\n };\n\n setGeoJSON(map, \"selected-columns\", data);\n setGeoJSON(map, \"selected-column-centroids\", {\n type: \"FeatureCollection\",\n features: [columnCentroidLine],\n });\n },\n [focusedColumns],\n );\n return null;\n}\n\nfunction ColumnsLayer({ enabled = true, color }) {\n const columns = useCorrelationMapStore((state) => state.columns);\n return h(BaseColumnsLayer, { enabled, color, columns });\n}\n\nconst selectedColumnsStyle: Style = {\n version: 8,\n sources: {\n \"selected-columns\": buildGeoJSONSource(),\n \"selected-column-centroids\": buildGeoJSONSource(),\n },\n layers: [\n {\n id: \"selected-columns-fill\",\n type: \"fill\",\n source: \"selected-columns\",\n paint: {\n \"fill-color\": \"rgba(255, 0, 0, 0.1)\",\n },\n },\n {\n id: \"selected-column-centroids-line\",\n type: \"line\",\n source: \"selected-column-centroids\",\n paint: {\n \"line-color\": \"rgba(255, 0, 0, 0.8)\",\n \"line-width\": 2,\n \"line-dasharray\": [2, 2],\n },\n },\n {\n id: \"selected-column-centroids-points\",\n type: \"circle\",\n source: \"selected-column-centroids\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": \"rgba(255, 0, 0, 0.8)\",\n },\n },\n ],\n};\n\nconst lineOfSectionStyle: Style = {\n version: 8,\n sources: {\n elevationMarker: buildGeoJSONSource(),\n crossSectionLine: buildGeoJSONSource(),\n crossSectionEndpoints: buildGeoJSONSource(),\n },\n layers: buildCrossSectionLayers(),\n};\n\nfunction SectionLine({ padding }: { padding: number }) {\n useOverlayStyle(() => lineOfSectionStyle, []);\n const focusedLine = useCorrelationMapStore((state) => state.focusedLine);\n const focusedColumns = useCorrelationMapStore(\n (state) => state.focusedColumns,\n );\n\n // Setup focused line (only drawn in line-of-section mode)\n useMapStyleOperator(\n (map) => {\n if (focusedLine == null) {\n // Clear any previously-drawn line (e.g. after switching to manual mode)\n setGeoJSON(map, \"crossSectionLine\", emptyFeatureCollection);\n setGeoJSON(map, \"crossSectionEndpoints\", emptyFeatureCollection);\n return;\n }\n const data: FeatureCollection = {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n geometry: focusedLine,\n properties: { id: \"focusedLine\" },\n },\n ],\n };\n\n setGeoJSON(map, \"crossSectionLine\", data);\n setGeoJSON(map, \"crossSectionEndpoints\", {\n type: \"FeatureCollection\",\n features: focusedLine.coordinates.map((coord) => ({\n type: \"Feature\",\n geometry: { type: \"Point\", coordinates: coord },\n properties: {},\n })),\n });\n },\n [focusedLine],\n );\n\n const bounds = useMemo(() => {\n // In line mode, frame the line; in manual mode, frame the selected columns\n const coords: number[][] =\n focusedLine != null && focusedLine.coordinates.length >= 2\n ? focusedLine.coordinates\n : focusedColumns.map((c) => c.properties.centroid.geometry.coordinates);\n if (coords.length < 2) return null;\n const bounds = new LngLatBounds();\n for (const coord of coords) {\n bounds.extend(coord as [number, number]);\n }\n return bounds;\n }, [focusedLine, focusedColumns]);\n\n useMapEaseTo({ bounds, padding, trackResize: true });\n\n return null;\n}\n\nconst emptyFeatureCollection: FeatureCollection = {\n type: \"FeatureCollection\",\n features: [],\n};\n"],"names":["bounds"],"mappings":";;;;;;;;;AAwBO,SAAS,qBAAqB,OAA4B;AAC/D,QAAM,EAAE,UAAU,IAAI,UAAU,aAAa,WAAW,GAAG,SAAS;AAEpE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,SAAS;AAAA,MACT,YAAY;AAAA,IAAA;AAAA,IAEd;AAAA,MACE,EAAE,cAAc,EAAE,OAAO,aAAa;AAAA,MACtC,EAAE,oBAAoB;AAAA,MACtB,EAAE,eAAe;AAAA,MACjB,EAAE,wBAAwB;AAAA,MAC1B,EAAE,sBAAsB;AAAA,MACxB,EAAE,cAAc,EAAE,SAAS;AAAA,MAC3B,EAAE,aAAa,EAAE,SAAS;AAAA,MAC1B;AAAA,IAAA;AAAA,EACF;AAEJ;AAEA,SAAS,aAAa,EAAE,WAAgC;AAEtD,QAAM,aAAa,uBAAuB,CAAC,UAAU,MAAM,UAAU;AACrE,QAAM,YAAY,uBAAuB,CAAC,UAAU,MAAM,SAAS;AACnE,QAAM,UAAU,uBAAuB,CAAC,UAAU,MAAM,OAAO;AAE/D,QAAM,SAAS,QAAQ,MAAM;AAC3B,QAAI,cAAc,QAAQ,WAAW,KAAM,QAAO;AAClD,UAAM,MAAM,QAAQ,KAAK,CAAC,MAAM,EAAE,YAAY,WAAW,UAAU;AACnE,QAAI,KAAK,YAAY,KAAM,QAAO;AAClC,UAAM,IAAI,IAAI,aAAA;AACd,sBAAkB,IAAI,UAAU,CAAC,UAAU,EAAE,OAAO,KAAyB,CAAC;AAC9E,WAAO,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xC,iBAAW,KAAK,yBAAyB;AAAA,QACvC,MAAM;AAAA,QACN,UAAU,YAAY,YAAY,IAAI,CAAC,WAAW;AAAA,UAChD,MAAM;AAAA,UACN,UAAU,EAAE,MAAM,SAAS,aAAa,MAAA;AAAA,UACxC,YAAY,CAAA;AAAA,QAAC,EACb;AAAA,MAAA,CACH;AAAA,IACH;AAAA,IACA,CAAC,WAAW;AAAA,EAAA;AAGd,QAAM,SAAS,QAAQ,MAAM;AAE3B,UAAM,SACJ,eAAe,QAAQ,YAAY,YAAY,UAAU,IACrD,YAAY,cACZ,eAAe,IAAI,CAAC,MAAM,EAAE,WAAW,SAAS,SAAS,WAAW;AAC1E,QAAI,OAAO,SAAS,EAAG,QAAO;AAC9B,UAAMA,UAAS,IAAI,aAAA;AACnB,eAAW,SAAS,QAAQ;AAC1BA,cAAO,OAAO,KAAyB;AAAA,IACzC;AACA,WAAOA;AAAAA,EACT,GAAG,CAAC,aAAa,cAAc,CAAC;AAEhC,eAAa,EAAE,QAAQ,SAAS,aAAa,MAAM;AAEnD,SAAO;AACT;AAEA,MAAM,yBAA4C;AAAA,EAChD,MAAM;AAAA,EACN,UAAU,CAAA;AACZ;"}
@@ -1,2 +0,0 @@
1
- export * from './core';
2
- export * from './state';
@@ -1,193 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const zustand = require("zustand");
4
- const lineIntersect = require("@turf/line-intersect");
5
- const distance = require("@turf/distance");
6
- const nearestPointOnLine = require("@turf/nearest-point-on-line");
7
- const centroid = require("@turf/centroid");
8
- const React = require("react");
9
- const h = require("@macrostrat/hyper");
10
- const zustandComputed = require("zustand-computed");
11
- const dataProvider = require("@macrostrat/data-provider");
12
- const buffer = require("@turf/buffer");
13
- const booleanPointInPolygon = require("@turf/boolean-point-in-polygon");
14
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
- const distance__default = /* @__PURE__ */ _interopDefault(distance);
16
- const h__default = /* @__PURE__ */ _interopDefault(h);
17
- const CorrelationStoreContext = React.createContext(null);
18
- const computed = zustandComputed.createComputed((state) => {
19
- const manual = state.manualColumns != null;
20
- return {
21
- selectionMode: manual ? "manual" : "line",
22
- // Focused columns are derived either from an explicit manual selection or
23
- // from the columns intersecting the line of section.
24
- focusedColumns: manual ? buildManualColumns(state.columns, state.manualColumns) : buildCorrelationColumns(state.columns, state.focusedLine)
25
- };
26
- });
27
- function ColumnCorrelationProvider({
28
- children,
29
- columns,
30
- projectID,
31
- inProcess,
32
- focusedLine,
33
- manualColumns = null,
34
- onSelectColumns
35
- }) {
36
- const [store] = React.useState(() => {
37
- return zustand.create(
38
- computed((set, get) => {
39
- return {
40
- focusedLine,
41
- manualColumns,
42
- hoveredColumn: null,
43
- zoomColumn: null,
44
- zoomNonce: 0,
45
- projectID,
46
- columns: null,
47
- onClickMap(event, point) {
48
- const state = get();
49
- if (state.manualColumns != null) return;
50
- const shiftKeyPressed = event.originalEvent.shiftKey;
51
- let existingCoords = state.focusedLine?.coordinates ?? [];
52
- if (existingCoords.length >= 2 && !shiftKeyPressed) {
53
- existingCoords = [];
54
- }
55
- set({
56
- focusedLine: {
57
- type: "LineString",
58
- coordinates: [...existingCoords, point.coordinates]
59
- }
60
- });
61
- },
62
- toggleColumn(colID) {
63
- const state = get();
64
- const current = state.manualColumns ?? state.focusedColumns.map((d) => d.properties.col_id);
65
- const next = current.includes(colID) ? current.filter((d) => d !== colID) : [...current, colID];
66
- set({ manualColumns: next, focusedLine: null });
67
- },
68
- removeColumn(colID) {
69
- const state = get();
70
- const current = state.manualColumns ?? state.focusedColumns.map((d) => d.properties.col_id);
71
- set({
72
- manualColumns: current.filter((d) => d !== colID),
73
- focusedLine: null
74
- });
75
- },
76
- setManualColumns(colIDs) {
77
- set({ manualColumns: colIDs, focusedLine: null });
78
- },
79
- setHoveredColumn(colID) {
80
- set({ hoveredColumn: colID });
81
- },
82
- zoomToColumn(colID) {
83
- set({ zoomColumn: colID, zoomNonce: get().zoomNonce + 1 });
84
- }
85
- };
86
- })
87
- );
88
- });
89
- const _columns = dataProvider.useMacrostratColumns(projectID, inProcess);
90
- React.useEffect(() => {
91
- if (_columns != null) {
92
- store.setState({ columns: _columns });
93
- }
94
- }, [_columns]);
95
- const focusedColumns = zustand.useStore(store, (state) => state.focusedColumns);
96
- const _focusedLine = zustand.useStore(store, (state) => state.focusedLine);
97
- React.useEffect(() => {
98
- onSelectColumns?.(focusedColumns, _focusedLine);
99
- }, [focusedColumns, _focusedLine]);
100
- return h__default.default(CorrelationStoreContext.Provider, { value: store }, children);
101
- }
102
- function useCorrelationMapStore(selector) {
103
- const storeApi = React.useContext(CorrelationStoreContext);
104
- if (storeApi == null) {
105
- throw new Error("Missing CorrelationMapProvider");
106
- }
107
- return zustand.useStore(storeApi, selector);
108
- }
109
- function useColumnMapLink() {
110
- const setHoveredColumn = useCorrelationMapStore((s) => s.setHoveredColumn);
111
- const zoomToColumn = useCorrelationMapStore((s) => s.zoomToColumn);
112
- return {
113
- onColumnMouseOver: setHoveredColumn,
114
- onColumnClick: zoomToColumn
115
- };
116
- }
117
- function buildCorrelationColumns(columns, line) {
118
- if (columns == null || line == null || line.coordinates.length < 2) {
119
- return [];
120
- }
121
- return orderColumnsByDistance(
122
- computeIntersectingColumns(columns, line),
123
- line
124
- );
125
- }
126
- function buildManualColumns(columns, ids) {
127
- if (columns == null || ids == null) return [];
128
- const byID = new Map(columns.map((c) => [c.properties.col_id, c]));
129
- const result = [];
130
- ids.forEach((id, i) => {
131
- const col = byID.get(id);
132
- if (col == null) return;
133
- const c = centroid.centroid(col.geometry);
134
- result.push({
135
- ...col,
136
- properties: {
137
- ...col.properties,
138
- centroid: c,
139
- nearestPointOnLine: c,
140
- distanceAlongLine: i
141
- }
142
- });
143
- });
144
- return result;
145
- }
146
- function computeIntersectingColumns(columns, line) {
147
- if (columns == null || line == null) {
148
- return [];
149
- }
150
- const bufferedLine = buffer.buffer(line, 1, { units: "degrees" });
151
- const nearbyPoints = columns.filter((col) => {
152
- if (col.geometry?.type != "Point") {
153
- return false;
154
- }
155
- return booleanPointInPolygon.booleanPointInPolygon(col.geometry, bufferedLine);
156
- });
157
- const intersectingPolygons = columns.filter((col) => {
158
- const poly = col.geometry;
159
- if (poly == null) return false;
160
- if (poly.type != "Polygon" && poly.type != "MultiPolygon") return false;
161
- const intersection = lineIntersect.lineIntersect(line, poly);
162
- return intersection.features.length > 0;
163
- });
164
- return [...intersectingPolygons, ...nearbyPoints];
165
- }
166
- function orderColumnsByDistance(columns, line) {
167
- const centroids = columns.map((col) => centroid.centroid(col.geometry));
168
- const projectedPoints = centroids.map(
169
- (point) => nearestPointOnLine.nearestPointOnLine(line, point)
170
- );
171
- const distances = projectedPoints.map(
172
- (point) => distance__default.default(point.geometry.coordinates, line.coordinates[0])
173
- );
174
- let newColumns = columns.map((col, i) => {
175
- return {
176
- ...col,
177
- properties: {
178
- ...col.properties,
179
- centroid: centroids[i],
180
- nearestPointOnLine: projectedPoints[i],
181
- distanceAlongLine: distances[i]
182
- }
183
- };
184
- });
185
- return sorted(newColumns, (d) => d.properties.distanceAlongLine);
186
- }
187
- function sorted(data, accessor) {
188
- return data.sort((a, b) => accessor(a) - accessor(b));
189
- }
190
- exports.ColumnCorrelationProvider = ColumnCorrelationProvider;
191
- exports.useColumnMapLink = useColumnMapLink;
192
- exports.useCorrelationMapStore = useCorrelationMapStore;
193
- //# sourceMappingURL=state.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.cjs","sources":["../../../src/maps/column-correlation/state.ts"],"sourcesContent":["import { LineString, Point } from \"geojson\";\nimport { create, StoreApi, useStore } from \"zustand\";\nimport type { ColumnGeoJSONRecord } from \"@macrostrat/api-types\";\n// Turf intersection\nimport { lineIntersect } from \"@turf/line-intersect\";\nimport distance from \"@turf/distance\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\nimport { centroid } from \"@turf/centroid\";\nimport {\n createContext,\n useState,\n useContext,\n ReactNode,\n useEffect,\n} from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { createComputed } from \"zustand-computed\";\nimport { useMacrostratColumns } from \"@macrostrat/data-provider\";\nimport { buffer } from \"@turf/buffer\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\n\nexport type CorrelationSelectionMode = \"line\" | \"manual\";\n\nexport interface CorrelationMapInput {\n columns: ColumnGeoJSONRecord[];\n focusedLine: LineString | null;\n /** When set, columns are selected manually (by clicking) in this order,\n * rather than derived from a line of section. */\n manualColumns?: number[] | null;\n}\n\nexport interface CorrelationMapStore extends CorrelationMapInput {\n onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;\n /** Toggle a column in/out of the manual selection (used in \"manual\" mode) */\n toggleColumn: (colID: number) => void;\n /** Remove a column from the selection. In \"line\" mode this converts the\n * current selection to a manual one (a line can't represent an arbitrary\n * subset), so removing a column switches modes. */\n removeColumn: (colID: number) => void;\n /** Replace the manual column selection with an explicit ordered list (used\n * e.g. for drag-and-drop reordering). Switches to manual mode. */\n setManualColumns: (colIDs: number[]) => void;\n setHoveredColumn: (colID: number | null) => void;\n hoveredColumn: number | null;\n /** Request the map to frame a particular column (e.g. on header click). */\n zoomToColumn: (colID: number | null) => void;\n zoomColumn: number | null;\n /** Incremented on each zoom request so repeat clicks re-frame the column. */\n zoomNonce: number;\n projectID?: number;\n}\n\nexport interface CorrelationProviderProps extends CorrelationMapInput {\n projectID?: number;\n inProcess?: boolean;\n columns: ColumnGeoJSONRecord[] | null;\n children: ReactNode;\n onSelectColumns?: (\n columns: FocusedColumnGeoJSONRecord[],\n line: LineString | null,\n ) => void;\n}\n\nconst CorrelationStoreContext =\n createContext<StoreApi<CorrelationMapStore> | null>(null);\n\ntype ComputedStore = {\n focusedColumns: FocusedColumnGeoJSONRecord[];\n selectionMode: CorrelationSelectionMode;\n};\n\n/** A computed store that will automatically update when the state changes */\nconst computed = createComputed((state: CorrelationMapStore): ComputedStore => {\n const manual = state.manualColumns != null;\n return {\n selectionMode: manual ? \"manual\" : \"line\",\n // Focused columns are derived either from an explicit manual selection or\n // from the columns intersecting the line of section.\n focusedColumns: manual\n ? buildManualColumns(state.columns, state.manualColumns)\n : buildCorrelationColumns(state.columns, state.focusedLine),\n };\n}) as any;\n\nexport function ColumnCorrelationProvider({\n children,\n columns,\n projectID,\n inProcess,\n focusedLine,\n manualColumns = null,\n onSelectColumns,\n}: CorrelationProviderProps) {\n const [store] = useState(() => {\n return create<CorrelationMapStore & ComputedStore>(\n computed((set, get): CorrelationMapStore => {\n return {\n focusedLine,\n manualColumns,\n hoveredColumn: null,\n zoomColumn: null,\n zoomNonce: 0,\n projectID,\n columns: null,\n onClickMap(event: mapboxgl.MapMouseEvent, point: Point) {\n const state = get();\n // In manual-selection mode the map click is handled per-column\n if (state.manualColumns != null) return;\n // Check if shift key is pressed\n const shiftKeyPressed = event.originalEvent.shiftKey;\n let existingCoords = state.focusedLine?.coordinates ?? [];\n\n if (existingCoords.length >= 2 && !shiftKeyPressed) {\n // Reset the line to zero length\n existingCoords = [];\n }\n set({\n focusedLine: {\n type: \"LineString\",\n coordinates: [...existingCoords, point.coordinates],\n },\n });\n },\n toggleColumn(colID: number) {\n const state = get();\n const current =\n state.manualColumns ??\n state.focusedColumns.map((d) => d.properties.col_id);\n const next = current.includes(colID)\n ? current.filter((d) => d !== colID)\n : [...current, colID];\n set({ manualColumns: next, focusedLine: null });\n },\n removeColumn(colID: number) {\n const state = get();\n // Seed from the current selection (line-derived or manual)\n const current =\n state.manualColumns ??\n state.focusedColumns.map((d) => d.properties.col_id);\n set({\n manualColumns: current.filter((d) => d !== colID),\n focusedLine: null,\n });\n },\n setManualColumns(colIDs: number[]) {\n set({ manualColumns: colIDs, focusedLine: null });\n },\n setHoveredColumn(colID: number | null) {\n set({ hoveredColumn: colID });\n },\n zoomToColumn(colID: number | null) {\n set({ zoomColumn: colID, zoomNonce: get().zoomNonce + 1 });\n },\n };\n }),\n );\n });\n\n // Set up the store\n /** TODO: move the fetching of all columns to within the map */\n const _columns = useMacrostratColumns(projectID, inProcess);\n useEffect(() => {\n if (_columns != null) {\n store.setState({ columns: _columns });\n }\n }, [_columns]);\n\n // Kind of an awkward way to do this but we need to allow the selector to run\n const focusedColumns = useStore(store, (state) => state.focusedColumns);\n const _focusedLine = useStore(store, (state) => state.focusedLine);\n\n useEffect(() => {\n onSelectColumns?.(focusedColumns, _focusedLine);\n }, [focusedColumns, _focusedLine]);\n\n return h(CorrelationStoreContext.Provider, { value: store }, children);\n}\n\nexport function useCorrelationMapStore(\n selector: (state: CorrelationMapStore & ComputedStore) => any,\n) {\n const storeApi = useContext(CorrelationStoreContext);\n if (storeApi == null) {\n throw new Error(\"Missing CorrelationMapProvider\");\n }\n return useStore(storeApi, selector);\n}\n\nexport interface ColumnMapLink {\n onColumnMouseOver: (colID: number | null) => void;\n onColumnClick: (colID: number) => void;\n}\n\n/** Wire a correlation chart's column-level events to the correlation map:\n * hovering a column highlights it on the map, and clicking a column header\n * frames it. Spread the result into `CorrelationChart`. Must be used within a\n * `ColumnCorrelationProvider`. */\nexport function useColumnMapLink(): ColumnMapLink {\n const setHoveredColumn = useCorrelationMapStore((s) => s.setHoveredColumn);\n const zoomToColumn = useCorrelationMapStore((s) => s.zoomToColumn);\n return {\n onColumnMouseOver: setHoveredColumn,\n onColumnClick: zoomToColumn,\n };\n}\n\nfunction buildCorrelationColumns(\n columns: ColumnGeoJSONRecord[],\n line: LineString,\n): FocusedColumnGeoJSONRecord[] {\n if (columns == null || line == null || line.coordinates.length < 2) {\n return [];\n }\n return orderColumnsByDistance(\n computeIntersectingColumns(columns, line),\n line,\n );\n}\n\nfunction buildManualColumns(\n columns: ColumnGeoJSONRecord[],\n ids: number[],\n): FocusedColumnGeoJSONRecord[] {\n /** Build focused columns from an explicit, ordered list of column IDs. The\n * ordering line simply connects them in the order they were selected. */\n if (columns == null || ids == null) return [];\n const byID = new Map(columns.map((c) => [c.properties.col_id, c]));\n const result: FocusedColumnGeoJSONRecord[] = [];\n ids.forEach((id, i) => {\n const col = byID.get(id);\n if (col == null) return;\n const c = centroid(col.geometry);\n result.push({\n ...col,\n properties: {\n ...col.properties,\n centroid: c,\n nearestPointOnLine: c,\n distanceAlongLine: i,\n },\n });\n });\n return result;\n}\n\nfunction computeIntersectingColumns(\n columns: ColumnGeoJSONRecord[],\n line: LineString,\n): ColumnGeoJSONRecord[] {\n if (columns == null || line == null) {\n return [];\n }\n\n /** eODP-focused process. Find buffers around line and then find columns intersecting that buffer */\n const bufferedLine = buffer(line, 1, { units: \"degrees\" });\n\n const nearbyPoints = columns.filter((col) => {\n if (col.geometry?.type != \"Point\") {\n return false;\n }\n return booleanPointInPolygon(col.geometry, bufferedLine);\n });\n\n const intersectingPolygons = columns.filter((col) => {\n const poly = col.geometry;\n\n // Some in-process datasets seem to have null geometries\n if (poly == null) return false;\n if (poly.type != \"Polygon\" && poly.type != \"MultiPolygon\") return false;\n\n const intersection = lineIntersect(line, poly);\n return intersection.features.length > 0;\n });\n\n return [...intersectingPolygons, ...nearbyPoints];\n}\n\ninterface FocusedColumnGeoJSONRecord extends ColumnGeoJSONRecord {\n properties: {\n centroid: Point;\n nearestPointOnLine: Point;\n distanceAlongLine: number;\n } & ColumnGeoJSONRecord[\"properties\"];\n}\n\nfunction orderColumnsByDistance(\n columns: ColumnGeoJSONRecord[],\n line: LineString,\n): FocusedColumnGeoJSONRecord[] {\n const centroids = columns.map((col) => centroid(col.geometry));\n const projectedPoints = centroids.map((point) =>\n nearestPointOnLine(line, point),\n );\n const distances = projectedPoints.map((point) =>\n distance(point.geometry.coordinates, line.coordinates[0]),\n );\n\n let newColumns = columns.map((col, i) => {\n return {\n ...col,\n properties: {\n ...col.properties,\n centroid: centroids[i],\n nearestPointOnLine: projectedPoints[i],\n distanceAlongLine: distances[i],\n },\n };\n });\n\n return sorted(newColumns, (d) => d.properties.distanceAlongLine);\n}\n\nfunction sorted(data, accessor: (d) => number) {\n return data.sort((a, b) => accessor(a) - accessor(b));\n}\n"],"names":["createContext","createComputed","useState","create","useMacrostratColumns","useEffect","useStore","h","useContext","centroid","buffer","booleanPointInPolygon","lineIntersect","nearestPointOnLine","distance"],"mappings":";;;;;;;;;;;;;;;;AA+DA,MAAM,0BACJA,MAAAA,cAAoD,IAAI;AAQ1D,MAAM,WAAWC,gBAAAA,eAAe,CAAC,UAA8C;AAC7E,QAAM,SAAS,MAAM,iBAAiB;AACtC,SAAO;AAAA,IACL,eAAe,SAAS,WAAW;AAAA;AAAA;AAAA,IAGnC,gBAAgB,SACZ,mBAAmB,MAAM,SAAS,MAAM,aAAa,IACrD,wBAAwB,MAAM,SAAS,MAAM,WAAW;AAAA,EAAA;AAEhE,CAAC;AAEM,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AACF,GAA6B;AAC3B,QAAM,CAAC,KAAK,IAAIC,MAAAA,SAAS,MAAM;AAC7B,WAAOC,QAAAA;AAAAA,MACL,SAAS,CAAC,KAAK,QAA6B;AAC1C,eAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,eAAe;AAAA,UACf,YAAY;AAAA,UACZ,WAAW;AAAA,UACX;AAAA,UACA,SAAS;AAAA,UACT,WAAW,OAA+B,OAAc;AACtD,kBAAM,QAAQ,IAAA;AAEd,gBAAI,MAAM,iBAAiB,KAAM;AAEjC,kBAAM,kBAAkB,MAAM,cAAc;AAC5C,gBAAI,iBAAiB,MAAM,aAAa,eAAe,CAAA;AAEvD,gBAAI,eAAe,UAAU,KAAK,CAAC,iBAAiB;AAElD,+BAAiB,CAAA;AAAA,YACnB;AACA,gBAAI;AAAA,cACF,aAAa;AAAA,gBACX,MAAM;AAAA,gBACN,aAAa,CAAC,GAAG,gBAAgB,MAAM,WAAW;AAAA,cAAA;AAAA,YACpD,CACD;AAAA,UACH;AAAA,UACA,aAAa,OAAe;AAC1B,kBAAM,QAAQ,IAAA;AACd,kBAAM,UACJ,MAAM,iBAC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,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;AACtD;;;;"}
@@ -1,62 +0,0 @@
1
- import { LineString, Point } from 'geojson';
2
- import { StoreApi } from 'zustand';
3
- import { ColumnGeoJSONRecord } from '@macrostrat/api-types';
4
- import { ReactNode } from 'react';
5
- export type CorrelationSelectionMode = "line" | "manual";
6
- export interface CorrelationMapInput {
7
- columns: ColumnGeoJSONRecord[];
8
- focusedLine: LineString | null;
9
- /** When set, columns are selected manually (by clicking) in this order,
10
- * rather than derived from a line of section. */
11
- manualColumns?: number[] | null;
12
- }
13
- export interface CorrelationMapStore extends CorrelationMapInput {
14
- onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;
15
- /** Toggle a column in/out of the manual selection (used in "manual" mode) */
16
- toggleColumn: (colID: number) => void;
17
- /** Remove a column from the selection. In "line" mode this converts the
18
- * current selection to a manual one (a line can't represent an arbitrary
19
- * subset), so removing a column switches modes. */
20
- removeColumn: (colID: number) => void;
21
- /** Replace the manual column selection with an explicit ordered list (used
22
- * e.g. for drag-and-drop reordering). Switches to manual mode. */
23
- setManualColumns: (colIDs: number[]) => void;
24
- setHoveredColumn: (colID: number | null) => void;
25
- hoveredColumn: number | null;
26
- /** Request the map to frame a particular column (e.g. on header click). */
27
- zoomToColumn: (colID: number | null) => void;
28
- zoomColumn: number | null;
29
- /** Incremented on each zoom request so repeat clicks re-frame the column. */
30
- zoomNonce: number;
31
- projectID?: number;
32
- }
33
- export interface CorrelationProviderProps extends CorrelationMapInput {
34
- projectID?: number;
35
- inProcess?: boolean;
36
- columns: ColumnGeoJSONRecord[] | null;
37
- children: ReactNode;
38
- onSelectColumns?: (columns: FocusedColumnGeoJSONRecord[], line: LineString | null) => void;
39
- }
40
- type ComputedStore = {
41
- focusedColumns: FocusedColumnGeoJSONRecord[];
42
- selectionMode: CorrelationSelectionMode;
43
- };
44
- export declare function ColumnCorrelationProvider({ children, columns, projectID, inProcess, focusedLine, manualColumns, onSelectColumns, }: CorrelationProviderProps): import('react').FunctionComponentElement<import('react').ProviderProps<StoreApi<CorrelationMapStore> | null>>;
45
- export declare function useCorrelationMapStore(selector: (state: CorrelationMapStore & ComputedStore) => any): any;
46
- export interface ColumnMapLink {
47
- onColumnMouseOver: (colID: number | null) => void;
48
- onColumnClick: (colID: number) => void;
49
- }
50
- /** Wire a correlation chart's column-level events to the correlation map:
51
- * hovering a column highlights it on the map, and clicking a column header
52
- * frames it. Spread the result into `CorrelationChart`. Must be used within a
53
- * `ColumnCorrelationProvider`. */
54
- export declare function useColumnMapLink(): ColumnMapLink;
55
- interface FocusedColumnGeoJSONRecord extends ColumnGeoJSONRecord {
56
- properties: {
57
- centroid: Point;
58
- nearestPointOnLine: Point;
59
- distanceAlongLine: number;
60
- } & ColumnGeoJSONRecord["properties"];
61
- }
62
- export {};