@macrostrat/column-views 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/esm/_shared.f7eec55a.js +9 -0
- package/dist/esm/_shared.f7eec55a.js.map +1 -0
- package/dist/esm/age-axis.4a8cf5e6.js +98 -0
- package/dist/esm/age-axis.4a8cf5e6.js.map +1 -0
- package/dist/esm/age-axis.module.03773a80.css +33 -0
- package/dist/esm/age-axis.module.03773a80.css.map +1 -0
- package/dist/esm/age-axis.module.3cc91335.js +22 -0
- package/dist/esm/age-axis.module.3cc91335.js.map +1 -0
- package/dist/esm/age-model-overlay.c7226855.js +57 -0
- package/dist/esm/age-model-overlay.c7226855.js.map +1 -0
- package/dist/esm/age-model-overlay.module.5d9e78fb.css +14 -0
- package/dist/esm/age-model-overlay.module.5d9e78fb.css.map +1 -0
- package/dist/esm/age-model-overlay.module.cd985dcb.js +16 -0
- package/dist/esm/age-model-overlay.module.cd985dcb.js.map +1 -0
- package/dist/esm/base.910b80b4.js +288 -0
- package/dist/esm/base.910b80b4.js.map +1 -0
- package/dist/esm/boxes.8292cff2.js +258 -0
- package/dist/esm/boxes.8292cff2.js.map +1 -0
- package/dist/esm/boxes.module.2b5fb18e.css +26 -0
- package/dist/esm/boxes.module.2b5fb18e.css.map +1 -0
- package/dist/esm/boxes.module.4ebc7796.js +19 -0
- package/dist/esm/boxes.module.4ebc7796.js.map +1 -0
- package/dist/esm/{carbon-isotopes.3b502a9e.js → carbon-isotopes.10db8285.js} +2 -2
- package/dist/esm/{carbon-isotopes.3b502a9e.js.map → carbon-isotopes.10db8285.js.map} +1 -1
- package/dist/esm/colors.395c6db5.js +40 -0
- package/dist/esm/colors.395c6db5.js.map +1 -0
- package/dist/esm/column-correlation.c8dcfe98.js +9 -0
- package/dist/esm/column-correlation.c8dcfe98.js.map +1 -0
- package/dist/esm/column-nav.5414677c.js +55 -0
- package/dist/esm/column-nav.5414677c.js.map +1 -0
- package/dist/esm/column-navigation.37cd3245.js +9 -0
- package/dist/esm/column-navigation.37cd3245.js.map +1 -0
- package/dist/esm/column.01d68dd8.js +127 -0
- package/dist/esm/column.01d68dd8.js.map +1 -0
- package/dist/esm/{column.db058031.js → column.a25f8ebd.js} +4 -4
- package/dist/esm/column.a25f8ebd.js.map +1 -0
- package/dist/esm/column.module.1b776e15.js +46 -0
- package/dist/esm/column.module.1b776e15.js.map +1 -0
- package/dist/esm/column.module.a67a6b4c.css +159 -0
- package/dist/esm/column.module.a67a6b4c.css.map +1 -0
- package/dist/esm/composite-scale.577bf64a.js +222 -0
- package/dist/esm/composite-scale.577bf64a.js.map +1 -0
- package/dist/esm/composite.039e4798.js +163 -0
- package/dist/esm/composite.039e4798.js.map +1 -0
- package/dist/esm/{core.4db8e452.js → core.843310d3.js} +11 -12
- package/dist/esm/core.843310d3.js.map +1 -0
- package/dist/esm/core.91ede078.js +206 -0
- package/dist/esm/core.91ede078.js.map +1 -0
- package/dist/esm/correlation-chart.abd8b346.js +9 -0
- package/dist/esm/correlation-chart.abd8b346.js.map +1 -0
- package/dist/esm/data-provider.1506eb64.js.map +1 -1
- package/dist/esm/data-provider.f10c6d0b.js +13 -0
- package/dist/esm/data-provider.f10c6d0b.js.map +1 -0
- package/dist/esm/fetch.99aec438.js +152 -0
- package/dist/esm/fetch.99aec438.js.map +1 -0
- package/dist/esm/hash-string.285b37fb.js +39 -0
- package/dist/esm/hash-string.285b37fb.js.map +1 -0
- package/dist/esm/helpers.2f0a0cb7.js +141 -0
- package/dist/esm/helpers.2f0a0cb7.js.map +1 -0
- package/dist/esm/index.d.ts +797 -130
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +13 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/inset-map.3c18106d.js +66 -0
- package/dist/esm/inset-map.3c18106d.js.map +1 -0
- package/dist/esm/keyboard-navigation.6713401b.js +48 -0
- package/dist/esm/keyboard-navigation.6713401b.js.map +1 -0
- package/dist/esm/keyboard-navigation.a9fc80dd.js +112 -0
- package/dist/esm/keyboard-navigation.a9fc80dd.js.map +1 -0
- package/dist/esm/layers.033d3fb0.js +170 -0
- package/dist/esm/layers.033d3fb0.js.map +1 -0
- package/dist/esm/main.2e0375a5.js +221 -0
- package/dist/esm/main.2e0375a5.js.map +1 -0
- package/dist/esm/main.module.3dd9500b.css +134 -0
- package/dist/esm/main.module.3dd9500b.css.map +1 -0
- package/dist/esm/main.module.c09154b1.js +70 -0
- package/dist/esm/main.module.c09154b1.js.map +1 -0
- package/dist/esm/mapbox.cac42eed.js +167 -0
- package/dist/esm/mapbox.cac42eed.js.map +1 -0
- package/dist/esm/maps.bcdea9c1.js +11 -0
- package/dist/esm/maps.bcdea9c1.js.map +1 -0
- package/dist/esm/{names.f6a4e9a4.js → names.a8f2b452.js} +5 -5
- package/dist/esm/names.a8f2b452.js.map +1 -0
- package/dist/esm/panel.598f76a5.js +420 -0
- package/dist/esm/panel.598f76a5.js.map +1 -0
- package/dist/esm/panel.module.386166cc.js +58 -0
- package/dist/esm/panel.module.386166cc.js.map +1 -0
- package/dist/esm/panel.module.3d2ea3c6.css +111 -0
- package/dist/esm/panel.module.3d2ea3c6.css.map +1 -0
- package/dist/esm/popover.a810b7bc.js +66 -0
- package/dist/esm/popover.a810b7bc.js.map +1 -0
- package/dist/esm/popover.module.c4ba4189.js +22 -0
- package/dist/esm/popover.module.c4ba4189.js.map +1 -0
- package/dist/esm/{selection-popover.module.0a701258.css → popover.module.c4d6bfb0.css} +11 -8
- package/dist/esm/popover.module.c4d6bfb0.css.map +1 -0
- package/dist/esm/prepare-data.d4284b4a.js +125 -0
- package/dist/esm/prepare-data.d4284b4a.js.map +1 -0
- package/dist/esm/prepare-units.6c890a96.js +104 -0
- package/dist/esm/prepare-units.6c890a96.js.map +1 -0
- package/dist/esm/{resolvers.b5c82b78.js → resolvers.36013b49.js} +13 -2
- package/dist/esm/resolvers.36013b49.js.map +1 -0
- package/dist/esm/section.a34d379a.js +215 -0
- package/dist/esm/section.a34d379a.js.map +1 -0
- package/dist/esm/selection.f5b0297e.js +143 -0
- package/dist/esm/selection.f5b0297e.js.map +1 -0
- package/dist/esm/state.178ef364.js +75 -0
- package/dist/esm/state.178ef364.js.map +1 -0
- package/dist/esm/state.2952cbca.js +118 -0
- package/dist/esm/state.2952cbca.js.map +1 -0
- package/dist/esm/store.c4d7a8a4.js +52 -0
- package/dist/esm/store.c4d7a8a4.js.map +1 -0
- package/dist/esm/styles.7bc776d1.js +95 -0
- package/dist/esm/styles.7bc776d1.js.map +1 -0
- package/dist/esm/svg.4b9a96c1.js +89 -0
- package/dist/esm/svg.4b9a96c1.js.map +1 -0
- package/dist/esm/types.0f0b57c9.js +3 -0
- package/dist/esm/types.0f0b57c9.js.map +1 -0
- package/dist/esm/unit-details.071cefed.js +9 -0
- package/dist/esm/unit-details.071cefed.js.map +1 -0
- package/dist/esm/units.5a4fc058.js +98 -0
- package/dist/esm/units.5a4fc058.js.map +1 -0
- package/dist/esm/utils.d7a43a2a.js +55 -0
- package/dist/esm/utils.d7a43a2a.js.map +1 -0
- package/dist/node/index.js.map +1 -1
- package/package.json +24 -7
- package/src/age-axis.module.sass +27 -0
- package/src/age-axis.ts +82 -19
- package/src/age-model-overlay.module.sass +11 -0
- package/src/age-model-overlay.ts +73 -0
- package/src/carbon-isotopes/column.ts +4 -2
- package/src/carbon-isotopes/core.ts +9 -6
- package/src/carbon-isotopes/data-provider.ts +3 -3
- package/src/column.module.sass +58 -49
- package/src/column.ts +149 -135
- package/src/correlation-chart/hash-string.ts +57 -0
- package/src/correlation-chart/index.ts +2 -0
- package/src/correlation-chart/main.module.sass +122 -0
- package/src/correlation-chart/main.ts +305 -0
- package/src/correlation-chart/prepare-data.ts +217 -0
- package/src/correlation-chart/stories/correlation-chart.stories.ts +192 -0
- package/src/correlation-chart/stories/stories.module.sass +18 -0
- package/src/correlation-chart/unconformity-line.module.sass +8 -0
- package/src/correlation-chart/unconformity-line.ts +25 -0
- package/src/data-provider/base.ts +388 -0
- package/src/data-provider/column-nav.ts +53 -0
- package/src/data-provider/fetch.ts +231 -0
- package/src/data-provider/index.ts +4 -0
- package/src/data-provider/store.ts +72 -0
- package/src/index.ts +5 -3
- package/src/maps/_shared/index.ts +2 -0
- package/src/maps/_shared/inset-map.stories.ts +20 -0
- package/src/maps/_shared/inset-map.ts +87 -0
- package/src/maps/_shared/styles.ts +57 -0
- package/src/maps/column-correlation/column-correlation-map.stories.ts +96 -0
- package/src/maps/column-correlation/core.ts +225 -0
- package/src/maps/column-correlation/index.ts +2 -0
- package/src/maps/column-correlation/state.ts +192 -0
- package/src/maps/column-navigation/index.ts +2 -0
- package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +102 -0
- package/src/maps/column-navigation/mapbox/index.ts +219 -0
- package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +119 -0
- package/src/maps/column-navigation/mapbox/state.ts +109 -0
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +46 -0
- package/src/{map → maps/column-navigation/svg}/index.ts +18 -6
- package/src/{map → maps/column-navigation/svg}/layers.ts +28 -109
- package/src/maps/column-navigation/utils/keyboard-navigation.ts +58 -0
- package/src/maps/index.ts +3 -0
- package/src/prepare-units/composite-scale.ts +353 -0
- package/src/prepare-units/helpers.ts +226 -0
- package/src/prepare-units/index.ts +177 -0
- package/src/prepare-units/utils.ts +98 -0
- package/src/section.ts +264 -84
- package/src/unit-details/index.ts +2 -215
- package/src/unit-details/{index.module.sass → panel.module.sass} +39 -8
- package/src/unit-details/panel.ts +523 -0
- package/src/{selection-popover.module.sass → unit-details/popover.module.sass} +4 -2
- package/src/unit-details/popover.ts +82 -0
- package/src/units/boxes.module.sass +16 -0
- package/src/units/boxes.ts +243 -90
- package/src/units/colors.ts +64 -0
- package/src/units/composite.ts +157 -152
- package/src/units/index.ts +76 -9
- package/src/units/names.ts +8 -4
- package/src/units/resolvers.ts +11 -0
- package/src/units/selection.ts +115 -101
- package/src/units/types.ts +5 -16
- package/dist/esm/age-axis.64c509ee.js +0 -41
- package/dist/esm/age-axis.64c509ee.js.map +0 -1
- package/dist/esm/boxes.13968b76.js +0 -164
- package/dist/esm/boxes.13968b76.js.map +0 -1
- package/dist/esm/boxes.module.28873d08.css +0 -4
- package/dist/esm/boxes.module.28873d08.css.map +0 -1
- package/dist/esm/boxes.module.605bdcd6.js +0 -13
- package/dist/esm/boxes.module.605bdcd6.js.map +0 -1
- package/dist/esm/column.8dd26e1a.js +0 -149
- package/dist/esm/column.8dd26e1a.js.map +0 -1
- package/dist/esm/column.db058031.js.map +0 -1
- package/dist/esm/column.module.039d872c.css +0 -151
- package/dist/esm/column.module.039d872c.css.map +0 -1
- package/dist/esm/column.module.e632868a.js +0 -19
- package/dist/esm/column.module.e632868a.js.map +0 -1
- package/dist/esm/composite.608a4ca2.js +0 -153
- package/dist/esm/composite.608a4ca2.js.map +0 -1
- package/dist/esm/core.4db8e452.js.map +0 -1
- package/dist/esm/helpers.8a03cfc7.js +0 -94
- package/dist/esm/helpers.8a03cfc7.js.map +0 -1
- package/dist/esm/index.module.0844afd8.css +0 -65
- package/dist/esm/index.module.0844afd8.css.map +0 -1
- package/dist/esm/index.module.24fe3a2e.js +0 -37
- package/dist/esm/index.module.24fe3a2e.js.map +0 -1
- package/dist/esm/layers.ad5fd25d.js +0 -231
- package/dist/esm/layers.ad5fd25d.js.map +0 -1
- package/dist/esm/map.7aa26f17.js +0 -82
- package/dist/esm/map.7aa26f17.js.map +0 -1
- package/dist/esm/names.f6a4e9a4.js.map +0 -1
- package/dist/esm/providers.cd1e652f.js +0 -25
- package/dist/esm/providers.cd1e652f.js.map +0 -1
- package/dist/esm/resolvers.b5c82b78.js.map +0 -1
- package/dist/esm/section.cc1b1100.js +0 -118
- package/dist/esm/section.cc1b1100.js.map +0 -1
- package/dist/esm/selection-popover.17d1bd55.js +0 -60
- package/dist/esm/selection-popover.17d1bd55.js.map +0 -1
- package/dist/esm/selection-popover.module.0a701258.css.map +0 -1
- package/dist/esm/selection-popover.module.e22f5183.js +0 -22
- package/dist/esm/selection-popover.module.e22f5183.js.map +0 -1
- package/dist/esm/selection.bbf26d0e.js +0 -117
- package/dist/esm/selection.bbf26d0e.js.map +0 -1
- package/dist/esm/store.25eaa168.js +0 -18
- package/dist/esm/store.25eaa168.js.map +0 -1
- package/dist/esm/types.f016e032.js +0 -18
- package/dist/esm/types.f016e032.js.map +0 -1
- package/dist/esm/unit-details.56ff8b70.js +0 -209
- package/dist/esm/unit-details.56ff8b70.js.map +0 -1
- package/dist/esm/units.361088d4.js +0 -42
- package/dist/esm/units.361088d4.js.map +0 -1
- package/src/helpers.ts +0 -133
- package/src/providers.ts +0 -34
- package/src/selection-popover.ts +0 -71
- package/src/store.ts +0 -12
- package/src/units/units.scss +0 -16
- /package/src/{map → maps/column-navigation/svg}/animated.ts +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {joinURL as $Qf46V$joinURL, addQueryString as $Qf46V$addQueryString, useAPIResult as $Qf46V$useAPIResult} from "@macrostrat/ui-components";
|
|
2
|
+
import $Qf46V$crossfetch from "cross-fetch";
|
|
3
|
+
import {feature as $Qf46V$feature} from "topojson-client";
|
|
4
|
+
import {geoArea as $Qf46V$geoArea} from "d3-geo";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function $33a46f9423c8104a$var$defaultFetch(url, options) {
|
|
11
|
+
const baseURL = "https://macrostrat.org/api/v2";
|
|
12
|
+
return (0, $Qf46V$crossfetch)(baseURL + url, options);
|
|
13
|
+
}
|
|
14
|
+
async function $33a46f9423c8104a$export$45bd78cd093090fa(options = {}) {
|
|
15
|
+
const { apiBaseURL: apiBaseURL, projectID: projectID, format: format = "topojson", statusCode: statusCode, fetch: fetch = (0, $Qf46V$crossfetch) } = options;
|
|
16
|
+
let args = {
|
|
17
|
+
format: format
|
|
18
|
+
};
|
|
19
|
+
if (projectID != null) args = {
|
|
20
|
+
...args,
|
|
21
|
+
project_id: projectID
|
|
22
|
+
};
|
|
23
|
+
if (statusCode != null) args = {
|
|
24
|
+
...args,
|
|
25
|
+
status_code: statusCode
|
|
26
|
+
};
|
|
27
|
+
if (projectID == null) args = {
|
|
28
|
+
...args,
|
|
29
|
+
all: true
|
|
30
|
+
};
|
|
31
|
+
let url = "/columns";
|
|
32
|
+
if (apiBaseURL != null) url = (0, $Qf46V$joinURL)(apiBaseURL, url);
|
|
33
|
+
// Try with fetch
|
|
34
|
+
url = (0, $Qf46V$addQueryString)(url, args);
|
|
35
|
+
const res = await fetch(url, {
|
|
36
|
+
method: "GET",
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (res == null) return null;
|
|
42
|
+
// Get JSON
|
|
43
|
+
const data = await res.json();
|
|
44
|
+
return $33a46f9423c8104a$var$postProcessColumns($33a46f9423c8104a$var$columnProcessors[format](data));
|
|
45
|
+
}
|
|
46
|
+
function $33a46f9423c8104a$export$e3270a4e30e40ff9({ apiRoute: apiRoute = "/columns", status_code: status_code, project_id: project_id, format: format = "geojson" }) {
|
|
47
|
+
let all = undefined;
|
|
48
|
+
if (status_code == null && project_id == null) all = true;
|
|
49
|
+
const processor = $33a46f9423c8104a$var$columnProcessors[format];
|
|
50
|
+
return (0, $Qf46V$useAPIResult)(apiRoute, {
|
|
51
|
+
format: format,
|
|
52
|
+
all: all,
|
|
53
|
+
status_code: status_code,
|
|
54
|
+
project_id: project_id
|
|
55
|
+
}, processor);
|
|
56
|
+
}
|
|
57
|
+
function $33a46f9423c8104a$var$processGeoJSON(res) {
|
|
58
|
+
return $33a46f9423c8104a$var$processGeoJSONBare(res?.success?.data);
|
|
59
|
+
}
|
|
60
|
+
function $33a46f9423c8104a$var$processGeoJSONBare(res) {
|
|
61
|
+
return res?.features;
|
|
62
|
+
}
|
|
63
|
+
function $33a46f9423c8104a$var$processTopoJSON(res) {
|
|
64
|
+
try {
|
|
65
|
+
const { data: data } = res.success;
|
|
66
|
+
const { features: f } = (0, $Qf46V$feature)(data, data.objects.output);
|
|
67
|
+
return f;
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.error(err);
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function $33a46f9423c8104a$var$postProcessColumns(columns) {
|
|
74
|
+
return $33a46f9423c8104a$var$promoteColumnIDs($33a46f9423c8104a$var$convertSmallAreasToPoints($33a46f9423c8104a$var$removeFeaturesWithoutGeometry(columns)));
|
|
75
|
+
}
|
|
76
|
+
function $33a46f9423c8104a$var$promoteColumnIDs(features) {
|
|
77
|
+
return features.map((f, i)=>{
|
|
78
|
+
return {
|
|
79
|
+
id: f.properties?.col_id,
|
|
80
|
+
...f
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function $33a46f9423c8104a$var$removeFeaturesWithoutGeometry(features) {
|
|
85
|
+
return features.filter((f)=>f.geometry != null);
|
|
86
|
+
}
|
|
87
|
+
function $33a46f9423c8104a$var$convertSmallAreasToPoints(features) {
|
|
88
|
+
return features.map((f)=>{
|
|
89
|
+
// GeoArea takes a long time to run. We are really more worried about points that are zero-area
|
|
90
|
+
if ((0, $Qf46V$geoArea)(f.geometry) < 1e-8) {
|
|
91
|
+
const centroid = f.geometry.coordinates[0][0];
|
|
92
|
+
f.geometry = {
|
|
93
|
+
type: "Point",
|
|
94
|
+
coordinates: centroid
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return f;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const $33a46f9423c8104a$var$columnProcessors = {
|
|
101
|
+
topojson: $33a46f9423c8104a$var$processTopoJSON,
|
|
102
|
+
geojson: $33a46f9423c8104a$var$processGeoJSON,
|
|
103
|
+
geojson_bare: $33a46f9423c8104a$var$processGeoJSONBare
|
|
104
|
+
};
|
|
105
|
+
async function $33a46f9423c8104a$var$unwrapResponse(res) {
|
|
106
|
+
if (res == null) return null;
|
|
107
|
+
const resData = await res.json();
|
|
108
|
+
return resData["success"]["data"];
|
|
109
|
+
}
|
|
110
|
+
async function $33a46f9423c8104a$export$1aa679bd5e605f82(fetch = $33a46f9423c8104a$var$defaultFetch) {
|
|
111
|
+
const res = await fetch("/defs/lithologies?all");
|
|
112
|
+
return await $33a46f9423c8104a$var$unwrapResponse(res);
|
|
113
|
+
}
|
|
114
|
+
async function $33a46f9423c8104a$export$5d2ec2e733dfe6c7(timescaleID, fetch = $33a46f9423c8104a$var$defaultFetch) {
|
|
115
|
+
let url = `/defs/intervals`;
|
|
116
|
+
if (timescaleID != null) url += `?timescale_id=${timescaleID}`;
|
|
117
|
+
else url += "?all";
|
|
118
|
+
const res = await fetch(url);
|
|
119
|
+
return await $33a46f9423c8104a$var$unwrapResponse(res);
|
|
120
|
+
}
|
|
121
|
+
async function $33a46f9423c8104a$export$780b4b253712916c(fetch = $33a46f9423c8104a$var$defaultFetch) {
|
|
122
|
+
const res = await fetch("/defs/environments?all");
|
|
123
|
+
return await $33a46f9423c8104a$var$unwrapResponse(res);
|
|
124
|
+
}
|
|
125
|
+
async function $33a46f9423c8104a$export$cd7bfa0860f58b96(refs, fetch = $33a46f9423c8104a$var$defaultFetch) {
|
|
126
|
+
let url = `/defs/refs`;
|
|
127
|
+
if (refs.length == 0) return [];
|
|
128
|
+
url += "?ref_id=" + refs.join(",");
|
|
129
|
+
const res = await fetch(url);
|
|
130
|
+
return await $33a46f9423c8104a$var$unwrapResponse(res);
|
|
131
|
+
}
|
|
132
|
+
async function $33a46f9423c8104a$export$b97b9bdd6a521298(columns, fetch = $33a46f9423c8104a$var$defaultFetch) {
|
|
133
|
+
const promises = columns.map((col_id)=>$33a46f9423c8104a$export$d3d8b0fabcc76c5d(col_id, fetch));
|
|
134
|
+
return await Promise.all(promises);
|
|
135
|
+
}
|
|
136
|
+
async function $33a46f9423c8104a$export$d3d8b0fabcc76c5d(col_id, fetch = $33a46f9423c8104a$var$defaultFetch) {
|
|
137
|
+
const params = new URLSearchParams();
|
|
138
|
+
params.append("response", "long");
|
|
139
|
+
params.append("col_id", col_id.toString());
|
|
140
|
+
const res = await fetch("/units?" + params.toString());
|
|
141
|
+
const data = await res.json();
|
|
142
|
+
if (!data.success) throw new Error("Failed to fetch column units");
|
|
143
|
+
const units = data.success.data;
|
|
144
|
+
return {
|
|
145
|
+
columnID: col_id,
|
|
146
|
+
units: units
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
export {$33a46f9423c8104a$export$45bd78cd093090fa as fetchAllColumns, $33a46f9423c8104a$export$e3270a4e30e40ff9 as useColumnFeatures, $33a46f9423c8104a$export$1aa679bd5e605f82 as fetchLithologies, $33a46f9423c8104a$export$5d2ec2e733dfe6c7 as fetchIntervals, $33a46f9423c8104a$export$780b4b253712916c as fetchEnvironments, $33a46f9423c8104a$export$cd7bfa0860f58b96 as fetchRefs, $33a46f9423c8104a$export$b97b9bdd6a521298 as fetchUnits, $33a46f9423c8104a$export$d3d8b0fabcc76c5d as fetchColumnUnits};
|
|
152
|
+
//# sourceMappingURL=fetch.99aec438.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAeA,SAAS,mCACP,GAAW,EACX,OAA4C;IAE5C,MAAM,UAAU;IAChB,OAAO,CAAA,GAAA,iBAAS,EAAE,UAAU,KAAK;AACnC;AAUO,eAAe,0CACpB,UAA8B,CAAC,CAAC;IAEhC,MAAM,cACJ,UAAU,aACV,SAAS,UACT,SAAS,wBACT,UAAU,SACV,QAAQ,CAAA,GAAA,iBAAS,GAClB,GAAG;IAEJ,IAAI,OAAY;gBAAE;IAAO;IACzB,IAAI,aAAa,MACf,OAAO;QAAE,GAAG,IAAI;QAAE,YAAY;IAAU;IAE1C,IAAI,cAAc,MAChB,OAAO;QAAE,GAAG,IAAI;QAAE,aAAa;IAAW;IAG5C,IAAI,aAA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AO,MAAM,qCAAe;AAC9B;AAOO,eAAe,0CACpB,OAAiB,EACjB,QAAQ,kCAAY;IAEpB,MAAM,WAAW,QAAQ,GAAG,CAAC,CAAC,SAAW,0CAAiB,QAAQ;IAClE,OAAO,MAAM,QAAQ,GAAG,CAAC;AAC3B;AAEO,eAAe,0CACpB,MAAc,EACd,QAAQ,kCAAY;IAEpB,MAAM,SAAS,IAAI;IACnB,OAAO,MAAM,CAAC,YAAY;IAC1B,OAAO,MAAM,CAAC,UAAU,OAAO,QAAQ;IACvC,MAAM,MAAM,MAAM,MAAM,YAAiB,OAAO,QAAQ;IACxD,MAAM,OAAO,MAAM,IAAI,IAAI;IAC3B,IAAI,CAAC,KAAK,OAAO,EACf,MAAM,IAAI,MAAM;IAElB,MAAM,QAAQ,KAAK,OAAO,CAAC,IAAI;IAC/B,OAAO;QAAE,UAAU;eAAQ;IAAM;AACnC","sources":["packages/column-views/src/data-provider/fetch.ts"],"sourcesContent":["import {\n ColumnGeoJSONRecord,\n ColumnGeoJSONRecordWithID,\n MacrostratRef,\n UnitLong,\n} from \"@macrostrat/api-types\";\nimport {\n addQueryString,\n joinURL,\n useAPIResult,\n} from \"@macrostrat/ui-components\";\nimport crossFetch from \"cross-fetch\";\nimport { feature } from \"topojson-client\";\nimport { geoArea } from \"d3-geo\";\n\nfunction defaultFetch(\n url: string,\n options: RequestInit | undefined = undefined\n) {\n const baseURL = \"https://macrostrat.org/api/v2\";\n return crossFetch(baseURL + url, options);\n}\n\nexport interface ColumnFetchOptions {\n apiBaseURL?: string;\n projectID?: number;\n statusCode?: \"in process\";\n format?: \"geojson\" | \"topojson\" | \"geojson_bare\";\n fetch?: any;\n}\n\nexport async function fetchAllColumns(\n options: ColumnFetchOptions = {}\n): Promise<ColumnGeoJSONRecord[]> {\n const {\n apiBaseURL,\n projectID,\n format = \"topojson\",\n statusCode,\n fetch = crossFetch,\n } = options;\n\n let args: any = { format };\n if (projectID != null) {\n args = { ...args, project_id: projectID };\n }\n if (statusCode != null) {\n args = { ...args, status_code: statusCode };\n }\n\n if (projectID == null) {\n args = { ...args, all: true };\n }\n\n let url = \"/columns\";\n if (apiBaseURL != null) {\n url = joinURL(apiBaseURL, url);\n }\n\n // Try with fetch\n url = addQueryString(url, args);\n\n const res = await fetch(url, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (res == null) {\n return null;\n }\n\n // Get JSON\n const data = await res.json();\n return postProcessColumns(columnProcessors[format](data));\n}\n\nexport function useColumnFeatures({\n apiRoute = \"/columns\",\n status_code,\n project_id,\n format = \"geojson\",\n}) {\n let all: boolean = undefined;\n if (status_code == null && project_id == null) {\n all = true;\n }\n\n const processor = columnProcessors[format];\n\n return useAPIResult(\n apiRoute,\n { format, all, status_code, project_id },\n processor\n );\n}\n\nfunction processGeoJSON(res) {\n return processGeoJSONBare(res?.success?.data);\n}\n\nfunction processGeoJSONBare(res) {\n return res?.features;\n}\n\nfunction processTopoJSON(res) {\n try {\n const { data } = res.success;\n const { features: f } = feature(data, data.objects.output) as any;\n return f;\n } catch (err) {\n console.error(err);\n return [];\n }\n}\n\nfunction postProcessColumns(columns) {\n return promoteColumnIDs(\n convertSmallAreasToPoints(removeFeaturesWithoutGeometry(columns))\n );\n}\n\nfunction promoteColumnIDs(\n features: ColumnGeoJSONRecord[]\n): ColumnGeoJSONRecordWithID[] {\n return features.map((f, i) => {\n return {\n id: f.properties?.col_id,\n ...f,\n };\n });\n}\n\nfunction removeFeaturesWithoutGeometry(features) {\n return features.filter((f) => f.geometry != null);\n}\n\nfunction convertSmallAreasToPoints(features) {\n return features.map((f) => {\n // GeoArea takes a long time to run. We are really more worried about points that are zero-area\n if (geoArea(f.geometry) < 1e-8) {\n const centroid = f.geometry.coordinates[0][0];\n f.geometry = {\n type: \"Point\",\n coordinates: centroid,\n };\n }\n return f;\n });\n}\n\nconst columnProcessors = {\n topojson: processTopoJSON,\n geojson: processGeoJSON,\n geojson_bare: processGeoJSONBare,\n};\n\nasync function unwrapResponse(res) {\n if (res == null) {\n return null;\n }\n const resData = await res.json();\n return resData[\"success\"][\"data\"];\n}\n\nexport async function fetchLithologies(fetch = defaultFetch) {\n const res = await fetch(\"/defs/lithologies?all\");\n return await unwrapResponse(res);\n}\n\nexport async function fetchIntervals(\n timescaleID: number | null,\n fetch = defaultFetch\n) {\n let url = `/defs/intervals`;\n if (timescaleID != null) {\n url += `?timescale_id=${timescaleID}`;\n } else {\n url += \"?all\";\n }\n const res = await fetch(url);\n return await unwrapResponse(res);\n}\n\nexport async function fetchEnvironments(fetch = defaultFetch) {\n const res = await fetch(\"/defs/environments?all\");\n return await unwrapResponse(res);\n}\n\nexport async function fetchRefs(\n refs: number[],\n fetch = defaultFetch\n): Promise<MacrostratRef[]> {\n let url = `/defs/refs`;\n if (refs.length == 0) {\n return [];\n }\n url += \"?ref_id=\" + refs.join(\",\");\n const res = await fetch(url);\n return await unwrapResponse(res);\n}\n\nexport type ColumnData = {\n units: UnitLong[];\n columnID: number;\n};\n\nexport async function fetchUnits(\n columns: number[],\n fetch = defaultFetch\n): Promise<ColumnData[]> {\n const promises = columns.map((col_id) => fetchColumnUnits(col_id, fetch));\n return await Promise.all(promises);\n}\n\nexport async function fetchColumnUnits(\n col_id: number,\n fetch = defaultFetch\n): Promise<ColumnData> {\n const params = new URLSearchParams();\n params.append(\"response\", \"long\");\n params.append(\"col_id\", col_id.toString());\n const res = await fetch(\"/units\" + \"?\" + params.toString());\n const data = await res.json();\n if (!data.success) {\n throw new Error(\"Failed to fetch column units\");\n }\n const units = data.success.data;\n return { columnID: col_id, units };\n}\n"],"names":[],"version":3,"file":"fetch.99aec438.js.map"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function $c491b6231216b7f9$export$77c3cc7a57c6db5f(section) {
|
|
2
|
+
/* Section should be specified as space-separated coordinates */ if (section == null || typeof section !== "string") return null;
|
|
3
|
+
try {
|
|
4
|
+
let coords = section.split(" ").map($c491b6231216b7f9$var$parseCoordinates);
|
|
5
|
+
return {
|
|
6
|
+
type: "LineString",
|
|
7
|
+
coordinates: coords
|
|
8
|
+
};
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.warn(e);
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function $c491b6231216b7f9$export$8c53992169ff5301(line) {
|
|
15
|
+
if (line == null || line.type !== "LineString" || line.coordinates.length < 2) return null;
|
|
16
|
+
return line.coordinates.map((coord)=>coord.map($c491b6231216b7f9$var$stringifyNumber).join(",")).join(" ");
|
|
17
|
+
}
|
|
18
|
+
function $c491b6231216b7f9$var$parseCoordinates(s) {
|
|
19
|
+
let [x, y] = s.split(",").map($c491b6231216b7f9$var$parseNumber);
|
|
20
|
+
if (x == null || y == null || isNaN(x) || isNaN(y)) throw new Error("Invalid coordinate string");
|
|
21
|
+
if (x > 180 || x < -180 || y > 90 || y < -90) throw new Error("Invalid coordinate value");
|
|
22
|
+
return [
|
|
23
|
+
x,
|
|
24
|
+
y
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function $c491b6231216b7f9$var$parseNumber(s) {
|
|
28
|
+
let s1 = s;
|
|
29
|
+
// For some reason, we sometimes get en-dashes in the hash string
|
|
30
|
+
if (s1[0] == "\u2212") s1 = "-" + s1.slice(1);
|
|
31
|
+
return Number(s1);
|
|
32
|
+
}
|
|
33
|
+
const $c491b6231216b7f9$var$stringifyNumber = (d)=>d.toLocaleString("en-US", {
|
|
34
|
+
maximumFractionDigits: 2
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export {$c491b6231216b7f9$export$77c3cc7a57c6db5f as parseLineFromString, $c491b6231216b7f9$export$8c53992169ff5301 as stringifyLine};
|
|
39
|
+
//# sourceMappingURL=hash-string.285b37fb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAEO,SAAS,0CAAoB,OAAe;IACjD,8DAA8D,GAC9D,IAAI,WAAW,QAAQ,OAAO,YAAY,UACxC,OAAO;IAGT,IAAI;QACF,IAAI,SAAS,QAAQ,KAAK,CAAC,KAAK,GAAG,CAAC;QACpC,OAAO;YACL,MAAM;YACN,aAAa;QACf;IACF,EAAE,OAAO,GAAG;QACV,QAAQ,IAAI,CAAC;QACb,OAAO;IACT;AACF;AAEO,SAAS,0CAAc,IAAuB;IACnD,IACE,QAAQ,QACR,KAAK,IAAI,KAAK,gBACd,KAAK,WAAW,CAAC,MAAM,GAAG,GAE1B,OAAO;IAET,OAAO,KAAK,WAAW,CACpB,GAAG,CAAC,CAAC,QAAU,MAAM,GAAG,CAAC,uCAAiB,IAAI,CAAC,MAC/C,IAAI,CAAC;AACV;AAEA,SAAS,uCAAiB,CAAS;IACjC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;IAC9B,IAAI,KAAK,QAAQ,KAAK,QAAQ,MAAM,MAAM,MAAM,IAC9C,MAAM,IAAI,MAAM;IAElB,IAAI,IAAI,OAAO,IAAI,QAAQ,IAAI,MAAM,IAAI,KACvC,MAAM,IAAI,MAAM;IAElB,OAAO;QAAC;QAAG;KAAE;AACf;AAEA,SAAS,kCAAY,CAAS;IAC5B,IAAI,KAAK;IACT,iEAAiE;IACjE,IAAI,EAAE,CAAC,EAAE,IAAI,UACX,KAAK,MAAM,GAAG,KAAK,CAAC;IAEtB,OAAO,OAAO;AAChB;AAEA,MAAM,wCAAkB,CAAC,IACvB,EAAE,cAAc,CAAC,SAAS;QACxB,uBAAuB;IACzB","sources":["packages/column-views/src/correlation-chart/hash-string.ts"],"sourcesContent":["import { LineString } from \"geojson\";\n\nexport function parseLineFromString(section: string): LineString | null {\n /* Section should be specified as space-separated coordinates */\n if (section == null || typeof section !== \"string\") {\n return null;\n }\n\n try {\n let coords = section.split(\" \").map(parseCoordinates);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\n } catch (e) {\n console.warn(e);\n return null;\n }\n}\n\nexport function stringifyLine(line: LineString | null): string | null {\n if (\n line == null ||\n line.type !== \"LineString\" ||\n line.coordinates.length < 2\n ) {\n return null;\n }\n return line.coordinates\n .map((coord) => coord.map(stringifyNumber).join(\",\"))\n .join(\" \");\n}\n\nfunction parseCoordinates(s: string): [number, number] {\n let [x, y] = s.split(\",\").map(parseNumber);\n if (x == null || y == null || isNaN(x) || isNaN(y)) {\n throw new Error(\"Invalid coordinate string\");\n }\n if (x > 180 || x < -180 || y > 90 || y < -90) {\n throw new Error(\"Invalid coordinate value\");\n }\n return [x, y];\n}\n\nfunction parseNumber(s: string): number {\n let s1 = s;\n // For some reason, we sometimes get en-dashes in the hash string\n if (s1[0] == \"−\") {\n s1 = \"-\" + s1.slice(1);\n }\n return Number(s1);\n}\n\nconst stringifyNumber = (d) =>\n d.toLocaleString(\"en-US\", {\n maximumFractionDigits: 2,\n });\n"],"names":[],"version":3,"file":"hash-string.285b37fb.js.map"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {createUnitSorter as $b6657fba8924a702$export$ab14c04795685c55, ensureArray as $b6657fba8924a702$export$d0c8ecbd4ed8940c, ensureRealFloat as $b6657fba8924a702$export$97de5b0a6b4e4dac, getUnitHeightRange as $b6657fba8924a702$export$70e712e2ac0237a, unitsOverlap as $b6657fba8924a702$export$f1a15f539858307} from "./utils.d7a43a2a.js";
|
|
2
|
+
import {group as $ailTa$group} from "d3-array";
|
|
3
|
+
import {ColumnAxisType as $ailTa$ColumnAxisType} from "@macrostrat/column-components";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const $663a0cdd08b02256$var$dt = 0.001;
|
|
9
|
+
function $663a0cdd08b02256$export$55543e159517d62d(section, axisType = (0, $ailTa$ColumnAxisType).AGE) {
|
|
10
|
+
/** Preprocess units to add overlapping units and columns. */ const units = section.units;
|
|
11
|
+
let divisions = units.map((...args)=>$663a0cdd08b02256$var$extendDivision(...args, axisType));
|
|
12
|
+
for (let d of divisions){
|
|
13
|
+
const overlappingUnits = divisions.filter((u)=>d.overlappingUnits.includes(u.unit_id));
|
|
14
|
+
// Overlapping columns
|
|
15
|
+
const columns = overlappingUnits.map((d)=>d.column);
|
|
16
|
+
if (columns.includes(d.column)) {
|
|
17
|
+
let col = 0;
|
|
18
|
+
// Go through columns to find a better index
|
|
19
|
+
while(columns.includes(col))col++;
|
|
20
|
+
d.column = col;
|
|
21
|
+
}
|
|
22
|
+
// If unit overlaps the edges of a section, set the clip positions
|
|
23
|
+
if (axisType == (0, $ailTa$ColumnAxisType).AGE) {
|
|
24
|
+
const [b_pos, t_pos] = (0, $b6657fba8924a702$export$70e712e2ac0237a)(d, axisType);
|
|
25
|
+
if (b_pos > section.b_age) d.b_clip_pos = section.b_age;
|
|
26
|
+
if (t_pos < section.t_age) d.t_clip_pos = section.t_age;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (axisType != (0, $ailTa$ColumnAxisType).AGE) return $663a0cdd08b02256$var$preprocessSectionUnits(divisions, axisType);
|
|
30
|
+
return divisions;
|
|
31
|
+
}
|
|
32
|
+
function $663a0cdd08b02256$var$extendDivision(unit, i, divisions, axisType = (0, $ailTa$ColumnAxisType).AGE) {
|
|
33
|
+
const overlappingUnits = divisions.filter((d)=>d.unit_id != unit.unit_id && (0, $b6657fba8924a702$export$f1a15f539858307)(unit, d, axisType));
|
|
34
|
+
const u_pos = (0, $b6657fba8924a702$export$70e712e2ac0237a)(unit, axisType);
|
|
35
|
+
const bottomOverlap = overlappingUnits.some((d)=>{
|
|
36
|
+
const d_pos = (0, $b6657fba8924a702$export$70e712e2ac0237a)(d, axisType);
|
|
37
|
+
// Check if the unit is below the current unit
|
|
38
|
+
return d_pos[0] < u_pos[0] + $663a0cdd08b02256$var$dt;
|
|
39
|
+
});
|
|
40
|
+
let column = 0;
|
|
41
|
+
if (overlappingUnits.length == 1) column = 1;
|
|
42
|
+
return {
|
|
43
|
+
...unit,
|
|
44
|
+
bottomOverlap: bottomOverlap,
|
|
45
|
+
column: column,
|
|
46
|
+
overlappingUnits: overlappingUnits.map((d)=>d.unit_id)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function $663a0cdd08b02256$export$dfbd00399d639b4c(units, axisType = (0, $ailTa$ColumnAxisType).AGE) {
|
|
50
|
+
let groups = Array.from((0, $ailTa$group)(units, (d)=>d.section_id));
|
|
51
|
+
const unitComparator = (0, $b6657fba8924a702$export$ab14c04795685c55)(axisType);
|
|
52
|
+
const groups1 = groups.map(([section_id, sectionUnits])=>{
|
|
53
|
+
const [b_age, t_age] = $663a0cdd08b02256$export$8093438ec3e4c6fd(sectionUnits);
|
|
54
|
+
// sort units by position
|
|
55
|
+
sectionUnits.sort(unitComparator);
|
|
56
|
+
return {
|
|
57
|
+
section_id: section_id,
|
|
58
|
+
t_age: t_age,
|
|
59
|
+
b_age: b_age,
|
|
60
|
+
units: sectionUnits
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
// Sort sections by increasing top age, then increasing bottom age.
|
|
64
|
+
// Sections have no relative ordinal position other than age...
|
|
65
|
+
const compareSections = (0, $b6657fba8924a702$export$ab14c04795685c55)((0, $ailTa$ColumnAxisType).AGE);
|
|
66
|
+
groups1.sort(compareSections);
|
|
67
|
+
return groups1;
|
|
68
|
+
}
|
|
69
|
+
function $663a0cdd08b02256$export$8093438ec3e4c6fd(units) {
|
|
70
|
+
/** Get the overall age range of a set of units. */ const t_ages = units.map((d)=>d.t_age);
|
|
71
|
+
const b_ages = units.map((d)=>d.b_age);
|
|
72
|
+
const t_age = Math.min(...t_ages);
|
|
73
|
+
const b_age = Math.max(...b_ages);
|
|
74
|
+
return [
|
|
75
|
+
b_age,
|
|
76
|
+
t_age
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
function $663a0cdd08b02256$export$e7bb744b9be37f3d(sections) {
|
|
80
|
+
/** Columns can have sections that overlap in time. Here, we merge overlapping
|
|
81
|
+
* sections into a single section to correctly render gap-bound packages.
|
|
82
|
+
*/ const [firstSection, ...rest] = sections;
|
|
83
|
+
const newSections = [
|
|
84
|
+
firstSection
|
|
85
|
+
];
|
|
86
|
+
for (const section of rest){
|
|
87
|
+
const lastSection = newSections[newSections.length - 1];
|
|
88
|
+
if (lastSection.b_age < section.t_age || lastSection.t_age > section.b_age) {
|
|
89
|
+
// No overlap, add the section as normal
|
|
90
|
+
newSections.push(section);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// Overlap, merge the sections
|
|
94
|
+
lastSection.section_id = [
|
|
95
|
+
...(0, $b6657fba8924a702$export$d0c8ecbd4ed8940c)(lastSection.section_id),
|
|
96
|
+
...(0, $b6657fba8924a702$export$d0c8ecbd4ed8940c)(section.section_id)
|
|
97
|
+
];
|
|
98
|
+
lastSection.units.push(...section.units);
|
|
99
|
+
lastSection.b_age = Math.max(lastSection.b_age, section.b_age);
|
|
100
|
+
lastSection.t_age = Math.min(lastSection.t_age, section.t_age);
|
|
101
|
+
}
|
|
102
|
+
return newSections;
|
|
103
|
+
}
|
|
104
|
+
function $663a0cdd08b02256$var$preprocessSectionUnits(units, axisType = (0, $ailTa$ColumnAxisType).DEPTH) {
|
|
105
|
+
/** Preprocess units for a "section" column type, which is guaranteed to be simpler. */ // We have to assume the units are ordered...
|
|
106
|
+
let thickness = 0;
|
|
107
|
+
return units.map((unit, i)=>{
|
|
108
|
+
let u1 = $663a0cdd08b02256$var$preprocessSectionUnit(unit, i, units, thickness, axisType);
|
|
109
|
+
thickness += Math.abs(u1.t_pos - u1.b_pos);
|
|
110
|
+
return u1;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function $663a0cdd08b02256$var$preprocessSectionUnit(unit, i, units, accumulatedThickness = 0, axisType = (0, $ailTa$ColumnAxisType).DEPTH) {
|
|
114
|
+
/** Preprocess a single unit for a "section" column type.
|
|
115
|
+
* No provision for overlapping units.
|
|
116
|
+
* */ let b_pos = unit.b_pos;
|
|
117
|
+
let t_pos = unit.t_pos;
|
|
118
|
+
if (b_pos == t_pos && axisType == (0, $ailTa$ColumnAxisType).ORDINAL) t_pos = t_pos - 1;
|
|
119
|
+
let unit_name = unit.unit_name;
|
|
120
|
+
// eODP columns sometimes have overlapping core sections, which are encoded in the name field
|
|
121
|
+
// Match eODP section names
|
|
122
|
+
const match = unit.unit_name.match(/^(\d+(\.\d+)?)-(\d+(\.\d+)?): (.+)/);
|
|
123
|
+
if (match) {
|
|
124
|
+
// These values should already be set if we've used the show_positions flag
|
|
125
|
+
t_pos ??= (0, $b6657fba8924a702$export$97de5b0a6b4e4dac)(match[1]);
|
|
126
|
+
b_pos ??= (0, $b6657fba8924a702$export$97de5b0a6b4e4dac)(match[3]);
|
|
127
|
+
unit_name = match[5];
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
...unit,
|
|
131
|
+
b_pos: (0, $b6657fba8924a702$export$97de5b0a6b4e4dac)(b_pos),
|
|
132
|
+
t_pos: (0, $b6657fba8924a702$export$97de5b0a6b4e4dac)(t_pos),
|
|
133
|
+
unit_name: unit_name,
|
|
134
|
+
bottomOverlap: false,
|
|
135
|
+
overlappingUnits: []
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
export {$663a0cdd08b02256$export$55543e159517d62d as preprocessUnits, $663a0cdd08b02256$export$dfbd00399d639b4c as groupUnitsIntoSections, $663a0cdd08b02256$export$8093438ec3e4c6fd as getSectionAgeRange, $663a0cdd08b02256$export$e7bb744b9be37f3d as mergeOverlappingSections};
|
|
141
|
+
//# sourceMappingURL=helpers.2f0a0cb7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;AAWA,MAAM,2BAAK;AA2BJ,SAAS,0CACd,OAAuB,EACvB,WAA2B,CAAA,GAAA,qBAAa,EAAE,GAAG;IAE7C,2DAA2D,GAC3D,MAAM,QAAQ,QAAQ,KAAK;IAC3B,IAAI,YAAY,MAAM,GAAG,CAAC,CAAC,GAAG,OAAS,wCAAkB,MAAM;IA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EAAE;QAClC,YAAY,KAAK,CAAC,EAAE;IACtB;IAEA,OAAO;QACL,GAAG,IAAI;QACP,OAAO,CAAA,GAAA,yCAAc,EAAE;QACvB,OAAO,CAAA,GAAA,yCAAc,EAAE;mBACvB;QACA,eAAe;QACf,kBAAkB,EAAE;IACtB;AACF","sources":["packages/column-views/src/prepare-units/helpers.ts"],"sourcesContent":["import type { BaseUnit, UnitLong } from \"@macrostrat/api-types\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n unitsOverlap,\n getUnitHeightRange,\n createUnitSorter,\n ensureArray,\n ensureRealFloat,\n} from \"./utils\";\n\nconst dt = 0.001;\n\nexport interface StratigraphicPackage {\n /** A collection of stratigraphic information organized in time, corresponding\n * to single or multiple columns. */\n t_age: number;\n b_age: number;\n}\n\nexport interface SectionInfo<T extends UnitLong = ExtUnit>\n extends StratigraphicPackage {\n /** A time-bounded part of a single stratigraphic column. */\n section_id: number | number[];\n units: T[];\n}\n\nexport interface ExtUnit extends UnitLong {\n bottomOverlap: boolean;\n overlappingUnits: number[];\n column?: number;\n /* Positions (ages or heights) where the unit is clipped to its containing section.\n * This is relevant if we are filtering by age/height/depth range.\n */\n t_clip_pos?: number;\n b_clip_pos?: number;\n}\n\nexport function preprocessUnits<T extends UnitLong = UnitLong>(\n section: SectionInfo<T>,\n axisType: ColumnAxisType = ColumnAxisType.AGE\n): ExtUnit[] {\n /** Preprocess units to add overlapping units and columns. */\n const units = section.units;\n let divisions = units.map((...args) => extendDivision(...args, axisType));\n for (let d of divisions) {\n const overlappingUnits = divisions.filter((u) =>\n d.overlappingUnits.includes(u.unit_id)\n );\n\n // Overlapping columns\n const columns = overlappingUnits.map((d) => d.column);\n\n if (columns.includes(d.column)) {\n let col = 0;\n // Go through columns to find a better index\n while (columns.includes(col)) {\n col++;\n }\n d.column = col;\n }\n\n // If unit overlaps the edges of a section, set the clip positions\n if (axisType == ColumnAxisType.AGE) {\n const [b_pos, t_pos] = getUnitHeightRange(d, axisType);\n if (b_pos > section.b_age) {\n d.b_clip_pos = section.b_age;\n }\n if (t_pos < section.t_age) {\n d.t_clip_pos = section.t_age;\n }\n }\n }\n\n if (axisType != ColumnAxisType.AGE) {\n return preprocessSectionUnits(divisions, axisType);\n }\n\n return divisions;\n}\n\nfunction extendDivision(\n unit: UnitLong,\n i: number,\n divisions: UnitLong[],\n axisType: ColumnAxisType = ColumnAxisType.AGE\n): ExtUnit {\n const overlappingUnits = divisions.filter(\n (d) => d.unit_id != unit.unit_id && unitsOverlap(unit, d, axisType)\n );\n const u_pos = getUnitHeightRange(unit, axisType);\n const bottomOverlap = overlappingUnits.some((d) => {\n const d_pos = getUnitHeightRange(d, axisType);\n // Check if the unit is below the current unit\n return d_pos[0] < u_pos[0] + dt;\n });\n let column = 0;\n if (overlappingUnits.length == 1) {\n column = 1;\n }\n\n return {\n ...unit,\n bottomOverlap,\n column,\n overlappingUnits: overlappingUnits.map((d) => d.unit_id),\n };\n}\n\nexport function groupUnitsIntoSections<T extends UnitLong>(\n units: T[],\n axisType: ColumnAxisType = ColumnAxisType.AGE\n): SectionInfo<T>[] {\n let groups = Array.from(group(units, (d) => d.section_id));\n const unitComparator = createUnitSorter(axisType);\n\n const groups1 = groups.map(([section_id, sectionUnits]) => {\n const [b_age, t_age] = getSectionAgeRange(sectionUnits);\n // sort units by position\n sectionUnits.sort(unitComparator);\n return { section_id, t_age, b_age, units: sectionUnits };\n });\n // Sort sections by increasing top age, then increasing bottom age.\n // Sections have no relative ordinal position other than age...\n const compareSections = createUnitSorter(ColumnAxisType.AGE) as (\n a: StratigraphicPackage,\n b: StratigraphicPackage\n ) => number;\n groups1.sort(compareSections);\n return groups1;\n}\n\nexport function getSectionAgeRange(units: BaseUnit[]): [number, number] {\n /** Get the overall age range of a set of units. */\n const t_ages = units.map((d) => d.t_age);\n const b_ages = units.map((d) => d.b_age);\n const t_age = Math.min(...t_ages);\n const b_age = Math.max(...b_ages);\n return [b_age, t_age];\n}\n\nexport function mergeOverlappingSections<T extends UnitLong>(\n sections: SectionInfo<T>[]\n): SectionInfo<T>[] {\n /** Columns can have sections that overlap in time. Here, we merge overlapping\n * sections into a single section to correctly render gap-bound packages.\n */\n const [firstSection, ...rest] = sections;\n const newSections = [firstSection];\n for (const section of rest) {\n const lastSection = newSections[newSections.length - 1];\n if (\n lastSection.b_age < section.t_age ||\n lastSection.t_age > section.b_age\n ) {\n // No overlap, add the section as normal\n newSections.push(section);\n continue;\n }\n\n // Overlap, merge the sections\n lastSection.section_id = [\n ...ensureArray(lastSection.section_id),\n ...ensureArray(section.section_id),\n ];\n lastSection.units.push(...section.units);\n lastSection.b_age = Math.max(lastSection.b_age, section.b_age);\n lastSection.t_age = Math.min(lastSection.t_age, section.t_age);\n }\n return newSections;\n}\n\nfunction preprocessSectionUnits(\n units: UnitLong[],\n axisType: ColumnAxisType = ColumnAxisType.DEPTH\n): ExtUnit[] {\n /** Preprocess units for a \"section\" column type, which is guaranteed to be simpler. */\n // We have to assume the units are ordered...\n let thickness = 0;\n return units.map((unit, i) => {\n let u1 = preprocessSectionUnit(unit, i, units, thickness, axisType);\n thickness += Math.abs(u1.t_pos - u1.b_pos);\n return u1;\n });\n}\n\nfunction preprocessSectionUnit(\n unit: UnitLong,\n i: number,\n units: UnitLong[],\n accumulatedThickness: number = 0,\n axisType: ColumnAxisType = ColumnAxisType.DEPTH\n): ExtUnit {\n /** Preprocess a single unit for a \"section\" column type.\n * No provision for overlapping units.\n * */\n\n let b_pos = unit.b_pos;\n let t_pos = unit.t_pos;\n\n if (b_pos == t_pos && axisType == ColumnAxisType.ORDINAL) {\n t_pos = t_pos - 1;\n }\n\n let unit_name = unit.unit_name;\n\n // eODP columns sometimes have overlapping core sections, which are encoded in the name field\n // Match eODP section names\n const match = unit.unit_name.match(/^(\\d+(\\.\\d+)?)-(\\d+(\\.\\d+)?): (.+)/);\n\n if (match) {\n // These values should already be set if we've used the show_positions flag\n t_pos ??= ensureRealFloat(match[1]);\n b_pos ??= ensureRealFloat(match[3]);\n unit_name = match[5];\n }\n\n return {\n ...unit,\n b_pos: ensureRealFloat(b_pos),\n t_pos: ensureRealFloat(t_pos),\n unit_name,\n bottomOverlap: false,\n overlappingUnits: [],\n };\n}\n"],"names":[],"version":3,"file":"helpers.2f0a0cb7.js.map"}
|