Skip to content

Commit

Permalink
Merge pull request #124 from UW-Macrostrat/map-interface-updates
Browse files Browse the repository at this point in the history
Map interface updates
  • Loading branch information
davenquinn authored Jan 22, 2024
2 parents c43f3e1 + 1200bc0 commit 725bccb
Show file tree
Hide file tree
Showing 47 changed files with 631 additions and 663 deletions.
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build": "vite build",
"server": "node --env-file=.env ./server/index.js",
"server:dev": "yarn run server",
"server:prod": "cross-env NODE_ENV=production npm run server"
"server:prod": "NODE_ENV=production npm run server"
},
"workspaces": [
"deps/web-components/packages/*",
Expand Down Expand Up @@ -53,6 +53,7 @@
"@macrostrat-web/data-sheet-test": "workspace:*",
"@macrostrat-web/globe": "workspace:*",
"@macrostrat-web/security": "workspace:*",
"@macrostrat-web/settings": "workspace:*",
"@macrostrat/api-utils": "workspace:*",
"@macrostrat/api-views": "workspace:*",
"@macrostrat/column-components": "workspace:*",
Expand All @@ -65,9 +66,6 @@
"@macrostrat/style-system": "workspace:*",
"@macrostrat/timescale": "workspace:*",
"@macrostrat/ui-components": "workspace:*",
"@mapbox/point-geometry": "^0.1.0",
"@mapbox/tilebelt": "^1.0.2",
"@mapbox/vector-tile": "^1.3.1",
"@turf/bbox": "^6.5.0",
"@turf/boolean-contains": "^6.5.0",
"@turf/buffer": "^6.5.0",
Expand All @@ -88,25 +86,20 @@
"classnames": "^2.2.6",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"cross-env": "^7.0.3",
"d3-array": "^3.1.1",
"d3-axis": "^3.0.0",
"d3-format": "^1.4.4",
"d3-geo": "^3.0.1",
"d3-scale": "^4.0.2",
"d3-selection": "^1.0.0",
"d3-shape": "^3.2.0",
"esprima": "^4.0.1",
"express": "^4.18.2",
"history": "^5.3.0",
"immutability-helper": "^3.1.1",
"jose": "^5.1.2",
"mapbox-gl": "^2.15.0",
"new-github-issue-url": "^1.0.0",
"pbf": "^3.2.1",
"prop-types": "^15.6.0",
"react": "^18.2.0",
"react-animate-height": "^0.10.9",
"react-cookie": "^3.0.4",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.4.3",
Expand All @@ -122,7 +115,6 @@
"supports-color": "^9.4.0",
"topojson-client": "^3.0.0",
"transition-hook": "^1.5.2",
"ts-node": "^10.9.1",
"use-debounce": "^9.0.4",
"use-react-router-breadcrumbs": "^3.2.1",
"use-resize-observer": "^9.1.0",
Expand Down
31 changes: 14 additions & 17 deletions packages/globe-dev/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import h from "@macrostrat/hyper";
import CesiumView from "./cesium-view";
import { MapPosition } from "@macrostrat/mapbox-utils";
import { useState, useMemo, useRef, useEffect, useCallback, memo } from "react";
import {
flyToParams,
ViewInfo,
translateCameraPosition,
getInitialPosition,
buildPositionHash,
CameraParams,
DisplayQuality,
flyToParams,
translateCameraPosition,
} from "@macrostrat/cesium-viewer";
import h from "@macrostrat/hyper";
import { MapPosition } from "@macrostrat/mapbox-utils";
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Link } from "~/renderer/Link";
import CesiumView from "./cesium-view";

import "./app.scss";
import "cesium/Source/Widgets/widgets.css";
import "@znemz/cesium-navigation/dist/index.css";
import {
applyMapPositionToHash,
getMapPositionForHash,
} from "@macrostrat/map-interface";
import {
buildQueryString,
getHashString,
setHashString,
buildQueryString,
} from "@macrostrat/ui-components";
import "@znemz/cesium-navigation/dist/index.css";
import "cesium/Source/Widgets/widgets.css";
import "./app.scss";
import Map from "./map-comparison";
import {
getMapPositionForHash,
applyMapPositionToHash,
} from "../../../src/pages/map/map-interface/app-state/reducers/hash-string";

