@macrostrat/column-views 3.0.3 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/age-axis.js +2 -2
- package/dist/age-axis.js.map +1 -1
- package/dist/age-axis.module.sass.cjs +6 -1
- package/dist/age-axis.module.sass.cjs.map +1 -1
- package/dist/age-axis.module.sass.js +4 -1
- package/dist/age-axis.module.sass.js.map +1 -1
- package/dist/age-model-overlay.js +2 -2
- package/dist/age-model-overlay.js.map +1 -1
- package/dist/age-model-overlay.module.sass.cjs +6 -1
- package/dist/age-model-overlay.module.sass.cjs.map +1 -1
- package/dist/age-model-overlay.module.sass.js +4 -1
- package/dist/age-model-overlay.module.sass.js.map +1 -1
- package/dist/column.js +2 -2
- package/dist/column.js.map +1 -1
- package/dist/column.module.sass.cjs +6 -1
- package/dist/column.module.sass.cjs.map +1 -1
- package/dist/column.module.sass.js +4 -1
- package/dist/column.module.sass.js.map +1 -1
- package/dist/correlation-chart/main.js +2 -2
- package/dist/correlation-chart/main.js.map +1 -1
- package/dist/correlation-chart/main.module.sass.cjs +6 -1
- package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
- package/dist/correlation-chart/main.module.sass.js +4 -1
- package/dist/correlation-chart/main.module.sass.js.map +1 -1
- package/dist/data-provider/column-nav.js +1 -1
- package/dist/data-provider/index.d.ts +0 -2
- package/dist/data-provider/store.cjs +49 -6
- package/dist/data-provider/store.cjs.map +1 -1
- package/dist/data-provider/store.js +47 -4
- package/dist/data-provider/store.js.map +1 -1
- package/dist/data-provider/unit-selection.cjs +9 -9
- package/dist/data-provider/unit-selection.cjs.map +1 -1
- package/dist/data-provider/unit-selection.d.ts +1 -1
- package/dist/data-provider/unit-selection.js +2 -2
- package/dist/data-provider/unit-selection.js.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.js +2 -2
- package/dist/facets/carbon-isotopes/isotopes-column.js.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs +6 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js +4 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js.map +1 -1
- package/dist/facets/detrital-zircon/index.js +2 -2
- package/dist/facets/detrital-zircon/index.js.map +1 -1
- package/dist/facets/detrital-zircon/index.module.sass.cjs +6 -1
- package/dist/facets/detrital-zircon/index.module.sass.cjs.map +1 -1
- package/dist/facets/detrital-zircon/index.module.sass.js +4 -1
- package/dist/facets/detrital-zircon/index.module.sass.js.map +1 -1
- package/dist/facets/fossils/index.js +2 -2
- package/dist/facets/fossils/index.js.map +1 -1
- package/dist/facets/fossils/taxon-ranges.js +2 -2
- package/dist/facets/fossils/taxon-ranges.js.map +1 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.cjs +6 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.cjs.map +1 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.js +4 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.js.map +1 -1
- package/dist/facets/measurements/base.js +2 -2
- package/dist/facets/measurements/base.js.map +1 -1
- package/dist/facets/measurements/base.module.sass.cjs +6 -1
- package/dist/facets/measurements/base.module.sass.cjs.map +1 -1
- package/dist/facets/measurements/base.module.sass.js +4 -1
- package/dist/facets/measurements/base.module.sass.js.map +1 -1
- package/dist/index.cjs +15 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -24
- package/dist/index.js.map +1 -1
- package/dist/maps/_shared/styles.cjs +6 -1
- package/dist/maps/_shared/styles.cjs.map +1 -1
- package/dist/maps/_shared/styles.js +6 -1
- package/dist/maps/_shared/styles.js.map +1 -1
- package/dist/maps/column-correlation/state.cjs +2 -2
- package/dist/maps/column-correlation/state.cjs.map +1 -1
- package/dist/maps/column-correlation/state.d.ts +1 -0
- package/dist/maps/column-correlation/state.js +1 -1
- package/dist/maps/column-correlation/state.js.map +1 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +1 -1
- package/dist/maps/column-navigation/mapbox/state.cjs +3 -3
- package/dist/maps/column-navigation/mapbox/state.cjs.map +1 -1
- package/dist/maps/column-navigation/mapbox/state.js +1 -1
- package/dist/maps/column-navigation/mapbox/state.js.map +1 -1
- package/dist/maps/column-navigation/svg/data-fetcher.cjs +25 -0
- package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +1 -0
- package/dist/maps/column-navigation/svg/data-fetcher.d.ts +6 -0
- package/dist/maps/column-navigation/svg/data-fetcher.js +25 -0
- package/dist/maps/column-navigation/svg/data-fetcher.js.map +1 -0
- package/dist/maps/column-navigation/svg/layers.cjs +2 -3
- package/dist/maps/column-navigation/svg/layers.cjs.map +1 -1
- package/dist/maps/column-navigation/svg/layers.js +1 -2
- package/dist/maps/column-navigation/svg/layers.js.map +1 -1
- package/dist/maps/index.d.ts +1 -0
- package/dist/maps/units-overlay/index.cjs +254 -0
- package/dist/maps/units-overlay/index.cjs.map +1 -0
- package/dist/maps/units-overlay/index.d.ts +14 -0
- package/dist/maps/units-overlay/index.js +252 -0
- package/dist/maps/units-overlay/index.js.map +1 -0
- package/dist/section.cjs +3 -3
- package/dist/section.cjs.map +1 -1
- package/dist/section.js +4 -4
- package/dist/section.js.map +1 -1
- package/dist/unit-details/panel.cjs +76 -57
- package/dist/unit-details/panel.cjs.map +1 -1
- package/dist/unit-details/panel.js +74 -55
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/unit-details/panel.module.sass.cjs +6 -1
- package/dist/unit-details/panel.module.sass.cjs.map +1 -1
- package/dist/unit-details/panel.module.sass.js +4 -1
- package/dist/unit-details/panel.module.sass.js.map +1 -1
- package/dist/unit-details/popover.js +2 -2
- package/dist/unit-details/popover.js.map +1 -1
- package/dist/unit-details/popover.module.sass.cjs +6 -1
- package/dist/unit-details/popover.module.sass.cjs.map +1 -1
- package/dist/unit-details/popover.module.sass.js +4 -1
- package/dist/unit-details/popover.module.sass.js.map +1 -1
- package/dist/units/boxes.cjs +1 -0
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +3 -2
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/boxes.module.sass.cjs +6 -1
- package/dist/units/boxes.module.sass.cjs.map +1 -1
- package/dist/units/boxes.module.sass.js +4 -1
- package/dist/units/boxes.module.sass.js.map +1 -1
- package/dist/units/colors.cjs +79 -18
- package/dist/units/colors.cjs.map +1 -1
- package/dist/units/colors.d.ts +17 -4
- package/dist/units/colors.js +79 -18
- package/dist/units/colors.js.map +1 -1
- package/dist/units/composite.js +2 -2
- package/dist/units/composite.js.map +1 -1
- package/dist/units/composite.module.sass.cjs +6 -1
- package/dist/units/composite.module.sass.cjs.map +1 -1
- package/dist/units/composite.module.sass.js +4 -1
- package/dist/units/composite.module.sass.js.map +1 -1
- package/dist/units/index.cjs +6 -4
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.js +4 -1
- package/dist/units/index.js.map +1 -1
- package/dist/units/resolvers.cjs +11 -0
- package/dist/units/resolvers.cjs.map +1 -1
- package/dist/units/resolvers.d.ts +5 -0
- package/dist/units/resolvers.js +11 -0
- package/dist/units/resolvers.js.map +1 -1
- package/package.json +11 -9
- package/src/correlation-chart/stories/correlation-chart.stories.ts +29 -22
- package/src/data-provider/index.ts +0 -2
- package/src/data-provider/store.ts +52 -10
- package/src/data-provider/unit-selection.ts +4 -4
- package/src/maps/_shared/styles.ts +10 -3
- package/src/maps/column-correlation/state.ts +2 -1
- package/src/maps/column-navigation/mapbox/state.ts +1 -1
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +1 -1
- package/src/maps/column-navigation/svg/data-fetcher.ts +34 -0
- package/src/maps/column-navigation/svg/layers.ts +1 -1
- package/src/maps/index.ts +1 -0
- package/src/maps/unit-map.stories.ts +64 -0
- package/src/maps/units-overlay/index.ts +336 -0
- package/src/section.ts +1 -1
- package/src/unit-details/panel.ts +97 -60
- package/src/units/boxes.ts +2 -1
- package/src/units/colors.ts +137 -25
- package/src/units/index.ts +1 -1
- package/src/units/resolvers.ts +16 -0
- package/dist/data-provider/base.cjs +0 -352
- package/dist/data-provider/base.cjs.map +0 -1
- package/dist/data-provider/base.d.ts +0 -65
- package/dist/data-provider/base.js +0 -349
- package/dist/data-provider/base.js.map +0 -1
- package/dist/data-provider/core.cjs +0 -58
- package/dist/data-provider/core.cjs.map +0 -1
- package/dist/data-provider/core.d.ts +0 -31
- package/dist/data-provider/core.js +0 -56
- package/dist/data-provider/core.js.map +0 -1
- package/dist/data-provider/fetch.cjs +0 -212
- package/dist/data-provider/fetch.cjs.map +0 -1
- package/dist/data-provider/fetch.d.ts +0 -27
- package/dist/data-provider/fetch.js +0 -210
- package/dist/data-provider/fetch.js.map +0 -1
- package/dist/data-provider/store.d.ts +0 -34
- package/dist/unit-details/panel.d.ts +0 -87
- package/src/data-provider/base.ts +0 -475
- package/src/data-provider/core.ts +0 -89
- package/src/data-provider/fetch.ts +0 -278
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/facets/fossils/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport type { IUnit } from \"../../units\";\nimport {\n BaseMeasurementsColumn,\n ColumnMeasurementData,\n MeasurementHeightData,\n standardizeMeasurementHeight,\n groupNotesByPixelDistance,\n TruncatedList,\n} from \"../measurements\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport {\n CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { scaleLinear } from \"d3-scale\";\n\nexport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n};\nexport * from \"./taxon-ranges\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBFossilsColumn({\n columnID,\n type = FossilDataType.Collections,\n}: {\n columnID: number;\n type: FossilDataType;\n}) {\n const data = useFossilData(columnID, type);\n const { axisType, units } = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null || units == null || scale == null) return null;\n\n const data1 = preparePBDBData(data, units, scale, axisType);\n\n return h(BaseMeasurementsColumn, {\n data: data1,\n noteComponent: FossilInfo,\n focusedNoteComponent: FossilInfo,\n className: \"fossil-collections\",\n });\n}\n\ninterface FossilItemProps {\n note: {\n data: PBDBCollection[];\n unit?: IUnit;\n };\n spacing?: {\n below?: number;\n above?: number;\n };\n width?: number;\n height?: number;\n color?: string;\n focused?: boolean;\n maxItems?: number;\n}\n\nfunction FossilInfo(props: FossilItemProps) {\n const { note, maxItems, focused = false } = props;\n const { data } = note;\n // Sort collections by name\n data.sort((a, b) => {\n const nameA = a.best_name ?? a.cltn_name ?? \"\";\n const nameB = b.best_name ?? b.cltn_name ?? \"\";\n return nameA.localeCompare(nameB);\n });\n\n return h(TruncatedList, {\n data,\n className: \"fossil-collections\",\n itemRenderer: PBDBCollectionLink,\n maxItems: focused ? Infinity : (maxItems ?? 5),\n });\n}\n\nfunction PBDBCollectionLink({\n data,\n}: {\n data: PBDBCollection | PBDBOccurrence;\n}) {\n /** A link to a PBDB collection that handles either an occurrence or collection object */\n return h(\n \"a.link-id\",\n {\n href: `https://paleobiodb.org/app/collections#display=col:${data.cltn_id}`,\n target: \"_blank\",\n onClick(e) {\n e.stopPropagation();\n },\n },\n data.best_name ?? data.cltn_name,\n );\n}\n\ninterface PreparePBDBDataOptions {\n /** If set, group close notes within this distance (in pixels in display space)\n * into a single note. If a number is provided, that number is used as the distance,\n * otherwise a default of 5 pixels is used.\n */\n groupCloseNotes?: boolean | number;\n}\n\nfunction preparePBDBData<T extends PBDBEntity>(\n data: T[],\n units: UnitLong[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n options?: PreparePBDBDataOptions,\n) {\n /** Prepare PBDB fossil data for display in a measurements column */\n const { groupCloseNotes = true } = options ?? {};\n const groupDistance =\n typeof groupCloseNotes === \"number\" ? groupCloseNotes : 10;\n\n // Map of data to its defined height ranges\n const dataMap = new Map<string, ColumnMeasurementData<T[]>>();\n\n // Todo: if we wanted, we could add a step where we group notes that are too close together here...\n\n for (const d of data) {\n const range = getHeightRangeForPBDBEntity(d, units, axisType);\n\n if (range == null) continue;\n const { height, top_height } = range;\n // compose the key based on height info\n let key = `${height}`;\n if (top_height != null) {\n key += `-${top_height}`;\n }\n\n // Group by height key\n if (!dataMap.has(key)) {\n dataMap.set(key, {\n height,\n top_height: top_height ?? height,\n data: [],\n id: key,\n });\n }\n dataMap.get(key)!.data.push(d);\n }\n\n return groupNotesByPixelDistance(\n Array.from(dataMap.values()),\n scale,\n axisType,\n groupDistance,\n );\n}\n\nfunction getHeightRangeForPBDBEntity<T extends PBDBEntity>(\n d: T,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n let height: number | null = null;\n if (d.slb != null && d.slu == \"mbsf\") {\n // Meters below sea floor - special case for eODP where we have\n // specific depth data referenced\n height = Number(d.slb);\n if (axisType === ColumnAxisType.DEPTH) {\n // Data is already in depth units\n return { height };\n }\n }\n if (d.unit_id == null) return null;\n if (height != null) {\n // If we have both height and unit info, we need to adjust the height\n // to fit whatever scale type we're using.\n // TODO: we could improve how this works by having concurrent age and\n // height scales, which would allow us to do this without having to\n // reference to a specific unit.\n const unit = units.find((u) => u.unit_id === d.unit_id);\n if (unit == null) return null;\n const relHeight = getRelativePositionInUnit(\n height,\n unit,\n ColumnAxisType.DEPTH,\n );\n if (relHeight == null) return null;\n height = getPositionWithinUnit(relHeight, unit, axisType);\n return { height };\n }\n // We can just get the height within the unit, clipped to the unit boundaries\n return standardizeMeasurementHeight({ unit_id: d.unit_id }, units, axisType);\n}\n\nfunction getRelativePositionInUnit(\n pos: number,\n unit: UnitLong,\n axisType: ColumnAxisType,\n): number | null {\n // This is the inverse of getPositionWithinUnit\n const heights = getUnitHeightRange(unit, axisType, false);\n const scale = scaleLinear(heights).domain([0, 1]);\n const relPos = scale.invert(pos);\n if (relPos < 0 || relPos > 1) return null;\n return relPos;\n}\n"],"names":["hyper"],"mappings":";;;;;;;;AAwCA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/facets/fossils/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport type { IUnit } from \"../../units\";\nimport {\n BaseMeasurementsColumn,\n ColumnMeasurementData,\n MeasurementHeightData,\n standardizeMeasurementHeight,\n groupNotesByPixelDistance,\n TruncatedList,\n} from \"../measurements\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport {\n CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { scaleLinear } from \"d3-scale\";\n\nexport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n};\nexport * from \"./taxon-ranges\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBFossilsColumn({\n columnID,\n type = FossilDataType.Collections,\n}: {\n columnID: number;\n type: FossilDataType;\n}) {\n const data = useFossilData(columnID, type);\n const { axisType, units } = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null || units == null || scale == null) return null;\n\n const data1 = preparePBDBData(data, units, scale, axisType);\n\n return h(BaseMeasurementsColumn, {\n data: data1,\n noteComponent: FossilInfo,\n focusedNoteComponent: FossilInfo,\n className: \"fossil-collections\",\n });\n}\n\ninterface FossilItemProps {\n note: {\n data: PBDBCollection[];\n unit?: IUnit;\n };\n spacing?: {\n below?: number;\n above?: number;\n };\n width?: number;\n height?: number;\n color?: string;\n focused?: boolean;\n maxItems?: number;\n}\n\nfunction FossilInfo(props: FossilItemProps) {\n const { note, maxItems, focused = false } = props;\n const { data } = note;\n // Sort collections by name\n data.sort((a, b) => {\n const nameA = a.best_name ?? a.cltn_name ?? \"\";\n const nameB = b.best_name ?? b.cltn_name ?? \"\";\n return nameA.localeCompare(nameB);\n });\n\n return h(TruncatedList, {\n data,\n className: \"fossil-collections\",\n itemRenderer: PBDBCollectionLink,\n maxItems: focused ? Infinity : (maxItems ?? 5),\n });\n}\n\nfunction PBDBCollectionLink({\n data,\n}: {\n data: PBDBCollection | PBDBOccurrence;\n}) {\n /** A link to a PBDB collection that handles either an occurrence or collection object */\n return h(\n \"a.link-id\",\n {\n href: `https://paleobiodb.org/app/collections#display=col:${data.cltn_id}`,\n target: \"_blank\",\n onClick(e) {\n e.stopPropagation();\n },\n },\n data.best_name ?? data.cltn_name,\n );\n}\n\ninterface PreparePBDBDataOptions {\n /** If set, group close notes within this distance (in pixels in display space)\n * into a single note. If a number is provided, that number is used as the distance,\n * otherwise a default of 5 pixels is used.\n */\n groupCloseNotes?: boolean | number;\n}\n\nfunction preparePBDBData<T extends PBDBEntity>(\n data: T[],\n units: UnitLong[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n options?: PreparePBDBDataOptions,\n) {\n /** Prepare PBDB fossil data for display in a measurements column */\n const { groupCloseNotes = true } = options ?? {};\n const groupDistance =\n typeof groupCloseNotes === \"number\" ? groupCloseNotes : 10;\n\n // Map of data to its defined height ranges\n const dataMap = new Map<string, ColumnMeasurementData<T[]>>();\n\n // Todo: if we wanted, we could add a step where we group notes that are too close together here...\n\n for (const d of data) {\n const range = getHeightRangeForPBDBEntity(d, units, axisType);\n\n if (range == null) continue;\n const { height, top_height } = range;\n // compose the key based on height info\n let key = `${height}`;\n if (top_height != null) {\n key += `-${top_height}`;\n }\n\n // Group by height key\n if (!dataMap.has(key)) {\n dataMap.set(key, {\n height,\n top_height: top_height ?? height,\n data: [],\n id: key,\n });\n }\n dataMap.get(key)!.data.push(d);\n }\n\n return groupNotesByPixelDistance(\n Array.from(dataMap.values()),\n scale,\n axisType,\n groupDistance,\n );\n}\n\nfunction getHeightRangeForPBDBEntity<T extends PBDBEntity>(\n d: T,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n let height: number | null = null;\n if (d.slb != null && d.slu == \"mbsf\") {\n // Meters below sea floor - special case for eODP where we have\n // specific depth data referenced\n height = Number(d.slb);\n if (axisType === ColumnAxisType.DEPTH) {\n // Data is already in depth units\n return { height };\n }\n }\n if (d.unit_id == null) return null;\n if (height != null) {\n // If we have both height and unit info, we need to adjust the height\n // to fit whatever scale type we're using.\n // TODO: we could improve how this works by having concurrent age and\n // height scales, which would allow us to do this without having to\n // reference to a specific unit.\n const unit = units.find((u) => u.unit_id === d.unit_id);\n if (unit == null) return null;\n const relHeight = getRelativePositionInUnit(\n height,\n unit,\n ColumnAxisType.DEPTH,\n );\n if (relHeight == null) return null;\n height = getPositionWithinUnit(relHeight, unit, axisType);\n return { height };\n }\n // We can just get the height within the unit, clipped to the unit boundaries\n return standardizeMeasurementHeight({ unit_id: d.unit_id }, units, axisType);\n}\n\nfunction getRelativePositionInUnit(\n pos: number,\n unit: UnitLong,\n axisType: ColumnAxisType,\n): number | null {\n // This is the inverse of getPositionWithinUnit\n const heights = getUnitHeightRange(unit, axisType, false);\n const scale = scaleLinear(heights).domain([0, 1]);\n const relPos = scale.invert(pos);\n if (relPos < 0 || relPos > 1) return null;\n return relPos;\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;;;AAwCA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAEtB,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,OAAO,eAAe;AACxB,GAGG;AACD,QA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C,CAAC;AAChD,QAAM,SAAS,MAAM,OAAO,GAAG;AAC/B,MAAI,SAAS,KAAK,SAAS,EAAG,QAAO;AACrC,SAAO;AACT;"}
|
|
@@ -3,10 +3,10 @@ import { useFossilData, FossilDataType } from "./provider.js";
|
|
|
3
3
|
import { Box, useElementSize } from "@macrostrat/ui-components";
|
|
4
4
|
import { group } from "d3-array";
|
|
5
5
|
import { ColumnAxisType, ColumnSVG } from "@macrostrat/column-components";
|
|
6
|
-
import
|
|
6
|
+
import h$2 from "./taxon-ranges.module.sass.js";
|
|
7
7
|
import { useRef } from "react";
|
|
8
8
|
import { useMacrostratColumnData, useCompositeScale } from "../../data-provider/store.js";
|
|
9
|
-
const h = h$1.styled(
|
|
9
|
+
const h = h$1.styled(h$2);
|
|
10
10
|
function PBDBOccurrencesMatrix({ columnID }) {
|
|
11
11
|
const data = useFossilData(columnID, FossilDataType.Occurrences);
|
|
12
12
|
const col = useMacrostratColumnData();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxon-ranges.js","sources":["../../../src/facets/fossils/taxon-ranges.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n PBDBEntity,\n PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport { Box, useElementSize } from \"@macrostrat/ui-components\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType, ColumnSVG } from \"@macrostrat/column-components\";\nimport {\n useMacrostratColumnData,\n useCompositeScale,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport { useRef } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBOccurrencesMatrix({ columnID }) {\n /* A column for a matrix of taxon occurrences displayed as a table beside the main column. This will\n eventually be extended with first/last occurrence markers and range bars.\n */\n const data = useFossilData(columnID, FossilDataType.Occurrences);\n const col = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null) return null;\n\n // convert the data to a map\n const occurrenceMap = new Map(group(data, (d) => d.unit_id)) as Map<\n number,\n PBDBOccurrence[]\n >;\n\n const matrix = createOccurrenceMatrix(col.units, occurrenceMap, col.axisType);\n\n const { taxonRanges } = matrix;\n\n const padding = 16;\n const spacing = 16;\n\n const taxonEntries = Array.from(taxonRanges.entries());\n //const taxon = taxonEntries.slice(0, 50); // limit to top 50 taxa\n\n const width = padding * 2 + spacing * taxonEntries.length;\n\n return h(Box, { className: \"taxon-ranges\", width, height: col.totalHeight }, [\n h(TaxonOccurrenceLabels, {\n taxonEntries,\n padding,\n spacing,\n scale,\n }),\n h(\n ColumnSVG,\n {\n width: padding * 2 + spacing * taxonEntries.length,\n },\n h(\n \"g.taxa-occurrences-matrix\",\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const xPosition = padding + rowIndex * spacing;\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n }),\n ),\n ),\n ]);\n}\n\nfunction TaxonOccurrenceLabels({ taxonEntries, padding, spacing, scale }) {\n return h(\"div.taxon-labels\", [\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const top = ranges[0]?.[0] ?? 0;\n let topPx = scale(top) - 20;\n if (topPx < 200) topPx = 0;\n\n return h(TaxonLabel, {\n top: topPx,\n left: padding + rowIndex * spacing,\n taxonName,\n });\n }),\n ]);\n}\n\nfunction TaxonLabel({ top, left, taxonName }) {\n const ref = useRef();\n const textSize = useElementSize(ref);\n const labelWidth = textSize?.height ?? 200;\n return h(\n \"div.taxon-label\",\n {\n style: {\n top: `${top}px`,\n marginLeft: `${left}px`,\n \"--label-width\": `${labelWidth}px`,\n },\n },\n h(\"div.taxon-label-inner\", h(\"div.taxon-label-text\", { ref }, taxonName)),\n );\n}\n\ntype TaxonUnitMap = Map<string, Set<number>>;\n\ninterface OccurrenceMatrixData {\n occurrenceMap: Map<number, PBDBEntity[]>; // Map of unit IDs to occurrences (original data)\n taxonUnitMap: TaxonUnitMap; // Map of taxon names to sets of unit IDs\n taxonOccurrenceMap: Map<string, PBDBOccurrence[]>; // Map of taxon names to occurrences\n taxonRanges: Map<string, [number, number][]>; // Map of taxon names to [top, bottom] pixel ranges\n}\n\nfunction TaxonOccurrenceEntry({\n xPosition,\n ranges,\n scale,\n name,\n}: {\n xPosition: number;\n units: Set<number>;\n ranges: any;\n scale: any;\n name: string;\n}) {\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n}\n\nfunction createOccurrenceMatrix(\n units: UnitLong[],\n data: Map<number, PBDBOccurrence[]>,\n axisType: ColumnAxisType = ColumnAxisType.AGE,\n): OccurrenceMatrixData {\n const taxonUnitMap = new Map<string, Set<number>>();\n const taxonOccurrenceMap = new Map<string, PBDBOccurrence[]>();\n\n for (const [unit_id, occurrences] of data.entries()) {\n for (const occ of occurrences) {\n const taxonName = occ.best_name ?? occ.taxon_name;\n if (!taxonUnitMap.has(taxonName)) {\n taxonUnitMap.set(taxonName, new Set());\n taxonOccurrenceMap.set(taxonName, []);\n }\n taxonUnitMap.get(taxonName).add(unit_id);\n taxonOccurrenceMap.get(taxonName).push(occ);\n }\n }\n\n // sort the taxon occurrence map by number of occurrences\n const sortedTaxa = Array.from(taxonUnitMap.entries()).sort((a, b) => {\n // Sort alphabetically by taxon name\n return b[0].localeCompare(a[0]);\n });\n\n const taxonRanges = new Map<string, [number, number][]>();\n for (const [taxonName, unitSet] of taxonUnitMap.entries()) {\n taxonRanges.set(\n taxonName,\n accumulatePresenceDomains(units, unitSet, axisType),\n );\n }\n\n return {\n occurrenceMap: data,\n taxonUnitMap: new Map(sortedTaxa),\n taxonOccurrenceMap: taxonOccurrenceMap,\n taxonRanges,\n };\n}\n\nfunction accumulatePresenceDomains(\n unit: UnitLong[],\n presenceUnits: Set<number>,\n axisType: ColumnAxisType,\n): Array<[number, number]> {\n const domains: Array<[number, number]> = [];\n let currentDomain: [number, number] | null = null;\n\n for (const u of unit) {\n if (presenceUnits.has(u.unit_id)) {\n if (currentDomain == null) {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain = [u.t_pos, u.b_pos];\n } else {\n currentDomain = [u.t_age, u.b_age];\n }\n } else {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain[1] = u.b_pos;\n } else {\n currentDomain[1] = u.b_age;\n }\n }\n } else {\n if (currentDomain != null) {\n domains.push(currentDomain);\n currentDomain = null;\n }\n }\n }\n\n if (currentDomain != null) {\n domains.push(currentDomain);\n }\n\n return domains;\n}\n"],"names":["hyper"],"mappings":";;;;;;;;AAkBA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"taxon-ranges.js","sources":["../../../src/facets/fossils/taxon-ranges.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n PBDBEntity,\n PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport { Box, useElementSize } from \"@macrostrat/ui-components\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType, ColumnSVG } from \"@macrostrat/column-components\";\nimport {\n useMacrostratColumnData,\n useCompositeScale,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport { useRef } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBOccurrencesMatrix({ columnID }) {\n /* A column for a matrix of taxon occurrences displayed as a table beside the main column. This will\n eventually be extended with first/last occurrence markers and range bars.\n */\n const data = useFossilData(columnID, FossilDataType.Occurrences);\n const col = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null) return null;\n\n // convert the data to a map\n const occurrenceMap = new Map(group(data, (d) => d.unit_id)) as Map<\n number,\n PBDBOccurrence[]\n >;\n\n const matrix = createOccurrenceMatrix(col.units, occurrenceMap, col.axisType);\n\n const { taxonRanges } = matrix;\n\n const padding = 16;\n const spacing = 16;\n\n const taxonEntries = Array.from(taxonRanges.entries());\n //const taxon = taxonEntries.slice(0, 50); // limit to top 50 taxa\n\n const width = padding * 2 + spacing * taxonEntries.length;\n\n return h(Box, { className: \"taxon-ranges\", width, height: col.totalHeight }, [\n h(TaxonOccurrenceLabels, {\n taxonEntries,\n padding,\n spacing,\n scale,\n }),\n h(\n ColumnSVG,\n {\n width: padding * 2 + spacing * taxonEntries.length,\n },\n h(\n \"g.taxa-occurrences-matrix\",\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const xPosition = padding + rowIndex * spacing;\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n }),\n ),\n ),\n ]);\n}\n\nfunction TaxonOccurrenceLabels({ taxonEntries, padding, spacing, scale }) {\n return h(\"div.taxon-labels\", [\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const top = ranges[0]?.[0] ?? 0;\n let topPx = scale(top) - 20;\n if (topPx < 200) topPx = 0;\n\n return h(TaxonLabel, {\n top: topPx,\n left: padding + rowIndex * spacing,\n taxonName,\n });\n }),\n ]);\n}\n\nfunction TaxonLabel({ top, left, taxonName }) {\n const ref = useRef();\n const textSize = useElementSize(ref);\n const labelWidth = textSize?.height ?? 200;\n return h(\n \"div.taxon-label\",\n {\n style: {\n top: `${top}px`,\n marginLeft: `${left}px`,\n \"--label-width\": `${labelWidth}px`,\n },\n },\n h(\"div.taxon-label-inner\", h(\"div.taxon-label-text\", { ref }, taxonName)),\n );\n}\n\ntype TaxonUnitMap = Map<string, Set<number>>;\n\ninterface OccurrenceMatrixData {\n occurrenceMap: Map<number, PBDBEntity[]>; // Map of unit IDs to occurrences (original data)\n taxonUnitMap: TaxonUnitMap; // Map of taxon names to sets of unit IDs\n taxonOccurrenceMap: Map<string, PBDBOccurrence[]>; // Map of taxon names to occurrences\n taxonRanges: Map<string, [number, number][]>; // Map of taxon names to [top, bottom] pixel ranges\n}\n\nfunction TaxonOccurrenceEntry({\n xPosition,\n ranges,\n scale,\n name,\n}: {\n xPosition: number;\n units: Set<number>;\n ranges: any;\n scale: any;\n name: string;\n}) {\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n}\n\nfunction createOccurrenceMatrix(\n units: UnitLong[],\n data: Map<number, PBDBOccurrence[]>,\n axisType: ColumnAxisType = ColumnAxisType.AGE,\n): OccurrenceMatrixData {\n const taxonUnitMap = new Map<string, Set<number>>();\n const taxonOccurrenceMap = new Map<string, PBDBOccurrence[]>();\n\n for (const [unit_id, occurrences] of data.entries()) {\n for (const occ of occurrences) {\n const taxonName = occ.best_name ?? occ.taxon_name;\n if (!taxonUnitMap.has(taxonName)) {\n taxonUnitMap.set(taxonName, new Set());\n taxonOccurrenceMap.set(taxonName, []);\n }\n taxonUnitMap.get(taxonName).add(unit_id);\n taxonOccurrenceMap.get(taxonName).push(occ);\n }\n }\n\n // sort the taxon occurrence map by number of occurrences\n const sortedTaxa = Array.from(taxonUnitMap.entries()).sort((a, b) => {\n // Sort alphabetically by taxon name\n return b[0].localeCompare(a[0]);\n });\n\n const taxonRanges = new Map<string, [number, number][]>();\n for (const [taxonName, unitSet] of taxonUnitMap.entries()) {\n taxonRanges.set(\n taxonName,\n accumulatePresenceDomains(units, unitSet, axisType),\n );\n }\n\n return {\n occurrenceMap: data,\n taxonUnitMap: new Map(sortedTaxa),\n taxonOccurrenceMap: taxonOccurrenceMap,\n taxonRanges,\n };\n}\n\nfunction accumulatePresenceDomains(\n unit: UnitLong[],\n presenceUnits: Set<number>,\n axisType: ColumnAxisType,\n): Array<[number, number]> {\n const domains: Array<[number, number]> = [];\n let currentDomain: [number, number] | null = null;\n\n for (const u of unit) {\n if (presenceUnits.has(u.unit_id)) {\n if (currentDomain == null) {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain = [u.t_pos, u.b_pos];\n } else {\n currentDomain = [u.t_age, u.b_age];\n }\n } else {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain[1] = u.b_pos;\n } else {\n currentDomain[1] = u.b_age;\n }\n }\n } else {\n if (currentDomain != null) {\n domains.push(currentDomain);\n currentDomain = null;\n }\n }\n }\n\n if (currentDomain != null) {\n domains.push(currentDomain);\n }\n\n return domains;\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;;;AAkBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAEtB,SAAS,sBAAsB,EAAE,YAAY;AAIlD,QAAM,OAAO,cAAc,UAAU,eAAe,WAAW;AAC/D,QAAM,MAAM,wBAAA;AACZ,QAAM,QAAQ,kBAAA;AAEd,MAAI,QAAQ,KAAM,QAAO;AAGzB,QAAM,gBAAgB,IAAI,IAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;AAK3D,QAAM,SAAS,uBAAuB,IAAI,OAAO,eAAe,IAAI,QAAQ;AAE5E,QAAM,EAAE,gBAAgB;AAExB,QAAM,UAAU;AAChB,QAAM,UAAU;AAEhB,QAAM,eAAe,MAAM,KAAK,YAAY,SAAS;AAGrD,QAAM,QAAQ,UAAU,IAAI,UAAU,aAAa;AAEnD,SAAO,EAAE,KAAK,EAAE,WAAW,gBAAgB,OAAO,QAAQ,IAAI,eAAe;AAAA,IAC3E,EAAE,uBAAuB;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACD;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO,UAAU,IAAI,UAAU,aAAa;AAAA,MAAA;AAAA,MAE9C;AAAA,QACE;AAAA,QACA,aAAa,IAAI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;AAAA,QACvB,OAAO;AACL,wBAAc,CAAC,IAAI,EAAE;AAAA,QACvB;AAAA,MACF;AAAA,IACF,OAAO;AACL,UAAI,iBAAiB,MAAM;AACzB,gBAAQ,KAAK,aAAa;AAC1B,wBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAEA,MAAI,iBAAiB,MAAM;AACzB,YAAQ,KAAK,aAAa;AAAA,EAC5B;AAEA,SAAO;AACT;"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
2
5
|
const styles = {
|
|
3
6
|
"taxa-occurrences-matrix": "_taxa-occurrences-matrix_14h8h_1",
|
|
4
7
|
"taxon-name": "_taxon-name_14h8h_8",
|
|
@@ -8,5 +11,7 @@ const styles = {
|
|
|
8
11
|
"taxon-label-inner": "_taxon-label-inner_14h8h_35",
|
|
9
12
|
"taxon-label-text": "_taxon-label-text_14h8h_42"
|
|
10
13
|
};
|
|
11
|
-
|
|
14
|
+
let h = h__default.default.styled(styles);
|
|
15
|
+
Object.assign(h, styles);
|
|
16
|
+
module.exports = h;
|
|
12
17
|
//# sourceMappingURL=taxon-ranges.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxon-ranges.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taxon-ranges.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const styles = {
|
|
2
3
|
"taxa-occurrences-matrix": "_taxa-occurrences-matrix_14h8h_1",
|
|
3
4
|
"taxon-name": "_taxon-name_14h8h_8",
|
|
@@ -7,7 +8,9 @@ const styles = {
|
|
|
7
8
|
"taxon-label-inner": "_taxon-label-inner_14h8h_35",
|
|
8
9
|
"taxon-label-text": "_taxon-label-text_14h8h_42"
|
|
9
10
|
};
|
|
11
|
+
let h = h$1.styled(styles);
|
|
12
|
+
Object.assign(h, styles);
|
|
10
13
|
export {
|
|
11
|
-
|
|
14
|
+
h as default
|
|
12
15
|
};
|
|
13
16
|
//# sourceMappingURL=taxon-ranges.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxon-ranges.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taxon-ranges.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import h$1 from "@macrostrat/hyper";
|
|
2
|
-
import
|
|
2
|
+
import h$2 from "./base.module.sass.js";
|
|
3
3
|
import { ColumnNotes } from "../../notes.js";
|
|
4
4
|
import { ColumnAxisType } from "@macrostrat/column-components";
|
|
5
5
|
import { getPositionWithinUnit, getUnitHeightRange } from "../../prepare-units/utils.js";
|
|
6
|
-
const h = h$1.styled(
|
|
6
|
+
const h = h$1.styled(h$2);
|
|
7
7
|
function standardizeMeasurementHeight(pos, units, axisType) {
|
|
8
8
|
if ("height" in pos) {
|
|
9
9
|
return pos;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sources":["../../../src/facets/measurements/base.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./base.module.sass\";\nimport {\n type CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { ColumnNotes } from \"../../notes\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nconst h = hyper.styled(styles);\n\ntype GetHeightRangeFn<T> = (\n data: T,\n unit: UnitLong | null,\n axisType: ColumnAxisType,\n) => MeasurementHeightData;\n\nexport interface BaseMeasurementsColumnProps<T> {\n data: T[];\n noteComponent?: any;\n width?: number;\n paddingLeft?: number;\n className?: string;\n // TODO: these props are confusing\n getUnitID?: (d: T) => number | string;\n isMatchingUnit?: (d: T, unit: UnitLong) => boolean;\n getHeightRange?: GetHeightRangeFn<T>;\n deltaConnectorAttachment?: number;\n focusedNoteComponent?: any;\n}\n\nexport interface ColumnMeasurementData<T = any> extends MeasurementHeightData {\n data: T;\n id: string | number;\n}\n\ntype MeasurementPositionInformation =\n | MeasurementHeightData\n | {\n unit_id: number;\n unit_rel_pos?: number;\n };\n\nexport function standardizeMeasurementHeight(\n pos: MeasurementPositionInformation,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n /** Get a standardized height representation from position information for\n * a measurement\n */\n if (\"height\" in pos) {\n return pos;\n }\n const unit = units.find((u) => u.unit_id === pos.unit_id);\n if (unit == null) {\n return null;\n }\n if (pos.unit_rel_pos != null) {\n const res = getPositionWithinUnit(pos.unit_rel_pos, unit, axisType);\n if (res == null) return null;\n return { height: res };\n } else {\n const [height, top_height] = getUnitHeightRange(unit, axisType);\n return { height, top_height };\n }\n}\n\nexport function mergeHeightRanges(\n data: MeasurementHeightData[],\n axisType: ColumnAxisType,\n): MeasurementHeightData {\n /** Merge multiple height ranges into a single range */\n const heights = [];\n\n for (const d of data) {\n heights.push(d.height);\n if (d.top_height != null) {\n heights.push(d.top_height);\n }\n }\n\n let height: number;\n let top_height: number;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n height = Math.max(...heights);\n top_height = Math.min(...heights);\n } else {\n height = Math.min(...heights);\n top_height = Math.max(...heights);\n }\n\n if (top_height === height) {\n return { height };\n }\n return { height, top_height };\n}\n\nexport type MeasurementHeightData = {\n height: number;\n top_height?: number | null;\n};\n\nexport function BaseMeasurementsColumn({\n data,\n noteComponent,\n width = 500,\n paddingLeft = 40,\n className,\n deltaConnectorAttachment,\n focusedNoteComponent,\n}: BaseMeasurementsColumnProps<any>) {\n if (data == null) return null;\n\n return h(\n \"div.measurements-column\",\n { className },\n h(ColumnNotes, {\n width,\n paddingLeft,\n notes: data,\n noteComponent,\n deltaConnectorAttachment,\n focusedNoteComponent,\n }),\n );\n}\n\ninterface TruncatedListProps {\n data: any[];\n className?: string;\n maxItems?: number;\n itemRenderer?: (props: { data: any }) => any;\n}\n\nexport function TruncatedList({\n data,\n className,\n maxItems = 5,\n itemRenderer = (p) => h(\"span\", p.data),\n}: TruncatedListProps) {\n let tooMany = null;\n let d1 = data;\n if (data.length > maxItems) {\n const n = data.length - maxItems;\n d1 = data.slice(0, maxItems);\n tooMany = h(\"li.too-many\", `and ${n} more`);\n }\n\n return h(\"ul.truncated-list\", { className }, [\n d1.map((d, i) => {\n return h(\"li.element\", { key: i }, h(itemRenderer, { data: d }));\n }),\n tooMany,\n ]);\n}\n\nexport function groupNotesByPixelDistance<T = any>(\n data: ColumnMeasurementData<T[]>[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n groupDistance: number,\n) {\n /** Group notes that are within a certain pixel distance of each other\n * in display space\n */\n if (data.length === 0 || groupDistance <= 0) return data;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n data.sort((a, b) => b.height - a.height);\n } else {\n // Sort data by height (ascending up the column)\n data.sort((a, b) => a.height - b.height);\n }\n\n const groupedData: ColumnMeasurementData<T[]>[] = [];\n let currentGroup: ColumnMeasurementData<T[]> | null = null;\n let currentGroupPosition: number = Infinity;\n\n for (const d of data) {\n // Check distance from current max position\n // Pixels go up as we go down in the section\n\n // The _top_ of the next group must be within groupDistance of the\n // _bottom_ of the current group. This makes sure that we don't collapse\n // groups that are separated by a large distance\n const distance = currentGroupPosition - scale(d.top_height ?? d.height);\n\n if (distance <= groupDistance) {\n if (currentGroup == null) {\n throw new Error(\"Current group is null when it shouldn't be\");\n }\n // Merge into current group\n currentGroup.data.push(...d.data);\n // Update height range\n const top_height = d.top_height ?? d.height;\n if (\n axisType === ColumnAxisType.AGE ||\n axisType === ColumnAxisType.DEPTH\n ) {\n // Inverted axis\n currentGroup.top_height = Math.min(currentGroup.top_height, top_height);\n } else {\n currentGroup.top_height = Math.max(currentGroup.top_height, top_height);\n }\n currentGroup.id = `${currentGroup.height}-${currentGroup.top_height}`;\n } else {\n // Start a new group\n currentGroup = { ...d, data: [...d.data] };\n currentGroupPosition =\n scale(currentGroup.height) ??\n scale(currentGroup.top_height) ??\n Infinity;\n groupedData.push(currentGroup);\n }\n }\n\n return groupedData;\n}\n"],"names":["hyper"],"mappings":";;;;;AAUA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"base.js","sources":["../../../src/facets/measurements/base.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./base.module.sass\";\nimport {\n type CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { ColumnNotes } from \"../../notes\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nconst h = hyper.styled(styles);\n\ntype GetHeightRangeFn<T> = (\n data: T,\n unit: UnitLong | null,\n axisType: ColumnAxisType,\n) => MeasurementHeightData;\n\nexport interface BaseMeasurementsColumnProps<T> {\n data: T[];\n noteComponent?: any;\n width?: number;\n paddingLeft?: number;\n className?: string;\n // TODO: these props are confusing\n getUnitID?: (d: T) => number | string;\n isMatchingUnit?: (d: T, unit: UnitLong) => boolean;\n getHeightRange?: GetHeightRangeFn<T>;\n deltaConnectorAttachment?: number;\n focusedNoteComponent?: any;\n}\n\nexport interface ColumnMeasurementData<T = any> extends MeasurementHeightData {\n data: T;\n id: string | number;\n}\n\ntype MeasurementPositionInformation =\n | MeasurementHeightData\n | {\n unit_id: number;\n unit_rel_pos?: number;\n };\n\nexport function standardizeMeasurementHeight(\n pos: MeasurementPositionInformation,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n /** Get a standardized height representation from position information for\n * a measurement\n */\n if (\"height\" in pos) {\n return pos;\n }\n const unit = units.find((u) => u.unit_id === pos.unit_id);\n if (unit == null) {\n return null;\n }\n if (pos.unit_rel_pos != null) {\n const res = getPositionWithinUnit(pos.unit_rel_pos, unit, axisType);\n if (res == null) return null;\n return { height: res };\n } else {\n const [height, top_height] = getUnitHeightRange(unit, axisType);\n return { height, top_height };\n }\n}\n\nexport function mergeHeightRanges(\n data: MeasurementHeightData[],\n axisType: ColumnAxisType,\n): MeasurementHeightData {\n /** Merge multiple height ranges into a single range */\n const heights = [];\n\n for (const d of data) {\n heights.push(d.height);\n if (d.top_height != null) {\n heights.push(d.top_height);\n }\n }\n\n let height: number;\n let top_height: number;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n height = Math.max(...heights);\n top_height = Math.min(...heights);\n } else {\n height = Math.min(...heights);\n top_height = Math.max(...heights);\n }\n\n if (top_height === height) {\n return { height };\n }\n return { height, top_height };\n}\n\nexport type MeasurementHeightData = {\n height: number;\n top_height?: number | null;\n};\n\nexport function BaseMeasurementsColumn({\n data,\n noteComponent,\n width = 500,\n paddingLeft = 40,\n className,\n deltaConnectorAttachment,\n focusedNoteComponent,\n}: BaseMeasurementsColumnProps<any>) {\n if (data == null) return null;\n\n return h(\n \"div.measurements-column\",\n { className },\n h(ColumnNotes, {\n width,\n paddingLeft,\n notes: data,\n noteComponent,\n deltaConnectorAttachment,\n focusedNoteComponent,\n }),\n );\n}\n\ninterface TruncatedListProps {\n data: any[];\n className?: string;\n maxItems?: number;\n itemRenderer?: (props: { data: any }) => any;\n}\n\nexport function TruncatedList({\n data,\n className,\n maxItems = 5,\n itemRenderer = (p) => h(\"span\", p.data),\n}: TruncatedListProps) {\n let tooMany = null;\n let d1 = data;\n if (data.length > maxItems) {\n const n = data.length - maxItems;\n d1 = data.slice(0, maxItems);\n tooMany = h(\"li.too-many\", `and ${n} more`);\n }\n\n return h(\"ul.truncated-list\", { className }, [\n d1.map((d, i) => {\n return h(\"li.element\", { key: i }, h(itemRenderer, { data: d }));\n }),\n tooMany,\n ]);\n}\n\nexport function groupNotesByPixelDistance<T = any>(\n data: ColumnMeasurementData<T[]>[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n groupDistance: number,\n) {\n /** Group notes that are within a certain pixel distance of each other\n * in display space\n */\n if (data.length === 0 || groupDistance <= 0) return data;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n data.sort((a, b) => b.height - a.height);\n } else {\n // Sort data by height (ascending up the column)\n data.sort((a, b) => a.height - b.height);\n }\n\n const groupedData: ColumnMeasurementData<T[]>[] = [];\n let currentGroup: ColumnMeasurementData<T[]> | null = null;\n let currentGroupPosition: number = Infinity;\n\n for (const d of data) {\n // Check distance from current max position\n // Pixels go up as we go down in the section\n\n // The _top_ of the next group must be within groupDistance of the\n // _bottom_ of the current group. This makes sure that we don't collapse\n // groups that are separated by a large distance\n const distance = currentGroupPosition - scale(d.top_height ?? d.height);\n\n if (distance <= groupDistance) {\n if (currentGroup == null) {\n throw new Error(\"Current group is null when it shouldn't be\");\n }\n // Merge into current group\n currentGroup.data.push(...d.data);\n // Update height range\n const top_height = d.top_height ?? d.height;\n if (\n axisType === ColumnAxisType.AGE ||\n axisType === ColumnAxisType.DEPTH\n ) {\n // Inverted axis\n currentGroup.top_height = Math.min(currentGroup.top_height, top_height);\n } else {\n currentGroup.top_height = Math.max(currentGroup.top_height, top_height);\n }\n currentGroup.id = `${currentGroup.height}-${currentGroup.top_height}`;\n } else {\n // Start a new group\n currentGroup = { ...d, data: [...d.data] };\n currentGroupPosition =\n scale(currentGroup.height) ??\n scale(currentGroup.top_height) ??\n Infinity;\n groupedData.push(currentGroup);\n }\n }\n\n return groupedData;\n}\n"],"names":["hyper","styles"],"mappings":";;;;;AAUA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAkCtB,SAAS,6BACd,KACA,OACA,UAC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ACE,aAAa,eAAe,OAC5B,aAAa,eAAe,OAC5B;AAEA,qBAAa,aAAa,KAAK,IAAI,aAAa,YAAY,UAAU;AAAA,MACxE,OAAO;AACL,qBAAa,aAAa,KAAK,IAAI,aAAa,YAAY,UAAU;AAAA,MACxE;AACA,mBAAa,KAAK,GAAG,aAAa,MAAM,IAAI,aAAa,UAAU;AAAA,IACrE,OAAO;AAEL,qBAAe,EAAE,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE,IAAI,EAAA;AACvC,6BACE,MAAM,aAAa,MAAM,KACzB,MAAM,aAAa,UAAU,KAC7B;AACF,kBAAY,KAAK,YAAY;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO;AACT;"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
2
5
|
const styles = {
|
|
3
6
|
"truncated-list": "_truncated-list_120po_1",
|
|
4
7
|
"too-many": "_too-many_120po_16"
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
let h = h__default.default.styled(styles);
|
|
10
|
+
Object.assign(h, styles);
|
|
11
|
+
module.exports = h;
|
|
7
12
|
//# sourceMappingURL=base.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const styles = {
|
|
2
3
|
"truncated-list": "_truncated-list_120po_1",
|
|
3
4
|
"too-many": "_too-many_120po_16"
|
|
4
5
|
};
|
|
6
|
+
let h = h$1.styled(styles);
|
|
7
|
+
Object.assign(h, styles);
|
|
5
8
|
export {
|
|
6
|
-
|
|
9
|
+
h as default
|
|
7
10
|
};
|
|
8
11
|
//# sourceMappingURL=base.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const index = require("./units/index.cjs");
|
|
4
4
|
const ageAxis = require("./age-axis.cjs");
|
|
5
|
-
const index$
|
|
5
|
+
const index$6 = require("./prepare-units/index.cjs");
|
|
6
6
|
const column = require("./column.cjs");
|
|
7
7
|
const ageModelOverlay = require("./age-model-overlay.cjs");
|
|
8
8
|
const notes = require("./notes.cjs");
|
|
@@ -21,18 +21,17 @@ const provider = require("./facets/fossils/provider.cjs");
|
|
|
21
21
|
const types = require("./prepare-units/types.cjs");
|
|
22
22
|
const insetMap = require("./maps/_shared/inset-map.cjs");
|
|
23
23
|
const isotopesColumn = require("./facets/carbon-isotopes/isotopes-column.cjs");
|
|
24
|
-
const base$1 = require("./data-provider/base.cjs");
|
|
25
24
|
const store = require("./data-provider/store.cjs");
|
|
25
|
+
const index$4 = require("./maps/units-overlay/index.cjs");
|
|
26
26
|
const dataProvider = require("./facets/carbon-isotopes/data-provider.cjs");
|
|
27
27
|
const utils = require("./prepare-units/utils.cjs");
|
|
28
|
-
const index$
|
|
28
|
+
const index$5 = require("./facets/fossils/index.cjs");
|
|
29
29
|
const taxonRanges = require("./facets/fossils/taxon-ranges.cjs");
|
|
30
30
|
const sgp = require("./facets/measurements/sgp.cjs");
|
|
31
31
|
const modalPanel = require("./unit-details/modal-panel.cjs");
|
|
32
32
|
const popover = require("./unit-details/popover.cjs");
|
|
33
33
|
const unitSelection = require("./data-provider/unit-selection.cjs");
|
|
34
34
|
const styles = require("./maps/_shared/styles.cjs");
|
|
35
|
-
const fetch = require("./data-provider/fetch.cjs");
|
|
36
35
|
const colors = require("./units/colors.cjs");
|
|
37
36
|
const hashString = require("./correlation-chart/hash-string.cjs");
|
|
38
37
|
const helpers = require("./prepare-units/helpers.cjs");
|
|
@@ -49,8 +48,8 @@ exports.ApproximateHeightAxis = ageAxis.ApproximateHeightAxis;
|
|
|
49
48
|
exports.CompositeAgeAxis = ageAxis.CompositeAgeAxis;
|
|
50
49
|
exports.CompositeAgeAxisCore = ageAxis.CompositeAgeAxisCore;
|
|
51
50
|
exports.VerticalAxisLabel = ageAxis.VerticalAxisLabel;
|
|
52
|
-
exports.prepareColumnUnits = index$
|
|
53
|
-
exports.usePreparedColumnUnits = index$
|
|
51
|
+
exports.prepareColumnUnits = index$6.prepareColumnUnits;
|
|
52
|
+
exports.usePreparedColumnUnits = index$6.usePreparedColumnUnits;
|
|
54
53
|
exports.Column = column.Column;
|
|
55
54
|
exports.ColumnBasicInfo = column.ColumnBasicInfo;
|
|
56
55
|
exports.ColumnContainer = column.ColumnContainer;
|
|
@@ -101,26 +100,20 @@ exports.HybridScaleType = types.HybridScaleType;
|
|
|
101
100
|
exports.InsetMap = insetMap.InsetMap;
|
|
102
101
|
exports.IsotopesColumn = isotopesColumn.IsotopesColumn;
|
|
103
102
|
exports.IsotopesDataset = isotopesColumn.IsotopesDataset;
|
|
104
|
-
exports.LithologiesProvider =
|
|
105
|
-
exports.MacrostratAPIProvider = base$1.MacrostratAPIProvider;
|
|
106
|
-
exports.MacrostratColumnProvider = base$1.MacrostratColumnProvider;
|
|
107
|
-
exports.MacrostratDataProvider = base$1.MacrostratDataProvider;
|
|
108
|
-
exports.useEnvironments = base$1.useEnvironments;
|
|
109
|
-
exports.useLithologies = base$1.useLithologies;
|
|
110
|
-
exports.useMacrostratBaseURL = base$1.useMacrostratBaseURL;
|
|
111
|
-
exports.useMacrostratColumnInfo = base$1.useMacrostratColumnInfo;
|
|
112
|
-
exports.useMacrostratColumns = base$1.useMacrostratColumns;
|
|
113
|
-
exports.useMacrostratData = base$1.useMacrostratData;
|
|
114
|
-
exports.useMacrostratDefs = base$1.useMacrostratDefs;
|
|
115
|
-
exports.useMacrostratFetch = base$1.useMacrostratFetch;
|
|
116
|
-
exports.useMacrostratStore = base$1.useMacrostratStore;
|
|
103
|
+
exports.LithologiesProvider = store.LithologiesProvider;
|
|
117
104
|
exports.MacrostratColumnDataProvider = store.MacrostratColumnDataProvider;
|
|
105
|
+
exports.MacrostratColumnProvider = store.MacrostratColumnProvider;
|
|
118
106
|
exports.MacrostratColumnStateProvider = store.MacrostratColumnStateProvider;
|
|
119
107
|
exports.UnitSelectionProvider = store.UnitSelectionProvider;
|
|
108
|
+
exports.columnUnitsAtom = store.columnUnitsAtom;
|
|
109
|
+
exports.columnUnitsMapAtom = store.columnUnitsMapAtom;
|
|
110
|
+
exports.scope = store.scope;
|
|
120
111
|
exports.useColumnUnitsMap = store.useColumnUnitsMap;
|
|
121
112
|
exports.useCompositeScale = store.useCompositeScale;
|
|
122
113
|
exports.useMacrostratColumnData = store.useMacrostratColumnData;
|
|
123
114
|
exports.useMacrostratUnits = store.useMacrostratUnits;
|
|
115
|
+
exports.MacrostratUnitsOverlay = index$4.MacrostratUnitsOverlay;
|
|
116
|
+
exports.buildUnitsStyle = index$4.buildUnitsStyle;
|
|
124
117
|
exports.MeasurementDataContext = dataProvider.MeasurementDataContext;
|
|
125
118
|
exports.MeasurementDataProvider = dataProvider.MeasurementDataProvider;
|
|
126
119
|
exports.useMeasurementData = dataProvider.useMeasurementData;
|
|
@@ -132,7 +125,7 @@ exports.ensureRealFloat = utils.ensureRealFloat;
|
|
|
132
125
|
exports.getPositionWithinUnit = utils.getPositionWithinUnit;
|
|
133
126
|
exports.getUnitHeightRange = utils.getUnitHeightRange;
|
|
134
127
|
exports.unitsOverlap = utils.unitsOverlap;
|
|
135
|
-
exports.PBDBFossilsColumn = index$
|
|
128
|
+
exports.PBDBFossilsColumn = index$5.PBDBFossilsColumn;
|
|
136
129
|
exports.PBDBOccurrencesMatrix = taxonRanges.PBDBOccurrencesMatrix;
|
|
137
130
|
exports.SGPMeasurementsColumn = sgp.SGPMeasurementsColumn;
|
|
138
131
|
exports.UnitDetailsPanelWithNavigation = modalPanel.UnitDetailsPanelWithNavigation;
|
|
@@ -148,15 +141,8 @@ exports.useSelectedUnit = unitSelection.useSelectedUnit;
|
|
|
148
141
|
exports.useUnitSelectionDispatch = unitSelection.useUnitSelectionDispatch;
|
|
149
142
|
exports.useUnitSelectionTarget = unitSelection.useUnitSelectionTarget;
|
|
150
143
|
exports.buildColumnsStyle = styles.buildColumnsStyle;
|
|
151
|
-
exports.
|
|
152
|
-
exports.
|
|
153
|
-
exports.fetchEnvironments = fetch.fetchEnvironments;
|
|
154
|
-
exports.fetchIntervals = fetch.fetchIntervals;
|
|
155
|
-
exports.fetchLithologies = fetch.fetchLithologies;
|
|
156
|
-
exports.fetchRefs = fetch.fetchRefs;
|
|
157
|
-
exports.fetchStratNames = fetch.fetchStratNames;
|
|
158
|
-
exports.fetchUnits = fetch.fetchUnits;
|
|
159
|
-
exports.useColumnFeatures = fetch.useColumnFeatures;
|
|
144
|
+
exports.flattenLithologies = colors.flattenLithologies;
|
|
145
|
+
exports.getMixedColorForData = colors.getMixedColorForData;
|
|
160
146
|
exports.getMixedUnitColor = colors.getMixedUnitColor;
|
|
161
147
|
exports.parseLineFromString = hashString.parseLineFromString;
|
|
162
148
|
exports.stringifyLine = hashString.stringifyLine;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -19,8 +19,8 @@ import { FossilDataType, useFossilData } from "./facets/fossils/provider.js";
|
|
|
19
19
|
import { HeightMethod, HybridScaleType } from "./prepare-units/types.js";
|
|
20
20
|
import { InsetMap } from "./maps/_shared/inset-map.js";
|
|
21
21
|
import { IsotopesColumn, IsotopesDataset } from "./facets/carbon-isotopes/isotopes-column.js";
|
|
22
|
-
import { LithologiesProvider,
|
|
23
|
-
import {
|
|
22
|
+
import { LithologiesProvider, MacrostratColumnDataProvider, MacrostratColumnProvider, MacrostratColumnStateProvider, UnitSelectionProvider, columnUnitsAtom, columnUnitsMapAtom, scope, useColumnUnitsMap, useCompositeScale, useMacrostratColumnData, useMacrostratUnits } from "./data-provider/store.js";
|
|
23
|
+
import { MacrostratUnitsOverlay, buildUnitsStyle } from "./maps/units-overlay/index.js";
|
|
24
24
|
import { MeasurementDataContext, MeasurementDataProvider, useMeasurementData } from "./facets/carbon-isotopes/data-provider.js";
|
|
25
25
|
import { MergeSectionsMode, agesOverlap, createUnitSorter, ensureArray, ensureRealFloat, getPositionWithinUnit, getUnitHeightRange, unitsOverlap } from "./prepare-units/utils.js";
|
|
26
26
|
import { PBDBFossilsColumn } from "./facets/fossils/index.js";
|
|
@@ -30,8 +30,7 @@ import { UnitDetailsPanelWithNavigation } from "./unit-details/modal-panel.js";
|
|
|
30
30
|
import { UnitDetailsPopover, UnitSelectionPopover } from "./unit-details/popover.js";
|
|
31
31
|
import { UnitKeyboardNavigation, UnitSelectionCallbackManager, allowUnitSelectionAtom, selectedUnitIDAtom, useAtomOverlayPosition, useColumnRef, useSelectedUnit, useUnitSelectionDispatch, useUnitSelectionTarget } from "./data-provider/unit-selection.js";
|
|
32
32
|
import { buildColumnsStyle } from "./maps/_shared/styles.js";
|
|
33
|
-
import {
|
|
34
|
-
import { getMixedUnitColor } from "./units/colors.js";
|
|
33
|
+
import { flattenLithologies, getMixedColorForData, getMixedUnitColor } from "./units/colors.js";
|
|
35
34
|
import { parseLineFromString, stringifyLine } from "./correlation-chart/hash-string.js";
|
|
36
35
|
import { preprocessUnits } from "./prepare-units/helpers.js";
|
|
37
36
|
export {
|
|
@@ -79,11 +78,10 @@ export {
|
|
|
79
78
|
LabelTrackerProvider,
|
|
80
79
|
LegendPanelHeader,
|
|
81
80
|
LithologiesProvider,
|
|
82
|
-
MacrostratAPIProvider,
|
|
83
81
|
MacrostratColumnDataProvider,
|
|
84
82
|
MacrostratColumnProvider,
|
|
85
83
|
MacrostratColumnStateProvider,
|
|
86
|
-
|
|
84
|
+
MacrostratUnitsOverlay,
|
|
87
85
|
MeasurementDataContext,
|
|
88
86
|
MeasurementDataProvider,
|
|
89
87
|
MeasurementsLayer,
|
|
@@ -111,17 +109,14 @@ export {
|
|
|
111
109
|
agesOverlap,
|
|
112
110
|
allowUnitSelectionAtom,
|
|
113
111
|
buildColumnsStyle,
|
|
112
|
+
buildUnitsStyle,
|
|
113
|
+
columnUnitsAtom,
|
|
114
|
+
columnUnitsMapAtom,
|
|
114
115
|
createUnitSorter,
|
|
115
116
|
ensureArray,
|
|
116
117
|
ensureRealFloat,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
fetchEnvironments,
|
|
120
|
-
fetchIntervals,
|
|
121
|
-
fetchLithologies,
|
|
122
|
-
fetchRefs,
|
|
123
|
-
fetchStratNames,
|
|
124
|
-
fetchUnits,
|
|
118
|
+
flattenLithologies,
|
|
119
|
+
getMixedColorForData,
|
|
125
120
|
getMixedUnitColor,
|
|
126
121
|
getPositionWithinUnit,
|
|
127
122
|
getUnitHeightRange,
|
|
@@ -130,28 +125,19 @@ export {
|
|
|
130
125
|
parseLineFromString,
|
|
131
126
|
prepareColumnUnits,
|
|
132
127
|
preprocessUnits,
|
|
128
|
+
scope,
|
|
133
129
|
selectedUnitIDAtom,
|
|
134
130
|
standardizeMeasurementHeight,
|
|
135
131
|
stringifyLine,
|
|
136
132
|
unitsOverlap,
|
|
137
133
|
useAtomOverlayPosition,
|
|
138
|
-
useColumnFeatures,
|
|
139
134
|
useColumnNav,
|
|
140
135
|
useColumnRef,
|
|
141
136
|
useColumnUnitsMap,
|
|
142
137
|
useCompositeScale,
|
|
143
138
|
useCorrelationMapStore,
|
|
144
|
-
useEnvironments,
|
|
145
139
|
useFossilData,
|
|
146
|
-
useLithologies,
|
|
147
|
-
useMacrostratBaseURL,
|
|
148
140
|
useMacrostratColumnData,
|
|
149
|
-
useMacrostratColumnInfo,
|
|
150
|
-
useMacrostratColumns,
|
|
151
|
-
useMacrostratData,
|
|
152
|
-
useMacrostratDefs,
|
|
153
|
-
useMacrostratFetch,
|
|
154
|
-
useMacrostratStore,
|
|
155
141
|
useMacrostratUnits,
|
|
156
142
|
useMeasurementData,
|
|
157
143
|
usePreparedColumnUnits,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5,7 +5,12 @@ const mapboxUtils = require("@macrostrat/mapbox-utils");
|
|
|
5
5
|
function buildColumnsStyle(color) {
|
|
6
6
|
let columnColor = color ?? colorUtils.getCSSVariable("--text-subtle-color", "black");
|
|
7
7
|
const columnSelectedColor = colorUtils.getCSSVariable("--selection-color", "purple");
|
|
8
|
-
columnColor = [
|
|
8
|
+
columnColor = [
|
|
9
|
+
"coalesce",
|
|
10
|
+
["feature-state", "color"],
|
|
11
|
+
["get", "color"],
|
|
12
|
+
columnColor
|
|
13
|
+
];
|
|
9
14
|
return {
|
|
10
15
|
sources: {
|
|
11
16
|
columns: mapboxUtils.buildGeoJSONSource()
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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\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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;;"}
|
|
@@ -3,7 +3,12 @@ import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
|
|
|
3
3
|
function buildColumnsStyle(color) {
|
|
4
4
|
let columnColor = color ?? getCSSVariable("--text-subtle-color", "black");
|
|
5
5
|
const columnSelectedColor = getCSSVariable("--selection-color", "purple");
|
|
6
|
-
columnColor = [
|
|
6
|
+
columnColor = [
|
|
7
|
+
"coalesce",
|
|
8
|
+
["feature-state", "color"],
|
|
9
|
+
["get", "color"],
|
|
10
|
+
columnColor
|
|
11
|
+
];
|
|
7
12
|
return {
|
|
8
13
|
sources: {
|
|
9
14
|
columns: buildGeoJSONSource()
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;"}
|
|
@@ -8,7 +8,7 @@ const centroid = require("@turf/centroid");
|
|
|
8
8
|
const React = require("react");
|
|
9
9
|
const h = require("@macrostrat/hyper");
|
|
10
10
|
const zustandComputed = require("zustand-computed");
|
|
11
|
-
const
|
|
11
|
+
const dataProvider = require("@macrostrat/data-provider");
|
|
12
12
|
const buffer = require("@turf/buffer");
|
|
13
13
|
const booleanPointInPolygon = require("@turf/boolean-point-in-polygon");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
@@ -54,7 +54,7 @@ function ColumnCorrelationProvider({
|
|
|
54
54
|
})
|
|
55
55
|
);
|
|
56
56
|
});
|
|
57
|
-
const _columns =
|
|
57
|
+
const _columns = dataProvider.useMacrostratColumns(projectID, inProcess);
|
|
58
58
|
React.useEffect(() => {
|
|
59
59
|
if (_columns != null) {
|
|
60
60
|
store.setState({ columns: _columns });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.cjs","sources":["../../../src/maps/column-correlation/state.ts"],"sourcesContent":["import { LineString, Point } from \"geojson\";\nimport { create, StoreApi, useStore } from \"zustand\";\nimport type { ColumnGeoJSONRecord } from \"@macrostrat/api-types\";\n// Turf intersection\nimport { lineIntersect } from \"@turf/line-intersect\";\nimport distance from \"@turf/distance\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\nimport { centroid } from \"@turf/centroid\";\nimport {\n createContext,\n useState,\n useContext,\n ReactNode,\n useEffect,\n} from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { createComputed } from \"zustand-computed\";\nimport { useMacrostratColumns } from \"
|
|
1
|
+
{"version":3,"file":"state.cjs","sources":["../../../src/maps/column-correlation/state.ts"],"sourcesContent":["import { LineString, Point } from \"geojson\";\nimport { create, StoreApi, useStore } from \"zustand\";\nimport type { ColumnGeoJSONRecord } from \"@macrostrat/api-types\";\n// Turf intersection\nimport { lineIntersect } from \"@turf/line-intersect\";\nimport distance from \"@turf/distance\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\nimport { centroid } from \"@turf/centroid\";\nimport {\n createContext,\n useState,\n useContext,\n ReactNode,\n useEffect,\n} from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { createComputed } from \"zustand-computed\";\nimport { useMacrostratColumns } from \"@macrostrat/data-provider\";\nimport { buffer } from \"@turf/buffer\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\n\nexport interface CorrelationMapInput {\n columns: ColumnGeoJSONRecord[];\n focusedLine: LineString | null;\n}\n\nexport interface CorrelationMapStore extends CorrelationMapInput {\n onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;\n projectID?: number;\n}\n\nexport interface CorrelationProviderProps extends CorrelationMapInput {\n projectID?: number;\n inProcess?: boolean;\n columns: ColumnGeoJSONRecord[] | null;\n children: ReactNode;\n onSelectColumns?: (\n columns: FocusedColumnGeoJSONRecord[],\n line: LineString | null,\n ) => void;\n}\n\nconst CorrelationStoreContext =\n createContext<StoreApi<CorrelationMapStore> | null>(null);\n\ntype ComputedStore = {\n focusedColumns: FocusedColumnGeoJSONRecord[];\n};\n\n/** A computed store that will automatically update when the state changes */\nconst computed = createComputed((state: CorrelationMapStore): ComputedStore => {\n return {\n // We compute the focused columns based on columns and focusedLine\n focusedColumns: buildCorrelationColumns(state.columns, state.focusedLine),\n };\n}) as any;\n\nexport function ColumnCorrelationProvider({\n children,\n columns,\n projectID,\n inProcess,\n focusedLine,\n onSelectColumns,\n}: CorrelationProviderProps) {\n const [store] = useState(() => {\n return create<CorrelationMapStore & ComputedStore>(\n computed((set, get): CorrelationMapStore => {\n return {\n focusedLine,\n projectID,\n columns: null,\n onClickMap(event: mapboxgl.MapMouseEvent, point: Point) {\n const state = get();\n // Check if shift key is pressed\n const shiftKeyPressed = event.originalEvent.shiftKey;\n let existingCoords = state.focusedLine?.coordinates ?? [];\n\n if (existingCoords.length >= 2 && !shiftKeyPressed) {\n // Reset the line to zero length\n existingCoords = [];\n }\n set({\n focusedLine: {\n type: \"LineString\",\n coordinates: [...existingCoords, point.coordinates],\n },\n });\n },\n };\n }),\n );\n });\n\n // Set up the store\n /** TODO: move the fetching of all columns to within the map */\n const _columns = useMacrostratColumns(projectID, inProcess);\n useEffect(() => {\n if (_columns != null) {\n store.setState({ columns: _columns });\n }\n }, [_columns]);\n\n // Kind of an awkward way to do this but we need to allow the selector to run\n const focusedColumns = useStore(store, (state) => state.focusedColumns);\n const _focusedLine = useStore(store, (state) => state.focusedLine);\n\n useEffect(() => {\n onSelectColumns?.(focusedColumns, _focusedLine);\n }, [focusedColumns, _focusedLine]);\n\n return h(CorrelationStoreContext.Provider, { value: store }, children);\n}\n\nexport function useCorrelationMapStore(\n selector: (state: CorrelationMapStore & ComputedStore) => any,\n) {\n const storeApi = useContext(CorrelationStoreContext);\n if (storeApi == null) {\n throw new Error(\"Missing CorrelationMapProvider\");\n }\n return useStore(storeApi, selector);\n}\n\nfunction buildCorrelationColumns(\n columns: ColumnGeoJSONRecord[],\n line: LineString,\n): FocusedColumnGeoJSONRecord[] {\n if (columns == null || line == null || line.coordinates.length < 2) {\n return [];\n }\n return orderColumnsByDistance(\n computeIntersectingColumns(columns, line),\n line,\n );\n}\n\nfunction computeIntersectingColumns(\n columns: ColumnGeoJSONRecord[],\n line: LineString,\n): ColumnGeoJSONRecord[] {\n if (columns == null || line == null) {\n return [];\n }\n\n /** eODP-focused process. Find buffers around line and then find columns intersecting that buffer */\n const bufferedLine = buffer(line, 1, { units: \"degrees\" });\n\n const nearbyPoints = columns.filter((col) => {\n if (col.geometry?.type != \"Point\") {\n return false;\n }\n return booleanPointInPolygon(col.geometry, bufferedLine);\n });\n\n const intersectingPolygons = columns.filter((col) => {\n const poly = col.geometry;\n\n // Some in-process datasets seem to have null geometries\n if (poly == null) return false;\n if (poly.type != \"Polygon\" && poly.type != \"MultiPolygon\") return false;\n\n const intersection = lineIntersect(line, poly);\n return intersection.features.length > 0;\n });\n\n return [...intersectingPolygons, ...nearbyPoints];\n}\n\ninterface FocusedColumnGeoJSONRecord extends ColumnGeoJSONRecord {\n properties: {\n centroid: Point;\n nearestPointOnLine: Point;\n distanceAlongLine: number;\n } & ColumnGeoJSONRecord[\"properties\"];\n}\n\nfunction orderColumnsByDistance(\n columns: ColumnGeoJSONRecord[],\n line: LineString,\n): FocusedColumnGeoJSONRecord[] {\n const centroids = columns.map((col) => centroid(col.geometry));\n const projectedPoints = centroids.map((point) =>\n nearestPointOnLine(line, point),\n );\n const distances = projectedPoints.map((point) =>\n distance(point.geometry.coordinates, line.coordinates[0]),\n );\n\n let newColumns = columns.map((col, i) => {\n return {\n ...col,\n properties: {\n ...col.properties,\n centroid: centroids[i],\n nearestPointOnLine: projectedPoints[i],\n distanceAlongLine: distances[i],\n },\n };\n });\n\n return sorted(newColumns, (d) => d.properties.distanceAlongLine);\n}\n\nfunction sorted(data, accessor: (d) => number) {\n return data.sort((a, b) => accessor(a) - accessor(b));\n}\n"],"names":["createContext","createComputed","useState","create","useMacrostratColumns","useEffect","useStore","h","useContext","buffer","booleanPointInPolygon","lineIntersect","centroid","nearestPointOnLine","distance"],"mappings":";;;;;;;;;;;;;;;;AA0CA,MAAM,0BACJA,MAAAA,cAAoD,IAAI;AAO1D,MAAM,WAAWC,gBAAAA,eAAe,CAAC,UAA8C;AAC7E,SAAO;AAAA;AAAA,IAEL,gBAAgB,wBAAwB,MAAM,SAAS,MAAM,WAAW;AAAA,EAAA;AAE5E,CAAC;AAEM,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,QAAM,CAAC,KAAK,IAAIC,MAAAA,SAAS,MAAM;AAC7B,WAAOC,QAAAA;AAAAA,MACL,SAAS,CAAC,KAAK,QAA6B;AAC1C,eAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,SAAS;AAAA,UACT,WAAW,OAA+B,OAAc;AACtD,kBAAM,QAAQ,IAAA;AAEd,kBAAM,kBAAkB,MAAM,cAAc;AAC5C,gBAAI,iBAAiB,MAAM,aAAa,eAAe,CAAA;AAEvD,gBAAI,eAAe,UAAU,KAAK,CAAC,iBAAiB;AAElD,+BAAiB,CAAA;AAAA,YACnB;AACA,gBAAI;AAAA,cACF,aAAa;AAAA,gBACX,MAAM;AAAA,gBACN,aAAa,CAAC,GAAG,gBAAgB,MAAM,WAAW;AAAA,cAAA;AAAA,YACpD,CACD;AAAA,UACH;AAAA,QAAA;AAAA,MAEJ,CAAC;AAAA,IAAA;AAAA,EAEL,CAAC;AAID,QAAM,WAAWC,aAAAA,qBAAqB,WAAW,SAAS;AAC1DC,QAAAA,UAAU,MAAM;AACd,QAAI,YAAY,MAAM;AACpB,YAAM,SAAS,EAAE,SAAS,SAAA,CAAU;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,QAA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a,SAAS,SAAS;AAAA,EACxC,CAAC;AAED,SAAO,CAAC,GAAG,sBAAsB,GAAG,YAAY;AAClD;AAUA,SAAS,uBACP,SACA,MAC8B;AAC9B,QAAM,YAAY,QAAQ,IAAI,CAAC,QAAQC,kBAAS,IAAI,QAAQ,CAAC;AAC7D,QAAM,kBAAkB,UAAU;AAAA,IAAI,CAAC,UACrCC,sCAAmB,MAAM,KAAK;AAAA,EAAA;AAEhC,QAAM,YAAY,gBAAgB;AAAA,IAAI,CAAC,UACrCC,kBAAAA,QAAS,MAAM,SAAS,aAAa,KAAK,YAAY,CAAC,CAAC;AAAA,EAAA;AAG1D,MAAI,aAAa,QAAQ,IAAI,CAAC,KAAK,MAAM;AACvC,WAAO;AAAA,MACL,GAAG;AAAA,MACH,YAAY;AAAA,QACV,GAAG,IAAI;AAAA,QACP,UAAU,UAAU,CAAC;AAAA,QACrB,oBAAoB,gBAAgB,CAAC;AAAA,QACrC,mBAAmB,UAAU,CAAC;AAAA,MAAA;AAAA,IAChC;AAAA,EAEJ,CAAC;AAED,SAAO,OAAO,YAAY,CAAC,MAAM,EAAE,WAAW,iBAAiB;AACjE;AAEA,SAAS,OAAO,MAAM,UAAyB;AAC7C,SAAO,KAAK,KAAK,CAAC,GAAG,MAAM,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;AACtD;;;"}
|
|
@@ -8,6 +8,7 @@ export interface CorrelationMapInput {
|
|
|
8
8
|
}
|
|
9
9
|
export interface CorrelationMapStore extends CorrelationMapInput {
|
|
10
10
|
onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;
|
|
11
|
+
projectID?: number;
|
|
11
12
|
}
|
|
12
13
|
export interface CorrelationProviderProps extends CorrelationMapInput {
|
|
13
14
|
projectID?: number;
|
|
@@ -6,7 +6,7 @@ import { centroid } from "@turf/centroid";
|
|
|
6
6
|
import { useState, useEffect, useContext, createContext } from "react";
|
|
7
7
|
import h from "@macrostrat/hyper";
|
|
8
8
|
import { createComputed } from "zustand-computed";
|
|
9
|
-
import { useMacrostratColumns } from "
|
|
9
|
+
import { useMacrostratColumns } from "@macrostrat/data-provider";
|
|
10
10
|
import { buffer } from "@turf/buffer";
|
|
11
11
|
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
|
12
12
|
const CorrelationStoreContext = createContext(null);
|