Skip to content

Commit

Permalink
updating branch with changes from main
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Nov 18, 2024
1 parent d207307 commit fe6a0e4
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 35,993 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nodejs 20.7.0
python 3.11
2 changes: 1 addition & 1 deletion deps/cesium-martini
2 changes: 1 addition & 1 deletion deps/web-components
6 changes: 0 additions & 6 deletions package-lock.json

This file was deleted.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
"dev": "NODE_NO_WARNINGS=1 yarn run server:dev",
"build": "vite build",
"server": "tsx ./server/index.ts",
"server:dev": "tsx --env-file=.env ./server/index.ts",
"server:dev": "tsx ./server/index.ts",
"format": "prettier --write src packages",
"server:prod": "NODE_NO_WARNINGS=1 NODE_ENV=production yarn run server",
"dev:storybook": "yarn workspace @macrostrat/storybook run dev",
"start": "yarn run build && yarn run server",
"test:runtime": "tsx tests/test-urls.ts",
"test": "vitest"
},
"workspaces": [
"deps/web-components/packages/*",
"deps/web-components/storybook",
"deps/cesium-viewer",
"deps/cesium-martini",
"packages/*"
Expand All @@ -33,16 +35,15 @@
"@babel/preset-env": "^7.19.4",
"@babel/preset-typescript": "^7.18.6",
"@macrostrat/revision-info-webpack": "^1.0.0",
"@macrostrat/storybook": "workspace:*",
"@mdx-js/rollup": "^2.3.0",
"@types/esprima": "^4",
"@types/prop-types": "^15",
"@types/underscore": "^1",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@yarnpkg/sdks": "^3.1.0",
"chalk": "^5.3.0",
"http-proxy-middleware": "^3.0.3",
"prettier": "^2.7.1",
"react-arborist": "^3.4.0",
"react-text-annotate-blend": "^1.2.0",
"sass": "^1.49.0",
"sass-embedded": "^1.79.1",
"stylus": "^0.55.0",
Expand Down Expand Up @@ -116,7 +117,8 @@
"@vx/shape": "^0.0.199",
"@znemz/cesium-navigation": "^4.0.0",
"axios": "^0.25.0",
"chroma-js": "^3.0.0",
"cesium": "^1.122.0",
"chroma-js": "^2.4.2",
"classnames": "^2.2.6",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
Expand All @@ -133,7 +135,6 @@
"esprima": "^4.0.1",
"express": "^4.18.2",
"express-http-proxy": "^2.0.0",
"fuse.js": "^7.0.0",
"gl-matrix": "^3.4.3",
"hex-to-css-filter": "^5.4.0",
"history": "^5.3.0",
Expand Down Expand Up @@ -162,18 +163,17 @@
"tsx": "^4.11.2",
"underscore": "^1.13.6",
"use-debounce": "^9.0.4",
"use-element-dimensions": "^2.1.3",
"use-react-router-breadcrumbs": "^3.2.1",
"use-resize-observer": "^9.1.0",
"vike": "^0.4.199",
"vike-react": "^0.5.7",
"vite": "^5.3.2",
"vike": "^0.4.177",
"vike-react": "^0.4.15",
"vite": "5.4.11",
"vite-plugin-cesium": "^1.2.22",
"vite-plugin-inspect": "^0.8.4",
"zustand": "^4.5.1"
},
"prettier": {
"proseWrap": "always"
},
"packageManager": "yarn@4.5.1"
"packageManager": "yarn@4.3.1"
}
2 changes: 1 addition & 1 deletion packages/globe-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react": "^18",
"react-dom": "^18",
"typescript": "^5.0.0",
"vite": "^4.4.9",
"vite": "5.4.11",
"vite-plugin-cesium": "^1.2.22"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sift/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitejs/plugin-react": "^4.2.1",
"vite": "^5.0.12"
"vite": "5.4.11"
}
}
2 changes: 2 additions & 0 deletions pages/dev/map/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Pages for development of Macrostrat mapping interfaces

- [StraboSpot](/dev/map/strabospot) - StraboSpot development integration
- [Weaver](/dev/map/weaver) - point data experiments
- [Rockd checkins](/dev/map/checkins) - point data experiments

245 changes: 245 additions & 0 deletions pages/dev/map/rockd_checkins/+Page.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
/**
* A development interface for the "Weaver" point data server.
*/

import h from "@macrostrat/hyper";

import { Button, MenuItem, Spinner } from "@blueprintjs/core";
import { Select2 } from "@blueprintjs/select";
import { SETTINGS } from "@macrostrat-web/settings";
import {
FeatureProperties,
FloatingNavbar,
LocationPanel,
MapAreaContainer,
MapLoadingButton,
MapMarker,
MapView,
PanelCard,
buildInspectorStyle,
} from "@macrostrat/map-interface";
import { useMapRef } from "@macrostrat/mapbox-react";
import { buildMacrostratStyle } from "@macrostrat/mapbox-styles";
import { mergeStyles } from "@macrostrat/mapbox-utils";
import {
DarkModeButton,
Spacer,
useAPIResult,
useDarkMode,
} from "@macrostrat/ui-components";
import mapboxgl from "mapbox-gl";
import { useCallback, useEffect, useState } from "react";


export function Page() {
return h(
"div.rockdcheckins-page",
h(RockdCheckinsMap, { mapboxToken: SETTINGS.mapboxAccessToken })
);
}

mapboxgl.accessToken = SETTINGS.mapboxAccessToken;