function VisControl({ show, setShown, name }) {
const className = show ? "active" : "";
Expand Down
47 changes: 47 additions & 0 deletions packages/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export const darkMapURL =
"mapbox://styles/jczaplewski/cl5uoqzzq003614o6url9ou9z?optimize=true";
export const baseMapURL =
"mapbox://styles/jczaplewski/clatdbkw4002q14lov8zx0bm0?optimize=true";
export const satelliteMapURL =
"mapbox://styles/jczaplewski/cl51esfdm000e14mq51erype3?optimize=true";
// TODO: make these configurable with environment variables
// burwellTileDomain:
// window.location.hostname === "localhost"
// ? "https://tiles.macrostrat.org"
// : window.location.hostname === "dev.macrostrat.org"
// ? "https://devtiles.macrostrat.org"
// : "https://tiles.macrostrat.org",
// apiDomain:
// window.location.hostname === "localhost"
// ? "https://dev.macrostrat.org"
// : `https://${window.location.hostname}`,
// burwellTileDomain: "https://devtiles.macrostrat.org",
// apiDomain: "https://dev.macrostrat.org",
export const burwellTileDomain = import.meta.env
.VITE_MACROSTRAT_TILESERVER_DOMAIN;
export const apiDomain = import.meta.env.VITE_MACROSTRAT_API_DOMAIN;
export const gddDomain = "https://xdd.wisc.edu";
export const pbdbDomain = "https://paleobiodb.org";
export const mapboxAccessToken = import.meta.env.VITE_MAPBOX_API_TOKEN;

export const apiV2Prefix =
import.meta.env.VITE_MACROSTRAT_API_V2 ?? apiDomain + "/api/v2";

export const mapPagePrefix = "/map";

export const routerBasename = import.meta.env.BASE_URL + "map";

/** Legacy settings object */
export const SETTINGS = {
darkMapURL,
baseMapURL,
satelliteMapURL,
burwellTileDomain,
apiDomain,
gddDomain,
pbdbDomain,
mapboxAccessToken,
apiV2Prefix,
mapPagePrefix,
routerBasename,
};
5 changes: 5 additions & 0 deletions packages/settings/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@macrostrat-web/settings",
"version": "1.0.0",
"source": "index.ts"
}
14 changes: 7 additions & 7 deletions src/_legacy/map-dev/map-layers/catalog.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Map layer catalog
import hyper from "@macrostrat/hyper";

import { Routes, Route, Link, useParams } from "react-router-dom";
import styles from "../main.module.styl";
import { useAPIResult, ErrorBoundary } from "@macrostrat/ui-components";
import { ParentRouteButton } from "~/components/map-navbar";
import { SETTINGS } from "~/settings";
import { Spinner } from "@blueprintjs/core";
import { burwellTileDomain } from "@macrostrat-web/settings";
import { ErrorBoundary, useAPIResult } from "@macrostrat/ui-components";
import { Link, Route, Routes, useParams } from "react-router-dom";
import { ParentRouteButton } from "~/components/map-navbar";
import { BasicLayerInspectorPage } from ".";
import styles from "../main.module.styl";

const h = hyper.styled(styles);

