@macrostrat/column-views 3.9.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.
- package/CHANGELOG.md +25 -0
- package/dist/index.cjs +15 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -34
- package/dist/index.js.map +1 -1
- package/dist/units/boxes.cjs +3 -3
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +3 -3
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/index.cjs +7 -11
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.d.ts +0 -1
- package/dist/units/index.js +4 -9
- package/dist/units/index.js.map +1 -1
- package/package.json +6 -27
- package/src/index.ts +3 -1
- package/src/units/boxes.ts +7 -4
- package/src/units/index.ts +9 -26
- package/dist/maps/column-correlation/core.cjs +0 -288
- package/dist/maps/column-correlation/core.cjs.map +0 -1
- package/dist/maps/column-correlation/core.d.ts +0 -9
- package/dist/maps/column-correlation/core.js +0 -286
- package/dist/maps/column-correlation/core.js.map +0 -1
- package/dist/maps/column-correlation/index.d.ts +0 -2
- package/dist/maps/column-correlation/state.cjs +0 -193
- package/dist/maps/column-correlation/state.cjs.map +0 -1
- package/dist/maps/column-correlation/state.d.ts +0 -62
- package/dist/maps/column-correlation/state.js +0 -190
- package/dist/maps/column-correlation/state.js.map +0 -1
- package/dist/maps/column-navigation/index.d.ts +0 -2
- package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
- package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
- package/dist/maps/column-navigation/mapbox/index.js +0 -213
- package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
- package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
- package/dist/maps/column-navigation/mapbox/state.js +0 -71
- package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
- package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
- package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
- package/dist/maps/column-navigation/svg/index.cjs +0 -94
- package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/index.d.ts +0 -9
- package/dist/maps/column-navigation/svg/index.js +0 -93
- package/dist/maps/column-navigation/svg/index.js.map +0 -1
- package/dist/maps/column-navigation/svg/layers.cjs +0 -177
- package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
- package/dist/maps/column-navigation/svg/layers.js +0 -174
- package/dist/maps/column-navigation/svg/layers.js.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
- package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
- package/dist/maps/index.d.ts +0 -4
- package/dist/maps/inset-map/index.cjs +0 -71
- package/dist/maps/inset-map/index.cjs.map +0 -1
- package/dist/maps/inset-map/index.d.ts +0 -16
- package/dist/maps/inset-map/index.js +0 -69
- package/dist/maps/inset-map/index.js.map +0 -1
- package/dist/maps/layers/columns.cjs +0 -165
- package/dist/maps/layers/columns.cjs.map +0 -1
- package/dist/maps/layers/columns.d.ts +0 -28
- package/dist/maps/layers/columns.js +0 -165
- package/dist/maps/layers/columns.js.map +0 -1
- package/dist/maps/layers/index.d.ts +0 -2
- package/dist/maps/layers/units.cjs +0 -207
- package/dist/maps/layers/units.cjs.map +0 -1
- package/dist/maps/layers/units.d.ts +0 -14
- package/dist/maps/layers/units.js +0 -204
- package/dist/maps/layers/units.js.map +0 -1
- package/dist/units/colors.cjs +0 -115
- package/dist/units/colors.cjs.map +0 -1
- package/dist/units/colors.d.ts +0 -20
- package/dist/units/colors.js +0 -113
- package/dist/units/colors.js.map +0 -1
- package/dist/units/resolvers.cjs +0 -125
- package/dist/units/resolvers.cjs.map +0 -1
- package/dist/units/resolvers.d.ts +0 -8
- package/dist/units/resolvers.js +0 -125
- package/dist/units/resolvers.js.map +0 -1
- package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
- package/src/maps/column-correlation/core.ts +0 -342
- package/src/maps/column-correlation/index.ts +0 -2
- package/src/maps/column-correlation/state.ts +0 -315
- package/src/maps/column-navigation/index.ts +0 -2
- package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
- package/src/maps/column-navigation/mapbox/index.ts +0 -276
- package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
- package/src/maps/column-navigation/mapbox/state.ts +0 -119
- package/src/maps/column-navigation/svg/animated.ts +0 -78
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
- package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
- package/src/maps/column-navigation/svg/index.ts +0 -96
- package/src/maps/column-navigation/svg/layers.ts +0 -233
- package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
- package/src/maps/index.ts +0 -4
- package/src/maps/inset-map/index.ts +0 -87
- package/src/maps/inset-map/inset-map.stories.ts +0 -20
- package/src/maps/layers/columns.ts +0 -216
- package/src/maps/layers/index.ts +0 -2
- package/src/maps/layers/units.ts +0 -286
- package/src/maps/unit-map.stories.ts +0 -79
- package/src/units/colors.ts +0 -183
- package/src/units/resolvers.ts +0 -141
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { LineString, Point } from "geojson";
|
|
2
|
-
import { create, StoreApi, useStore } from "zustand";
|
|
3
|
-
import type { ColumnGeoJSONRecord } from "@macrostrat/api-types";
|
|
4
|
-
// Turf intersection
|
|
5
|
-
import { lineIntersect } from "@turf/line-intersect";
|
|
6
|
-
import distance from "@turf/distance";
|
|
7
|
-
import { nearestPointOnLine } from "@turf/nearest-point-on-line";
|
|
8
|
-
import { centroid } from "@turf/centroid";
|
|
9
|
-
import {
|
|
10
|
-
createContext,
|
|
11
|
-
useState,
|
|
12
|
-
useContext,
|
|
13
|
-
ReactNode,
|
|
14
|
-
useEffect,
|
|
15
|
-
} from "react";
|
|
16
|
-
import h from "@macrostrat/hyper";
|
|
17
|
-
import { createComputed } from "zustand-computed";
|
|
18
|
-
import { useMacrostratColumns } from "@macrostrat/data-provider";
|
|
19
|
-
import { buffer } from "@turf/buffer";
|
|
20
|
-
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
|
21
|
-
|
|
22
|
-
export type CorrelationSelectionMode = "line" | "manual";
|
|
23
|
-
|
|
24
|
-
export interface CorrelationMapInput {
|
|
25
|
-
columns: ColumnGeoJSONRecord[];
|
|
26
|
-
focusedLine: LineString | null;
|
|
27
|
-
/** When set, columns are selected manually (by clicking) in this order,
|
|
28
|
-
* rather than derived from a line of section. */
|
|
29
|
-
manualColumns?: number[] | null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface CorrelationMapStore extends CorrelationMapInput {
|
|
33
|
-
onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;
|
|
34
|
-
/** Toggle a column in/out of the manual selection (used in "manual" mode) */
|
|
35
|
-
toggleColumn: (colID: number) => void;
|
|
36
|
-
/** Remove a column from the selection. In "line" mode this converts the
|
|
37
|
-
* current selection to a manual one (a line can't represent an arbitrary
|
|
38
|
-
* subset), so removing a column switches modes. */
|
|
39
|
-
removeColumn: (colID: number) => void;
|
|
40
|
-
/** Replace the manual column selection with an explicit ordered list (used
|
|
41
|
-
* e.g. for drag-and-drop reordering). Switches to manual mode. */
|
|
42
|
-
setManualColumns: (colIDs: number[]) => void;
|
|
43
|
-
setHoveredColumn: (colID: number | null) => void;
|
|
44
|
-
hoveredColumn: number | null;
|
|
45
|
-
/** Request the map to frame a particular column (e.g. on header click). */
|
|
46
|
-
zoomToColumn: (colID: number | null) => void;
|
|
47
|
-
zoomColumn: number | null;
|
|
48
|
-
/** Incremented on each zoom request so repeat clicks re-frame the column. */
|
|
49
|
-
zoomNonce: number;
|
|
50
|
-
projectID?: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface CorrelationProviderProps extends CorrelationMapInput {
|
|
54
|
-
projectID?: number;
|
|
55
|
-
inProcess?: boolean;
|
|
56
|
-
columns: ColumnGeoJSONRecord[] | null;
|
|
57
|
-
children: ReactNode;
|
|
58
|
-
onSelectColumns?: (
|
|
59
|
-
columns: FocusedColumnGeoJSONRecord[],
|
|
60
|
-
line: LineString | null,
|
|
61
|
-
) => void;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const CorrelationStoreContext =
|
|
65
|
-
createContext<StoreApi<CorrelationMapStore> | null>(null);
|
|
66
|
-
|
|
67
|
-
type ComputedStore = {
|
|
68
|
-
focusedColumns: FocusedColumnGeoJSONRecord[];
|
|
69
|
-
selectionMode: CorrelationSelectionMode;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/** A computed store that will automatically update when the state changes */
|
|
73
|
-
const computed = createComputed((state: CorrelationMapStore): ComputedStore => {
|
|
74
|
-
const manual = state.manualColumns != null;
|
|
75
|
-
return {
|
|
76
|
-
selectionMode: manual ? "manual" : "line",
|
|
77
|
-
// Focused columns are derived either from an explicit manual selection or
|
|
78
|
-
// from the columns intersecting the line of section.
|
|
79
|
-
focusedColumns: manual
|
|
80
|
-
? buildManualColumns(state.columns, state.manualColumns)
|
|
81
|
-
: buildCorrelationColumns(state.columns, state.focusedLine),
|
|
82
|
-
};
|
|
83
|
-
}) as any;
|
|
84
|
-
|
|
85
|
-
export function ColumnCorrelationProvider({
|
|
86
|
-
children,
|
|
87
|
-
columns,
|
|
88
|
-
projectID,
|
|
89
|
-
inProcess,
|
|
90
|
-
focusedLine,
|
|
91
|
-
manualColumns = null,
|
|
92
|
-
onSelectColumns,
|
|
93
|
-
}: CorrelationProviderProps) {
|
|
94
|
-
const [store] = useState(() => {
|
|
95
|
-
return create<CorrelationMapStore & ComputedStore>(
|
|
96
|
-
computed((set, get): CorrelationMapStore => {
|
|
97
|
-
return {
|
|
98
|
-
focusedLine,
|
|
99
|
-
manualColumns,
|
|
100
|
-
hoveredColumn: null,
|
|
101
|
-
zoomColumn: null,
|
|
102
|
-
zoomNonce: 0,
|
|
103
|
-
projectID,
|
|
104
|
-
columns: null,
|
|
105
|
-
onClickMap(event: mapboxgl.MapMouseEvent, point: Point) {
|
|
106
|
-
const state = get();
|
|
107
|
-
// In manual-selection mode the map click is handled per-column
|
|
108
|
-
if (state.manualColumns != null) return;
|
|
109
|
-
// Check if shift key is pressed
|
|
110
|
-
const shiftKeyPressed = event.originalEvent.shiftKey;
|
|
111
|
-
let existingCoords = state.focusedLine?.coordinates ?? [];
|
|
112
|
-
|
|
113
|
-
if (existingCoords.length >= 2 && !shiftKeyPressed) {
|
|
114
|
-
// Reset the line to zero length
|
|
115
|
-
existingCoords = [];
|
|
116
|
-
}
|
|
117
|
-
set({
|
|
118
|
-
focusedLine: {
|
|
119
|
-
type: "LineString",
|
|
120
|
-
coordinates: [...existingCoords, point.coordinates],
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
toggleColumn(colID: number) {
|
|
125
|
-
const state = get();
|
|
126
|
-
const current =
|
|
127
|
-
state.manualColumns ??
|
|
128
|
-
state.focusedColumns.map((d) => d.properties.col_id);
|
|
129
|
-
const next = current.includes(colID)
|
|
130
|
-
? current.filter((d) => d !== colID)
|
|
131
|
-
: [...current, colID];
|
|
132
|
-
set({ manualColumns: next, focusedLine: null });
|
|
133
|
-
},
|
|
134
|
-
removeColumn(colID: number) {
|
|
135
|
-
const state = get();
|
|
136
|
-
// Seed from the current selection (line-derived or manual)
|
|
137
|
-
const current =
|
|
138
|
-
state.manualColumns ??
|
|
139
|
-
state.focusedColumns.map((d) => d.properties.col_id);
|
|
140
|
-
set({
|
|
141
|
-
manualColumns: current.filter((d) => d !== colID),
|
|
142
|
-
focusedLine: null,
|
|
143
|
-
});
|
|
144
|
-
},
|
|
145
|
-
setManualColumns(colIDs: number[]) {
|
|
146
|
-
set({ manualColumns: colIDs, focusedLine: null });
|
|
147
|
-
},
|
|
148
|
-
setHoveredColumn(colID: number | null) {
|
|
149
|
-
set({ hoveredColumn: colID });
|
|
150
|
-
},
|
|
151
|
-
zoomToColumn(colID: number | null) {
|
|
152
|
-
set({ zoomColumn: colID, zoomNonce: get().zoomNonce + 1 });
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}),
|
|
156
|
-
);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Set up the store
|
|
160
|
-
/** TODO: move the fetching of all columns to within the map */
|
|
161
|
-
const _columns = useMacrostratColumns(projectID, inProcess);
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
if (_columns != null) {
|
|
164
|
-
store.setState({ columns: _columns });
|
|
165
|
-
}
|
|
166
|
-
}, [_columns]);
|
|
167
|
-
|
|
168
|
-
// Kind of an awkward way to do this but we need to allow the selector to run
|
|
169
|
-
const focusedColumns = useStore(store, (state) => state.focusedColumns);
|
|
170
|
-
const _focusedLine = useStore(store, (state) => state.focusedLine);
|
|
171
|
-
|
|
172
|
-
useEffect(() => {
|
|
173
|
-
onSelectColumns?.(focusedColumns, _focusedLine);
|
|
174
|
-
}, [focusedColumns, _focusedLine]);
|
|
175
|
-
|
|
176
|
-
return h(CorrelationStoreContext.Provider, { value: store }, children);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function useCorrelationMapStore(
|
|
180
|
-
selector: (state: CorrelationMapStore & ComputedStore) => any,
|
|
181
|
-
) {
|
|
182
|
-
const storeApi = useContext(CorrelationStoreContext);
|
|
183
|
-
if (storeApi == null) {
|
|
184
|
-
throw new Error("Missing CorrelationMapProvider");
|
|
185
|
-
}
|
|
186
|
-
return useStore(storeApi, selector);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface ColumnMapLink {
|
|
190
|
-
onColumnMouseOver: (colID: number | null) => void;
|
|
191
|
-
onColumnClick: (colID: number) => void;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** Wire a correlation chart's column-level events to the correlation map:
|
|
195
|
-
* hovering a column highlights it on the map, and clicking a column header
|
|
196
|
-
* frames it. Spread the result into `CorrelationChart`. Must be used within a
|
|
197
|
-
* `ColumnCorrelationProvider`. */
|
|
198
|
-
export function useColumnMapLink(): ColumnMapLink {
|
|
199
|
-
const setHoveredColumn = useCorrelationMapStore((s) => s.setHoveredColumn);
|
|
200
|
-
const zoomToColumn = useCorrelationMapStore((s) => s.zoomToColumn);
|
|
201
|
-
return {
|
|
202
|
-
onColumnMouseOver: setHoveredColumn,
|
|
203
|
-
onColumnClick: zoomToColumn,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function buildCorrelationColumns(
|
|
208
|
-
columns: ColumnGeoJSONRecord[],
|
|
209
|
-
line: LineString,
|
|
210
|
-
): FocusedColumnGeoJSONRecord[] {
|
|
211
|
-
if (columns == null || line == null || line.coordinates.length < 2) {
|
|
212
|
-
return [];
|
|
213
|
-
}
|
|
214
|
-
return orderColumnsByDistance(
|
|
215
|
-
computeIntersectingColumns(columns, line),
|
|
216
|
-
line,
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function buildManualColumns(
|
|
221
|
-
columns: ColumnGeoJSONRecord[],
|
|
222
|
-
ids: number[],
|
|
223
|
-
): FocusedColumnGeoJSONRecord[] {
|
|
224
|
-
/** Build focused columns from an explicit, ordered list of column IDs. The
|
|
225
|
-
* ordering line simply connects them in the order they were selected. */
|
|
226
|
-
if (columns == null || ids == null) return [];
|
|
227
|
-
const byID = new Map(columns.map((c) => [c.properties.col_id, c]));
|
|
228
|
-
const result: FocusedColumnGeoJSONRecord[] = [];
|
|
229
|
-
ids.forEach((id, i) => {
|
|
230
|
-
const col = byID.get(id);
|
|
231
|
-
if (col == null) return;
|
|
232
|
-
const c = centroid(col.geometry);
|
|
233
|
-
result.push({
|
|
234
|
-
...col,
|
|
235
|
-
properties: {
|
|
236
|
-
...col.properties,
|
|
237
|
-
centroid: c,
|
|
238
|
-
nearestPointOnLine: c,
|
|
239
|
-
distanceAlongLine: i,
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
return result;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function computeIntersectingColumns(
|
|
247
|
-
columns: ColumnGeoJSONRecord[],
|
|
248
|
-
line: LineString,
|
|
249
|
-
): ColumnGeoJSONRecord[] {
|
|
250
|
-
if (columns == null || line == null) {
|
|
251
|
-
return [];
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** eODP-focused process. Find buffers around line and then find columns intersecting that buffer */
|
|
255
|
-
const bufferedLine = buffer(line, 1, { units: "degrees" });
|
|
256
|
-
|
|
257
|
-
const nearbyPoints = columns.filter((col) => {
|
|
258
|
-
if (col.geometry?.type != "Point") {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
return booleanPointInPolygon(col.geometry, bufferedLine);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
const intersectingPolygons = columns.filter((col) => {
|
|
265
|
-
const poly = col.geometry;
|
|
266
|
-
|
|
267
|
-
// Some in-process datasets seem to have null geometries
|
|
268
|
-
if (poly == null) return false;
|
|
269
|
-
if (poly.type != "Polygon" && poly.type != "MultiPolygon") return false;
|
|
270
|
-
|
|
271
|
-
const intersection = lineIntersect(line, poly);
|
|
272
|
-
return intersection.features.length > 0;
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
return [...intersectingPolygons, ...nearbyPoints];
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
interface FocusedColumnGeoJSONRecord extends ColumnGeoJSONRecord {
|
|
279
|
-
properties: {
|
|
280
|
-
centroid: Point;
|
|
281
|
-
nearestPointOnLine: Point;
|
|
282
|
-
distanceAlongLine: number;
|
|
283
|
-
} & ColumnGeoJSONRecord["properties"];
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function orderColumnsByDistance(
|
|
287
|
-
columns: ColumnGeoJSONRecord[],
|
|
288
|
-
line: LineString,
|
|
289
|
-
): FocusedColumnGeoJSONRecord[] {
|
|
290
|
-
const centroids = columns.map((col) => centroid(col.geometry));
|
|
291
|
-
const projectedPoints = centroids.map((point) =>
|
|
292
|
-
nearestPointOnLine(line, point),
|
|
293
|
-
);
|
|
294
|
-
const distances = projectedPoints.map((point) =>
|
|
295
|
-
distance(point.geometry.coordinates, line.coordinates[0]),
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
let newColumns = columns.map((col, i) => {
|
|
299
|
-
return {
|
|
300
|
-
...col,
|
|
301
|
-
properties: {
|
|
302
|
-
...col.properties,
|
|
303
|
-
centroid: centroids[i],
|
|
304
|
-
nearestPointOnLine: projectedPoints[i],
|
|
305
|
-
distanceAlongLine: distances[i],
|
|
306
|
-
},
|
|
307
|
-
};
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
return sorted(newColumns, (d) => d.properties.distanceAlongLine);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function sorted(data, accessor: (d) => number) {
|
|
314
|
-
return data.sort((a, b) => accessor(a) - accessor(b));
|
|
315
|
-
}
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import h from "@macrostrat/hyper";
|
|
2
|
-
|
|
3
|
-
const mapboxToken = import.meta.env.VITE_MAPBOX_API_TOKEN;
|
|
4
|
-
|
|
5
|
-
import { Meta } from "@storybook/react-vite";
|
|
6
|
-
import { ColumnNavigationMap } from ".";
|
|
7
|
-
import { useState } from "react";
|
|
8
|
-
|
|
9
|
-
function ColumnNavigationMapExt(props) {
|
|
10
|
-
return h(ColumnNavigationMap, {
|
|
11
|
-
style: { width: "800px", height: "600px" },
|
|
12
|
-
padding: 100,
|
|
13
|
-
accessToken: mapboxToken,
|
|
14
|
-
...props,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
19
|
-
export default {
|
|
20
|
-
title: "Column views/Maps/Column navigation",
|
|
21
|
-
component: ColumnNavigationMapExt,
|
|
22
|
-
description: "Cross section creation map",
|
|
23
|
-
} as Meta<typeof ColumnNavigationMap>;
|
|
24
|
-
|
|
25
|
-
export const ColumnNavigation = {
|
|
26
|
-
args: {
|
|
27
|
-
showTriangulation: false,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const ColumnNavigationFilterableByIds = {
|
|
32
|
-
args: {
|
|
33
|
-
showTriangulation: false,
|
|
34
|
-
columnIDs: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const colData = [
|
|
39
|
-
{
|
|
40
|
-
id: 1,
|
|
41
|
-
type: "Feature",
|
|
42
|
-
geometry: {
|
|
43
|
-
type: "Polygon",
|
|
44
|
-
coordinates: [
|
|
45
|
-
[
|
|
46
|
-
[-86.9992, 34.6946],
|
|
47
|
-
[-86.9041, 35.4015],
|
|
48
|
-
[-86.5971, 35.4513],
|
|
49
|
-
[-86.1652, 35.0947],
|
|
50
|
-
[-86.1746, 34.7447],
|
|
51
|
-
[-86.5036, 34.4262],
|
|
52
|
-
[-86.6318, 34.4244],
|
|
53
|
-
[-86.9992, 34.6946],
|
|
54
|
-
],
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
properties: {
|
|
58
|
-
col_id: 2,
|
|
59
|
-
col_name: "Madison Co, Alabama",
|
|
60
|
-
col_group: "Southern Appalachians",
|
|
61
|
-
col_group_id: 17,
|
|
62
|
-
group_col_id: "1.00",
|
|
63
|
-
lat: "34.85300",
|
|
64
|
-
lng: "-86.56200",
|
|
65
|
-
col_area: "6345.4",
|
|
66
|
-
project_id: 1,
|
|
67
|
-
col_type: "column",
|
|
68
|
-
refs: [1],
|
|
69
|
-
max_thick: 2559,
|
|
70
|
-
max_min_thick: 2411,
|
|
71
|
-
min_min_thick: 529,
|
|
72
|
-
b_age: 1550,
|
|
73
|
-
t_age: 322.15,
|
|
74
|
-
b_int_name: "Calymmian",
|
|
75
|
-
t_int_name: "Morrowan",
|
|
76
|
-
pbdb_collections: 3,
|
|
77
|
-
lith: [
|
|
78
|
-
{
|
|
79
|
-
name: "mudstone",
|
|
80
|
-
type: "siliciclastic",
|
|
81
|
-
class: "sedimentary",
|
|
82
|
-
prop: 0.0041,
|
|
83
|
-
lith_id: 7,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "shale",
|
|
87
|
-
type: "siliciclastic",
|
|
88
|
-
class: "sedimentary",
|
|
89
|
-
prop: 0.2598,
|
|
90
|
-
lith_id: 8,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "siltstone",
|
|
94
|
-
type: "siliciclastic",
|
|
95
|
-
class: "sedimentary",
|
|
96
|
-
prop: 0.0107,
|
|
97
|
-
lith_id: 9,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: "sandstone",
|
|
101
|
-
type: "siliciclastic",
|
|
102
|
-
class: "sedimentary",
|
|
103
|
-
prop: 0.0322,
|
|
104
|
-
lith_id: 10,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: "limestone",
|
|
108
|
-
type: "carbonate",
|
|
109
|
-
class: "sedimentary",
|
|
110
|
-
prop: 0.4093,
|
|
111
|
-
lith_id: 30,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: "dolomite",
|
|
115
|
-
type: "carbonate",
|
|
116
|
-
class: "sedimentary",
|
|
117
|
-
prop: 0.1132,
|
|
118
|
-
lith_id: 31,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: "coal",
|
|
122
|
-
type: "organic",
|
|
123
|
-
class: "sedimentary",
|
|
124
|
-
prop: 0.0057,
|
|
125
|
-
lith_id: 38,
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: "chert",
|
|
129
|
-
type: "chemical",
|
|
130
|
-
class: "sedimentary",
|
|
131
|
-
prop: 0.0674,
|
|
132
|
-
lith_id: 45,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: "granite",
|
|
136
|
-
type: "plutonic",
|
|
137
|
-
class: "igneous",
|
|
138
|
-
prop: 0.0379,
|
|
139
|
-
lith_id: 53,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: "rhyolite",
|
|
143
|
-
type: "volcanic",
|
|
144
|
-
class: "igneous",
|
|
145
|
-
prop: 0.0076,
|
|
146
|
-
lith_id: 64,
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: "ash",
|
|
150
|
-
type: "volcanic",
|
|
151
|
-
class: "igneous",
|
|
152
|
-
prop: 0.0107,
|
|
153
|
-
lith_id: 75,
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: "quartz arenite",
|
|
157
|
-
type: "siliciclastic",
|
|
158
|
-
class: "sedimentary",
|
|
159
|
-
prop: 0.0207,
|
|
160
|
-
lith_id: 169,
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
name: "sublitharenite",
|
|
164
|
-
type: "siliciclastic",
|
|
165
|
-
class: "sedimentary",
|
|
166
|
-
prop: 0.0207,
|
|
167
|
-
lith_id: 199,
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
environ: [
|
|
171
|
-
{
|
|
172
|
-
name: "marine",
|
|
173
|
-
type: "",
|
|
174
|
-
class: "marine",
|
|
175
|
-
prop: 0.0476,
|
|
176
|
-
environ_id: 38,
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
name: "fluvial-deltaic indet.",
|
|
180
|
-
type: "fluvial",
|
|
181
|
-
class: "non-marine",
|
|
182
|
-
prop: 0.0476,
|
|
183
|
-
environ_id: 57,
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: "inferred marine",
|
|
187
|
-
type: "",
|
|
188
|
-
class: "marine",
|
|
189
|
-
prop: 0.9048,
|
|
190
|
-
environ_id: 93,
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
econ: [],
|
|
194
|
-
t_units: 22,
|
|
195
|
-
t_sections: 6,
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
];
|
|
199
|
-
|
|
200
|
-
export const ColumnNavigationFilterableByGeojson = {
|
|
201
|
-
args: {
|
|
202
|
-
showTriangulation: false,
|
|
203
|
-
columns: colData,
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
export const nonStandardProjectInProcess = {
|
|
208
|
-
args: {
|
|
209
|
-
padding: 100,
|
|
210
|
-
projectID: 10,
|
|
211
|
-
inProcess: true,
|
|
212
|
-
showTriangulation: false,
|
|
213
|
-
mapPosition: {
|
|
214
|
-
camera: {
|
|
215
|
-
lng: -72,
|
|
216
|
-
lat: 44,
|
|
217
|
-
altitude: 600000,
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export const DeepSea = {
|
|
224
|
-
args: {
|
|
225
|
-
padding: 100,
|
|
226
|
-
projectID: 4,
|
|
227
|
-
inProcess: true,
|
|
228
|
-
showTriangulation: false,
|
|
229
|
-
center: [0, 0],
|
|
230
|
-
zoom: 2,
|
|
231
|
-
mapPosition: null,
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
export const eODP = {
|
|
236
|
-
args: {
|
|
237
|
-
projectID: 3,
|
|
238
|
-
inProcess: true,
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
export const showTriangulation = {
|
|
243
|
-
description: "Show the triangulation used for keyboard navigation",
|
|
244
|
-
args: {
|
|
245
|
-
showTriangulation: true,
|
|
246
|
-
columnColor: "#1fff53",
|
|
247
|
-
triangulationColor: "#9a33bb",
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
export const onlyPhysicalBasemap = {
|
|
252
|
-
args: {
|
|
253
|
-
mapStyle: "mapbox://styles/mapbox/outdoors-v11",
|
|
254
|
-
showLabels: true,
|
|
255
|
-
showAdmin: false,
|
|
256
|
-
showRoads: false,
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
export function ControlledColumnNavigation() {
|
|
261
|
-
const [selectedColumn, setSelectedColumn] = useState(157);
|
|
262
|
-
const [hoveredColumn, setHoveredColumn] = useState(null);
|
|
263
|
-
|
|
264
|
-
return h("div.controlled-navigation", [
|
|
265
|
-
h(ColumnNavigationMapExt, {
|
|
266
|
-
selectedColumn,
|
|
267
|
-
hoveredColumn,
|
|
268
|
-
onSelectColumn: setSelectedColumn,
|
|
269
|
-
onHoverColumn: setHoveredColumn,
|
|
270
|
-
}),
|
|
271
|
-
h("div.column-info", [
|
|
272
|
-
h("h3", "Selected column"),
|
|
273
|
-
h("p", selectedColumn),
|
|
274
|
-
h("h3", "Hovered column"),
|
|
275
|
-
h("p", hoveredColumn),
|
|
276
|
-
]),
|
|
277
|
-
]);
|
|
278
|
-
}
|