@macrostrat/column-views 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/index.cjs +15 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -34
- package/dist/index.js.map +1 -1
- package/dist/units/boxes.cjs +3 -3
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +3 -3
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/index.cjs +7 -11
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.d.ts +0 -1
- package/dist/units/index.js +4 -9
- package/dist/units/index.js.map +1 -1
- package/package.json +6 -27
- package/src/index.ts +3 -1
- package/src/units/boxes.ts +7 -4
- package/src/units/index.ts +9 -26
- package/dist/maps/column-correlation/core.cjs +0 -288
- package/dist/maps/column-correlation/core.cjs.map +0 -1
- package/dist/maps/column-correlation/core.d.ts +0 -9
- package/dist/maps/column-correlation/core.js +0 -286
- package/dist/maps/column-correlation/core.js.map +0 -1
- package/dist/maps/column-correlation/index.d.ts +0 -2
- package/dist/maps/column-correlation/state.cjs +0 -193
- package/dist/maps/column-correlation/state.cjs.map +0 -1
- package/dist/maps/column-correlation/state.d.ts +0 -62
- package/dist/maps/column-correlation/state.js +0 -190
- package/dist/maps/column-correlation/state.js.map +0 -1
- package/dist/maps/column-navigation/index.d.ts +0 -2
- package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
- package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
- package/dist/maps/column-navigation/mapbox/index.js +0 -213
- package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
- package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
- package/dist/maps/column-navigation/mapbox/state.js +0 -71
- package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
- package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
- package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
- package/dist/maps/column-navigation/svg/index.cjs +0 -94
- package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/index.d.ts +0 -9
- package/dist/maps/column-navigation/svg/index.js +0 -93
- package/dist/maps/column-navigation/svg/index.js.map +0 -1
- package/dist/maps/column-navigation/svg/layers.cjs +0 -177
- package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
- package/dist/maps/column-navigation/svg/layers.js +0 -174
- package/dist/maps/column-navigation/svg/layers.js.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
- package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
- package/dist/maps/index.d.ts +0 -4
- package/dist/maps/inset-map/index.cjs +0 -71
- package/dist/maps/inset-map/index.cjs.map +0 -1
- package/dist/maps/inset-map/index.d.ts +0 -16
- package/dist/maps/inset-map/index.js +0 -69
- package/dist/maps/inset-map/index.js.map +0 -1
- package/dist/maps/layers/columns.cjs +0 -165
- package/dist/maps/layers/columns.cjs.map +0 -1
- package/dist/maps/layers/columns.d.ts +0 -28
- package/dist/maps/layers/columns.js +0 -165
- package/dist/maps/layers/columns.js.map +0 -1
- package/dist/maps/layers/index.d.ts +0 -2
- package/dist/maps/layers/units.cjs +0 -207
- package/dist/maps/layers/units.cjs.map +0 -1
- package/dist/maps/layers/units.d.ts +0 -14
- package/dist/maps/layers/units.js +0 -204
- package/dist/maps/layers/units.js.map +0 -1
- package/dist/units/colors.cjs +0 -115
- package/dist/units/colors.cjs.map +0 -1
- package/dist/units/colors.d.ts +0 -20
- package/dist/units/colors.js +0 -113
- package/dist/units/colors.js.map +0 -1
- package/dist/units/resolvers.cjs +0 -125
- package/dist/units/resolvers.cjs.map +0 -1
- package/dist/units/resolvers.d.ts +0 -8
- package/dist/units/resolvers.js +0 -125
- package/dist/units/resolvers.js.map +0 -1
- package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
- package/src/maps/column-correlation/core.ts +0 -342
- package/src/maps/column-correlation/index.ts +0 -2
- package/src/maps/column-correlation/state.ts +0 -315
- package/src/maps/column-navigation/index.ts +0 -2
- package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
- package/src/maps/column-navigation/mapbox/index.ts +0 -276
- package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
- package/src/maps/column-navigation/mapbox/state.ts +0 -119
- package/src/maps/column-navigation/svg/animated.ts +0 -78
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
- package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
- package/src/maps/column-navigation/svg/index.ts +0 -96
- package/src/maps/column-navigation/svg/layers.ts +0 -233
- package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
- package/src/maps/index.ts +0 -4
- package/src/maps/inset-map/index.ts +0 -87
- package/src/maps/inset-map/inset-map.stories.ts +0 -20
- package/src/maps/layers/columns.ts +0 -216
- package/src/maps/layers/index.ts +0 -2
- package/src/maps/layers/units.ts +0 -286
- package/src/maps/unit-map.stories.ts +0 -79
- package/src/units/colors.ts +0 -183
- package/src/units/resolvers.ts +0 -141
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import h from "@macrostrat/hyper";
|
|
2
|
-
import { FeatureLayer, Feature, MapContext } from "@macrostrat/svg-map-components";
|
|
3
|
-
import { useKeyHandler, useAPIResult } from "@macrostrat/ui-components";
|
|
4
|
-
import chroma from "chroma-js";
|
|
5
|
-
import { useContext, useMemo } from "react";
|
|
6
|
-
import { useColumnFeatures } from "./data-fetcher.js";
|
|
7
|
-
import { buildTriangulation, buildKeyMapping } from "../utils/keyboard-navigation.js";
|
|
8
|
-
const defaultStyle = {
|
|
9
|
-
fill: "rgb(239, 180, 249)",
|
|
10
|
-
stroke: "magenta"
|
|
11
|
-
};
|
|
12
|
-
function MeasurementsLayer(props) {
|
|
13
|
-
const { style = defaultStyle, ...params } = props;
|
|
14
|
-
const res = useAPIResult("/measurements", {
|
|
15
|
-
...params,
|
|
16
|
-
format: "geojson",
|
|
17
|
-
response: "light"
|
|
18
|
-
});
|
|
19
|
-
if (res == null) return null;
|
|
20
|
-
return h(FeatureLayer, {
|
|
21
|
-
useCanvas: false,
|
|
22
|
-
style,
|
|
23
|
-
features: res.features?.filter((d) => d.properties.unit_id != null) ?? []
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function ColumnFeatures(props) {
|
|
27
|
-
const {
|
|
28
|
-
features,
|
|
29
|
-
onClick,
|
|
30
|
-
color = "rgba(150,150,150, 1)",
|
|
31
|
-
singleFeature = true
|
|
32
|
-
} = props;
|
|
33
|
-
const c = chroma(color);
|
|
34
|
-
return h(
|
|
35
|
-
FeatureLayer,
|
|
36
|
-
{
|
|
37
|
-
className: "columns",
|
|
38
|
-
useCanvas: onClick == null,
|
|
39
|
-
style: {
|
|
40
|
-
fill: c.alpha(0.2).css(),
|
|
41
|
-
stroke: c.alpha(0.4).css()
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
features?.map((f) => {
|
|
45
|
-
return h(Feature, {
|
|
46
|
-
id: f.id ?? f.properties.col_id,
|
|
47
|
-
onClick,
|
|
48
|
-
feature: f
|
|
49
|
-
});
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
function ColumnKeyboardNavigation(props) {
|
|
54
|
-
const {
|
|
55
|
-
features = [],
|
|
56
|
-
col_id = null,
|
|
57
|
-
onChange,
|
|
58
|
-
showLayers = false,
|
|
59
|
-
...projectArgs
|
|
60
|
-
} = props;
|
|
61
|
-
const { projection } = useContext(MapContext);
|
|
62
|
-
const { centroids, tri } = useMemo(
|
|
63
|
-
() => buildTriangulation(features),
|
|
64
|
-
[features]
|
|
65
|
-
);
|
|
66
|
-
const currentIndex = useMemo(() => {
|
|
67
|
-
return features.findIndex((d) => d.properties.col_id == col_id);
|
|
68
|
-
}, [features, col_id]);
|
|
69
|
-
const neighbors = tri.delaunay.neighbors[currentIndex];
|
|
70
|
-
const keyMapping = useMemo(() => {
|
|
71
|
-
return buildKeyMapping(neighbors, centroids, currentIndex, projection);
|
|
72
|
-
}, [neighbors, currentIndex]);
|
|
73
|
-
useKeyHandler(
|
|
74
|
-
(event) => {
|
|
75
|
-
const nextColumnIx = keyMapping[event.keyCode];
|
|
76
|
-
if (nextColumnIx == null) return;
|
|
77
|
-
onChange(features[nextColumnIx]);
|
|
78
|
-
},
|
|
79
|
-
[keyMapping]
|
|
80
|
-
);
|
|
81
|
-
if (neighbors == null) return null;
|
|
82
|
-
const neighborFeatures = neighbors.map((d) => features[d]);
|
|
83
|
-
return h.if(showLayers)([
|
|
84
|
-
h(FeatureLayer, {
|
|
85
|
-
features: tri.links().features,
|
|
86
|
-
useCanvas: false,
|
|
87
|
-
style: {
|
|
88
|
-
stroke: "purple",
|
|
89
|
-
fill: "transparent"
|
|
90
|
-
}
|
|
91
|
-
}),
|
|
92
|
-
h(FeatureLayer, {
|
|
93
|
-
features: neighborFeatures,
|
|
94
|
-
useCanvas: false,
|
|
95
|
-
style: {
|
|
96
|
-
stroke: "rgb(93, 101, 212)",
|
|
97
|
-
strokeWidth: 3,
|
|
98
|
-
fill: "rgba(93, 101, 212, 0.5)"
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
h(FeatureLayer, {
|
|
102
|
-
features: [
|
|
103
|
-
{
|
|
104
|
-
type: "Feature",
|
|
105
|
-
geometry: {
|
|
106
|
-
type: "MultiPoint",
|
|
107
|
-
coordinates: centroids
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
useCanvas: false,
|
|
112
|
-
style: {
|
|
113
|
-
r: 1,
|
|
114
|
-
fill: "purple"
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
]);
|
|
118
|
-
}
|
|
119
|
-
const Columns = (props) => {
|
|
120
|
-
const {
|
|
121
|
-
apiRoute = "/columns",
|
|
122
|
-
onChange,
|
|
123
|
-
col_id = null,
|
|
124
|
-
status_code,
|
|
125
|
-
project_id,
|
|
126
|
-
color,
|
|
127
|
-
filterColumns,
|
|
128
|
-
showDebugLayers = false,
|
|
129
|
-
format = "topojson"
|
|
130
|
-
} = props;
|
|
131
|
-
let features = useColumnFeatures({
|
|
132
|
-
status_code,
|
|
133
|
-
project_id,
|
|
134
|
-
format
|
|
135
|
-
});
|
|
136
|
-
if (features == null) return null;
|
|
137
|
-
if (filterColumns != null) {
|
|
138
|
-
features = features.filter(filterColumns);
|
|
139
|
-
}
|
|
140
|
-
return h([
|
|
141
|
-
h(ColumnKeyboardNavigation, {
|
|
142
|
-
features,
|
|
143
|
-
col_id,
|
|
144
|
-
onChange,
|
|
145
|
-
status_code,
|
|
146
|
-
project_id,
|
|
147
|
-
showLayers: showDebugLayers
|
|
148
|
-
}),
|
|
149
|
-
h(ColumnFeatures, { features, onClick: onChange, color })
|
|
150
|
-
]);
|
|
151
|
-
};
|
|
152
|
-
const ColumnCenters = (props) => {
|
|
153
|
-
return h(Columns, { apiRoute: "/defs/columns", ...props });
|
|
154
|
-
};
|
|
155
|
-
const CurrentColumn = (props) => {
|
|
156
|
-
const { feature } = props;
|
|
157
|
-
return h(FeatureLayer, {
|
|
158
|
-
features: [feature],
|
|
159
|
-
style: {
|
|
160
|
-
fill: "rgba(255,0,0,0.4)",
|
|
161
|
-
stroke: "rgba(255,0,0,0.6)",
|
|
162
|
-
strokeWidth: 2
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
export {
|
|
167
|
-
ColumnCenters,
|
|
168
|
-
ColumnFeatures,
|
|
169
|
-
ColumnKeyboardNavigation,
|
|
170
|
-
Columns,
|
|
171
|
-
CurrentColumn,
|
|
172
|
-
MeasurementsLayer
|
|
173
|
-
};
|
|
174
|
-
//# sourceMappingURL=layers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layers.js","sources":["../../../../src/maps/column-navigation/svg/layers.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n Feature,\n FeatureLayer,\n MapContext,\n} from \"@macrostrat/svg-map-components\";\nimport { useAPIResult, useKeyHandler } from \"@macrostrat/ui-components\";\nimport chroma from \"chroma-js\";\nimport { ExtendedFeature } from \"d3-geo\";\nimport { Polygon } from \"geojson\";\nimport { useContext, useMemo } from \"react\";\nimport { useColumnFeatures } from \"./data-fetcher\";\nimport {\n buildKeyMapping,\n buildTriangulation,\n} from \"../utils/keyboard-navigation\";\n\nconst defaultStyle = {\n fill: \"rgb(239, 180, 249)\",\n stroke: \"magenta\",\n};\n\nexport function MeasurementsLayer(props) {\n const { style = defaultStyle, ...params } = props;\n const res: any = useAPIResult(\"/measurements\", {\n ...params,\n format: \"geojson\",\n response: \"light\",\n });\n if (res == null) return null;\n\n return h(FeatureLayer, {\n useCanvas: false,\n style,\n features: res.features?.filter((d) => d.properties.unit_id != null) ?? [],\n });\n}\n\ntype ColumnProps = { col_id: number };\n\ntype ColumnFeature = ExtendedFeature<Polygon, ColumnProps>;\n\nfunction ColumnFeatures(props) {\n const {\n features,\n onClick,\n color = \"rgba(150,150,150, 1)\",\n singleFeature = true,\n } = props;\n\n const c = chroma(color);\n\n return h(\n FeatureLayer,\n {\n className: \"columns\",\n useCanvas: onClick == null,\n style: {\n fill: c.alpha(0.2).css(),\n stroke: c.alpha(0.4).css(),\n },\n },\n features?.map((f) => {\n return h(Feature, {\n id: f.id ?? f.properties.col_id,\n onClick,\n feature: f,\n });\n }),\n );\n}\n\nenum MacrostratStatusCode {\n InProcess = \"in process\",\n}\n\ninterface ColumnNavProps {\n col_id: number;\n status_code?: MacrostratStatusCode;\n project_id?: number;\n onChange(col_id: number): void;\n}\n\ninterface KeyboardNavProps extends ColumnNavProps {\n features: ColumnFeature[];\n showLayers: boolean;\n}\n\nfunction ColumnKeyboardNavigation(props: KeyboardNavProps) {\n /** Keyboard navigation of columns using a Delaunay triangulation */\n const {\n features = [],\n col_id = null,\n onChange,\n showLayers = false,\n ...projectArgs\n } = props;\n const { projection } = useContext(MapContext);\n const { centroids, tri } = useMemo(\n () => buildTriangulation(features),\n [features],\n );\n\n const currentIndex = useMemo(() => {\n return features.findIndex((d) => d.properties.col_id == col_id);\n }, [features, col_id]);\n\n const neighbors = tri.delaunay.neighbors[currentIndex];\n\n const keyMapping = useMemo(() => {\n return buildKeyMapping(neighbors, centroids, currentIndex, projection);\n }, [neighbors, currentIndex]);\n\n useKeyHandler(\n (event) => {\n const nextColumnIx = keyMapping[event.keyCode];\n if (nextColumnIx == null) return;\n // @ts-ignore\n onChange(features[nextColumnIx]);\n },\n [keyMapping],\n );\n\n if (neighbors == null) return null;\n const neighborFeatures = neighbors.map((d) => features[d]);\n\n return h.if(showLayers)([\n h(FeatureLayer, {\n features: tri.links().features,\n useCanvas: false,\n style: {\n stroke: \"purple\",\n fill: \"transparent\",\n },\n }),\n h(FeatureLayer, {\n features: neighborFeatures,\n useCanvas: false,\n style: {\n stroke: \"rgb(93, 101, 212)\",\n strokeWidth: 3,\n fill: \"rgba(93, 101, 212, 0.5)\",\n },\n }),\n h(FeatureLayer, {\n features: [\n {\n type: \"Feature\",\n geometry: {\n type: \"MultiPoint\",\n coordinates: centroids,\n },\n },\n ],\n useCanvas: false,\n style: {\n r: 1,\n fill: \"purple\",\n },\n }),\n ]);\n}\n\ninterface ColumnExtraInfo {\n apiRoute?: string;\n color?: string;\n filterColumns?(d: ColumnFeature): boolean;\n showDebugLayers?: boolean;\n format?: \"topojson\" | \"geojson\";\n}\n\nconst Columns = (props: ColumnNavProps & ColumnExtraInfo) => {\n const {\n apiRoute = \"/columns\",\n onChange,\n col_id = null,\n status_code,\n project_id,\n color,\n filterColumns,\n showDebugLayers = false,\n format = \"topojson\",\n } = props;\n\n let features: any[] = useColumnFeatures({\n apiRoute,\n status_code,\n project_id,\n format,\n }) as any;\n\n if (features == null) return null;\n\n if (filterColumns != null) {\n features = features.filter(filterColumns);\n }\n\n return h([\n h(ColumnKeyboardNavigation, {\n features,\n col_id,\n onChange,\n status_code,\n project_id,\n showLayers: showDebugLayers,\n }),\n h(ColumnFeatures, { features, onClick: onChange, color }),\n ]);\n};\n\nconst ColumnCenters = (props: ColumnNavProps) => {\n return h(Columns, { apiRoute: \"/defs/columns\", ...props });\n};\n\nconst CurrentColumn = (props) => {\n const { feature } = props;\n return h(FeatureLayer, {\n features: [feature],\n style: {\n fill: \"rgba(255,0,0,0.4)\",\n stroke: \"rgba(255,0,0,0.6)\",\n strokeWidth: 2,\n },\n });\n};\n\nexport {\n Columns,\n CurrentColumn,\n ColumnCenters,\n ColumnFeatures,\n ColumnKeyboardNavigation,\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const d3Geo = require("d3-geo");
|
|
4
|
-
const d3GeoVoronoi = require("d3-geo-voronoi");
|
|
5
|
-
function buildKeyMapping(neighbors, centroids, currentIndex, projection) {
|
|
6
|
-
if (neighbors == null) return;
|
|
7
|
-
const currentCentroid = projection(centroids[currentIndex]);
|
|
8
|
-
let edgeAngles = neighbors.map((index) => {
|
|
9
|
-
const centroid = projection(centroids[index]);
|
|
10
|
-
const dx = centroid[0] - currentCentroid[0];
|
|
11
|
-
const dy = centroid[1] - currentCentroid[1];
|
|
12
|
-
return { col_index: index, angle: Math.atan2(dy, dx) };
|
|
13
|
-
});
|
|
14
|
-
edgeAngles.sort((d) => d.angle);
|
|
15
|
-
function closestAngle(num) {
|
|
16
|
-
let curr = edgeAngles[0];
|
|
17
|
-
for (let next of edgeAngles) {
|
|
18
|
-
if (Math.abs(normalize(num - next.angle)) < Math.abs(normalize(num - curr.angle))) {
|
|
19
|
-
curr = next;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return curr.col_index;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
37: closestAngle(Math.PI),
|
|
26
|
-
// left
|
|
27
|
-
38: closestAngle(3 * Math.PI / 2),
|
|
28
|
-
// up
|
|
29
|
-
39: closestAngle(0),
|
|
30
|
-
// right
|
|
31
|
-
40: closestAngle(Math.PI / 2)
|
|
32
|
-
// down
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function normalize(angle) {
|
|
36
|
-
if (angle > Math.PI) {
|
|
37
|
-
angle -= 2 * Math.PI;
|
|
38
|
-
} else if (angle <= -Math.PI) {
|
|
39
|
-
angle += 2 * Math.PI;
|
|
40
|
-
}
|
|
41
|
-
return angle;
|
|
42
|
-
}
|
|
43
|
-
function buildTriangulation(features) {
|
|
44
|
-
const centroids = features.map(d3Geo.geoCentroid);
|
|
45
|
-
const tri = d3GeoVoronoi.geoVoronoi(centroids);
|
|
46
|
-
return { centroids, tri };
|
|
47
|
-
}
|
|
48
|
-
exports.buildKeyMapping = buildKeyMapping;
|
|
49
|
-
exports.buildTriangulation = buildTriangulation;
|
|
50
|
-
//# sourceMappingURL=keyboard-navigation.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-navigation.cjs","sources":["../../../../src/maps/column-navigation/utils/keyboard-navigation.ts"],"sourcesContent":["import { geoCentroid } from \"d3-geo\";\nimport { geoVoronoi } from \"d3-geo-voronoi\";\n\nexport function buildKeyMapping(\n neighbors,\n centroids,\n currentIndex,\n projection,\n) {\n if (neighbors == null) return;\n\n const currentCentroid = projection(centroids[currentIndex]);\n\n let edgeAngles = neighbors.map((index) => {\n const centroid = projection(centroids[index]);\n const dx = centroid[0] - currentCentroid[0];\n const dy = centroid[1] - currentCentroid[1];\n return { col_index: index, angle: Math.atan2(dy, dx) };\n });\n\n edgeAngles.sort((d) => d.angle);\n\n function closestAngle(num) {\n // Find closest angle in array of neighbors\n let curr = edgeAngles[0];\n for (let next of edgeAngles) {\n if (\n Math.abs(normalize(num - next.angle)) <\n Math.abs(normalize(num - curr.angle))\n ) {\n curr = next;\n }\n }\n return curr.col_index;\n }\n\n return {\n 37: closestAngle(Math.PI), // left\n 38: closestAngle((3 * Math.PI) / 2), // up\n 39: closestAngle(0), // right\n 40: closestAngle(Math.PI / 2), // down\n };\n}\n\nfunction normalize(angle) {\n if (angle > Math.PI) {\n angle -= 2 * Math.PI;\n } else if (angle <= -Math.PI) {\n angle += 2 * Math.PI;\n }\n return angle;\n}\n\nexport function buildTriangulation(features) {\n const centroids = features.map(geoCentroid);\n const tri = geoVoronoi(centroids);\n return { centroids, tri };\n}\n"],"names":["geoCentroid","geoVoronoi"],"mappings":";;;;AAGO,SAAS,gBACd,WACA,WACA,cACA,YACA;AACA,MAAI,aAAa,KAAM;AAEvB,QAAM,kBAAkB,WAAW,UAAU,YAAY,CAAC;AAE1D,MAAI,aAAa,UAAU,IAAI,CAAC,UAAU;AACxC,UAAM,WAAW,WAAW,UAAU,KAAK,CAAC;AAC5C,UAAM,KAAK,SAAS,CAAC,IAAI,gBAAgB,CAAC;AAC1C,UAAM,KAAK,SAAS,CAAC,IAAI,gBAAgB,CAAC;AAC1C,WAAO,EAAE,WAAW,OAAO,OAAO,KAAK,MAAM,IAAI,EAAE,EAAA;AAAA,EACrD,CAAC;AAED,aAAW,KAAK,CAAC,MAAM,EAAE,KAAK;AAE9B,WAAS,aAAa,KAAK;AAEzB,QAAI,OAAO,WAAW,CAAC;AACvB,aAAS,QAAQ,YAAY;AAC3B,UACE,KAAK,IAAI,UAAU,MAAM,KAAK,KAAK,CAAC,IACpC,KAAK,IAAI,UAAU,MAAM,KAAK,KAAK,CAAC,GACpC;AACA,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAEA,SAAO;AAAA,IACL,IAAI,aAAa,KAAK,EAAE;AAAA;AAAA,IACxB,IAAI,aAAc,IAAI,KAAK,KAAM,CAAC;AAAA;AAAA,IAClC,IAAI,aAAa,CAAC;AAAA;AAAA,IAClB,IAAI,aAAa,KAAK,KAAK,CAAC;AAAA;AAAA,EAAA;AAEhC;AAEA,SAAS,UAAU,OAAO;AACxB,MAAI,QAAQ,KAAK,IAAI;AACnB,aAAS,IAAI,KAAK;AAAA,EACpB,WAAW,SAAS,CAAC,KAAK,IAAI;AAC5B,aAAS,IAAI,KAAK;AAAA,EACpB;AACA,SAAO;AACT;AAEO,SAAS,mBAAmB,UAAU;AAC3C,QAAM,YAAY,SAAS,IAAIA,iBAAW;AAC1C,QAAM,MAAMC,aAAAA,WAAW,SAAS;AAChC,SAAO,EAAE,WAAW,IAAA;AACtB;;;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function buildKeyMapping(neighbors: any, centroids: any, currentIndex: any, projection: any): {
|
|
2
|
-
37: any;
|
|
3
|
-
38: any;
|
|
4
|
-
39: any;
|
|
5
|
-
40: any;
|
|
6
|
-
} | undefined;
|
|
7
|
-
export declare function buildTriangulation(features: any): {
|
|
8
|
-
centroids: any;
|
|
9
|
-
tri: any;
|
|
10
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { geoCentroid } from "d3-geo";
|
|
2
|
-
import { geoVoronoi } from "d3-geo-voronoi";
|
|
3
|
-
function buildKeyMapping(neighbors, centroids, currentIndex, projection) {
|
|
4
|
-
if (neighbors == null) return;
|
|
5
|
-
const currentCentroid = projection(centroids[currentIndex]);
|
|
6
|
-
let edgeAngles = neighbors.map((index) => {
|
|
7
|
-
const centroid = projection(centroids[index]);
|
|
8
|
-
const dx = centroid[0] - currentCentroid[0];
|
|
9
|
-
const dy = centroid[1] - currentCentroid[1];
|
|
10
|
-
return { col_index: index, angle: Math.atan2(dy, dx) };
|
|
11
|
-
});
|
|
12
|
-
edgeAngles.sort((d) => d.angle);
|
|
13
|
-
function closestAngle(num) {
|
|
14
|
-
let curr = edgeAngles[0];
|
|
15
|
-
for (let next of edgeAngles) {
|
|
16
|
-
if (Math.abs(normalize(num - next.angle)) < Math.abs(normalize(num - curr.angle))) {
|
|
17
|
-
curr = next;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return curr.col_index;
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
37: closestAngle(Math.PI),
|
|
24
|
-
// left
|
|
25
|
-
38: closestAngle(3 * Math.PI / 2),
|
|
26
|
-
// up
|
|
27
|
-
39: closestAngle(0),
|
|
28
|
-
// right
|
|
29
|
-
40: closestAngle(Math.PI / 2)
|
|
30
|
-
// down
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function normalize(angle) {
|
|
34
|
-
if (angle > Math.PI) {
|
|
35
|
-
angle -= 2 * Math.PI;
|
|
36
|
-
} else if (angle <= -Math.PI) {
|
|
37
|
-
angle += 2 * Math.PI;
|
|
38
|
-
}
|
|
39
|
-
return angle;
|
|
40
|
-
}
|
|
41
|
-
function buildTriangulation(features) {
|
|
42
|
-
const centroids = features.map(geoCentroid);
|
|
43
|
-
const tri = geoVoronoi(centroids);
|
|
44
|
-
return { centroids, tri };
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
buildKeyMapping,
|
|
48
|
-
buildTriangulation
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=keyboard-navigation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-navigation.js","sources":["../../../../src/maps/column-navigation/utils/keyboard-navigation.ts"],"sourcesContent":["import { geoCentroid } from \"d3-geo\";\nimport { geoVoronoi } from \"d3-geo-voronoi\";\n\nexport function buildKeyMapping(\n neighbors,\n centroids,\n currentIndex,\n projection,\n) {\n if (neighbors == null) return;\n\n const currentCentroid = projection(centroids[currentIndex]);\n\n let edgeAngles = neighbors.map((index) => {\n const centroid = projection(centroids[index]);\n const dx = centroid[0] - currentCentroid[0];\n const dy = centroid[1] - currentCentroid[1];\n return { col_index: index, angle: Math.atan2(dy, dx) };\n });\n\n edgeAngles.sort((d) => d.angle);\n\n function closestAngle(num) {\n // Find closest angle in array of neighbors\n let curr = edgeAngles[0];\n for (let next of edgeAngles) {\n if (\n Math.abs(normalize(num - next.angle)) <\n Math.abs(normalize(num - curr.angle))\n ) {\n curr = next;\n }\n }\n return curr.col_index;\n }\n\n return {\n 37: closestAngle(Math.PI), // left\n 38: closestAngle((3 * Math.PI) / 2), // up\n 39: closestAngle(0), // right\n 40: closestAngle(Math.PI / 2), // down\n };\n}\n\nfunction normalize(angle) {\n if (angle > Math.PI) {\n angle -= 2 * Math.PI;\n } else if (angle <= -Math.PI) {\n angle += 2 * Math.PI;\n }\n return angle;\n}\n\nexport function buildTriangulation(features) {\n const centroids = features.map(geoCentroid);\n const tri = geoVoronoi(centroids);\n return { centroids, tri };\n}\n"],"names":[],"mappings":";;AAGO,SAAS,gBACd,WACA,WACA,cACA,YACA;AACA,MAAI,aAAa,KAAM;AAEvB,QAAM,kBAAkB,WAAW,UAAU,YAAY,CAAC;AAE1D,MAAI,aAAa,UAAU,IAAI,CAAC,UAAU;AACxC,UAAM,WAAW,WAAW,UAAU,KAAK,CAAC;AAC5C,UAAM,KAAK,SAAS,CAAC,IAAI,gBAAgB,CAAC;AAC1C,UAAM,KAAK,SAAS,CAAC,IAAI,gBAAgB,CAAC;AAC1C,WAAO,EAAE,WAAW,OAAO,OAAO,KAAK,MAAM,IAAI,EAAE,EAAA;AAAA,EACrD,CAAC;AAED,aAAW,KAAK,CAAC,MAAM,EAAE,KAAK;AAE9B,WAAS,aAAa,KAAK;AAEzB,QAAI,OAAO,WAAW,CAAC;AACvB,aAAS,QAAQ,YAAY;AAC3B,UACE,KAAK,IAAI,UAAU,MAAM,KAAK,KAAK,CAAC,IACpC,KAAK,IAAI,UAAU,MAAM,KAAK,KAAK,CAAC,GACpC;AACA,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAEA,SAAO;AAAA,IACL,IAAI,aAAa,KAAK,EAAE;AAAA;AAAA,IACxB,IAAI,aAAc,IAAI,KAAK,KAAM,CAAC;AAAA;AAAA,IAClC,IAAI,aAAa,CAAC;AAAA;AAAA,IAClB,IAAI,aAAa,KAAK,KAAK,CAAC;AAAA;AAAA,EAAA;AAEhC;AAEA,SAAS,UAAU,OAAO;AACxB,MAAI,QAAQ,KAAK,IAAI;AACnB,aAAS,IAAI,KAAK;AAAA,EACpB,WAAW,SAAS,CAAC,KAAK,IAAI;AAC5B,aAAS,IAAI,KAAK;AAAA,EACpB;AACA,SAAO;AACT;AAEO,SAAS,mBAAmB,UAAU;AAC3C,QAAM,YAAY,SAAS,IAAI,WAAW;AAC1C,QAAM,MAAM,WAAW,SAAS;AAChC,SAAO,EAAE,WAAW,IAAA;AACtB;"}
|
package/dist/maps/index.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const mapInterface = require("@macrostrat/map-interface");
|
|
5
|
-
const h = require("@macrostrat/hyper");
|
|
6
|
-
const mapboxReact = require("@macrostrat/mapbox-react");
|
|
7
|
-
const uiComponents = require("@macrostrat/ui-components");
|
|
8
|
-
const mapboxUtils = require("@macrostrat/mapbox-utils");
|
|
9
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
-
const h__default = /* @__PURE__ */ _interopDefault(h);
|
|
11
|
-
function InsetMap({
|
|
12
|
-
controls,
|
|
13
|
-
className,
|
|
14
|
-
children,
|
|
15
|
-
style,
|
|
16
|
-
mapStyle,
|
|
17
|
-
accessToken,
|
|
18
|
-
showLabels = false,
|
|
19
|
-
showAdmin = false,
|
|
20
|
-
showRoads = false,
|
|
21
|
-
...rest
|
|
22
|
-
}) {
|
|
23
|
-
const inDarkMode = uiComponents.useInDarkMode();
|
|
24
|
-
const _style = React.useMemo(() => {
|
|
25
|
-
return mapStyle ?? mapInterface.getBasicMapStyle({ inDarkMode });
|
|
26
|
-
}, [mapStyle, inDarkMode]);
|
|
27
|
-
const transformStyle = React.useCallback(
|
|
28
|
-
(style2) => {
|
|
29
|
-
let newStyle = style2;
|
|
30
|
-
if (!showLabels) {
|
|
31
|
-
newStyle = mapboxUtils.removeMapLabels(newStyle);
|
|
32
|
-
}
|
|
33
|
-
if (!showAdmin) {
|
|
34
|
-
newStyle = mapboxUtils.removeSourceFromStyle(newStyle, null, "admin");
|
|
35
|
-
}
|
|
36
|
-
if (!showRoads) {
|
|
37
|
-
newStyle = mapboxUtils.removeSourceFromStyle(newStyle, null, "road");
|
|
38
|
-
newStyle = mapboxUtils.removeSourceFromStyle(newStyle, null, "aeroway");
|
|
39
|
-
}
|
|
40
|
-
return newStyle;
|
|
41
|
-
},
|
|
42
|
-
[mapStyle, showLabels, showRoads, showAdmin]
|
|
43
|
-
);
|
|
44
|
-
return h__default.default("div.inset-map", { className, style }, [
|
|
45
|
-
h__default.default(mapboxReact.MapboxMapProvider, [
|
|
46
|
-
controls,
|
|
47
|
-
h__default.default(
|
|
48
|
-
mapInterface.MapView,
|
|
49
|
-
{
|
|
50
|
-
style: _style,
|
|
51
|
-
accessToken,
|
|
52
|
-
standalone: true,
|
|
53
|
-
/* Default map position that centers on the bulk of Macrostrat columns
|
|
54
|
-
*/
|
|
55
|
-
mapPosition: {
|
|
56
|
-
camera: {
|
|
57
|
-
lng: -100,
|
|
58
|
-
lat: 38,
|
|
59
|
-
altitude: 5e6
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
transformStyle,
|
|
63
|
-
...rest
|
|
64
|
-
},
|
|
65
|
-
children
|
|
66
|
-
)
|
|
67
|
-
])
|
|
68
|
-
]);
|
|
69
|
-
}
|
|
70
|
-
exports.InsetMap = InsetMap;
|
|
71
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/maps/inset-map/index.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n MapView,\n getBasicMapStyle,\n MapViewProps,\n} from \"@macrostrat/map-interface\";\nimport h from \"@macrostrat/hyper\";\nimport { MapboxMapProvider } from \"@macrostrat/mapbox-react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n removeMapLabels,\n removeSourceFromStyle,\n} from \"@macrostrat/mapbox-utils\";\nimport type { ReactNode, CSSProperties } from \"react\";\n\nexport interface InsetMapProps extends Omit<MapViewProps, \"style\"> {\n controls?: ReactNode;\n className?: string;\n children?: ReactNode;\n style?: CSSProperties;\n mapStyle?: mapboxgl.Style | string;\n showLabels?: boolean;\n showAdmin?: boolean;\n showRoads?: boolean;\n}\n\nexport function InsetMap({\n controls,\n className,\n children,\n style,\n mapStyle,\n accessToken,\n showLabels = false,\n showAdmin = false,\n showRoads = false,\n ...rest\n}: InsetMapProps) {\n const inDarkMode = useInDarkMode();\n const _style = useMemo((): mapboxgl.Style | string => {\n return mapStyle ?? getBasicMapStyle({ inDarkMode });\n }, [mapStyle, inDarkMode]);\n\n const transformStyle = useCallback(\n (style) => {\n let newStyle = style;\n if (!showLabels) {\n newStyle = removeMapLabels(newStyle);\n }\n if (!showAdmin) {\n newStyle = removeSourceFromStyle(newStyle, null, \"admin\");\n }\n if (!showRoads) {\n newStyle = removeSourceFromStyle(newStyle, null, \"road\");\n newStyle = removeSourceFromStyle(newStyle, null, \"aeroway\");\n }\n return newStyle;\n },\n [mapStyle, showLabels, showRoads, showAdmin],\n );\n\n return h(\"div.inset-map\", { className, style }, [\n h(MapboxMapProvider, [\n controls,\n h(\n MapView,\n {\n style: _style,\n accessToken,\n standalone: true,\n /* Default map position that centers on the bulk of Macrostrat columns\n */\n mapPosition: {\n camera: {\n lng: -100,\n lat: 38,\n altitude: 5000000,\n },\n },\n transformStyle,\n ...rest,\n },\n children,\n ),\n ]),\n ]);\n}\n"],"names":["useInDarkMode","useMemo","getBasicMapStyle","useCallback","style","removeMapLabels","removeSourceFromStyle","h","MapboxMapProvider","MapView"],"mappings":";;;;;;;;;;AA0BO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,GAAG;AACL,GAAkB;AAChB,QAAM,aAAaA,aAAAA,cAAA;AACnB,QAAM,SAASC,MAAAA,QAAQ,MAA+B;AACpD,WAAO,YAAYC,aAAAA,iBAAiB,EAAE,YAAY;AAAA,EACpD,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,QAAM,iBAAiBC,MAAAA;AAAAA,IACrB,CAACC,WAAU;AACT,UAAI,WAAWA;AACf,UAAI,CAAC,YAAY;AACf,mBAAWC,YAAAA,gBAAgB,QAAQ;AAAA,MACrC;AACA,UAAI,CAAC,WAAW;AACd,mBAAWC,YAAAA,sBAAsB,UAAU,MAAM,OAAO;AAAA,MAC1D;AACA,UAAI,CAAC,WAAW;AACd,mBAAWA,YAAAA,sBAAsB,UAAU,MAAM,MAAM;AACvD,mBAAWA,YAAAA,sBAAsB,UAAU,MAAM,SAAS;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,YAAY,WAAW,SAAS;AAAA,EAAA;AAG7C,SAAOC,WAAAA,QAAE,iBAAiB,EAAE,WAAW,SAAS;AAAA,IAC9CA,WAAAA,QAAEC,YAAAA,mBAAmB;AAAA,MACnB;AAAA,MACAD,WAAAA;AAAAA,QACEE,aAAAA;AAAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP;AAAA,UACA,YAAY;AAAA;AAAA;AAAA,UAGZ,aAAa;AAAA,YACX,QAAQ;AAAA,cACN,KAAK;AAAA,cACL,KAAK;AAAA,cACL,UAAU;AAAA,YAAA;AAAA,UACZ;AAAA,UAEF;AAAA,UACA,GAAG;AAAA,QAAA;AAAA,QAEL;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA,CACF;AACH;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MapViewProps } from '@macrostrat/map-interface';
|
|
2
|
-
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
export interface InsetMapProps extends Omit<MapViewProps, "style"> {
|
|
4
|
-
controls?: ReactNode;
|
|
5
|
-
className?: string;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
style?: CSSProperties;
|
|
8
|
-
mapStyle?: mapboxgl.Style | string;
|
|
9
|
-
showLabels?: boolean;
|
|
10
|
-
showAdmin?: boolean;
|
|
11
|
-
showRoads?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function InsetMap({ controls, className, children, style, mapStyle, accessToken, showLabels, showAdmin, showRoads, ...rest }: InsetMapProps): import('react').ReactElement<{
|
|
14
|
-
className: string | undefined;
|
|
15
|
-
style: CSSProperties | undefined;
|
|
16
|
-
}, string | import('react').JSXElementConstructor<any>>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useMemo, useCallback } from "react";
|
|
2
|
-
import { getBasicMapStyle, MapView } from "@macrostrat/map-interface";
|
|
3
|
-
import h from "@macrostrat/hyper";
|
|
4
|
-
import { MapboxMapProvider } from "@macrostrat/mapbox-react";
|
|
5
|
-
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
6
|
-
import { removeMapLabels, removeSourceFromStyle } from "@macrostrat/mapbox-utils";
|
|
7
|
-
function InsetMap({
|
|
8
|
-
controls,
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
style,
|
|
12
|
-
mapStyle,
|
|
13
|
-
accessToken,
|
|
14
|
-
showLabels = false,
|
|
15
|
-
showAdmin = false,
|
|
16
|
-
showRoads = false,
|
|
17
|
-
...rest
|
|
18
|
-
}) {
|
|
19
|
-
const inDarkMode = useInDarkMode();
|
|
20
|
-
const _style = useMemo(() => {
|
|
21
|
-
return mapStyle ?? getBasicMapStyle({ inDarkMode });
|
|
22
|
-
}, [mapStyle, inDarkMode]);
|
|
23
|
-
const transformStyle = useCallback(
|
|
24
|
-
(style2) => {
|
|
25
|
-
let newStyle = style2;
|
|
26
|
-
if (!showLabels) {
|
|
27
|
-
newStyle = removeMapLabels(newStyle);
|
|
28
|
-
}
|
|
29
|
-
if (!showAdmin) {
|
|
30
|
-
newStyle = removeSourceFromStyle(newStyle, null, "admin");
|
|
31
|
-
}
|
|
32
|
-
if (!showRoads) {
|
|
33
|
-
newStyle = removeSourceFromStyle(newStyle, null, "road");
|
|
34
|
-
newStyle = removeSourceFromStyle(newStyle, null, "aeroway");
|
|
35
|
-
}
|
|
36
|
-
return newStyle;
|
|
37
|
-
},
|
|
38
|
-
[mapStyle, showLabels, showRoads, showAdmin]
|
|
39
|
-
);
|
|
40
|
-
return h("div.inset-map", { className, style }, [
|
|
41
|
-
h(MapboxMapProvider, [
|
|
42
|
-
controls,
|
|
43
|
-
h(
|
|
44
|
-
MapView,
|
|
45
|
-
{
|
|
46
|
-
style: _style,
|
|
47
|
-
accessToken,
|
|
48
|
-
standalone: true,
|
|
49
|
-
/* Default map position that centers on the bulk of Macrostrat columns
|
|
50
|
-
*/
|
|
51
|
-
mapPosition: {
|
|
52
|
-
camera: {
|
|
53
|
-
lng: -100,
|
|
54
|
-
lat: 38,
|
|
55
|
-
altitude: 5e6
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
transformStyle,
|
|
59
|
-
...rest
|
|
60
|
-
},
|
|
61
|
-
children
|
|
62
|
-
)
|
|
63
|
-
])
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
InsetMap
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/maps/inset-map/index.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n MapView,\n getBasicMapStyle,\n MapViewProps,\n} from \"@macrostrat/map-interface\";\nimport h from \"@macrostrat/hyper\";\nimport { MapboxMapProvider } from \"@macrostrat/mapbox-react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n removeMapLabels,\n removeSourceFromStyle,\n} from \"@macrostrat/mapbox-utils\";\nimport type { ReactNode, CSSProperties } from \"react\";\n\nexport interface InsetMapProps extends Omit<MapViewProps, \"style\"> {\n controls?: ReactNode;\n className?: string;\n children?: ReactNode;\n style?: CSSProperties;\n mapStyle?: mapboxgl.Style | string;\n showLabels?: boolean;\n showAdmin?: boolean;\n showRoads?: boolean;\n}\n\nexport function InsetMap({\n controls,\n className,\n children,\n style,\n mapStyle,\n accessToken,\n showLabels = false,\n showAdmin = false,\n showRoads = false,\n ...rest\n}: InsetMapProps) {\n const inDarkMode = useInDarkMode();\n const _style = useMemo((): mapboxgl.Style | string => {\n return mapStyle ?? getBasicMapStyle({ inDarkMode });\n }, [mapStyle, inDarkMode]);\n\n const transformStyle = useCallback(\n (style) => {\n let newStyle = style;\n if (!showLabels) {\n newStyle = removeMapLabels(newStyle);\n }\n if (!showAdmin) {\n newStyle = removeSourceFromStyle(newStyle, null, \"admin\");\n }\n if (!showRoads) {\n newStyle = removeSourceFromStyle(newStyle, null, \"road\");\n newStyle = removeSourceFromStyle(newStyle, null, \"aeroway\");\n }\n return newStyle;\n },\n [mapStyle, showLabels, showRoads, showAdmin],\n );\n\n return h(\"div.inset-map\", { className, style }, [\n h(MapboxMapProvider, [\n controls,\n h(\n MapView,\n {\n style: _style,\n accessToken,\n standalone: true,\n /* Default map position that centers on the bulk of Macrostrat columns\n */\n mapPosition: {\n camera: {\n lng: -100,\n lat: 38,\n altitude: 5000000,\n },\n },\n transformStyle,\n ...rest,\n },\n children,\n ),\n ]),\n ]);\n}\n"],"names":["style"],"mappings":";;;;;;AA0BO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,GAAG;AACL,GAAkB;AAChB,QAAM,aAAa,cAAA;AACnB,QAAM,SAAS,QAAQ,MAA+B;AACpD,WAAO,YAAY,iBAAiB,EAAE,YAAY;AAAA,EACpD,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,QAAM,iBAAiB;AAAA,IACrB,CAACA,WAAU;AACT,UAAI,WAAWA;AACf,UAAI,CAAC,YAAY;AACf,mBAAW,gBAAgB,QAAQ;AAAA,MACrC;AACA,UAAI,CAAC,WAAW;AACd,mBAAW,sBAAsB,UAAU,MAAM,OAAO;AAAA,MAC1D;AACA,UAAI,CAAC,WAAW;AACd,mBAAW,sBAAsB,UAAU,MAAM,MAAM;AACvD,mBAAW,sBAAsB,UAAU,MAAM,SAAS;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,YAAY,WAAW,SAAS;AAAA,EAAA;AAG7C,SAAO,EAAE,iBAAiB,EAAE,WAAW,SAAS;AAAA,IAC9C,EAAE,mBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP;AAAA,UACA,YAAY;AAAA;AAAA;AAAA,UAGZ,aAAa;AAAA,YACX,QAAQ;AAAA,cACN,KAAK;AAAA,cACL,KAAK;AAAA,cACL,UAAU;AAAA,YAAA;AAAA,UACZ;AAAA,UAEF;AAAA,UACA,GAAG;AAAA,QAAA;AAAA,QAEL;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA,CACF;AACH;"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const mapboxReact = require("@macrostrat/mapbox-react");
|
|
4
|
-
const mapboxUtils = require("@macrostrat/mapbox-utils");
|
|
5
|
-
const colorUtils = require("@macrostrat/color-utils");
|
|
6
|
-
function BaseColumnsLayer({
|
|
7
|
-
enabled = true,
|
|
8
|
-
columns,
|
|
9
|
-
...rest
|
|
10
|
-
}) {
|
|
11
|
-
mapboxReact.useOverlayStyle(() => enabled ? buildColumnsStyle(rest) : null, [enabled]);
|
|
12
|
-
mapboxReact.useMapStyleOperator(
|
|
13
|
-
(map) => {
|
|
14
|
-
if (columns == null) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
mapboxUtils.setGeoJSON(map, "columns", promoteToFeatureCollection(columns));
|
|
18
|
-
},
|
|
19
|
-
[columns, enabled]
|
|
20
|
-
);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
function promoteToFeatureCollection(data) {
|
|
24
|
-
if (data == null) return null;
|
|
25
|
-
if ("type" in data && data.type == "Feature") {
|
|
26
|
-
return {
|
|
27
|
-
type: "FeatureCollection",
|
|
28
|
-
features: [data]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if ("type" in data && data.type == "FeatureCollection" && "features" in data) {
|
|
32
|
-
return data;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
type: "FeatureCollection",
|
|
36
|
-
features: data
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function buildColumnsStyle(opts = {}) {
|
|
40
|
-
const { color } = opts;
|
|
41
|
-
const columnBaseColor = color ?? colorUtils.getCSSVariable("--text-subtle-color", "black");
|
|
42
|
-
let columnColor = columnBaseColor;
|
|
43
|
-
const columnSelectedColor = opts.selectedColor ?? colorUtils.getCSSVariable("--selection-color", "purple");
|
|
44
|
-
const lineColor = opts.lineColor ?? columnBaseColor;
|
|
45
|
-
const isHovered = [
|
|
46
|
-
"any",
|
|
47
|
-
["boolean", ["feature-state", "hover"], false],
|
|
48
|
-
["boolean", ["feature-state", "highlighted"], false]
|
|
49
|
-
];
|
|
50
|
-
if (typeof columnColor === "string") {
|
|
51
|
-
columnColor = [
|
|
52
|
-
"coalesce",
|
|
53
|
-
["feature-state", "color"],
|
|
54
|
-
["get", "color"],
|
|
55
|
-
columnColor
|
|
56
|
-
];
|
|
57
|
-
}
|
|
58
|
-
const fillOpacity = opts.opacity ?? 0.1;
|
|
59
|
-
const lineOpacity = opts.lineOpacity ?? 0.5;
|
|
60
|
-
const lineWidth = opts.lineWidth ?? 2;
|
|
61
|
-
const circleRadius = opts.circleRadius ?? 4;
|
|
62
|
-
return {
|
|
63
|
-
sources: {
|
|
64
|
-
columns: mapboxUtils.buildGeoJSONSource()
|
|
65
|
-
},
|
|
66
|
-
version: 8,
|
|
67
|
-
layers: [
|
|
68
|
-
{
|
|
69
|
-
id: "columns-fill",
|
|
70
|
-
type: "fill",
|
|
71
|
-
source: "columns",
|
|
72
|
-
paint: {
|
|
73
|
-
"fill-color": columnColor,
|
|
74
|
-
"fill-opacity": fillOpacity
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
id: "columns-points",
|
|
79
|
-
type: "circle",
|
|
80
|
-
source: "columns",
|
|
81
|
-
paint: {
|
|
82
|
-
"circle-radius": circleRadius,
|
|
83
|
-
"circle-color": columnColor,
|
|
84
|
-
"circle-opacity": fillOpacity
|
|
85
|
-
},
|
|
86
|
-
filter: ["==", "$type", "Point"]
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
id: "columns-line",
|
|
90
|
-
type: "line",
|
|
91
|
-
source: "columns",
|
|
92
|
-
paint: {
|
|
93
|
-
"line-color": ["case", isHovered, columnSelectedColor, lineColor],
|
|
94
|
-
"line-width": lineWidth,
|
|
95
|
-
"line-opacity": ["case", isHovered, 1, lineOpacity]
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const selectedColumnSourceID = "selectedColumn";
|
|
102
|
-
function SelectedColumnOverlay({
|
|
103
|
-
selectedColumn,
|
|
104
|
-
...styleOpts
|
|
105
|
-
}) {
|
|
106
|
-
mapboxReact.useOverlayStyle(() => buildSelectedColumnStyle(styleOpts), []);
|
|
107
|
-
mapboxReact.useMapStyleOperator(
|
|
108
|
-
(map) => {
|
|
109
|
-
mapboxUtils.setGeoJSON(
|
|
110
|
-
map,
|
|
111
|
-
selectedColumnSourceID,
|
|
112
|
-
promoteToFeatureCollection(selectedColumn)
|
|
113
|
-
);
|
|
114
|
-
},
|
|
115
|
-
[selectedColumn]
|
|
116
|
-
);
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
function buildSelectedColumnStyle(opts = {}) {
|
|
120
|
-
const columnSelectedColor = opts.color ?? colorUtils.getCSSVariable("--selection-color", "purple");
|
|
121
|
-
return {
|
|
122
|
-
sources: {
|
|
123
|
-
selectedColumn: mapboxUtils.buildGeoJSONSource()
|
|
124
|
-
},
|
|
125
|
-
version: 8,
|
|
126
|
-
layers: [
|
|
127
|
-
{
|
|
128
|
-
id: "selected-column-highlight",
|
|
129
|
-
type: "fill",
|
|
130
|
-
source: selectedColumnSourceID,
|
|
131
|
-
paint: {
|
|
132
|
-
"fill-color": columnSelectedColor,
|
|
133
|
-
"fill-opacity": 0.5
|
|
134
|
-
},
|
|
135
|
-
filter: ["==", "$type", "Polygon"]
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: "selected-column-edge",
|
|
139
|
-
type: "line",
|
|
140
|
-
source: selectedColumnSourceID,
|
|
141
|
-
paint: {
|
|
142
|
-
"line-color": columnSelectedColor,
|
|
143
|
-
"line-width": 2,
|
|
144
|
-
"line-opacity": 1
|
|
145
|
-
},
|
|
146
|
-
filter: ["==", "$type", "Polygon"]
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
id: "selected-column-point",
|
|
150
|
-
type: "circle",
|
|
151
|
-
source: selectedColumnSourceID,
|
|
152
|
-
paint: {
|
|
153
|
-
"circle-radius": 6,
|
|
154
|
-
"circle-color": columnSelectedColor,
|
|
155
|
-
"circle-opacity": 1
|
|
156
|
-
},
|
|
157
|
-
filter: ["==", "$type", "Point"]
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
exports.BaseColumnsLayer = BaseColumnsLayer;
|
|
163
|
-
exports.SelectedColumnOverlay = SelectedColumnOverlay;
|
|
164
|
-
exports.buildColumnsStyle = buildColumnsStyle;
|
|
165
|
-
//# sourceMappingURL=columns.cjs.map
|