@macrostrat/column-views 3.2.1 → 3.3.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 (96) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/age-axis.cjs +2 -2
  3. package/dist/age-axis.cjs.map +1 -1
  4. package/dist/age-axis.js +1 -1
  5. package/dist/column-views.css +130 -125
  6. package/dist/index.cjs +30 -19
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.js +16 -5
  9. package/dist/index.js.map +1 -1
  10. package/dist/maps/column-correlation/core.cjs +10 -30
  11. package/dist/maps/column-correlation/core.cjs.map +1 -1
  12. package/dist/maps/column-correlation/core.d.ts +1 -1
  13. package/dist/maps/column-correlation/core.js +10 -30
  14. package/dist/maps/column-correlation/core.js.map +1 -1
  15. package/dist/maps/column-navigation/mapbox/index.cjs +156 -118
  16. package/dist/maps/column-navigation/mapbox/index.cjs.map +1 -1
  17. package/dist/maps/column-navigation/mapbox/index.d.ts +23 -2
  18. package/dist/maps/column-navigation/mapbox/index.js +158 -120
  19. package/dist/maps/column-navigation/mapbox/index.js.map +1 -1
  20. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +7 -1
  21. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +1 -1
  22. package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +3 -26
  23. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +9 -3
  24. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +1 -1
  25. package/dist/maps/index.d.ts +2 -2
  26. package/dist/maps/{_shared/inset-map.cjs → inset-map/index.cjs} +1 -1
  27. package/dist/maps/inset-map/index.cjs.map +1 -0
  28. package/dist/maps/{_shared/inset-map.js → inset-map/index.js} +1 -1
  29. package/dist/maps/inset-map/index.js.map +1 -0
  30. package/dist/maps/layers/columns.cjs +161 -0
  31. package/dist/maps/layers/columns.cjs.map +1 -0
  32. package/dist/maps/layers/columns.d.ts +28 -0
  33. package/dist/maps/layers/columns.js +161 -0
  34. package/dist/maps/layers/columns.js.map +1 -0
  35. package/dist/maps/layers/index.d.ts +2 -0
  36. package/dist/maps/{units-overlay/index.cjs → layers/units.cjs} +41 -88
  37. package/dist/maps/layers/units.cjs.map +1 -0
  38. package/dist/maps/{units-overlay/index.d.ts → layers/units.d.ts} +1 -1
  39. package/dist/maps/{units-overlay/index.js → layers/units.js} +34 -82
  40. package/dist/maps/layers/units.js.map +1 -0
  41. package/dist/section.cjs +2 -2
  42. package/dist/section.cjs.map +1 -1
  43. package/dist/section.js +1 -1
  44. package/dist/unit-details/age-range.cjs +196 -0
  45. package/dist/unit-details/age-range.cjs.map +1 -0
  46. package/dist/unit-details/age-range.d.ts +70 -0
  47. package/dist/unit-details/age-range.js +194 -0
  48. package/dist/unit-details/age-range.js.map +1 -0
  49. package/dist/unit-details/age-range.module.sass.cjs +16 -0
  50. package/dist/unit-details/age-range.module.sass.cjs.map +1 -0
  51. package/dist/unit-details/age-range.module.sass.js +14 -0
  52. package/dist/unit-details/age-range.module.sass.js.map +1 -0
  53. package/dist/unit-details/index.d.ts +1 -0
  54. package/dist/unit-details/panel.cjs +8 -173
  55. package/dist/unit-details/panel.cjs.map +1 -1
  56. package/dist/unit-details/panel.js +3 -168
  57. package/dist/unit-details/panel.js.map +1 -1
  58. package/dist/unit-details/panel.module.sass.cjs +20 -22
  59. package/dist/unit-details/panel.module.sass.cjs.map +1 -1
  60. package/dist/unit-details/panel.module.sass.js +20 -22
  61. package/dist/unit-details/panel.module.sass.js.map +1 -1
  62. package/dist/unit-details/utils.cjs +31 -0
  63. package/dist/unit-details/utils.cjs.map +1 -0
  64. package/dist/unit-details/utils.d.ts +3 -0
  65. package/dist/unit-details/utils.js +31 -0
  66. package/dist/unit-details/utils.js.map +1 -0
  67. package/package.json +4 -4
  68. package/src/maps/column-correlation/core.ts +9 -29
  69. package/src/maps/column-navigation/mapbox/index.ts +191 -138
  70. package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +17 -3
  71. package/src/maps/index.ts +2 -2
  72. package/src/maps/layers/columns.ts +210 -0
  73. package/src/maps/layers/index.ts +2 -0
  74. package/src/maps/{units-overlay/index.ts → layers/units.ts} +34 -84
  75. package/src/maps/unit-map.stories.ts +27 -12
  76. package/src/unit-details/age-range.module.sass +15 -0
  77. package/src/unit-details/age-range.ts +269 -0
  78. package/src/unit-details/index.ts +1 -0
  79. package/src/unit-details/panel.module.sass +0 -9
  80. package/src/unit-details/panel.ts +12 -226
  81. package/src/unit-details/utils.ts +33 -0
  82. package/dist/maps/_shared/index.d.ts +0 -2
  83. package/dist/maps/_shared/inset-map.cjs.map +0 -1
  84. package/dist/maps/_shared/inset-map.js.map +0 -1
  85. package/dist/maps/_shared/styles.cjs +0 -73
  86. package/dist/maps/_shared/styles.cjs.map +0 -1
  87. package/dist/maps/_shared/styles.d.ts +0 -2
  88. package/dist/maps/_shared/styles.js +0 -73
  89. package/dist/maps/_shared/styles.js.map +0 -1
  90. package/dist/maps/units-overlay/index.cjs.map +0 -1
  91. package/dist/maps/units-overlay/index.js.map +0 -1
  92. package/src/maps/_shared/index.ts +0 -2
  93. package/src/maps/_shared/styles.ts +0 -76
  94. /package/dist/maps/{_shared/inset-map.d.ts → inset-map/index.d.ts} +0 -0
  95. /package/src/maps/{_shared/inset-map.ts → inset-map/index.ts} +0 -0
  96. /package/src/maps/{_shared → inset-map}/inset-map.stories.ts +0 -0
