@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.
Files changed (118) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/index.cjs +15 -42
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +2 -1
  5. package/dist/index.js +1 -34
  6. package/dist/index.js.map +1 -1
  7. package/dist/units/boxes.cjs +3 -3
  8. package/dist/units/boxes.cjs.map +1 -1
  9. package/dist/units/boxes.js +3 -3
  10. package/dist/units/boxes.js.map +1 -1
  11. package/dist/units/index.cjs +7 -11
  12. package/dist/units/index.cjs.map +1 -1
  13. package/dist/units/index.d.ts +0 -1
  14. package/dist/units/index.js +4 -9
  15. package/dist/units/index.js.map +1 -1
  16. package/package.json +6 -27
  17. package/src/index.ts +3 -1
  18. package/src/units/boxes.ts +7 -4
  19. package/src/units/index.ts +9 -26
  20. package/dist/maps/column-correlation/core.cjs +0 -288
  21. package/dist/maps/column-correlation/core.cjs.map +0 -1
  22. package/dist/maps/column-correlation/core.d.ts +0 -9
  23. package/dist/maps/column-correlation/core.js +0 -286
  24. package/dist/maps/column-correlation/core.js.map +0 -1
  25. package/dist/maps/column-correlation/index.d.ts +0 -2
  26. package/dist/maps/column-correlation/state.cjs +0 -193
  27. package/dist/maps/column-correlation/state.cjs.map +0 -1
  28. package/dist/maps/column-correlation/state.d.ts +0 -62
  29. package/dist/maps/column-correlation/state.js +0 -190
  30. package/dist/maps/column-correlation/state.js.map +0 -1
  31. package/dist/maps/column-navigation/index.d.ts +0 -2
  32. package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
  33. package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
  34. package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
  35. package/dist/maps/column-navigation/mapbox/index.js +0 -213
  36. package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
  37. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
  38. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
  39. package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
  40. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
  41. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
  42. package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
  43. package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
  44. package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
  45. package/dist/maps/column-navigation/mapbox/state.js +0 -71
  46. package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
  47. package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
  48. package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
  49. package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
  50. package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
  51. package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
  52. package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
  53. package/dist/maps/column-navigation/svg/index.cjs +0 -94
  54. package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
  55. package/dist/maps/column-navigation/svg/index.d.ts +0 -9
  56. package/dist/maps/column-navigation/svg/index.js +0 -93
  57. package/dist/maps/column-navigation/svg/index.js.map +0 -1
  58. package/dist/maps/column-navigation/svg/layers.cjs +0 -177
  59. package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
  60. package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
  61. package/dist/maps/column-navigation/svg/layers.js +0 -174
  62. package/dist/maps/column-navigation/svg/layers.js.map +0 -1
  63. package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
  64. package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
  65. package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
  66. package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
  67. package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
  68. package/dist/maps/index.d.ts +0 -4
  69. package/dist/maps/inset-map/index.cjs +0 -71
  70. package/dist/maps/inset-map/index.cjs.map +0 -1
  71. package/dist/maps/inset-map/index.d.ts +0 -16
  72. package/dist/maps/inset-map/index.js +0 -69
  73. package/dist/maps/inset-map/index.js.map +0 -1
  74. package/dist/maps/layers/columns.cjs +0 -165
  75. package/dist/maps/layers/columns.cjs.map +0 -1
  76. package/dist/maps/layers/columns.d.ts +0 -28
  77. package/dist/maps/layers/columns.js +0 -165
  78. package/dist/maps/layers/columns.js.map +0 -1
  79. package/dist/maps/layers/index.d.ts +0 -2
  80. package/dist/maps/layers/units.cjs +0 -207
  81. package/dist/maps/layers/units.cjs.map +0 -1
  82. package/dist/maps/layers/units.d.ts +0 -14
  83. package/dist/maps/layers/units.js +0 -204
  84. package/dist/maps/layers/units.js.map +0 -1
  85. package/dist/units/colors.cjs +0 -115
  86. package/dist/units/colors.cjs.map +0 -1
  87. package/dist/units/colors.d.ts +0 -20
  88. package/dist/units/colors.js +0 -113
  89. package/dist/units/colors.js.map +0 -1
  90. package/dist/units/resolvers.cjs +0 -125
  91. package/dist/units/resolvers.cjs.map +0 -1
  92. package/dist/units/resolvers.d.ts +0 -8
  93. package/dist/units/resolvers.js +0 -125
  94. package/dist/units/resolvers.js.map +0 -1
  95. package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
  96. package/src/maps/column-correlation/core.ts +0 -342
  97. package/src/maps/column-correlation/index.ts +0 -2
  98. package/src/maps/column-correlation/state.ts +0 -315
  99. package/src/maps/column-navigation/index.ts +0 -2
  100. package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
  101. package/src/maps/column-navigation/mapbox/index.ts +0 -276
  102. package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
  103. package/src/maps/column-navigation/mapbox/state.ts +0 -119
  104. package/src/maps/column-navigation/svg/animated.ts +0 -78
  105. package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
  106. package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
  107. package/src/maps/column-navigation/svg/index.ts +0 -96
  108. package/src/maps/column-navigation/svg/layers.ts +0 -233
  109. package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
  110. package/src/maps/index.ts +0 -4
  111. package/src/maps/inset-map/index.ts +0 -87
  112. package/src/maps/inset-map/inset-map.stories.ts +0 -20
  113. package/src/maps/layers/columns.ts +0 -216
  114. package/src/maps/layers/index.ts +0 -2
  115. package/src/maps/layers/units.ts +0 -286
  116. package/src/maps/unit-map.stories.ts +0 -79
  117. package/src/units/colors.ts +0 -183
  118. package/src/units/resolvers.ts +0 -141