const _macrostratStyle = buildMacrostratStyle({
tileserverDomain: SETTINGS.burwellTileDomain,
fillOpacity: 0.3,
strokeOpacity: 0.1,
}) as mapboxgl.Style;

const types = [
{
id: "MineralResourceSite",
name: "Mineral Resource Site",
color: "dodgerblue",
},
{ id: "AgeSpectrum", name: "Detrital Zircon Age Spectrum", color: "red" },
{
id: "Sample",
name: "Sample",
color: "purple",
},
];

function rockdcheckinsStyle(type: object) {
const color = type?.color ?? "dodgerblue";
return {
sources: {
weaver: {
type: "vector",
tiles: ['http://localhost:8000/map/checkins/{z}/{x}/{y}'],
},
},
layers: [
{
id: "weaver",
type: "circle",
source: "weaver",
"source-layer": "default",
paint: {
"circle-radius": [
"step",
["get", "n"],
2,
1,
2,
5,
4,
10,
8,
50,
12,
100,
16,
200,
20,
],
"circle-color": color,
"circle-opacity": 0.8,
"circle-stroke-width": 0.5,
"circle-stroke-color": color,
},
},
],
};
}

function FeatureDetails({ position, model_name }) {
const mapRef = useMapRef();
const result = useAPIResult(
"https://dev.macrostrat.org/weaver-api/rpc/nearby_data",
{
x: position.lng,
y: position.lat,
zoom: Math.round(mapRef.current?.getZoom()) ?? 10,
model_name,
}
);

if (result == null) return h(Spinner);

return h(
"div.features",
result.map((f, i) => {
return h(FeatureProperties, { data: f.data, key: i, expandLevel: 1 });
})
);
}

function weaverStyle({
title = "Weaver",
headerElement = null,
mapboxToken,
}: {
headerElement?: React.ReactElement;
title?: string;
children?: React.ReactNode;
mapboxToken?: string;
}) {
/* We apply a custom style to the panel container when we are interacting
with the search bar, so that we can block map interactions until search
bar focus is lost.
We also apply a custom style when the infodrawer is open so we can hide
the search bar on mobile platforms
*/

const [isOpen, setOpen] = useState(false);

const [type, setType] = useState(types[0]);

const style = useMapStyle(type, mapboxToken);

const [inspectPosition, setInspectPosition] =
useState<mapboxgl.LngLat | null>(null);

const onSelectPosition = useCallback((position: mapboxgl.LngLat) => {
setInspectPosition(position);
}, []);

let detailElement = null;
if (inspectPosition != null) {
detailElement = h(
LocationPanel,
{
onClose() {
setInspectPosition(null);
},
position: inspectPosition,
},

h(FeatureDetails, { position: inspectPosition, model_name: type.id })
);
}

return h(
MapAreaContainer,
{
navbar: h(FloatingNavbar, [
headerElement ?? h("h2", title),
h(Spacer),
h(MapLoadingButton, {
active: isOpen,
onClick: () => setOpen(!isOpen),
}),
]),
contextPanel: h(PanelCard, [
h(DarkModeButton, { showText: true, minimal: true }),
h(
Select2,
{
items: types,
itemRenderer: (data, { handleClick, modifiers }) =>
h(MenuItem, {
roleStructure: "listoption",
active: modifiers.active,
disabled: modifiers.disabled,
text: data.name,
//style: { color: d.color },
key: data.id,
onClick() {
handleClick();
},
}),
itemPredicate: (query, item) =>
item.name.toLowerCase().includes(query.toLowerCase()),
onItemSelect: (item) => setType(item),
},
h(Button, {
text: type?.name,
placeholder: "Select type",
rightIcon: "caret-down",
})
),
]),
detailPanel: detailElement,
contextPanelOpen: isOpen,
},
h(MapView, { style, mapboxToken }, [
h(MapMarker, {
position: inspectPosition,
setPosition: onSelectPosition,
}),
])
);
}

function useMapStyle(type, mapboxToken) {
const dark = useDarkMode();
const isEnabled = dark?.isEnabled;

const baseStyle = isEnabled
? "mapbox://styles/mapbox/dark-v10"
: "mapbox://styles/mapbox/light-v10";

const [actualStyle, setActualStyle] = useState(baseStyle);

useEffect(() => {
const overlayStyle = mergeStyles(_macrostratStyle, weaverStyle(type));
buildInspectorStyle(baseStyle, overlayStyle, {
mapboxToken,
inDarkMode: isEnabled,
}).then((s) => {
setActualStyle(s);
});
}, [baseStyle, mapboxToken, isEnabled, type]);
return actualStyle;
}
6 changes: 3 additions & 3 deletions pages/integrations/xdd/types/+Page.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { PostgRESTTableView } from "~/components/legend-table";

import {
ColorCell,
EditableTextArea,
ColorPicker,
//EditableTextArea,
//ColorPicker,
} from "@macrostrat/data-sheet2";
import { asChromaColor } from "@macrostrat/color-utils";
import { LoginButton } from "#/maps/ingestion/components/navbar";
Expand All @@ -17,7 +17,7 @@ const colorField = {
key: "color",
required: false,
transform: (d) => d,
dataEditor: ColorPicker,
//dataEditor: ColorPicker,
valueRenderer: (d) => {
let color = asChromaColor(d);
return color?.name() ?? "";
Expand Down
Loading

0 comments on commit fe6a0e4

Please sign in to comment.