Skip to content
65 changes: 65 additions & 0 deletions pages/dev/map/outcrop/+Page.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import h from "@macrostrat/hyper";

import {
MapAreaContainer,
MapView,
buildInspectorStyle
} from "@macrostrat/map-interface";
import { mapboxAccessToken } from "@macrostrat-web/settings";
import { useEffect, useState } from "react";
import { useDarkMode, FlexRow } from "@macrostrat/ui-components";
import { FullscreenPage } from "~/layouts";
import { MultiSelect } from "@blueprintjs/select"
import { MenuItem, Switch, Divider, Icon } from "@blueprintjs/core";
import { tileserverDomain } from "@macrostrat-web/settings";
import { fetchAPIData, fetchPGData } from "~/_utils";
import { Measurement } from "./measurement";
import { usePageContext } from "vike-react/usePageContext";
import { Loading } from "~/components";
import { buildMacrostratStyle } from "@macrostrat/map-styles";

export function Page() {
return h(FullscreenPage, h(Map))
}

function Map() {



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

if(style == null) return null;

const mapPosition = {
camera: {
lat: 39,
lng: -98,
altitude: 6000000,
},
};


return h(
"div.map-container",
[
// The Map Area Container
h(
MapAreaContainer,
{
className: 'map-area-container',
},
[
h(MapView, {
style,
mapboxToken: mapboxAccessToken,
mapPosition,
}),
]
),
]
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function FeedbackInterface({ data, models, entityTypes, autoSelect, customFeedba
concept: "/lex/strat-concepts",
},
lineHeight: 3,
// view: user === null,
// view: user === null, TODO: Enable view mode for non-logged in users
autoSelect,
onSave: wrapWithToaster(
async (tree) => {
Expand Down
111 changes: 111 additions & 0 deletions pages/lex/legends/+Page.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import h from "./main.module.sass";
import { StickyHeader, LinkCard, PageBreadcrumbs, Footer, BetaTag } from "~/components";
import { ContentPage } from "~/layouts";
import { usePageContext } from "vike-react/usePageContext";
import { PostgRESTInfiniteScrollView } from "@macrostrat/ui-components";
import { postgrestPrefix, apiDomain } from "@macrostrat-web/settings";
import { LithologyTag, FlexRow, ExpansionPanel } from "~/components/lex/tag";

export function Page() {
const url = usePageContext().urlOriginal.split("?")[1];

if (!url) {
return h(Base);
}

const params = getUrlParams(url);
const idType = params.idType;
const id = params[idType];
const color = params.color;
const name = params.name;


return h(ContentPage, [
h(Header, { name, color, idType, id }),
h(FilterData),
]);
}

function Header({ name, color, idType, id }) {
const map = {
'int_id': "intervals",
'lith_id': "lithologies",
'econ_id': "economics",
'environ_id': "environments",
'strat_name_id': "strat-names",
}

return h(StickyHeader, { className: "header" }, [
h(PageBreadcrumbs, {
title: h(FlexRow, { gap: ".5em", alignItems: "center" }, [
h('p.title', 'Legends for '),
h(LithologyTag, { data: { name, color }, href: `/lex/${map[idType]}/${id}` }),
]),
}),
h(BetaTag)
]);
}

function getUrlParams(urlString) {
const params = new URLSearchParams(urlString);
const result = {};

for (const [key, value] of params.entries()) {
result[key] = value;

if (key.toLowerCase().includes('id')) {
result.idType = key;
}
}

return result;
}

function Base() {
return h(ContentPage, { className: 'page' }, [
h(StickyHeader, { className: "header" }, h(PageBreadcrumbs, { title: "Legends" })),
h(PostgRESTInfiniteScrollView, {
route: postgrestPrefix + '/legend_liths',
id_key: 'legend_id',
limit: 20,
itemComponent: LegendItem,
filterable: true,
searchColumns: [{value: "map_unit_name", label: "Map unit name"}],
}),
]);
}

function BaseUnitItem({ data }) {
const { id, col_id, strat_name } = data;

return h(LinkCard, {
href: `/columns/${col_id}#unit=${id}`,
title: strat_name,
})
}

function FilterData() {
const params = usePageContext().urlParsed.href.split("?")[1].split("=")
const id = params[1].split("&")[0]

return h(PostgRESTInfiniteScrollView, {
route: postgrestPrefix + `/legend_liths`,
id_key: "legend_id",
limit: 20,
extraParams: {
lith_ids: `cs.{${id}}`,
},
filterable: true,
searchColumns: [{value: "map_unit_name", label: "Map unit name"}],
itemComponent: LegendItem,
});
}

function LegendItem({ data }) {
const { map_unit_name, legend_id, source_id } = data;

return h(LinkCard, {
href: `/maps/${source_id}?legend_id=${legend_id}`,
title: h("div.title", map_unit_name),
});
}
13 changes: 13 additions & 0 deletions pages/lex/legends/@id/+Page.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import h from "@macrostrat/hyper";
import { usePageContext } from "vike-react/usePageContext";
import { fetchAPIData } from "~/_utils";
import { navigate } from "vike/client/router";

export function Page() {
const unit_id = usePageContext()?.urlPathname.split("/")?.[3] || [];

fetchAPIData("/units", { unit_id })
.then(data => navigate(`/columns/${data[0].col_id}#unit=${unit_id}`))

return null
}
23 changes: 23 additions & 0 deletions pages/lex/legends/main.module.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.title
margin: .5em 0

.page
display: flex
flex-direction: column
gap: 1em

.header
display: flex
justify-content: space-between

.units
margin: 1em 0

.unit-title
display: flex
justify-content: space-between
align-items: center

.count
margin: 0
font-size: 15px
6 changes: 3 additions & 3 deletions pages/lex/lithologies/@id/+Page.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export function Page() {
h(Charts, { features }),
h(PrevalentTaxa, { taxaData }),
h(Timescales, { timescales }),
h(Maps, { mapsData }),
h(TextExtractions, { lith_id: id, href: "autoselect=" + resData?.name + "&lith_id=" + id + "&color=" + resData?.color }),
h.if(fossilsData.features.length > 0)(Fossils, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
h.if(unitsData.length > 0)(Units, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
h.if(unitsData?.length > 0)(Units, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
h.if(mapsData?.length > 0)(Maps, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
h.if(fossilsData?.features.length > 0)(Fossils, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
];

return LexItemPage({ children, id, refs, resData, siftLink: "lithology" });
Expand Down
2 changes: 1 addition & 1 deletion pages/lex/lithologies/@id/+data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function data(pageContext) {
}),
"colData"
),
safeFetch(() => fetchAPIData("/geologic_units/map/legend", { lith_id }), "mapsData"),
safeFetch(() => fetchAPIData("/geologic_units/map/legend", { lith_id, sample: "true" }), "mapsData"),
safeFetch(() => fetchAPIData("/fossils", { lith_id, format: "geojson" }), "fossilsData"),
safeFetch(() => fetchAPIRefs("/fossils", { lith_id }), "refs1"),
safeFetch(() => fetchAPIRefs("/columns", { lith_id }), "refs2"),
Expand Down
6 changes: 3 additions & 3 deletions pages/lex/strat-names/@id/+Page.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export function Page() {
h(Charts, { features }),
h(PrevalentTaxa, { taxaData }),
h(Timescales, { timescales }),
h.if(unitsData.length > 0)(Units, { href: "strat_name_id=" + id + "&name=" + resData?.strat_name }),
h.if(fossilsData.features.length > 0)(Fossils, { href: "strat_name_id=" + id + "&name=" + resData?.name }),
h(Maps, { mapsData }),
h(TextExtractions, {
strat_name_id: id,
href: "autoselect=" + resData?.strat_name_long + "&strat_name_id=" + id,
}),
h.if(unitsData.length > 0)(Units, { href: "strat_name_id=" + id + "&name=" + resData?.strat_name }),
// h.if(mapsData?.length > 0)(Maps, { href: "strat_name_id=" + id + "&name=" + resData?.name }), (add strat names to legends view first)
h.if(fossilsData.features.length > 0)(Fossils, { href: "strat_name_id=" + id + "&name=" + resData?.name }),
h(StratNameHierarchy, { id }),
h(ConceptInfo, { concept_id: resData?.concept_id, showHeader: true }),
];
Expand Down
2 changes: 1 addition & 1 deletion pages/lex/strat-names/@id/+data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function data(pageContext) {
format: "geojson",
}),
fetchAPIData("/fossils", { strat_name_id, format: "geojson" }),
fetchAPIData("/geologic_units/map/legend", { strat_name_id }),
fetchAPIData("/geologic_units/map/legend", { strat_name_id, sample: "true" }),
fetchAPIRefs("/fossils", { strat_name_id }),
fetchAPIRefs("/columns", { strat_name_id }),
fetchAPIData("/units", { strat_name_id }),
Expand Down
2 changes: 1 addition & 1 deletion pages/maps/+Page.ts → pages/maps/+Page.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ function SourceItem({ data }) {
]),
]
);
}
}
4 changes: 4 additions & 0 deletions pages/maps/main.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ h3

.assistant-links
flex: 1

.top-row
display: flex
gap: .5em
Loading