@macrostrat/column-views 3.1.0 → 3.2.1

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 (121) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/age-axis.js +2 -2
  3. package/dist/age-axis.js.map +1 -1
  4. package/dist/age-axis.module.sass.cjs +6 -1
  5. package/dist/age-axis.module.sass.cjs.map +1 -1
  6. package/dist/age-axis.module.sass.js +4 -1
  7. package/dist/age-axis.module.sass.js.map +1 -1
  8. package/dist/age-model-overlay.js +2 -2
  9. package/dist/age-model-overlay.js.map +1 -1
  10. package/dist/age-model-overlay.module.sass.cjs +6 -1
  11. package/dist/age-model-overlay.module.sass.cjs.map +1 -1
  12. package/dist/age-model-overlay.module.sass.js +4 -1
  13. package/dist/age-model-overlay.module.sass.js.map +1 -1
  14. package/dist/column.js +2 -2
  15. package/dist/column.js.map +1 -1
  16. package/dist/column.module.sass.cjs +6 -1
  17. package/dist/column.module.sass.cjs.map +1 -1
  18. package/dist/column.module.sass.js +4 -1
  19. package/dist/column.module.sass.js.map +1 -1
  20. package/dist/correlation-chart/main.js +2 -2
  21. package/dist/correlation-chart/main.js.map +1 -1
  22. package/dist/correlation-chart/main.module.sass.cjs +6 -1
  23. package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
  24. package/dist/correlation-chart/main.module.sass.js +4 -1
  25. package/dist/correlation-chart/main.module.sass.js.map +1 -1
  26. package/dist/data-provider/store.cjs +1 -1
  27. package/dist/data-provider/store.cjs.map +1 -1
  28. package/dist/data-provider/store.js +1 -1
  29. package/dist/data-provider/store.js.map +1 -1
  30. package/dist/facets/carbon-isotopes/isotopes-column.js +2 -2
  31. package/dist/facets/carbon-isotopes/isotopes-column.js.map +1 -1
  32. package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs +6 -1
  33. package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs.map +1 -1
  34. package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js +4 -1
  35. package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js.map +1 -1
  36. package/dist/facets/detrital-zircon/index.js +2 -2
  37. package/dist/facets/detrital-zircon/index.js.map +1 -1
  38. package/dist/facets/detrital-zircon/index.module.sass.cjs +6 -1
  39. package/dist/facets/detrital-zircon/index.module.sass.cjs.map +1 -1
  40. package/dist/facets/detrital-zircon/index.module.sass.js +4 -1
  41. package/dist/facets/detrital-zircon/index.module.sass.js.map +1 -1
  42. package/dist/facets/fossils/index.js +2 -2
  43. package/dist/facets/fossils/index.js.map +1 -1
  44. package/dist/facets/fossils/taxon-ranges.js +2 -2
  45. package/dist/facets/fossils/taxon-ranges.js.map +1 -1
  46. package/dist/facets/fossils/taxon-ranges.module.sass.cjs +6 -1
  47. package/dist/facets/fossils/taxon-ranges.module.sass.cjs.map +1 -1
  48. package/dist/facets/fossils/taxon-ranges.module.sass.js +4 -1
  49. package/dist/facets/fossils/taxon-ranges.module.sass.js.map +1 -1
  50. package/dist/facets/measurements/base.js +2 -2
  51. package/dist/facets/measurements/base.js.map +1 -1
  52. package/dist/facets/measurements/base.module.sass.cjs +6 -1
  53. package/dist/facets/measurements/base.module.sass.cjs.map +1 -1
  54. package/dist/facets/measurements/base.module.sass.js +4 -1
  55. package/dist/facets/measurements/base.module.sass.js.map +1 -1
  56. package/dist/index.cjs +11 -5
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.js +8 -2
  59. package/dist/index.js.map +1 -1
  60. package/dist/maps/_shared/styles.cjs +6 -1
  61. package/dist/maps/_shared/styles.cjs.map +1 -1
  62. package/dist/maps/_shared/styles.js +6 -1
  63. package/dist/maps/_shared/styles.js.map +1 -1
  64. package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +1 -1
  65. package/dist/maps/index.d.ts +1 -0
  66. package/dist/maps/units-overlay/index.cjs +254 -0
  67. package/dist/maps/units-overlay/index.cjs.map +1 -0
  68. package/dist/maps/units-overlay/index.d.ts +14 -0
  69. package/dist/maps/units-overlay/index.js +252 -0
  70. package/dist/maps/units-overlay/index.js.map +1 -0
  71. package/dist/section.js +2 -2
  72. package/dist/section.js.map +1 -1
  73. package/dist/unit-details/panel.cjs +9 -0
  74. package/dist/unit-details/panel.cjs.map +1 -1
  75. package/dist/unit-details/panel.js +11 -2
  76. package/dist/unit-details/panel.js.map +1 -1
  77. package/dist/unit-details/panel.module.sass.cjs +6 -1
  78. package/dist/unit-details/panel.module.sass.cjs.map +1 -1
  79. package/dist/unit-details/panel.module.sass.js +4 -1
  80. package/dist/unit-details/panel.module.sass.js.map +1 -1
  81. package/dist/unit-details/popover.js +2 -2
  82. package/dist/unit-details/popover.js.map +1 -1
  83. package/dist/unit-details/popover.module.sass.cjs +6 -1
  84. package/dist/unit-details/popover.module.sass.cjs.map +1 -1
  85. package/dist/unit-details/popover.module.sass.js +4 -1
  86. package/dist/unit-details/popover.module.sass.js.map +1 -1
  87. package/dist/units/boxes.js +2 -2
  88. package/dist/units/boxes.js.map +1 -1
  89. package/dist/units/boxes.module.sass.cjs +6 -1
  90. package/dist/units/boxes.module.sass.cjs.map +1 -1
  91. package/dist/units/boxes.module.sass.js +4 -1
  92. package/dist/units/boxes.module.sass.js.map +1 -1
  93. package/dist/units/colors.cjs +79 -18
  94. package/dist/units/colors.cjs.map +1 -1
  95. package/dist/units/colors.d.ts +17 -4
  96. package/dist/units/colors.js +79 -18
  97. package/dist/units/colors.js.map +1 -1
  98. package/dist/units/composite.js +2 -2
  99. package/dist/units/composite.js.map +1 -1
  100. package/dist/units/composite.module.sass.cjs +6 -1
  101. package/dist/units/composite.module.sass.cjs.map +1 -1
  102. package/dist/units/composite.module.sass.js +4 -1
  103. package/dist/units/composite.module.sass.js.map +1 -1
  104. package/dist/units/index.cjs +2 -0
  105. package/dist/units/index.cjs.map +1 -1
  106. package/dist/units/index.js +3 -0
  107. package/dist/units/index.js.map +1 -1
  108. package/dist/units/resolvers.cjs +11 -0
  109. package/dist/units/resolvers.cjs.map +1 -1
  110. package/dist/units/resolvers.d.ts +5 -0
  111. package/dist/units/resolvers.js +11 -0
  112. package/dist/units/resolvers.js.map +1 -1
  113. package/package.json +12 -11
  114. package/src/data-provider/store.ts +1 -0
  115. package/src/maps/_shared/styles.ts +10 -3
  116. package/src/maps/index.ts +1 -0
  117. package/src/maps/unit-map.stories.ts +64 -0
  118. package/src/maps/units-overlay/index.ts +336 -0
  119. package/src/unit-details/panel.ts +1 -1
  120. package/src/units/colors.ts +137 -25
  121. package/src/units/resolvers.ts +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function SimpleUnitsColumn(props: ICompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const { columnWidth, width, gutterWidth = 0, labelOffset = 30 } = props;\n\n return h([\n h(UnitsColumn, {\n width: columnWidth,\n }),\n h(UnitNamesColumn, {\n transform: `translate(${columnWidth + gutterWidth})`,\n paddingLeft: labelOffset,\n width: width - columnWidth - gutterWidth,\n }),\n ]);\n}\n\nexport function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAO,EAAE;AAAA,IACP,EAAE,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,IACD,EAAE,iBAAiB;AAAA,MACjB,WAAW,aAAa,cAAc,WAAW;AAAA,MACjD,aAAa;AAAA,MACb,OAAO,QAAQ,cAAc;AAAA,IAAA,CAC9B;AAAA,EAAA,CACF;AACH;AAEO,SAAS,mBAAmB,EAAE,UAAU,GAAG,QAAQ;AAGxD,SAAO,EAAE,eAAe;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,IACH,iBAAiB,SAAS;AAAA,IAC1B,WAAW,SAAS;AAAA,EAAA,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AAI,IAAI,kBAAkB,MAAM,gBAAgB,YAAY,cAAc;AAAA,MACxE,KAAK;AAAA,MACL,QAAQ;AAAA,IAAA,CACT;AACD,QAAI,KAAK,MAAM;AACb,aAAO;AAAA,IACT;AAEA,WAAO,kBAAkB,MAAM,SAAS,YAAY,YAAY;AAAA,EAClE,GAAG,CAAC,MAAM,SAAS,gBAAgB,SAAS,YAAY,YAAY,CAAC;AACvE;AAEO,SAAS,gCAAgC,OAAO;AAGrD,QAAM,kBAAkB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAY,QAAQ,MAAM;AAC9B,WAAO,UAAU,MAAM,QAAQ;AAAA,EACjC,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAO,mBAAmB,SAAS;AAEzC,SAAO,EAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function SimpleUnitsColumn(props: ICompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const { columnWidth, width, gutterWidth = 0, labelOffset = 30 } = props;\n\n return h([\n h(UnitsColumn, {\n width: columnWidth,\n }),\n h(UnitNamesColumn, {\n transform: `translate(${columnWidth + gutterWidth})`,\n paddingLeft: labelOffset,\n width: width - columnWidth - gutterWidth,\n }),\n ]);\n}\n\nexport function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAqBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAO,EAAE;AAAA,IACP,EAAE,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,IACD,EAAE,iBAAiB;AAAA,MACjB,WAAW,aAAa,cAAc,WAAW;AAAA,MACjD,aAAa;AA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ACH;AAEO,SAAS,0BACd,MACA,OAAyB,IACV;AAEf,QAAM,iBAAiB,gBAAA;AACvB,QAAM,UAAU,eAAA;AAChB,QAAM,aAAa,cAAA;AACnB,QAAM,EAAE,eAAe,KAAA,IAAS;AAEhC,SAAO,QAAQ,MAAM;AACnB,QAAI,QAAQ,QAAQ,kBAAkB,KAAM,QAAO;AACnD,QAAI,IAAI,kBAAkB,MAAM,gBAAgB,YAAY,cAAc;AAAA,MACxE,KAAK;AAAA,MACL,QAAQ;AAAA,IAAA,CACT;AACD,QAAI,KAAK,MAAM;AACb,aAAO;AAAA,IACT;AAEA,WAAO,kBAAkB,MAAM,SAAS,YAAY,YAAY;AAAA,EAClE,GAAG,CAAC,MAAM,SAAS,gBAAgB,SAAS,YAAY,YAAY,CAAC;AACvE;AAEO,SAAS,gCAAgC,OAAO;AAGrD,QAAM,kBAAkB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAY,QAAQ,MAAM;AAC9B,WAAO,UAAU,MAAM,QAAQ;AAAA,EACjC,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAO,mBAAmB,SAAS;AAEzC,SAAO,EAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;"}
