-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating branch with changes from main
- Loading branch information
1 parent
d207307
commit fe6a0e4
Showing
13 changed files
with
269 additions
and
35,993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
nodejs 20.7.0 | ||
python 3.11 |
Submodule cesium-martini
updated
from 88779c to 1ebd4e
Submodule web-components
updated
from 0314f1 to 368978
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.