@@ -1,204 +0,0 @@
1
- import { useLithologies, useMacrostratColumns } from "@macrostrat/data-provider";
2
- import { useAPIResult } from "@macrostrat/ui-components";
3
- import { useOverlayStyle, useMapStyleOperator } from "@macrostrat/mapbox-react";
4
- import { useMemo } from "react";
5
- import { buildGeoJSONSource, mergeStyles, setGeoJSON } from "@macrostrat/mapbox-utils";
6
- import { getBestFGDCPatternForLithologyList } from "../../units/resolvers.js";
7
- import { setupStyleImageManager, loadStyleImage } from "@macrostrat/map-styles";
8
- import { asChromaColor } from "@macrostrat/color-utils";
9
- import pMap from "p-map";
10
- import { BaseColumnsLayer } from "./columns.js";
11
- import h from "@macrostrat/hyper";
12
- import { flattenLithologies, getMixedColorForData } from "../../units/colors.js";
13
- function MacrostratUnitsOverlay(props) {
14
- const { time, ageSpan = 0.05, patterns = false } = props;
15
- const lithMap = useLithologies();
16
- useOverlayStyle(() => {
17
- return buildUnitsStyle({ patterns });
18
- }, [patterns]);
19
- useMapStyleOperator(
20
- (map) => {
21
- if (!patterns) return;
22
- setupStyleImageManager(map, { verbose: false });
23
- },
24
- [patterns]
25
- );
26
- const params = useMemo(() => {
27
- let project;
28
- if (Number.isFinite(props.project)) {
29
- project = [props.project];
30
- } else if (!Array.isArray(props.project)) {
31
- project = void 0;
32
- }
33
- const projectCompat = project != null && project.length > 0 ? project[0] : void 0;
34
- return {
35
- age_bottom: time + ageSpan / 2,
36
- age_top: time - ageSpan / 2,
37
- response: "long",
38
- project: projectCompat
39
- };
40
- }, [time, ageSpan, props.project]);
41
- const units = useAPIResult("/units", params);
42
- const columns = useMacrostratColumns(params.project, false);
43
- useMapStyleOperator(
44
- (map) => {
45
- if (units == null || columns == null || lithMap == null) {
46
- return;
47
- }
48
- const getColorForLithology = (data) => {
49
- return lithMap?.get(data.lith_id)?.color ?? null;
50
- };
51
- const unitsMap = postProcessUnits(units, getColorForLithology);
52
- handleUnitsLayerUpdate(map, unitsMap, columns);
53
- if (patterns) {
54
- handlePatternOverlayUpdate(
55
- map,
56
- unitsMap,
57
- columns,
58
- getColorForLithology
59
- ).then(() => {
60
- });
61
- }
62
- },
63
- [units, lithMap, columns, patterns]
64
- );
65
- const isHovered = ["boolean", ["feature-state", "hover"], false];
66
- const isShown = ["boolean", ["feature-state", "shown"], false];
67
- const opacity = [
68
- "case",
69
- ["all", isHovered, isShown],
70
- 0.9,
71
- isShown,
72
- 0.8,
73
- isHovered,
74
- 0.3,
75
- 0
76
- ];
77
- return h([
78
- h(BaseColumnsLayer, {
79
- enabled: true,
80
- columns,
81
- opacity,
82
- lineOpacity: 0.2,
83
- lineColor: "lightgray",
84
- color: "transparent"
85
- })
86
- ]);
87
- }
88
- function handleUnitsLayerUpdate(map, unitsMap, columns) {
89
- for (const column of columns) {
90
- const col_id = column.properties.col_id;
91
- const info = unitsMap.get(Number(col_id));
92
- const color = info?.color;
93
- map.setFeatureState(
94
- { source: "columns", id: col_id },
95
- {
96
- color,
97
- shown: color != null
98
- }
99
- );
100
- }
101
- }
102
- async function handlePatternOverlayUpdate(map, unitsMap, columns, getColor) {
103
- const colsWithPatterns = [];
104
- const patternIDs = /* @__PURE__ */ new Set();
105
- for (const column of columns) {
106
- const col_id = column.properties.col_id;
107
- const info = unitsMap.get(Number(col_id));
108
- if (info == null) continue;
109
- const pattern = getPatternSpec(info?.liths, getColor);
110
- if (pattern == null) continue;
111
- colsWithPatterns.push({
112
- type: "Feature",
113
- geometry: column.geometry,
114
- properties: {
115
- col_id,
116
- pattern
117
- }
118
- });
119
- patternIDs.add(pattern);
120
- }
121
- const patternsToLoad = patternIDs.values().filter((d) => !map.hasImage(d));
122
- const mapper = async (patternID) => {
123
- try {
124
- await loadStyleImage(map, patternID, { pixelRatio: 10 });
125
- } catch (e) {
126
- }
127
- };
128
- await pMap(patternsToLoad, mapper, { concurrency: 5 });
129
- const patternData = {
130
- type: "FeatureCollection",
131
- features: colsWithPatterns
132
- };
133
- setGeoJSON(map, "column-patterns", patternData);
134
- }
135
- const cachedColors = /* @__PURE__ */ new Map();
136
- function getDarkenedColor(color) {
137
- if (cachedColors.has(color)) {
138
- return cachedColors.get(color);
139
- }
140
- const c1 = asChromaColor(color).set("hsl.l", 0.4).set("hsl.s", 0.8).hex();
141
- cachedColors.set(color, c1);
142
- return c1;
143
- }
144
- function postProcessUnits(units, getColor) {
145
- const unitsByColumn = /* @__PURE__ */ new Map();
146
- for (const unit of units) {
147
- const col_id = Number(unit.col_id);
148
- if (!unitsByColumn.has(col_id)) {
149
- unitsByColumn.set(col_id, [unit]);
150
- } else {
151
- unitsByColumn.set(col_id, [...unitsByColumn.get(col_id), unit]);
152
- }
153
- }
154
- const res = /* @__PURE__ */ new Map();
155
- for (const [col_id, unitList] of unitsByColumn.entries()) {
156
- const liths = flattenLithologies(unitList.map((u) => u.lith));
157
- res.set(col_id, {
158
- col_id,
159
- units: unitList,
160
- liths,
161
- color: getMixedColorForData(liths, getColor)
162
- });
163
- }
164
- return res;
165
- }
166
- function getPatternSpec(liths, getColor) {
167
- const patternData = getBestFGDCPatternForLithologyList(liths);
168
- if (patternData == null) return null;
169
- let { patternID, lith } = patternData;
170
- const color = getDarkenedColor(getColor(lith));
171
- return `fgdc:${patternID}:${color}:transparent`;
172
- }
173
- function buildUnitsStyle(opts = {}) {
174
- const { patterns = false } = opts;
175
- const baseStyle = {
176
- sources: {},
177
- version: 8
178
- };
179
- if (!patterns) {
180
- return baseStyle;
181
- }
182
- const patternStyle = {
183
- sources: {
184
- "column-patterns": buildGeoJSONSource()
185
- },
186
- layers: [
187
- {
188
- id: "columns-fill-pattern",
189
- type: "fill",
190
- source: "column-patterns",
191
- paint: {
192
- "fill-pattern": ["get", "pattern"],
193
- "fill-opacity": 1
194
- }
195
- }
196
- ]
197
- };
198
- return mergeStyles(baseStyle, patternStyle);
199
- }
200
- export {
201
- MacrostratUnitsOverlay,
202
- buildUnitsStyle
203
- };
204
- //# sourceMappingURL=units.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"units.js","sources":["../../../src/maps/layers/units.ts"],"sourcesContent":["import {\n useLithologies,\n useMacrostratColumns,\n} from \"@macrostrat/data-provider\";\nimport { useAPIResult } from \"@macrostrat/ui-components\";\nimport { useMapStyleOperator, useOverlayStyle } from \"@macrostrat/mapbox-react\";\nimport { FeatureCollection } from \"geojson\";\nimport { useMemo } from \"react\";\nimport { mergeStyles, setGeoJSON } from \"@macrostrat/mapbox-utils\";\nimport { UnitLithology, UnitLong } from \"@macrostrat/api-types\";\nimport { flattenLithologies, getMixedColorForData } from \"../../units\";\nimport { getBestFGDCPatternForLithologyList } from \"../../units/resolvers\";\nimport {\n setupStyleImageManager,\n loadStyleImage,\n StyleFragment,\n} from \"@macrostrat/map-styles\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport pMap from \"p-map\";\nimport { BaseColumnsLayer } from \"./columns\";\nimport h from \"@macrostrat/hyper\";\n\nexport interface UnitsOverlayProps {\n time: number;\n ageSpan?: number;\n project?: number | number[];\n patterns?: boolean;\n}\n\nexport function MacrostratUnitsOverlay(props: UnitsOverlayProps) {\n const { time, ageSpan = 0.05, patterns = false } = props;\n const lithMap = useLithologies();\n\n useOverlayStyle(() => {\n return buildUnitsStyle({ patterns });\n }, [patterns]);\n\n useMapStyleOperator(\n (map) => {\n if (!patterns) return;\n setupStyleImageManager(map, { verbose: false });\n },\n [patterns],\n );\n\n const params = useMemo(() => {\n let project: number[] | undefined;\n if (Number.isFinite(props.project)) {\n project = [props.project as number];\n } else if (!Array.isArray(props.project)) {\n project = undefined;\n }\n // Project can only be a single project for now\n const projectCompat =\n project != null && project.length > 0 ? project[0] : undefined;\n\n return {\n age_bottom: time + ageSpan / 2,\n age_top: time - ageSpan / 2,\n response: \"long\",\n project: projectCompat,\n };\n }, [time, ageSpan, props.project]);\n\n const units: UnitLong[] = useAPIResult(\"/units\", params);\n const columns = useMacrostratColumns(params.project, false);\n\n useMapStyleOperator(\n (map) => {\n if (units == null || columns == null || lithMap == null) {\n return;\n }\n\n const getColorForLithology = (data: UnitLithology): string | null => {\n return lithMap?.get(data.lith_id)?.color ?? null;\n };\n\n const unitsMap = postProcessUnits(units, getColorForLithology);\n handleUnitsLayerUpdate(map, unitsMap, columns);\n if (patterns) {\n handlePatternOverlayUpdate(\n map,\n unitsMap,\n columns,\n getColorForLithology,\n ).then(() => {});\n }\n },\n [units, lithMap, columns, patterns],\n );\n\n const isHovered = [\"boolean\", [\"feature-state\", \"hover\"], false];\n const isShown = [\"boolean\", [\"feature-state\", \"shown\"], false];\n\n const opacity = [\n \"case\",\n [\"all\", isHovered, isShown],\n 0.9,\n isShown,\n 0.8,\n isHovered,\n 0.3,\n 0.0,\n ];\n\n return h([\n h(BaseColumnsLayer, {\n enabled: true,\n columns,\n opacity,\n lineOpacity: 0.2,\n lineColor: \"lightgray\",\n color: \"transparent\",\n }),\n ]);\n}\n\nfunction handleUnitsLayerUpdate(\n map,\n unitsMap: Map<number, UnitsDisplayInfo>,\n columns: any[],\n) {\n // Update feature states\n for (const column of columns) {\n const col_id = column.properties.col_id;\n const info = unitsMap.get(Number(col_id));\n const color = info?.color;\n map.setFeatureState(\n { source: \"columns\", id: col_id },\n {\n color,\n shown: color != null,\n },\n );\n }\n}\n\nasync function handlePatternOverlayUpdate(\n map,\n unitsMap: Map<number, UnitsDisplayInfo>,\n columns: any[],\n getColor: LithologyColorGetter,\n) {\n // synthesize patterns not yet in cache\n\n const colsWithPatterns = [];\n const patternIDs = new Set<string>();\n // Update feature states\n for (const column of columns) {\n const col_id = column.properties.col_id;\n const info = unitsMap.get(Number(col_id));\n if (info == null) continue;\n const pattern = getPatternSpec(info?.liths, getColor);\n if (pattern == null) continue;\n\n colsWithPatterns.push({\n type: \"Feature\",\n geometry: column.geometry,\n properties: {\n col_id,\n pattern,\n },\n });\n patternIDs.add(pattern);\n }\n\n const patternsToLoad = patternIDs.values().filter((d) => !map.hasImage(d));\n\n const mapper = async (patternID) => {\n try {\n await loadStyleImage(map, patternID, { pixelRatio: 10 });\n } catch (e) {}\n };\n // Load all pattern images\n await pMap(patternsToLoad, mapper, { concurrency: 5 });\n\n // Set data for pattern layer\n // This is inefficient but the only way to set per-feature patterns in Mapbox\n const patternData: FeatureCollection = {\n type: \"FeatureCollection\",\n features: colsWithPatterns,\n };\n setGeoJSON(map, \"column-patterns\", patternData);\n}\n\nconst cachedColors = new Map<string, string>();\n\nfunction getDarkenedColor(color: string): string {\n /** Memoized function to get a darkened version of a color for pattern use */\n if (cachedColors.has(color)) {\n return cachedColors.get(color);\n }\n const c1 = asChromaColor(color).set(\"hsl.l\", 0.4).set(\"hsl.s\", 0.8).hex();\n cachedColors.set(color, c1);\n return c1;\n}\n\ninterface UnitsDisplayInfo {\n col_id: number;\n units: UnitLong[];\n color: string;\n liths: UnitLithology[];\n}\n\ntype LithologyColorGetter = (val: UnitLithology) => string | null;\n\nfunction postProcessUnits(\n units: UnitLong[],\n getColor: LithologyColorGetter,\n): Map<number, UnitsDisplayInfo> {\n // Group by col_id\n const unitsByColumn: Map<number, UnitLong[]> = new Map();\n for (const unit of units) {\n const col_id = Number(unit.col_id);\n if (!unitsByColumn.has(col_id)) {\n unitsByColumn.set(col_id, [unit]);\n } else {\n unitsByColumn.set(col_id, [...unitsByColumn.get(col_id), unit]);\n }\n }\n\n // Summarize units for display\n const res = new Map<number, UnitsDisplayInfo>();\n for (const [col_id, unitList] of unitsByColumn.entries()) {\n const liths = flattenLithologies(unitList.map((u) => u.lith));\n res.set(col_id, {\n col_id,\n units: unitList,\n liths,\n color: getMixedColorForData(liths, getColor),\n });\n }\n\n return res;\n}\n\nfunction getPatternSpec(\n liths: UnitLithology[],\n getColor: LithologyColorGetter,\n): string | null {\n const patternData = getBestFGDCPatternForLithologyList(liths);\n if (patternData == null) return null;\n let { patternID, lith } = patternData;\n const color = getDarkenedColor(getColor(lith));\n return `fgdc:${patternID}:${color}:transparent`;\n}\n\ntype UnitsStyleOptions = {\n color?: string;\n patterns?: boolean;\n};\n\nexport function buildUnitsStyle(opts: UnitsStyleOptions = {}): StyleFragment {\n const { patterns = false } = opts;\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n const baseStyle: StyleFragment = {\n sources: {},\n version: 8,\n };\n\n if (!patterns) {\n return baseStyle;\n }\n\n const patternStyle: StyleFragment = {\n sources: {\n \"column-patterns\": buildGeoJSONSource(),\n },\n layers: [\n {\n id: \"columns-fill-pattern\",\n type: \"fill\",\n source: \"column-patterns\",\n paint: {\n \"fill-pattern\": [\"get\", \"pattern\"],\n \"fill-opacity\": 1,\n },\n },\n ],\n };\n\n return mergeStyles(baseStyle, patternStyle);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BO,SAAS,uBAAuB,OAA0B;AAC/D,QAAM,EAAE,MAAM,UAAU,MAAM,WAAW,UAAU;AACnD,QAAM,UAAU,eAAA;AAEhB,kBAAgB,MAAM;AACpB,WAAO,gBAAgB,EAAE,UAAU;AAAA,EACrC,GAAG,CAAC,QAAQ,CAAC;AAEb;AAAA,IACE,CAAC,QAAQ;AACP,UAAI,CAAC,SAAU;AACf,6BAAuB,KAAK,EAAE,SAAS,MAAA,CAAO;AAAA,IAChD;AAAA,IACA,CAAC,QAAQ;AAAA,EAAA;AAGX,QAAM,SAAS,Q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C3E,QAAM,EAAE,WAAW,MAAA,IAAU;AAI7B,QAAM,YAA2B;AAAA,IAC/B,SAAS,CAAA;AAAA,IACT,SAAS;AAAA,EAAA;AAGX,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,eAA8B;AAAA,IAClC,SAAS;AAAA,MACP,mBAAmB,mBAAA;AAAA,IAAmB;AAAA,IAExC,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,gBAAgB,CAAC,OAAO,SAAS;AAAA,UACjC,gBAAgB;AAAA,QAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAGF,SAAO,YAAY,WAAW,YAAY;AAC5C;"}
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const chroma = require("chroma-js");
4
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
5
- const chroma__default = /* @__PURE__ */ _interopDefault(chroma);
6
- function getMixedUnitColor(unit, lithMap, inDarkMode = false, asBackground = true, keyOpts = null) {
7
- const { key = "lith", id_key = "lith_id" } = keyOpts ?? {};
8
- const liths = unit[key];
9
- const getColor = (data) => {
10
- return lithMap?.get(data[id_key])?.color ?? null;
11
- };
12
- return getMixedColorForData(liths, getColor, {
13
- inDarkMode,
14
- asBackground
15
- });
16
- }
17
- function flattenLithologies(liths, normalize = true) {
18
- if (liths == null || liths.length === 0) {
19
- return [];
20
- }
21
- const unitCount = liths.length;
22
- let newLiths = [];
23
- for (const unitLiths of liths) {
24
- let l1 = unitLiths;
25
- if (normalize) {
26
- l1 = addProportionsToAllData(unitLiths);
27
- }
28
- for (const lith of l1) {
29
- if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {
30
- continue;
31
- }
32
- lith.prop = lith.prop / unitCount;
33
- }
34
- newLiths.push(...l1);
35
- }
36
- if (newLiths[0]?.lith_id != null) {
37
- newLiths = mergeLikeData(newLiths, "lith_id");
38
- } else if (newLiths[0]?.environ_id != null) {
39
- newLiths = mergeLikeData(newLiths, "environ_id");
40
- }
41
- newLiths.sort((a, b) => b.prop - a.prop);
42
- return newLiths;
43
- }
44
- function getMixedColorForData(liths, getColor, options = {}) {
45
- const { inDarkMode = false, asBackground = true } = options;
46
- if (liths == null || liths.length === 0) {
47
- return null;
48
- }
49
- const lithData = liths.map((d) => {
50
- let prop = d.prop;
51
- if (prop == null || isNaN(prop) || prop <= 0) {
52
- prop = null;
53
- }
54
- return {
55
- ...d,
56
- prop,
57
- color: getColor?.(d) ?? d.color
58
- };
59
- }).filter((d) => d.color != null);
60
- if (lithData.length == 0) {
61
- return null;
62
- }
63
- const lithsWithProp = addProportionsToAllData(lithData);
64
- const baseColor = chroma__default.default.average(
65
- lithsWithProp.map((d) => d.color),
66
- "lrgb",
67
- lithsWithProp.map((d) => d.prop)
68
- );
69
- if (!asBackground) {
70
- return baseColor.hex();
71
- }
72
- if (inDarkMode) {
73
- return baseColor.set("hsl.l", 0.2).hex();
74
- } else {
75
- return baseColor.set("hsl.l", 0.9).hex();
76
- }
77
- }
78
- function addProportionsToAllData(liths) {
79
- const lithsWithProp = liths.filter((d) => d.prop != null);
80
- const lithsWithoutProp = liths.filter((d) => d.prop == null);
81
- const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);
82
- let overallTotal = 1;
83
- if (totalProp < overallTotal && lithsWithoutProp.length > 0) {
84
- const remainingProp = overallTotal - totalProp;
85
- const equalProp = remainingProp / lithsWithoutProp.length;
86
- lithsWithoutProp.forEach((d) => {
87
- lithsWithProp.push({
88
- ...d,
89
- prop: equalProp
90
- });
91
- });
92
- }
93
- return lithsWithProp;
94
- }
95
- function mergeLikeData(liths, key) {
96
- const mergedMap = /* @__PURE__ */ new Map();
97
- for (const lith of liths) {
98
- const id = lith[key];
99
- if (id == null) continue;
100
- if (mergedMap.has(id)) {
101
- const existing = mergedMap.get(id);
102
- mergedMap.set(id, {
103
- ...existing,
104
- prop: existing.prop + lith.prop
105
- });
106
- } else {
107
- mergedMap.set(id, { ...lith });
108
- }
109
- }
110
- return Array.from(mergedMap.values());
111
- }
112
- exports.flattenLithologies = flattenLithologies;
113
- exports.getMixedColorForData = getMixedColorForData;
114
- exports.getMixedUnitColor = getMixedUnitColor;
115
- //# sourceMappingURL=colors.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.cjs","sources":["../../src/units/colors.ts"],"sourcesContent":["import chroma from \"chroma-js\";\nimport {\n Environment,\n Lithology,\n UnitLithology,\n UnitLong,\n} from \"@macrostrat/api-types\";\n\ninterface KeyOptions {\n key?: \"lith\" | \"environ\";\n id_key?: \"lith_id\" | \"environ_id\";\n}\n\nexport function getMixedUnitColor(\n unit: UnitLong,\n lithMap: Map<number, { color: string }>,\n inDarkMode = false,\n asBackground = true,\n keyOpts: KeyOptions = null,\n): string | null {\n const { key = \"lith\", id_key = \"lith_id\" } = keyOpts ?? {};\n const liths = unit[key];\n const getColor = (data: UnitLithology): string | null => {\n return lithMap?.get(data[id_key])?.color ?? null;\n };\n\n return getMixedColorForData(liths, getColor, {\n inDarkMode,\n asBackground,\n key: id_key,\n });\n}\n\ninterface ColorBuilderOptions {\n key?: \"lith_id\" | \"environ_id\";\n inDarkMode?: boolean;\n asBackground?: boolean;\n}\n\nexport function flattenLithologies<\n T extends { prop: number | null; lith_id?: number; environ_id?: number },\n>(liths: T[][], normalize: boolean = true): T[] {\n /** Unify proportions in lithology/environment data across several units, normalizing if needed.\n * If normalize is true, proportions are scaled to sum to 1 within each unit (with remaining proportions\n * distributed equally among liths without specified proportions). This helps ensure that units with a\n * few lithologies with specified proportions don't skew the color mixing.\n *\n * Lithologies are deduplicated based on their identifying property (lith_id or environ_id) if that is present.\n */\n if (liths == null || liths.length === 0) {\n return [];\n }\n\n const unitCount = liths.length;\n\n let newLiths: T[] = [];\n for (const unitLiths of liths) {\n let l1 = unitLiths;\n if (normalize) {\n l1 = addProportionsToAllData(unitLiths);\n }\n // Divide proportions by number of units to balance influence\n for (const lith of l1) {\n if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {\n continue;\n }\n lith.prop = lith.prop / unitCount;\n }\n newLiths.push(...l1);\n }\n if (newLiths[0]?.lith_id != null) {\n newLiths = mergeLikeData(newLiths, \"lith_id\");\n } else if (newLiths[0]?.environ_id != null) {\n newLiths = mergeLikeData(newLiths, \"environ_id\");\n }\n // Sort by proportion descending\n newLiths.sort((a, b) => b.prop - a.prop);\n return newLiths;\n}\n\nexport function getMixedColorForData<\n T extends UnitLithology | Lithology | Environment,\n>(\n liths: T[] | null,\n getColor: (val: T) => string | null,\n options: ColorBuilderOptions = {},\n): string | null {\n const { inDarkMode = false, asBackground = true } = options;\n if (liths == null || liths.length === 0) {\n return null;\n }\n const lithData = liths\n .map((d) => {\n let prop = d.prop;\n if (prop == null || isNaN(prop) || prop <= 0) {\n prop = null;\n }\n return {\n ...d,\n prop,\n color: getColor?.(d) ?? d.color,\n };\n })\n .filter((d) => d.color != null);\n\n if (lithData.length == 0) {\n return null;\n }\n\n const lithsWithProp = addProportionsToAllData(lithData);\n\n // Mix colors proportionally\n const baseColor = chroma.average(\n lithsWithProp.map((d) => d.color),\n \"lrgb\",\n lithsWithProp.map((d) => d.prop),\n );\n\n if (!asBackground) {\n return baseColor.hex();\n }\n\n if (inDarkMode) {\n return baseColor.set(\"hsl.l\", 0.2).hex();\n } else {\n return baseColor.set(\"hsl.l\", 0.9).hex();\n }\n}\n\nfunction addProportionsToAllData<T extends { prop?: number }>(liths: T[]): T[] {\n /** Make sure that all lithologies/environments have a defined proportion,\n * and that proportions sum to 1. If some liths lack a defined proportion,\n * the remaining proportion is distributed equally among them.\n *\n * NOTE: This function does not normalize proportions if they already sum to more than 1.\n */\n const lithsWithProp = liths.filter((d) => d.prop != null);\n const lithsWithoutProp = liths.filter((d) => d.prop == null);\n\n const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);\n let overallTotal = 1;\n\n if (totalProp < overallTotal && lithsWithoutProp.length > 0) {\n const remainingProp = overallTotal - totalProp;\n // Distribute remaining proportion equally among liths without prop\n const equalProp = remainingProp / lithsWithoutProp.length;\n lithsWithoutProp.forEach((d) => {\n lithsWithProp.push({\n ...d,\n prop: equalProp,\n } as T);\n });\n }\n return lithsWithProp as T[];\n}\n\nfunction mergeLikeData<\n T extends { prop: number; lith_id?: number; environ_id?: number },\n>(liths: T[], key: \"lith_id\" | \"environ_id\"): T[] {\n /** Merge lithology/environment data with the same identifying property (lith_id or environ_id),\n * summing their proportions.\n *\n * TODO: handle attribute merging\n */\n const mergedMap: Map<number, T> = new Map();\n\n for (const lith of liths) {\n const id = lith[key];\n if (id == null) continue;\n\n if (mergedMap.has(id)) {\n const existing = mergedMap.get(id);\n mergedMap.set(id, {\n ...existing,\n prop: existing.prop + lith.prop,\n });\n } else {\n mergedMap.set(id, { ...lith });\n }\n }\n\n return Array.from(mergedMap.values());\n}\n"],"names":["chroma"],"mappings":";;;;;AAaO,SAAS,kBACd,MACA,SACA,aAAa,OACb,eAAe,MACf,UAAsB,MACP;AACf,QAAM,EAAE,MAAM,QAAQ,SAAS,UAAA,IAAc,WAAW,CAAA;AACxD,QAAM,QAAQ,KAAK,GAAG;AACtB,QAAM,WAAW,CAAC,SAAuC;AACvD,WAAO,SAAS,IAAI,KAAK,MAAM,CAAC,GAAG,SAAS;AAAA,EAC9C;AAEA,SAAO,qBAAqB,OAAO,UAAU;AAAA,IAC3C;AAAA,IACA;AAAA,EAEF,CAAC;AACH;AAQO,SAAS,mBAEd,OAAc,YAAqB,MAAW;AAQ9C,MAAI,SAAS,QAAQ,MAAM,WAAW,GAAG;AACvC,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,YAAY,MAAM;AAExB,MAAI,WAAgB,CAAA;AACpB,aAAW,aAAa,OAAO;AAC7B,QAAI,KAAK;AACT,QAAI,WAAW;AACb,WAAK,wBAAwB,SAAS;AAAA,IACxC;AAEA,eAAW,QAA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AG,EAAE,IAAA;AAAA,EACrC,OAAO;AACL,WAAO,UAAU,IAAI,SAAS,GAAG,EAAE,IAAA;AAAA,EACrC;AACF;AAEA,SAAS,wBAAqD,OAAiB;AAO7E,QAAM,gBAAgB,MAAM,OAAO,CAAC,MAAM,EAAE,QAAQ,IAAI;AACxD,QAAM,mBAAmB,MAAM,OAAO,CAAC,MAAM,EAAE,QAAQ,IAAI;AAE3D,QAAM,YAAY,cAAc,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,MAAM,CAAC;AAClE,MAAI,eAAe;AAEnB,MAAI,YAAY,gBAAgB,iBAAiB,SAAS,GAAG;AAC3D,UAAM,gBAAgB,eAAe;AAErC,UAAM,YAAY,gBAAgB,iBAAiB;AACnD,qBAAiB,QAAQ,CAAC,MAAM;AAC9B,oBAAc,KAAK;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACF;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,SAAS,cAEP,OAAY,KAAoC;AAMhD,QAAM,gCAAgC,IAAA;AAEtC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK,GAAG;AACnB,QAAI,MAAM,KAAM;AAEhB,QAAI,UAAU,IAAI,EAAE,GAAG;AACrB,YAAM,WAAW,UAAU,IAAI,EAAE;AACjC,gBAAU,IAAI,IAAI;AAAA,QAChB,GAAG;AAAA,QACH,MAAM,SAAS,OAAO,KAAK;AAAA,MAAA,CAC5B;AAAA,IACH,OAAO;AACL,gBAAU,IAAI,IAAI,EAAE,GAAG,MAAM;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,UAAU,OAAA,CAAQ;AACtC;;;;"}
@@ -1,20 +0,0 @@
1
- import { Environment, Lithology, UnitLithology, UnitLong } from '@macrostrat/api-types';
2
- interface KeyOptions {
3
- key?: "lith" | "environ";
4
- id_key?: "lith_id" | "environ_id";
5
- }
6
- export declare function getMixedUnitColor(unit: UnitLong, lithMap: Map<number, {
7
- color: string;
8
- }>, inDarkMode?: boolean, asBackground?: boolean, keyOpts?: KeyOptions): string | null;
9
- interface ColorBuilderOptions {
10
- key?: "lith_id" | "environ_id";
11
- inDarkMode?: boolean;
12
- asBackground?: boolean;
13
- }
14
- export declare function flattenLithologies<T extends {
15
- prop: number | null;
16
- lith_id?: number;
17
- environ_id?: number;
18
- }>(liths: T[][], normalize?: boolean): T[];
19
- export declare function getMixedColorForData<T extends UnitLithology | Lithology | Environment>(liths: T[] | null, getColor: (val: T) => string | null, options?: ColorBuilderOptions): string | null;
20
- export {};
@@ -1,113 +0,0 @@
1
- import chroma from "chroma-js";
2
- function getMixedUnitColor(unit, lithMap, inDarkMode = false, asBackground = true, keyOpts = null) {
3
- const { key = "lith", id_key = "lith_id" } = keyOpts ?? {};
4
- const liths = unit[key];
5
- const getColor = (data) => {
6
- return lithMap?.get(data[id_key])?.color ?? null;
7
- };
8
- return getMixedColorForData(liths, getColor, {
9
- inDarkMode,
10
- asBackground
11
- });
12
- }
13
- function flattenLithologies(liths, normalize = true) {
14
- if (liths == null || liths.length === 0) {
15
- return [];
16
- }
17
- const unitCount = liths.length;
18
- let newLiths = [];
19
- for (const unitLiths of liths) {
20
- let l1 = unitLiths;
21
- if (normalize) {
22
- l1 = addProportionsToAllData(unitLiths);
23
- }
24
- for (const lith of l1) {
25
- if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {
26
- continue;
27
- }
28
- lith.prop = lith.prop / unitCount;
29
- }
30
- newLiths.push(...l1);
31
- }
32
- if (newLiths[0]?.lith_id != null) {
33
- newLiths = mergeLikeData(newLiths, "lith_id");
34
- } else if (newLiths[0]?.environ_id != null) {
35
- newLiths = mergeLikeData(newLiths, "environ_id");
36
- }
37
- newLiths.sort((a, b) => b.prop - a.prop);
38
- return newLiths;
39
- }
40
- function getMixedColorForData(liths, getColor, options = {}) {
41
- const { inDarkMode = false, asBackground = true } = options;
42
- if (liths == null || liths.length === 0) {
43
- return null;
44
- }
45
- const lithData = liths.map((d) => {
46
- let prop = d.prop;
47
- if (prop == null || isNaN(prop) || prop <= 0) {
48
- prop = null;
49
- }
50
- return {
51
- ...d,
52
- prop,
53
- color: getColor?.(d) ?? d.color
54
- };
55
- }).filter((d) => d.color != null);
56
- if (lithData.length == 0) {
57
- return null;
58
- }
59
- const lithsWithProp = addProportionsToAllData(lithData);
60
- const baseColor = chroma.average(
61
- lithsWithProp.map((d) => d.color),
62
- "lrgb",
63
- lithsWithProp.map((d) => d.prop)
64
- );
65
- if (!asBackground) {
66
- return baseColor.hex();
67
- }
68
- if (inDarkMode) {
69
- return baseColor.set("hsl.l", 0.2).hex();
70
- } else {
71
- return baseColor.set("hsl.l", 0.9).hex();
72
- }
73
- }
74
- function addProportionsToAllData(liths) {
75
- const lithsWithProp = liths.filter((d) => d.prop != null);
76
- const lithsWithoutProp = liths.filter((d) => d.prop == null);
77
- const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);
78
- let overallTotal = 1;
79
- if (totalProp < overallTotal && lithsWithoutProp.length > 0) {
80
- const remainingProp = overallTotal - totalProp;
81
- const equalProp = remainingProp / lithsWithoutProp.length;
82
- lithsWithoutProp.forEach((d) => {
83
- lithsWithProp.push({
84
- ...d,
85
- prop: equalProp
86
- });
87
- });
88
- }
89
- return lithsWithProp;
90
- }
91
- function mergeLikeData(liths, key) {
92
- const mergedMap = /* @__PURE__ */ new Map();
93
- for (const lith of liths) {
94
- const id = lith[key];
95
- if (id == null) continue;
96
- if (mergedMap.has(id)) {
97
- const existing = mergedMap.get(id);
98
- mergedMap.set(id, {
99
- ...existing,
100
- prop: existing.prop + lith.prop
101
- });
102
- } else {
103
- mergedMap.set(id, { ...lith });
104
- }
105
- }
106
- return Array.from(mergedMap.values());
107
- }
108
- export {
109
- flattenLithologies,
110
- getMixedColorForData,
111
- getMixedUnitColor
112
- };
113
- //# sourceMappingURL=colors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.js","sources":["../../src/units/colors.ts"],"sourcesContent":["import chroma from \"chroma-js\";\nimport {\n Environment,\n Lithology,\n UnitLithology,\n UnitLong,\n} from \"@macrostrat/api-types\";\n\ninterface KeyOptions {\n key?: \"lith\" | \"environ\";\n id_key?: \"lith_id\" | \"environ_id\";\n}\n\nexport function getMixedUnitColor(\n unit: UnitLong,\n lithMap: Map<number, { color: string }>,\n inDarkMode = false,\n asBackground = true,\n keyOpts: KeyOptions = null,\n): string | null {\n const { key = \"lith\", id_key = \"lith_id\" } = keyOpts ?? {};\n const liths = unit[key];\n const getColor = (data: UnitLithology): string | null => {\n return lithMap?.get(data[id_key])?.color ?? null;\n };\n\n return getMixedColorForData(liths, getColor, {\n inDarkMode,\n asBackground,\n key: id_key,\n });\n}\n\ninterface ColorBuilderOptions {\n key?: \"lith_id\" | \"environ_id\";\n inDarkMode?: boolean;\n asBackground?: boolean;\n}\n\nexport function flattenLithologies<\n T extends { prop: number | null; lith_id?: number; environ_id?: number },\n>(liths: T[][], normalize: boolean = true): T[] {\n /** Unify proportions in lithology/environment data across several units, normalizing if needed.\n * If normalize is true, proportions are scaled to sum to 1 within each unit (with remaining proportions\n * distributed equally among liths without specified proportions). This helps ensure that units with a\n * few lithologies with specified proportions don't skew the color mixing.\n *\n * Lithologies are deduplicated based on their identifying property (lith_id or environ_id) if that is present.\n */\n if (liths == null || liths.length === 0) {\n return [];\n }\n\n const unitCount = liths.length;\n\n let newLiths: T[] = [];\n for (const unitLiths of liths) {\n let l1 = unitLiths;\n if (normalize) {\n l1 = addProportionsToAllData(unitLiths);\n }\n // Divide proportions by number of units to balance influence\n for (const lith of l1) {\n if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {\n continue;\n }\n lith.prop = lith.prop / unitCount;\n }\n newLiths.push(...l1);\n }\n if (newLiths[0]?.lith_id != null) {\n newLiths = mergeLikeData(newLiths, \"lith_id\");\n } else if (newLiths[0]?.environ_id != null) {\n newLiths = mergeLikeData(newLiths, \"environ_id\");\n }\n // Sort by proportion descending\n newLiths.sort((a, b) => b.prop - a.prop);\n return newLiths;\n}\n\nexport function getMixedColorForData<\n T extends UnitLithology | Lithology | Environment,\n>(\n liths: T[] | null,\n getColor: (val: T) => string | null,\n options: ColorBuilderOptions = {},\n): string | null {\n const { inDarkMode = false, asBackground = true } = options;\n if (liths == null || liths.length === 0) {\n return null;\n }\n const lithData = liths\n .map((d) => {\n let prop = d.prop;\n if (prop == null || isNaN(prop) || prop <= 0) {\n prop = null;\n }\n return {\n ...d,\n prop,\n color: getColor?.(d) ?? d.color,\n };\n })\n .filter((d) => d.color != null);\n\n if (lithData.length == 0) {\n return null;\n }\n\n const lithsWithProp = addProportionsToAllData(lithData);\n\n // Mix colors proportionally\n const baseColor = chroma.average(\n lithsWithProp.map((d) => d.color),\n \"lrgb\",\n lithsWithProp.map((d) => d.prop),\n );\n\n if (!asBackground) {\n return baseColor.hex();\n }\n\n if (inDarkMode) {\n return baseColor.set(\"hsl.l\", 0.2).hex();\n } else {\n return baseColor.set(\"hsl.l\", 0.9).hex();\n }\n}\n\nfunction addProportionsToAllData<T extends { prop?: number }>(liths: T[]): T[] {\n /** Make sure that all lithologies/environments have a defined proportion,\n * and that proportions sum to 1. If some liths lack a defined proportion,\n * the remaining proportion is distributed equally among them.\n *\n * NOTE: This function does not normalize proportions if they already sum to more than 1.\n */\n const lithsWithProp = liths.filter((d) => d.prop != null);\n const lithsWithoutProp = liths.filter((d) => d.prop == null);\n\n const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);\n let overallTotal = 1;\n\n if (totalProp < overallTotal && lithsWithoutProp.length > 0) {\n const remainingProp = overallTotal - totalProp;\n // Distribute remaining proportion equally among liths without prop\n const equalProp = remainingProp / lithsWithoutProp.length;\n lithsWithoutProp.forEach((d) => {\n lithsWithProp.push({\n ...d,\n prop: equalProp,\n } as T);\n });\n }\n return lithsWithProp as T[];\n}\n\nfunction mergeLikeData<\n T extends { prop: number; lith_id?: number; environ_id?: number },\n>(liths: T[], key: \"lith_id\" | \"environ_id\"): T[] {\n /** Merge lithology/environment data with the same identifying property (lith_id or environ_id),\n * summing their proportions.\n *\n * TODO: handle attribute merging\n */\n const mergedMap: Map<number, T> = new Map();\n\n for (const lith of liths) {\n const id = lith[key];\n if (id == null) continue;\n\n if (mergedMap.has(id)) {\n const existing = mergedMap.get(id);\n mergedMap.set(id, {\n ...existing,\n prop: existing.prop + lith.prop,\n });\n } else {\n mergedMap.set(id, { ...lith });\n }\n }\n\n return Array.from(mergedMap.values());\n}\n"],"names":[],"mappings":";AAaO,SAAS,kBACd,MACA,SACA,aAAa,OACb,eAAe,MACf,UAAsB,MACP;AACf,QAAM,EAAE,MAAM,QAAQ,SAAS,UAAA,IAAc,WAAW,CAAA;AACxD,QAAM,QAAQ,KAAK,GAAG;AACtB,QAAM,WAAW,CAAC,SAAuC;AACvD,WAAO,SAAS,IAAI,KAAK,MAAM,CAAC,GAAG,SAAS;AAAA,EAC9C;AAEA,SAAO,qBAAqB,OAAO,UAAU;AAAA,IAC3C;AAAA,IACA;AAAA,EAEF,CAAC;AACH;AAQO,SAAS,mBAEd,OAAc,YAAqB,MAAW;AAQ9C,MAAI,SAAS,QAAQ,MAAM,WAAW,GAAG;AACvC,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,YAAY,MAAM;AAExB,MAAI,WAAgB,CAAA;AACpB,aAAW,aAAa,OAAO;AAC7B,QAAI,KAAK;AACT,QAAI,WAAW;AACb,WAAK,wBAAwB,SAAS;AAAA,IACxC;AAEA,eAAW,QAAQ,IAAI;AACrB,UAAI,KAAK,QAAQ,QAAQ,MAAM,KAAK,IAAI,KAAK,KAAK,QAAQ,GAAG;AAC3D;AAAA,MACF;AACA,WAAK,OAAO,KAAK,OAAO;AAAA,IAC1B;AACA,aAAS,KAAK,GAAG,EAAE;AAAA,EACrB;AACA,MAAI,SAAS,CAAC,GAAG,WAAW,MAAM;AAChC,eAAW,cAAc,UAAU,SAAS;AAAA,EAC9C,WAAW,SAAS,CAAC,GAAG,cAAc,MA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E,MAAM,CAAC;AAClE,MAAI,eAAe;AAEnB,MAAI,YAAY,gBAAgB,iBAAiB,SAAS,GAAG;AAC3D,UAAM,gBAAgB,eAAe;AAErC,UAAM,YAAY,gBAAgB,iBAAiB;AACnD,qBAAiB,QAAQ,CAAC,MAAM;AAC9B,oBAAc,KAAK;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACF;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,SAAS,cAEP,OAAY,KAAoC;AAMhD,QAAM,gCAAgC,IAAA;AAEtC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK,GAAG;AACnB,QAAI,MAAM,KAAM;AAEhB,QAAI,UAAU,IAAI,EAAE,GAAG;AACrB,YAAM,WAAW,UAAU,IAAI,EAAE;AACjC,gBAAU,IAAI,IAAI;AAAA,QAChB,GAAG;AAAA,QACH,MAAM,SAAS,OAAO,KAAK;AAAA,MAAA,CAC5B;AAAA,IACH,OAAO;AACL,gBAAU,IAAI,IAAI,EAAE,GAAG,MAAM;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,UAAU,OAAA,CAAQ;AACtC;"}
@@ -1,125 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const symbolIndex = {
4
- "dolomite-limestone": 641,
5
- lime_mudstone: 627,
6
- sandstone: 607,
7
- "quartz arenite": 607,
8
- litharenite: 608,
9
- sand: 608,
10
- siltstone: 616,
11
- silt: 616,
12
- siliciclastic: 615,
13
- mud: 620,
14
- "dolomitic siltstone": 616,
15
- shale: 620,
16
- limestone: 627,
17
- dolomite: 642,
18
- conglomerate: 602,
19
- carbonate: 627,
20
- "dolomite-mudstone": 642,
21
- dolostone: 642,
22
- mudstone: 620,
23
- slate: 703,
24
- "sandy-dolomite": 645,
25
- quartzite: 702,
26
- halite: 668,
27
- gypsum: 667,
28
- evaporite: 667,
29
- claystone: 620,
30
- anhydrite: 667,
31
- gabbro: 720,
32
- basalt: 717,
33
- diabase: 717,
34
- rhyolite: 722,
35
- andesite: 723,
36
- till: 681,
37
- loess: 684,
38
- "calcareous ooze": 653,
39
- "siliceous ooze": 653,
40
- chalk: 626,
41
- gravel: 601,
42
- plutonic: 721,
43
- granite: 719,
44
- clay: 660,
45
- syenite: 722,
46
- tuff: 711,
47
- volcanic: 725,
48
- metamorphic: 707,
49
- volcaniclastic: 714,
50
- migmatite: 709,
51
- gneiss: 708,
52
- tonalite: 727,
53
- granodiorite: 725,
54
- monzonite: 723,
55
- argillite: 624,
56
- diamictite: 681
57
- };
58
- function getBestFGDCPatternForLithologyList(liths) {
59
- let lithsSorted = [...liths];
60
- lithsSorted.sort((a, b) => b.prop - a.prop);
61
- let firstLith = lithsSorted[0];
62
- let sym = symbolIndex[firstLith.name];
63
- if (sym != null) {
64
- return { lith: firstLith, patternID: `${sym}` };
65
- }
66
- return null;
67
- }
68
- const resolveID = (d) => {
69
- if (d.lith == null || d.lith.length == 0) {
70
- return null;
71
- }
72
- let liths = [...d.lith];
73
- let environs = d.environ.map((d2) => d2.name).join(" ");
74
- liths.sort((a, b) => b.prop - a.prop);
75
- let sym = null;
76
- if (d.unit_name == "clay") {
77
- return "650";
78
- }
79
- if (d.unit_name == "calcareous clay") {
80
- return "651";
81
- }
82
- for (const k of liths) {
83
- if (k.name == "sandstone") {
84
- if (environs.includes("dune")) {
85
- return "609";
86
- }
87
- if (environs.includes("marine")) {
88
- return "608";
89
- }
90
- if (environs.includes("shore")) {
91
- return "611";
92
- }
93
- if (environs.includes("loess")) {
94
- return "686";
95
- }
96
- }
97
- if (k.name == "conglomerate") {
98
- if (environs.includes("fluvial")) {
99
- return "603";
100
- }
101
- }
102
- if (k.name.includes("tuff")) {
103
- return "711";
104
- }
105
- sym = symbolIndex[k.name];
106
- if (sym != null) {
107
- return sym;
108
- }
109
- if (k.type == "volcanic") {
110
- return "725";
111
- }
112
- }
113
- return sym;
114
- };
115
- const patternScale = {
116
- "609": 1.5,
117
- "603": 1.5
118
- };
119
- const scalePattern = (id) => {
120
- return patternScale[`${id}`] ?? 1;
121
- };
122
- exports.getBestFGDCPatternForLithologyList = getBestFGDCPatternForLithologyList;
123
- exports.resolveID = resolveID;
124
- exports.scalePattern = scalePattern;
125
- //# sourceMappingURL=resolvers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolvers.cjs","sources":["../../src/units/resolvers.ts"],"sourcesContent":["import { Lithology, UnitLithology } from \"@macrostrat/api-types\";\nimport { LithologyCore } from \"@macrostrat/api-types/src/lithologies\";\n\nconst symbolIndex = {\n \"dolomite-limestone\": 641,\n lime_mudstone: 627,\n sandstone: 607,\n \"quartz arenite\": 607,\n litharenite: 608,\n sand: 608,\n siltstone: 616,\n silt: 616,\n siliciclastic: 615,\n mud: 620,\n \"dolomitic siltstone\": 616,\n shale: 620,\n limestone: 627,\n dolomite: 642,\n conglomerate: 602,\n carbonate: 627,\n \"dolomite-mudstone\": 642,\n dolostone: 642,\n mudstone: 620,\n slate: 703,\n \"sandy-dolomite\": 645,\n quartzite: 702,\n halite: 668,\n gypsum: 667,\n evaporite: 667,\n claystone: 620,\n anhydrite: 667,\n gabbro: 720,\n basalt: 717,\n diabase: 717,\n rhyolite: 722,\n andesite: 723,\n till: 681,\n loess: 684,\n \"calcareous ooze\": 653,\n \"siliceous ooze\": 653,\n chalk: 626,\n gravel: 601,\n plutonic: 721,\n granite: 719,\n clay: 660,\n syenite: 722,\n tuff: 711,\n volcanic: 725,\n metamorphic: 707,\n volcaniclastic: 714,\n migmatite: 709,\n gneiss: 708,\n tonalite: 727,\n granodiorite: 725,\n monzonite: 723,\n argillite: 624,\n diamictite: 681,\n};\n\nexport function getBestFGDCPatternForLithologyList<\n T extends UnitLithology | Lithology,\n>(liths: T[]): { lith: T; patternID: string } | null {\n let lithsSorted = [...liths];\n lithsSorted.sort((a, b) => b.prop - a.prop);\n let firstLith = lithsSorted[0];\n let sym = symbolIndex[firstLith.name];\n if (sym != null) {\n return { lith: firstLith, patternID: `${sym}` };\n }\n return null;\n}\n\nconst resolveID = (d: any) => {\n if (d.lith == null || d.lith.length == 0) {\n return null;\n }\n let liths = [...d.lith];\n let environs = d.environ.map((d) => d.name).join(\" \");\n liths.sort((a, b) => b.prop - a.prop);\n\n //console.log(d, d.unit_name, liths.map(d => d.name), environs)\n\n let sym = null;\n\n // overrides for IODP columns\n if (d.unit_name == \"clay\") {\n return \"650\";\n }\n if (d.unit_name == \"calcareous clay\") {\n return \"651\";\n }\n\n for (const k of liths) {\n if (k.name == \"sandstone\") {\n // Special cases for sandstone\n if (environs.includes(\"dune\")) {\n return \"609\";\n }\n if (environs.includes(\"marine\")) {\n return \"608\";\n }\n if (environs.includes(\"shore\")) {\n return \"611\";\n }\n if (environs.includes(\"loess\")) {\n return \"686\";\n }\n }\n\n if (k.name == \"conglomerate\") {\n // Special cases for sandstone\n if (environs.includes(\"fluvial\")) {\n return \"603\";\n }\n }\n\n if (k.name.includes(\"tuff\")) {\n return \"711\";\n }\n sym = symbolIndex[k.name];\n if (sym != null) {\n return sym;\n }\n\n if (k.type == \"volcanic\") {\n return \"725\";\n }\n }\n return sym;\n};\n\nconst patternScale = {\n \"609\": 1.5,\n \"603\": 1.5,\n};\n\nconst scalePattern = (id) => {\n return patternScale[`${id}`] ?? 1;\n};\n\nexport { resolveID, scalePattern };\n"],"names":["d"],"mappings":";;AAGA,MAAM,cAAc;AAAA,EAClB,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,eAAe;AAAA,EACf,KAAK;AAAA,EACL,uBAAuB;AAAA,EACvB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,cAAc;AAAA,EACd,WAAW;AAAA,EACX,qBAAqB;AAAA,EACrB,WAAW;AAAA,EACX,UAAU;AAAA,EAC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;AACzB,WAAO;AAAA,EACT;AACA,MAAI,EAAE,aAAa,mBAAmB;AACpC,WAAO;AAAA,EACT;AAEA,aAAW,KAAK,OAAO;AACrB,QAAI,EAAE,QAAQ,aAAa;AAEzB,UAAI,SAAS,SAAS,MAAM,GAAG;AAC7B,eAAO;AAAA,MACT;AACA,UAAI,SAAS,SAAS,QAAQ,GAAG;AAC/B,eAAO;AAAA,MACT;AACA,UAAI,SAAS,SAAS,OAAO,GAAG;AAC9B,eAAO;AAAA,MACT;AACA,UAAI,SAAS,SAAS,OAAO,GAAG;AAC9B,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,EAAE,QAAQ,gBAAgB;AAE5B,UAAI,SAAS,SAAS,SAAS,GAAG;AAChC,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,EAAE,KAAK,SAAS,MAAM,GAAG;AAC3B,aAAO;AAAA,IACT;AACA,UAAM,YAAY,EAAE,IAAI;AACxB,QAAI,OAAO,MAAM;AACf,aAAO;AAAA,IACT;AAEA,QAAI,EAAE,QAAQ,YAAY;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AACT;AAEA,MAAM,eAAe,CAAC,OAAO;AAC3B,SAAO,aAAa,GAAG,EAAE,EAAE,KAAK;AAClC;;;;"}
@@ -1,8 +0,0 @@
1
- import { Lithology, UnitLithology } from '@macrostrat/api-types';
2
- export declare function getBestFGDCPatternForLithologyList<T extends UnitLithology | Lithology>(liths: T[]): {
3
- lith: T;
4
- patternID: string;
5
- } | null;
6
- declare const resolveID: (d: any) => "650" | "651" | "609" | "608" | "611" | "686" | "603" | "711" | "725" | null;
7
- declare const scalePattern: (id: any) => any;
8
- export { resolveID, scalePattern };