@@ -55,6 +55,16 @@ const symbolIndex = {
55
55
  argillite: 624,
56
56
  diamictite: 681
57
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
+ }
58
68
  const resolveID = (d) => {
59
69
  if (d.lith == null || d.lith.length == 0) {
60
70
  return null;
@@ -109,6 +119,7 @@ const patternScale = {
109
119
  const scalePattern = (id) => {
110
120
  return patternScale[`${id}`] ?? 1;
111
121
  };
122
+ exports.getBestFGDCPatternForLithologyList = getBestFGDCPatternForLithologyList;
112
123
  exports.resolveID = resolveID;
113
124
  exports.scalePattern = scalePattern;
114
125
  //# sourceMappingURL=resolvers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.cjs","sources":["../../src/units/resolvers.ts"],"sourcesContent":["const 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\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":";;AAAA,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,EACV,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,EACP,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EAC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AA,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
+ {"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,EACV,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,Q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pC,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,3 +1,8 @@
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;
1
6
  declare const resolveID: (d: any) => any;
2
7
  declare const scalePattern: (id: any) => any;
3
8
  export { resolveID, scalePattern };
@@ -53,6 +53,16 @@ const symbolIndex = {
53
53
  argillite: 624,
54
54
  diamictite: 681
55
55
  };
56
+ function getBestFGDCPatternForLithologyList(liths) {
57
+ let lithsSorted = [...liths];
58
+ lithsSorted.sort((a, b) => b.prop - a.prop);
59
+ let firstLith = lithsSorted[0];
60
+ let sym = symbolIndex[firstLith.name];
61
+ if (sym != null) {
62
+ return { lith: firstLith, patternID: `${sym}` };
63
+ }
64
+ return null;
65
+ }
56
66
  const resolveID = (d) => {
57
67
  if (d.lith == null || d.lith.length == 0) {
58
68
  return null;
@@ -108,6 +118,7 @@ const scalePattern = (id) => {
108
118
  return patternScale[`${id}`] ?? 1;
109
119
  };
110
120
  export {
121
+ getBestFGDCPatternForLithologyList,
111
122
  resolveID,
112
123
  scalePattern
113
124
  };
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.js","sources":["../../src/units/resolvers.ts"],"sourcesContent":["const 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\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":"AAAA,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,EACV,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA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AAO;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
+ {"version":3,"file":"resolvers.js","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,cA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AG,MAAM,EAAE,OAAO,EAAE,IAAI;AAIpC,MAAI,MAAM;AAGV,MAAI,EAAE,aAAa,QAAQ;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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/column-views",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "Data views for Macrostrat stratigraphic columns",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,17 +49,17 @@
49
49
  "@macrostrat/api-types": "^1.1.5",
50
50
  "@macrostrat/color-utils": "^1.2.1",
51
51
  "@macrostrat/column-components": "^2.0.4",
52
- "@macrostrat/data-components": "^1.1.0",
53
- "@macrostrat/data-provider": "^1.0.0",
52
+ "@macrostrat/data-components": "^1.1.1",
53
+ "@macrostrat/data-provider": "^1.0.1",
54
54
  "@macrostrat/hyper": "^3.0.6",
55
- "@macrostrat/map-interface": "^2.0.1",
56
- "@macrostrat/map-styles": "^2.0.1",
57
- "@macrostrat/mapbox-react": "^3.0.1",
58
- "@macrostrat/mapbox-utils": "^1.7.1",
55
+ "@macrostrat/map-interface": "^2.0.2",
56
+ "@macrostrat/map-styles": "^2.1.0",
57
+ "@macrostrat/mapbox-react": "^3.0.2",
58
+ "@macrostrat/mapbox-utils": "^1.7.2",
59
59
  "@macrostrat/stratigraphy-utils": "^1.2.1",
60
60
  "@macrostrat/svg-map-components": "^2.0.1",
61
- "@macrostrat/timescale": "^3.0.1",
62
- "@macrostrat/ui-components": "^5.0.4",
61
+ "@macrostrat/timescale": "^3.1.1",
62
+ "@macrostrat/ui-components": "^5.0.5",
63
63
  "@turf/boolean-point-in-polygon": "^7.3.2",
64
64
  "@turf/buffer": "^7.3.2",
65
65
  "@turf/centroid": "^7.3.2",
@@ -84,14 +84,15 @@
84
84
  "d3-shape": "^3.2.0",
85
85
  "jotai": "^2.16.0",
86
86
  "jotai-scope": "^0.10.0",
87
- "mapbox-gl": "^2.15.0||^3.0.0",
87
+ "mapbox-gl": "^3.0.0",
88
+ "p-map": "^7.0.4",
88
89
  "react-spring": "^9.7.5",
89
90
  "topojson-client": "^3.1.0",
90
91
  "zustand": "^5.0.3",
91
92
  "zustand-computed": "^2.0.2"
92
93
  },
93
94
  "devDependencies": {
94
- "@macrostrat/web-components-bundler": "1.0.0"
95
+ "@macrostrat/web-components-bundler": "1.0.1"
95
96
  },
96
97
  "publishConfig": {
97
98
  "access": "public"
@@ -15,6 +15,7 @@ import {
15
15
  import type { BaseUnit } from "@macrostrat/api-types";
16
16
  import { type AtomMap, createScopedStore } from "@macrostrat/data-components";
17
17
  import { atom } from "jotai";
18
+ import { useEffect } from "react";
18
19
 
19
20
  export const scope = createScopedStore();
20
21
 
@@ -3,11 +3,18 @@ import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
3
3
  import type { Style } from "mapbox-gl";
4
4
 
5
5
  export function buildColumnsStyle(color: string): Style {
6
- let columnColor = color ?? getCSSVariable("--text-subtle-color", "black");
6
+ let columnColor: any =
7
+ color ?? getCSSVariable("--text-subtle-color", "black");
7
8
  const columnSelectedColor = getCSSVariable("--selection-color", "purple");
8
9
 
9
- // If color is in the geojson properties, use that
10
- columnColor = ["coalesce", ["get", "color"], columnColor];
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
+ ];
11
18
 
12
19
  return {
13
20
  sources: {
package/src/maps/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./column-navigation";
2
2
  export * from "./column-correlation";
3
3
  export * from "./_shared";
4
+ export * from "./units-overlay";
@@ -0,0 +1,64 @@
1
+ import h from "@macrostrat/hyper";
2
+ import { Meta } from "@storybook/react-vite";
3
+ import { InsetMap } from "./_shared";
4
+ import { MacrostratDataProvider } from "@macrostrat/data-provider";
5
+ import { useMemo } from "react";
6
+ import { buildUnitsStyle, MacrostratUnitsOverlay } from "./units-overlay";
7
+
8
+ // @ts-ignore
9
+ const mapboxToken = import.meta.env.VITE_MAPBOX_API_TOKEN;
10
+
11
+ // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
12
+ export default {
13
+ title: "Column views/Maps/Unit map",
14
+ component: UnitMapComponent,
15
+ description: "A map of units through time",
16
+ argTypes: {
17
+ time: { control: "number", defaultValue: 100 },
18
+ ageSpan: { control: "number", defaultValue: 0.05 },
19
+ patterns: { control: "boolean", defaultValue: false },
20
+ },
21
+ } as Meta<typeof InsetMap>;
22
+
23
+ function UnitMapComponent(props) {
24
+ const overlayStyles = useMemo(() => {
25
+ let styles: any[] = [
26
+ buildUnitsStyle({ color: "#444", patterns: props.patterns }),
27
+ ];
28
+ return styles;
29
+ }, []);
30
+
31
+ return h(
32
+ MacrostratDataProvider,
33
+ {
34
+ baseURL: "https://dev.macrostrat.org/api/v2",
35
+ },
36
+ h(
37
+ "div",
38
+ h(
39
+ InsetMap,
40
+ {
41
+ style: { width: "800px", height: "600px" },
42
+ accessToken: mapboxToken,
43
+ overlayStyles,
44
+ },
45
+ h(MacrostratUnitsOverlay, props),
46
+ ),
47
+ ),
48
+ );
49
+ }
50
+
51
+ export const UnitMap = {
52
+ args: {
53
+ time: 100,
54
+ ageSpan: 0.05,
55
+ },
56
+ };
57
+
58
+ export const WithPatterns = {
59
+ args: {
60
+ time: 100,
61
+ ageSpan: 0.05,
62
+ patterns: true,
63
+ },
64
+ };
@@ -0,0 +1,336 @@
1
+ import {
2
+ useLithologies,
3
+ useMacrostratColumns,
4
+ } from "@macrostrat/data-provider";
5
+ import { useAPIResult } from "@macrostrat/ui-components";
6
+ import { useMapStyleOperator } from "@macrostrat/mapbox-react";
7
+ import { FeatureCollection } from "geojson";
8
+ import { useMemo } from "react";
9
+ import { mergeStyles, setGeoJSON } from "@macrostrat/mapbox-utils";
10
+ import { UnitLithology, UnitLong } from "@macrostrat/api-types";
11
+ import { flattenLithologies, getMixedColorForData } from "../../units";
12
+ import { getBestFGDCPatternForLithologyList } from "../../units/resolvers";
13
+ import {
14
+ setupStyleImageManager,
15
+ loadStyleImage,
16
+ StyleFragment,
17
+ } from "@macrostrat/map-styles";
18
+ import { asChromaColor, getCSSVariable } from "@macrostrat/color-utils";
19
+ import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
20
+ import pMap from "p-map";
21
+
22
+ export interface UnitsOverlayProps {
23
+ time: number;
24
+ ageSpan?: number;
25
+ project?: number | number[];
26
+ patterns?: boolean;
27
+ }
28
+
29
+ export function MacrostratUnitsOverlay(props: UnitsOverlayProps) {
30
+ const { time, ageSpan = 0.05, patterns = false } = props;
31
+ const lithMap = useLithologies();
32
+
33
+ useMapStyleOperator(
34
+ (map) => {
35
+ if (!patterns) return;
36
+ setupStyleImageManager(map, { verbose: false });
37
+ },
38
+ [patterns],
39
+ );
40
+
41
+ const params = useMemo(() => {
42
+ let project: number[] | undefined;
43
+ if (Number.isFinite(props.project)) {
44
+ project = [props.project as number];
45
+ } else if (!Array.isArray(props.project)) {
46
+ project = undefined;
47
+ }
48
+ // Project can only be a single project for now
49
+ const projectCompat =
50
+ project != null && project.length > 0 ? project[0] : undefined;
51
+
52
+ return {
53
+ age_bottom: time + ageSpan / 2,
54
+ age_top: time - ageSpan / 2,
55
+ response: "long",
56
+ project: projectCompat,
57
+ };
58
+ }, [time, ageSpan, props.project]);
59
+
60
+ const units: UnitLong[] = useAPIResult("/units", params);
61
+ const columns = useMacrostratColumns(params.project, false);
62
+
63
+ // Set up basic columns layer
64
+ useMapStyleOperator(
65
+ (map) => {
66
+ if (columns == null) {
67
+ return;
68
+ }
69
+ const data: FeatureCollection = {
70
+ type: "FeatureCollection",
71
+ features: columns,
72
+ };
73
+ setGeoJSON(map, "columns", data);
74
+ },
75
+ [columns],
76
+ );
77
+
78
+ useMapStyleOperator(
79
+ (map) => {
80
+ if (units == null || columns == null || lithMap == null) {
81
+ return;
82
+ }
83
+
84
+ const getColorForLithology = (data: UnitLithology): string | null => {
85
+ return lithMap?.get(data.lith_id)?.color ?? null;
86
+ };
87
+
88
+ const unitsMap = postProcessUnits(units, getColorForLithology);
89
+ handleUnitsLayerUpdate(map, unitsMap, columns);
90
+ if (patterns) {
91
+ handlePatternOverlayUpdate(
92
+ map,
93
+ unitsMap,
94
+ columns,
95
+ getColorForLithology,
96
+ ).then(() => {});
97
+ }
98
+ },
99
+ [units, lithMap, columns, patterns],
100
+ );
101
+
102
+ return null;
103
+ }
104
+
105
+ function handleUnitsLayerUpdate(
106
+ map,
107
+ unitsMap: Map<number, UnitsDisplayInfo>,
108
+ columns: any[],
109
+ ) {
110
+ // Update feature states
111
+ for (const column of columns) {
112
+ const col_id = column.properties.col_id;
113
+ const info = unitsMap.get(Number(col_id));
114
+ const color = info?.color;
115
+ map.setFeatureState(
116
+ { source: "columns", id: col_id },
117
+ {
118
+ color,
119
+ shown: color != null,
120
+ },
121
+ );
122
+ }
123
+ }
124
+
125
+ async function handlePatternOverlayUpdate(
126
+ map,
127
+ unitsMap: Map<number, UnitsDisplayInfo>,
128
+ columns: any[],
129
+ getColor: LithologyColorGetter,
130
+ ) {
131
+ // synthesize patterns not yet in cache
132
+
133
+ const colsWithPatterns = [];
134
+ const patternIDs = new Set<string>();
135
+ // Update feature states
136
+ for (const column of columns) {
137
+ const col_id = column.properties.col_id;
138
+ const info = unitsMap.get(Number(col_id));
139
+ if (info == null) continue;
140
+ const pattern = getPatternSpec(info?.liths, getColor);
141
+ if (pattern == null) continue;
142
+
143
+ colsWithPatterns.push({
144
+ type: "Feature",
145
+ geometry: column.geometry,
146
+ properties: {
147
+ col_id,
148
+ pattern,
149
+ },
150
+ });
151
+ patternIDs.add(pattern);
152
+ }
153
+
154
+ const patternsToLoad = patternIDs.values().filter((d) => !map.hasImage(d));
155
+
156
+ const mapper = async (patternID) => {
157
+ try {
158
+ await loadStyleImage(map, patternID, { pixelRatio: 10 });
159
+ } catch (e) {}
160
+ };
161
+ // Load all pattern images
162
+ await pMap(patternsToLoad, mapper, { concurrency: 5 });
163
+
164
+ // Set data for pattern layer
165
+ // This is inefficient but the only way to set per-feature patterns in Mapbox
166
+ const patternData: FeatureCollection = {
167
+ type: "FeatureCollection",
168
+ features: colsWithPatterns,
169
+ };
170
+ setGeoJSON(map, "column-patterns", patternData);
171
+ }
172
+
173
+ const cachedColors = new Map<string, string>();
174
+
175
+ function getDarkenedColor(color: string): string {
176
+ /** Memoized function to get a darkened version of a color for pattern use */
177
+ if (cachedColors.has(color)) {
178
+ return cachedColors.get(color);
179
+ }
180
+ const c1 = asChromaColor(color).set("hsl.l", 0.4).set("hsl.s", 0.8).hex();
181
+ cachedColors.set(color, c1);
182
+ return c1;
183
+ }
184
+
185
+ interface UnitsDisplayInfo {
186
+ col_id: number;
187
+ units: UnitLong[];
188
+ color: string;
189
+ liths: UnitLithology[];
190
+ }
191
+
192
+ type LithologyColorGetter = (val: UnitLithology) => string | null;
193
+
194
+ function postProcessUnits(
195
+ units: UnitLong[],
196
+ getColor: LithologyColorGetter,
197
+ ): Map<number, UnitsDisplayInfo> {
198
+ // Group by col_id
199
+ const unitsByColumn: Map<number, UnitLong[]> = new Map();
200
+ for (const unit of units) {
201
+ const col_id = Number(unit.col_id);
202
+ if (!unitsByColumn.has(col_id)) {
203
+ unitsByColumn.set(col_id, [unit]);
204
+ } else {
205
+ unitsByColumn.set(col_id, [...unitsByColumn.get(col_id), unit]);
206
+ }
207
+ }
208
+
209
+ // Summarize units for display
210
+ const res = new Map<number, UnitsDisplayInfo>();
211
+ for (const [col_id, unitList] of unitsByColumn.entries()) {
212
+ const liths = flattenLithologies(unitList.map((u) => u.lith));
213
+ res.set(col_id, {
214
+ col_id,
215
+ units: unitList,
216
+ liths,
217
+ color: getMixedColorForData(liths, getColor),
218
+ });
219
+ }
220
+
221
+ return res;
222
+ }
223
+
224
+ function getPatternSpec(
225
+ liths: UnitLithology[],
226
+ getColor: LithologyColorGetter,
227
+ ): string | null {
228
+ const patternData = getBestFGDCPatternForLithologyList(liths);
229
+ if (patternData == null) return null;
230
+ let { patternID, lith } = patternData;
231
+ const color = getDarkenedColor(getColor(lith));
232
+ return `fgdc:${patternID}:${color}:transparent`;
233
+ }
234
+
235
+ type UnitsStyleOptions = {
236
+ color?: string;
237
+ patterns?: boolean;
238
+ };
239
+
240
+ export function buildUnitsStyle(opts: UnitsStyleOptions = {}): StyleFragment {
241
+ const { color = null, patterns = false } = opts;
242
+
243
+ let columnBaseColor: any =
244
+ color ?? getCSSVariable("--text-subtle-color", "black");
245
+ const columnSelectedColor = getCSSVariable("--selection-color", "purple");
246
+
247
+ // If color is in the feature state or geojson properties, use that as second choice
248
+
249
+ let columnColor: any = [
250
+ "coalesce",
251
+ ["feature-state", "color"],
252
+ ["get", "color"],
253
+ columnBaseColor,
254
+ ];
255
+
256
+ const baseStyle: StyleFragment = {
257
+ sources: {
258
+ columns: buildGeoJSONSource(),
259
+ },
260
+ version: 8,
261
+ layers: [
262
+ {
263
+ id: "columns-fill",
264
+ type: "fill",
265
+ source: "columns",
266
+ paint: {
267
+ "fill-color": columnColor,
268
+ "fill-opacity": [
269
+ "case",
270
+ ["boolean", ["feature-state", "shown"], false],
271
+ 0.8,
272
+ ["boolean", ["feature-state", "hover"], false],
273
+ 0.3,
274
+ 0.1,
275
+ ],
276
+ },
277
+ },
278
+ {
279
+ id: "columns-line",
280
+ type: "line",
281
+ source: "columns",
282
+ paint: {
283
+ "line-color": columnColor,
284
+ "line-width": 1,
285
+ "line-opacity": 0.5,
286
+ },
287
+ },
288
+ {
289
+ id: "columns-points",
290
+ type: "circle",
291
+ source: "columns",
292
+ paint: {
293
+ "circle-radius": 4,
294
+ "circle-color": [
295
+ "case",
296
+ ["boolean", ["feature-state", "shown"], false],
297
+ columnColor,
298
+ columnBaseColor,
299
+ ],
300
+ "circle-opacity": [
301
+ "case",
302
+ ["boolean", ["feature-state", "shown"], false],
303
+ 0.8,
304
+ ["boolean", ["feature-state", "hover"], false],
305
+ 0.3,
306
+ 0.1,
307
+ ],
308
+ },
309
+ filter: ["==", "$type", "Point"],
310
+ },
311
+ ],
312
+ };
313
+
314
+ if (!patterns) {
315
+ return baseStyle;
316
+ }
317
+
318
+ const patternStyle: StyleFragment = {
319
+ sources: {
320
+ "column-patterns": buildGeoJSONSource(),
321
+ },
322
+ layers: [
323
+ {
324
+ id: "columns-fill-pattern",
325
+ type: "fill",
326
+ source: "column-patterns",
327
+ paint: {
328
+ "fill-pattern": ["get", "pattern"],
329
+ "fill-opacity": 1,
330
+ },
331
+ },
332
+ ],
333
+ };
334
+
335
+ return mergeStyles(baseStyle, patternStyle);
336
+ }
@@ -437,7 +437,7 @@ function getThickness(unit): [string, string] {
437
437
  return [formatRange(minThickness, maxThickness), _unit];
438
438
  }
439
439
 
440
- function ThicknessField({ unit, label = "Thickness" }) {
440
+ export function ThicknessField({ unit, label = "Thickness" }) {
441
441
  const [value, thicknessUnit] = getThickness(unit);
442
442
  return h(DataField, {
443
443
  label,