Expand Down Expand Up @@ -40,7 +40,7 @@ function MapLayerCatalogPage() {

function MapLayerCatalogList() {
// A route for each layer
const url = SETTINGS.burwellTileDomain + "/tables.json";
const url = burwellTileDomain + "/tables.json";
const layers = useAPIResult(url);

if (layers == null) {
Expand All @@ -64,7 +64,7 @@ function MapLayerCatalogItem({ layer }) {
function MapLayerPage() {
const { layer } = useParams();
// get path from URL
const url = SETTINGS.burwellTileDomain + "/table/" + layer + ".json";
const url = burwellTileDomain + "/table/" + layer + ".json";
const layerDef = useAPIResult(url);
if (layerDef == null) {
return h("div", [h(BackButton), h("div.loading", h(Spinner))]);
Expand Down
61 changes: 32 additions & 29 deletions src/_legacy/map-dev/map-layers/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
// Import other components
import { Spinner, Switch } from "@blueprintjs/core";
import { Switch } from "@blueprintjs/core";
import { burwellTileDomain, mapboxAccessToken } from "@macrostrat-web/settings";
import hyper from "@macrostrat/hyper";
import { useMapConditionalStyle, useMapRef } from "@macrostrat/mapbox-react";
import {
DevMapPage,
FeaturePanel,
FeatureSelectionHandler,
FloatingNavbar,
LocationPanel,
MapLoadingButton,
MapMarker,
MapView,
TileExtentLayer,
TileInfo,
} from "@macrostrat/map-interface";
import {
useMapConditionalStyle,
useMapRef,
useMapStatus,
} from "@macrostrat/mapbox-react";
import {
buildBasicStyle,
buildMacrostratStyle,
toggleLineSymbols,
} from "@macrostrat/mapbox-styles";
import {
getMapboxStyle,
mergeStyles,
removeMapLabels,
setMapPosition,
} from "@macrostrat/mapbox-utils";
import { useStoredState, useDarkMode } from "@macrostrat/ui-components";
import { useDarkMode, useStoredState } from "@macrostrat/ui-components";
import mapboxgl from "mapbox-gl";
import { useCallback, useEffect, useState, useMemo } from "react";
import { SETTINGS } from "~/settings";
import { FloatingNavbar } from "@macrostrat/map-interface";
import { useCallback, useMemo, useState } from "react";
import { ParentRouteButton } from "~/components/map-navbar";
import { useAppActions } from "../../../pages/map/map-interface/app-state";
import { LocationPanel } from "@macrostrat/map-interface";
import { MapAreaContainer } from "../../../pages/map/map-interface/map-page";
import { PanelCard } from "../../../pages/map/map-interface/map-page/menu";
import { getBaseMapStyle } from "../../../pages/map/map-interface/map-page/map-view";
import { MapLoadingButton } from "@macrostrat/map-interface";
import {
toggleLineSymbols,
buildMacrostratStyle,
buildBasicStyle,
} from "@macrostrat/mapbox-styles";
import { MapView, MapMarker } from "@macrostrat/map-interface";
import {
FeaturePanel,
FeatureSelectionHandler,
TileInfo,
} from "@macrostrat/map-interface";
import { TileExtentLayer } from "@macrostrat/map-interface";
import { useMapStatus } from "@macrostrat/mapbox-react";
import { PanelCard } from "../../../pages/map/map-interface/map-page/menu";
import styles from "../main.module.styl";
import { useMapStyle } from "./utils";
import { DevMapPage } from "@macrostrat/map-interface";
import { ParentRouteButton } from "~/components/map-navbar";

export enum MacrostratVectorTileset {
Carto = "carto",
Expand All @@ -52,7 +55,7 @@ export enum MacrostratRasterTileset {
export const h = hyper.styled(styles);

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

function isStateValid(state) {
Expand Down Expand Up @@ -104,7 +107,7 @@ export function VectorMapInspectorPage({
if (
bypassCache &&
resourceType === "Tile" &&
url.startsWith(SETTINGS.burwellTileDomain)
url.startsWith(burwellTileDomain)
) {
return {
url: url + "?cache=bypass",
Expand Down Expand Up @@ -143,7 +146,7 @@ export function VectorMapInspectorPage({
DevMapPage,
{
headerElement,
mapboxToken: SETTINGS.mapboxAccessToken,
mapboxToken: mapboxAccessToken,
title: title ?? tileset,
overlayStyle: _overlayStyle,
transformRequest,
Expand Down Expand Up @@ -397,5 +400,5 @@ function LineSymbolManager({ showLineSymbols }) {
return null;
}

export * from "./raster-map";
export * from "./catalog";
export * from "./raster-map";
15 changes: 0 additions & 15 deletions src/index.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Typings for import.meta.env
import "vite/client";
2 changes: 1 addition & 1 deletion src/pages/column/@id/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apiV2Prefix } from "@macrostrat-web/settings";
import fetch from "node-fetch";
import { apiV2Prefix } from "~/settings";

const apiAddress = apiV2Prefix + "/units";

Expand Down
Loading

0 comments on commit 725bccb

Please sign in to comment.