@@ -2,24 +2,22 @@ import hyper from "@macrostrat/hyper";
2
2
  import styles from "./panel.module.sass";
3
3
  import { JSONView } from "@macrostrat/ui-components";
4
4
  import { Button, ButtonGroup } from "@blueprintjs/core";
5
- import { ReactNode, useCallback, useMemo, useState } from "react";
5
+ import { ReactNode, useMemo, useState } from "react";
6
6
  import {
7
7
  DataField,
8
8
  EnvironmentsList,
9
- IntervalShort,
10
- IntervalTag,
9
+ isClickable,
10
+ ItemInteractionProps,
11
11
  ItemList,
12
12
  LithologyList,
13
13
  LithologyTagFeature,
14
- Parenthetical,
15
- Value,
16
14
  MacrostratInteractionManager,
17
- useInteractionProps,
18
- ItemInteractionProps,
19
- useInteractionManager,
20
- MacrostratItemIdentifier,
21
15
  MacrostratInteractionProvider,
22
- isClickable,
16
+ MacrostratItemIdentifier,
17
+ Parenthetical,
18
+ useInteractionManager,
19
+ useInteractionProps,
20
+ Value,
23
21
  } from "@macrostrat/data-components";
24
22
  import { useColumnUnitsMap } from "../data-provider";
25
23
  import {
@@ -30,13 +28,15 @@ import {
30
28
  } from "@macrostrat/data-provider";
31
29
  import type {
32
30
  Environment,
31
+ Interval,
32
+ Lithology,
33
33
  UnitLong,
34
34
  UnitLongFull,
35
- Lithology,
36
- Interval,
37
35
  } from "@macrostrat/api-types";
38
36
  import { defaultNameFunction } from "../units/names";
39
37
  import classNames from "classnames";
38
+ import { AgeField, Duration, IntervalProportions } from "./age-range";
39
+ import { formatRange, formatSignificance } from "./utils.ts";
40
40
 
41
41
  const h = hyper.styled(styles);
42
42
 
@@ -479,106 +479,6 @@ function Citation({ data, tag = "p" }) {
479
479
  ]);
480
480
  }
481
481
 
482
- function AgeField({ unit, children }) {
483
- const [b_age, t_age, _unit] = getAgeRange(unit);
484
-
485
- return h(
486
- DataField,
487
- {
488
- label: "Age",
489
- value: formatRange(b_age, t_age),
490
- unit: _unit,
491
- },
492
- children,
493
- );
494
- }
495
-
496
- function getAgeRange(_unit) {
497
- let b_age = _unit.b_age;
498
- let t_age = _unit.t_age;
499
- let unit = "Ma";
500
-
501
- if (b_age < 0.8 && t_age < 1.2) {
502
- b_age *= 1000;
503
- t_age *= 1000;
504
- unit = "ka";
505
- } else if (b_age > 800 && t_age > 1200) {
506
- b_age /= 1000;
507
- t_age /= 1000;
508
- unit = "Ga";
509
- }
510
-
511
- return [b_age, t_age, unit];
512
- }
513
-
514
- function getAge(value) {
515
- /** Get the age value in Ma, ka, or Ga as appropriate */
516
- let unit = "Ma";
517
- if (value < 0.8) {
518
- unit = "ka";
519
- value *= 1000;
520
- if (value < 5) {
521
- unit = "yr";
522
- value *= 1000;
523
- }
524
- } else if (value > 1000) {
525
- unit = "Ga";
526
- value /= 1000;
527
- }
528
-
529
- return [value, unit];
530
- }
531
-
532
- export function AgeLabel({
533
- age,
534
- maximumFractionDigits = 2,
535
- minimumFractionDigits = 0,
536
- className,
537
- }: {
538
- age: number;
539
- className?: string;
540
- maximumFractionDigits?: number;
541
- minimumFractionDigits?: number;
542
- }) {
543
- /** Component to display a single age value with unit conversion from
544
- * Ma to ka or Ga as appropriate.
545
- */
546
- const [value, unit] = getAge(age);
547
-
548
- const _value = value.toLocaleString("en-US", {
549
- maximumFractionDigits,
550
- minimumFractionDigits,
551
- });
552
-
553
- return h(Value, { value: _value, unit, className });
554
- }
555
-
556
- export function Duration({
557
- value,
558
- maximumFractionDigits = 2,
559
- minimumFractionDigits = 0,
560
- }) {
561
- let unit = "Myr";
562
- if (value < 0.8) {
563
- unit = "kyr";
564
- value *= 1000;
565
- if (value < 5) {
566
- unit = "yr";
567
- value *= 1000;
568
- }
569
- } else if (value > 1000) {
570
- unit = "Gyr";
571
- value /= 1000;
572
- }
573
-
574
- let _value = value.toLocaleString("en-US", {
575
- maximumFractionDigits,
576
- minimumFractionDigits,
577
- });
578
-
579
- return h(Value, { value: _value, unit });
580
- }
581
-
582
482
  function enhanceEnvironments(
583
483
  environments: Partial<Environment>[] | null,
584
484
  envMap: Map<number, Environment>,
@@ -711,117 +611,3 @@ function UnitIdentifier({
711
611
  ...interactionProps,
712
612
  });
713
613
  }
714
-
715
- function IntervalProportions({ unit, onClickItem }) {
716
- if (
717
- unit.b_int_id == null &&
718
- unit.t_int_id == null &&
719
- unit.b_prop == null &&
720
- unit.t_prop == null
721
- )
722
- return null;
723
-
724
- const i0 = unit.b_int_id;
725
- const i1 = unit.t_int_id;
726
- let b_prop = unit.b_prop ?? 0;
727
- let t_prop = unit.t_prop ?? 1;
728
-
729
- const intervalMap = useMacrostratDefs("intervals");
730
- const int0 = intervalMap?.get(i0) ?? {};
731
-
732
- const interval0: IntervalShort = {
733
- ...int0,
734
- id: i0,
735
- name: unit.b_int_name,
736
- };
737
-
738
- let p0: ReactNode = null;
739
- const int1 = intervalMap?.get(i1) ?? {};
740
- const p1: ReactNode = h(Proportion, { value: t_prop });
741
-
742
- if (i0 !== i1 || b_prop !== 0 || t_prop !== 1) {
743
- // We have a single interval with undefined proportions
744
- p0 = h(Proportion, { value: b_prop });
745
- }
746
-
747
- if (i0 === i1 && (b_prop !== 0 || t_prop !== 1)) {
748
- p0 = h("span.joint-proportion", [p0, h("span.sep", "to"), p1]);
749
- }
750
-
751
- const clickable = onClickItem != null;
752
-
753
- const handleClick = (event: MouseEvent) => {
754
- if (onClickItem) {
755
- onClickItem(event, interval0);
756
- }
757
- };
758
-
759
- return h("div.interval-proportions", [
760
- h(IntervalTag, {
761
- className: clickable ? "clickable" : "",
762
- onClick: clickable ? handleClick : undefined,
763
- interval: interval0,
764
- prefix: p0,
765
- }),
766
- h.if(i0 != i1)("span.discourage-break", [
767
- h("span.sep", "to"),
768
- h(IntervalTag, {
769
- className: clickable ? "clickable" : "",
770
- onClick: clickable ? handleClick : undefined,
771
- interval: {
772
- ...int1,
773
- id: i1,
774
- name: unit.t_int_name,
775
- },
776
- prefix: p1,
777
- }),
778
- ]),
779
- ]);
780
- }
781
-
782
- const formatProportion = (d) => {
783
- if (d == null) return null;
784
- return d.toFixed(1);
785
- };
786
-
787
- function Proportion({ value }) {
788
- let content = null;
789
- if (value == 0) {
790
- content = "base";
791
- } else if (value == 1) {
792
- content = "top";
793
- } else {
794
- content = formatProportion(value * 100) + "%";
795
- }
796
-
797
- return h("span.proportion", content);
798
- }
799
-
800
- function formatRange(min, max, precision = null) {
801
- if (min == null || max == null) return null;
802
- if (min === max) {
803
- return min.toFixed(precision);
804
- }
805
-
806
- return `${formatSignificance(min, precision)}–${formatSignificance(
807
- max,
808
- precision,
809
- )}`;
810
- }
811
-
812
- function formatSignificance(value, precision = null) {
813
- // Format to preserve a reasonable number of significant figures
814
- // this could be done with an easier algorithm, probably:
815
-
816
- if (precision == null) {
817
- return value.toLocaleString();
818
- }
819
- if (precision >= 0) {
820
- return value.toFixed(precision);
821
- }
822
- if (precision < 0) {
823
- return (
824
- (value / Math.pow(10, -precision)).toFixed(0) + "0".repeat(-precision)
825
- );
826
- }
827
- }
@@ -0,0 +1,33 @@
1
+ export const formatProportion = (d) => {
2
+ if (d == null) return null;
3
+ return d.toFixed(1);
4
+ };
5
+
6
+ export function formatRange(min, max, precision = null) {
7
+ if (min == null || max == null) return null;
8
+ if (min === max) {
9
+ return min.toFixed(precision);
10
+ }
11
+
12
+ return `${formatSignificance(min, precision)}–${formatSignificance(
13
+ max,
14
+ precision,
15
+ )}`;
16
+ }
17
+
18
+ export function formatSignificance(value, precision = null) {
19
+ // Format to preserve a reasonable number of significant figures
20
+ // this could be done with an easier algorithm, probably:
21
+
22
+ if (precision == null) {
23
+ return value.toLocaleString();
24
+ }
25
+ if (precision >= 0) {
26
+ return value.toFixed(precision);
27
+ }
28
+ if (precision < 0) {
29
+ return (
30
+ (value / Math.pow(10, -precision)).toFixed(0) + "0".repeat(-precision)
31
+ );
32
+ }
33
+ }
@@ -1,2 +0,0 @@
1
- export * from './inset-map';
2
- export * from './styles';
@@ -1 +0,0 @@
1
- {"version":3,"file":"inset-map.cjs","sources":["../../../src/maps/_shared/inset-map.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n MapView,\n getBasicMapStyle,\n MapViewProps,\n} from \"@macrostrat/map-interface\";\nimport h from \"@macrostrat/hyper\";\nimport { MapboxMapProvider } from \"@macrostrat/mapbox-react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n removeMapLabels,\n removeSourceFromStyle,\n} from \"@macrostrat/mapbox-utils\";\nimport type { ReactNode, CSSProperties } from \"react\";\n\nexport interface InsetMapProps extends Omit<MapViewProps, \"style\"> {\n controls?: ReactNode;\n className?: string;\n children?: ReactNode;\n style?: CSSProperties;\n mapStyle?: mapboxgl.Style | string;\n showLabels?: boolean;\n showAdmin?: boolean;\n showRoads?: boolean;\n}\n\nexport function InsetMap({\n controls,\n className,\n children,\n style,\n mapStyle,\n accessToken,\n showLabels = false,\n showAdmin = false,\n showRoads = false,\n ...rest\n}: InsetMapProps) {\n const inDarkMode = useInDarkMode();\n const _style = useMemo((): mapboxgl.Style | string => {\n return mapStyle ?? getBasicMapStyle({ inDarkMode });\n }, [mapStyle, inDarkMode]);\n\n const transformStyle = useCallback(\n (style) => {\n let newStyle = style;\n if (!showLabels) {\n newStyle = removeMapLabels(newStyle);\n }\n if (!showAdmin) {\n newStyle = removeSourceFromStyle(newStyle, null, \"admin\");\n }\n if (!showRoads) {\n newStyle = removeSourceFromStyle(newStyle, null, \"road\");\n newStyle = removeSourceFromStyle(newStyle, null, \"aeroway\");\n }\n return newStyle;\n },\n [mapStyle, showLabels, showRoads, showAdmin],\n );\n\n return h(\"div.inset-map\", { className, style }, [\n h(MapboxMapProvider, [\n controls,\n h(\n MapView,\n {\n style: _style,\n accessToken,\n standalone: true,\n /* Default map position that centers on the bulk of Macrostrat columns\n */\n mapPosition: {\n camera: {\n lng: -100,\n lat: 38,\n altitude: 5000000,\n },\n },\n transformStyle,\n ...rest,\n },\n children,\n ),\n ]),\n ]);\n}\n"],"names":["useInDarkMode","useMemo","getBasicMapStyle","useCallback","style","removeMapLabels","removeSourceFromStyle","h","MapboxMapProvider","MapView"],"mappings":";;;;;;;;;;AA0BO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,GAAG;AACL,GAAkB;AAChB,QAAM,aAAaA,aAAAA,cAAA;AACnB,QAAM,SAASC,MAAAA,QAAQ,MAA+B;AACpD,WAAO,YAAYC,aAAAA,iBAAiB,EAAE,YAAY;AAAA,EACpD,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,QAAM,iBAAiBC,MAAAA;AAAAA,IACrB,CAACC,WAAU;AACT,UAAI,WAAWA;AACf,UAAI,CAAC,YAAY;AACf,mBAAWC,YAAAA,gBAAgB,QAAQ;AAAA,MACrC;AACA,UAAI,CAAC,WAAW;AACd,mBAAWC,YAAAA,sBAAsB,UAAU,MAAM,OAAO;AAAA,MAC1D;AACA,UAAI,CAAC,WAAW;AACd,mBAAWA,YAAAA,sBAAsB,UAAU,MAAM,MAAM;AACvD,mBAAWA,YAAAA,sBAAsB,UAAU,MAAM,SAAS;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,YAAY,WAAW,SAAS;AAAA,EAAA;AAG7C,SAAOC,WAAAA,QAAE,iBAAiB,EAAE,WAAW,SAAS;AAAA,IAC9CA,WAAAA,QAAEC,YAAAA,mBAAmB;AAAA,MACnB;AAAA,MACAD,WAAAA;AAAAA,QACEE,aAAAA;AAAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP;AAAA,UACA,YAAY;AAAA;AAAA;AAAA,UAGZ,aAAa;AAAA,YACX,QAAQ;AAAA,cACN,KAAK;AAAA,cACL,KAAK;AAAA,cACL,UAAU;AAAA,YAAA;AAAA,UACZ;AAAA,UAEF;AAAA,UACA,GAAG;AAAA,QAAA;AAAA,QAEL;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA,CACF;AACH;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inset-map.js","sources":["../../../src/maps/_shared/inset-map.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n MapView,\n getBasicMapStyle,\n MapViewProps,\n} from \"@macrostrat/map-interface\";\nimport h from \"@macrostrat/hyper\";\nimport { MapboxMapProvider } from \"@macrostrat/mapbox-react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n removeMapLabels,\n removeSourceFromStyle,\n} from \"@macrostrat/mapbox-utils\";\nimport type { ReactNode, CSSProperties } from \"react\";\n\nexport interface InsetMapProps extends Omit<MapViewProps, \"style\"> {\n controls?: ReactNode;\n className?: string;\n children?: ReactNode;\n style?: CSSProperties;\n mapStyle?: mapboxgl.Style | string;\n showLabels?: boolean;\n showAdmin?: boolean;\n showRoads?: boolean;\n}\n\nexport function InsetMap({\n controls,\n className,\n children,\n style,\n mapStyle,\n accessToken,\n showLabels = false,\n showAdmin = false,\n showRoads = false,\n ...rest\n}: InsetMapProps) {\n const inDarkMode = useInDarkMode();\n const _style = useMemo((): mapboxgl.Style | string => {\n return mapStyle ?? getBasicMapStyle({ inDarkMode });\n }, [mapStyle, inDarkMode]);\n\n const transformStyle = useCallback(\n (style) => {\n let newStyle = style;\n if (!showLabels) {\n newStyle = removeMapLabels(newStyle);\n }\n if (!showAdmin) {\n newStyle = removeSourceFromStyle(newStyle, null, \"admin\");\n }\n if (!showRoads) {\n newStyle = removeSourceFromStyle(newStyle, null, \"road\");\n newStyle = removeSourceFromStyle(newStyle, null, \"aeroway\");\n }\n return newStyle;\n },\n [mapStyle, showLabels, showRoads, showAdmin],\n );\n\n return h(\"div.inset-map\", { className, style }, [\n h(MapboxMapProvider, [\n controls,\n h(\n MapView,\n {\n style: _style,\n accessToken,\n standalone: true,\n /* Default map position that centers on the bulk of Macrostrat columns\n */\n mapPosition: {\n camera: {\n lng: -100,\n lat: 38,\n altitude: 5000000,\n },\n },\n transformStyle,\n ...rest,\n },\n children,\n ),\n ]),\n ]);\n}\n"],"names":["style"],"mappings":";;;;;;AA0BO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,GAAG;AACL,GAAkB;AAChB,QAAM,aAAa,cAAA;AACnB,QAAM,SAAS,QAAQ,MAA+B;AACpD,WAAO,YAAY,iBAAiB,EAAE,YAAY;AAAA,EACpD,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,QAAM,iBAAiB;AAAA,IACrB,CAACA,WAAU;AACT,UAAI,WAAWA;AACf,UAAI,CAAC,YAAY;AACf,mBAAW,gBAAgB,QAAQ;AAAA,MACrC;AACA,UAAI,CAAC,WAAW;AACd,mBAAW,sBAAsB,UAAU,MAAM,OAAO;AAAA,MAC1D;AACA,UAAI,CAAC,WAAW;AACd,mBAAW,sBAAsB,UAAU,MAAM,MAAM;AACvD,mBAAW,sBAAsB,UAAU,MAAM,SAAS;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,YAAY,WAAW,SAAS;AAAA,EAAA;AAG7C,SAAO,EAAE,iBAAiB,EAAE,WAAW,SAAS;AAAA,IAC9C,EAAE,mBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP;AAAA,UACA,YAAY;AAAA;AAAA;AAAA,UAGZ,aAAa;AAAA,YACX,QAAQ;AAAA,cACN,KAAK;AAAA,cACL,KAAK;AAAA,cACL,UAAU;AAAA,YAAA;AAAA,UACZ;AAAA,UAEF;AAAA,UACA,GAAG;AAAA,QAAA;AAAA,QAEL;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA,CACF;AACH;"}
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const colorUtils = require("@macrostrat/color-utils");
4
- const mapboxUtils = require("@macrostrat/mapbox-utils");
5
- function buildColumnsStyle(color) {
6
- let columnColor = color ?? colorUtils.getCSSVariable("--text-subtle-color", "black");
7
- const columnSelectedColor = colorUtils.getCSSVariable("--selection-color", "purple");
8
- columnColor = [
9
- "coalesce",
10
- ["feature-state", "color"],
11
- ["get", "color"],
12
- columnColor
13
- ];
14
- return {
15
- sources: {
16
- columns: mapboxUtils.buildGeoJSONSource()
17
- },
18
- version: 8,
19
- layers: [
20
- {
21
- id: "columns-fill",
22
- type: "fill",
23
- source: "columns",
24
- paint: {
25
- "fill-color": columnColor,
26
- "fill-opacity": [
27
- "case",
28
- ["boolean", ["feature-state", "selected"], false],
29
- 0.5,
30
- ["boolean", ["feature-state", "hover"], false],
31
- 0.3,
32
- 0.1
33
- ]
34
- }
35
- },
36
- {
37
- id: "columns-line",
38
- type: "line",
39
- source: "columns",
40
- paint: {
41
- "line-color": columnColor,
42
- "line-width": 2,
43
- "line-opacity": 0.5
44
- }
45
- },
46
- {
47
- id: "columns-points",
48
- type: "circle",
49
- source: "columns",
50
- paint: {
51
- "circle-radius": 4,
52
- "circle-color": [
53
- "case",
54
- ["boolean", ["feature-state", "selected"], false],
55
- columnSelectedColor,
56
- columnColor
57
- ],
58
- "circle-opacity": [
59
- "case",
60
- ["boolean", ["feature-state", "selected"], false],
61
- 1,
62
- ["boolean", ["feature-state", "hover"], false],
63
- 0.7,
64
- 0.5
65
- ]
66
- },
67
- filter: ["==", "$type", "Point"]
68
- }
69
- ]
70
- };
71
- }
72
- exports.buildColumnsStyle = buildColumnsStyle;
73
- //# sourceMappingURL=styles.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.cjs","sources":["../../../src/maps/_shared/styles.ts"],"sourcesContent":["import { getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport type { Style } from \"mapbox-gl\";\n\nexport function buildColumnsStyle(color: string): Style {\n let columnColor: any =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n const columnSelectedColor = getCSSVariable(\"--selection-color\", \"purple\");\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n columnColor = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnColor,\n ];\n\n return {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n 0.5,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": columnColor,\n \"line-width\": 2,\n \"line-opacity\": 0.5,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n columnSelectedColor,\n columnColor,\n ],\n \"circle-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n 1,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.7,\n 0.5,\n ],\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\n };\n}\n"],"names":["getCSSVariable","buildGeoJSONSource"],"mappings":";;;;AAIO,SAAS,kBAAkB,OAAsB;AACtD,MAAI,cACF,SAASA,0BAAe,uBAAuB,OAAO;AACxD,QAAM,sBAAsBA,WAAAA,eAAe,qBAAqB,QAAQ;AAIxE,gBAAc;AAAA,IACZ;AAAA,IACA,CAAC,iBAAiB,OAAO;AAAA,IACzB,CAAC,OAAO,OAAO;AAAA,IACf;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,SAAS;AAAA,MACP,SAASC,YAAAA,mBAAA;AAAA,IAAmB;AAAA,IAE9B,SAAS;AAAA,IACT,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,cAAc;AAAA,UACd,gBAAgB;AAAA,YACd;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,MACF;AAAA,MAEF;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,cAAc;AAAA,UACd,cAAc;AAAA,UACd,gBAAgB;AAAA,QAAA;AAAA,MAClB;AAAA,MAEF;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,iBAAiB;AAAA,UACjB,gBAAgB;AAAA,YACd;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA;AAAA,UAAA;AAAA,UAEF,kBAAkB;AAAA,YAChB;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,QAEF,QAAQ,CAAC,MAAM,SAAS,OAAO;AAAA,MAAA;AAAA,IACjC;AAAA,EACF;AAEJ;;"}
@@ -1,2 +0,0 @@
1
- import { Style } from 'mapbox-gl';
2
- export declare function buildColumnsStyle(color: string): Style;
@@ -1,73 +0,0 @@
1
- import { getCSSVariable } from "@macrostrat/color-utils";
2
- import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
3
- function buildColumnsStyle(color) {
4
- let columnColor = color ?? getCSSVariable("--text-subtle-color", "black");
5
- const columnSelectedColor = getCSSVariable("--selection-color", "purple");
6
- columnColor = [
7
- "coalesce",
8
- ["feature-state", "color"],
9
- ["get", "color"],
10
- columnColor
11
- ];
12
- return {
13
- sources: {
14
- columns: buildGeoJSONSource()
15
- },
16
- version: 8,
17
- layers: [
18
- {
19
- id: "columns-fill",
20
- type: "fill",
21
- source: "columns",
22
- paint: {
23
- "fill-color": columnColor,
24
- "fill-opacity": [
25
- "case",
26
- ["boolean", ["feature-state", "selected"], false],
27
- 0.5,
28
- ["boolean", ["feature-state", "hover"], false],
29
- 0.3,
30
- 0.1
31
- ]
32
- }
33
- },
34
- {
35
- id: "columns-line",
36
- type: "line",
37
- source: "columns",
38
- paint: {
39
- "line-color": columnColor,
40
- "line-width": 2,
41
- "line-opacity": 0.5
42
- }
43
- },
44
- {
45
- id: "columns-points",
46
- type: "circle",
47
- source: "columns",
48
- paint: {
49
- "circle-radius": 4,
50
- "circle-color": [
51
- "case",
52
- ["boolean", ["feature-state", "selected"], false],
53
- columnSelectedColor,
54
- columnColor
55
- ],
56
- "circle-opacity": [
57
- "case",
58
- ["boolean", ["feature-state", "selected"], false],
59
- 1,
60
- ["boolean", ["feature-state", "hover"], false],
61
- 0.7,
62
- 0.5
63
- ]
64
- },
65
- filter: ["==", "$type", "Point"]
66
- }
67
- ]
68
- };
69
- }
70
- export {
71
- buildColumnsStyle
72
- };
73
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.js","sources":["../../../src/maps/_shared/styles.ts"],"sourcesContent":["import { getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport type { Style } from \"mapbox-gl\";\n\nexport function buildColumnsStyle(color: string): Style {\n let columnColor: any =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n const columnSelectedColor = getCSSVariable(\"--selection-color\", \"purple\");\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n columnColor = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnColor,\n ];\n\n return {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n 0.5,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": columnColor,\n \"line-width\": 2,\n \"line-opacity\": 0.5,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n columnSelectedColor,\n columnColor,\n ],\n \"circle-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n 1,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.7,\n 0.5,\n ],\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\n };\n}\n"],"names":[],"mappings":";;AAIO,SAAS,kBAAkB,OAAsB;AACtD,MAAI,cACF,SAAS,eAAe,uBAAuB,OAAO;AACxD,QAAM,sBAAsB,eAAe,qBAAqB,QAAQ;AAIxE,gBAAc;AAAA,IACZ;AAAA,IACA,CAAC,iBAAiB,OAAO;AAAA,IACzB,CAAC,OAAO,OAAO;AAAA,IACf;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,SAAS;AAAA,MACP,SAAS,mBAAA;AAAA,IAAmB;AAAA,IAE9B,SAAS;AAAA,IACT,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,cAAc;AAAA,UACd,gBAAgB;AAAA,YACd;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,MACF;AAAA,MAEF;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,cAAc;AAAA,UACd,cAAc;AAAA,UACd,gBAAgB;AAAA,QAAA;AAAA,MAClB;AAAA,MAEF;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,iBAAiB;AAAA,UACjB,gBAAgB;AAAA,YACd;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA;AAAA,UAAA;AAAA,UAEF,kBAAkB;AAAA,YAChB;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,QAEF,QAAQ,CAAC,MAAM,SAAS,OAAO;AAAA,MAAA;AAAA,IACjC;AAAA,EACF;AAEJ;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/maps/units-overlay/index.ts"],"sourcesContent":["import {\n useLithologies,\n useMacrostratColumns,\n} from \"@macrostrat/data-provider\";\nimport { useAPIResult } from \"@macrostrat/ui-components\";\nimport { useMapStyleOperator } 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, getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport pMap from \"p-map\";\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 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 // Set up basic columns layer\n useMapStyleOperator(\n (map) => {\n if (columns == null) {\n return;\n }\n const data: FeatureCollection = {\n type: \"FeatureCollection\",\n features: columns,\n };\n setGeoJSON(map, \"columns\", data);\n },\n [columns],\n );\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 return null;\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 { color = null, patterns = false } = opts;\n\n let columnBaseColor: any =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n const columnSelectedColor = getCSSVariable(\"--selection-color\", \"purple\");\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n let columnColor: any = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnBaseColor,\n ];\n\n const baseStyle: StyleFragment = {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"shown\"], false],\n 0.8,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": columnColor,\n \"line-width\": 1,\n \"line-opacity\": 0.5,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"shown\"], false],\n columnColor,\n columnBaseColor,\n ],\n \"circle-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"shown\"], false],\n 0.8,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\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":["useLithologies","useMapStyleOperator","setupStyleImageManager","useMemo","useAPIResult","useMacrostratColumns","setGeoJSON","loadStyleImage","pMap","asChromaColor","flattenLithologies","getMixedColorForData","getBestFGDCPatternForLithologyList","getCSSVariable","buildGeoJSONSource","mergeStyles"],"mappings":";;;;;;;;;;;;;;AA4BO,SAAS,uBAAuB,OAA0B;AAC/D,QAAM,EAAE,MAAM,UAAU,MAAM,WAAW,UAAU;AACnD,QAAM,UAAUA,aAAAA,eAAA;AAEhBC,cAAAA;AAAAA,IACE,CAAC,QAAQ;AACP,UAAI,CAAC,SAAU;AACfC,gBAAAA,uBAAuB,KAAK,EAAE,SAAS,MAAA,CAAO;AAAA,IAChD;AAAA,IACA,CAAC,QAAQ;AAAA,EAAA;AAGX,QAAM,SAASC,MAAAA,QAAQ,MAAM;AAC3B,QAAI;AACJ,QAAI,OAAO,SAAS,MAAM,OAAO,GAAG;AAClC,gBAAU,CAAC,MAAM,OAAiB;AAAA,IACpC,WAAW,CAAC,MAAM,QAAQ,MAAM,OAAO,GAAG;AACxC,gBAAU;AAAA,IACZ;AAEA,UAAM,gBACJ,WAAW,QAAQ,QAAQ,SAAS,IAAI,QAAQ,CAAC,IAAI;AAEvD,WAAO;AAAA,MACL,YAAY,OAAO,UAAU;AAAA,MAC7B,SAAS,OAAO,UAAU;AAAA,MAC1B,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EAEb,GAAG,CAAC,MAAM,SAAS,MAAM,OAAO,CAAC;AAEjC,QAAM,QAAoBC,aAAAA,aAAa,UAAU,MAAM;AACvD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,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,MACF;AAAA,MAEF;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,cAAc;AAAA,UACd,cAAc;AAAA,UACd,gBAAgB;AAAA,QAAA;AAAA,MAClB;AAAA,MAEF;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,iBAAiB;AAAA,UACjB,gBAAgB;AAAA,YACd;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,UAEF,kBAAkB;AAAA,YAChB;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,QAEF,QAAQ,CAAC,MAAM,SAAS,OAAO;AAAA,MAAA;AAAA,IACjC;AAAA,EACF;AAGF,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,eAA8B;AAAA,IAClC,SAAS;AAAA,MACP,mBAAmBA,YAAAA,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,SAAOC,YAAAA,YAAY,WAAW,YAAY;AAC5C;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/maps/units-overlay/index.ts"],"sourcesContent":["import {\n useLithologies,\n useMacrostratColumns,\n} from \"@macrostrat/data-provider\";\nimport { useAPIResult } from \"@macrostrat/ui-components\";\nimport { useMapStyleOperator } 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, getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport pMap from \"p-map\";\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 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 // Set up basic columns layer\n useMapStyleOperator(\n (map) => {\n if (columns == null) {\n return;\n }\n const data: FeatureCollection = {\n type: \"FeatureCollection\",\n features: columns,\n };\n setGeoJSON(map, \"columns\", data);\n },\n [columns],\n );\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 return null;\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 { color = null, patterns = false } = opts;\n\n let columnBaseColor: any =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n const columnSelectedColor = getCSSVariable(\"--selection-color\", \"purple\");\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n let columnColor: any = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnBaseColor,\n ];\n\n const baseStyle: StyleFragment = {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"shown\"], false],\n 0.8,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": columnColor,\n \"line-width\": 1,\n \"line-opacity\": 0.5,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"shown\"], false],\n columnColor,\n columnBaseColor,\n ],\n \"circle-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"shown\"], false],\n 0.8,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\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":";;;;;;;;;;AA4BO,SAAS,uBAAuB,OAA0B;AAC/D,QAAM,EAAE,MAAM,UAAU,MAAM,WAAW,UAAU;AACnD,QAAM,UAAU,eAAA;AAEhB;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,QAAQ,MAAM;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,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,2 +0,0 @@
1
- export * from "./inset-map";
2
- export * from "./styles";
@@ -1,76 +0,0 @@
1
- import { getCSSVariable } from "@macrostrat/color-utils";
2
- import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
3
- import type { Style } from "mapbox-gl";
4
-
5
- export function buildColumnsStyle(color: string): Style {
6
- let columnColor: any =
7
- color ?? getCSSVariable("--text-subtle-color", "black");
8
- const columnSelectedColor = getCSSVariable("--selection-color", "purple");
9
-
10
- // If color is in the feature state or geojson properties, use that as second choice
11
-
12
- columnColor = [
13
- "coalesce",
14
- ["feature-state", "color"],
15
- ["get", "color"],
16
- columnColor,
17
- ];
18
-
19
- return {
20
- sources: {
21
- columns: buildGeoJSONSource(),
22
- },
23
- version: 8,
24
- layers: [
25
- {
26
- id: "columns-fill",
27
- type: "fill",
28
- source: "columns",
29
- paint: {
30
- "fill-color": columnColor,
31
- "fill-opacity": [
32
- "case",
33
- ["boolean", ["feature-state", "selected"], false],
34
- 0.5,
35
- ["boolean", ["feature-state", "hover"], false],
36
- 0.3,
37
- 0.1,
38
- ],
39
- },
40
- },
41
- {
42
- id: "columns-line",
43
- type: "line",
44
- source: "columns",
45
- paint: {
46
- "line-color": columnColor,
47
- "line-width": 2,
48
- "line-opacity": 0.5,
49
- },
50
- },
51
- {
52
- id: "columns-points",
53
- type: "circle",
54
- source: "columns",
55
- paint: {
56
- "circle-radius": 4,
57
- "circle-color": [
58
- "case",
59
- ["boolean", ["feature-state", "selected"], false],
60
- columnSelectedColor,
61
- columnColor,
62
- ],
63
- "circle-opacity": [
64
- "case",
65
- ["boolean", ["feature-state", "selected"], false],
66
- 1,
67
- ["boolean", ["feature-state", "hover"], false],
68
- 0.7,
69
- 0.5,
70
- ],
71
- },
72
- filter: ["==", "$type", "Point"],
73
- },
74
- ],
75
- };
76
- }