Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
"@deck.gl/core": "^9.2.11",
"@deck.gl/layers": "^9.2.11",
"@deck.gl/mapbox": "^9.2.11",
"@developmentseed/deck.gl-geotiff": "^0.2.0",
"@developmentseed/deck.gl-geotiff": "^0.4.0",
"@devseed-ui/collecticons-chakra": "^4.0.0",
"@duckdb/duckdb-wasm": "^1.32.0",
"@emotion/react": "^11.13.5",
"@geoarrow/deck.gl-layers": "^0.3.0",
"@geoarrow/geoarrow-js": "github:smohiudd/geoarrow-js#feature/wkb",
"@tanstack/react-query": "^5.90.21",
"@tanstack/react-query": "^5.95.2",
"@turf/bbox": "^7.3.4",
"@turf/bbox-polygon": "^7.3.4",
"@turf/boolean-valid": "^7.3.4",
"@turf/helpers": "^7.2.0",
"apache-arrow": "^21.1.0",
"deck.gl": "^9.2.11",
"duckdb-wasm-kit": "^0.1.38",
"geotiff-geokeys-to-proj4": "^2024.4.13",
"maplibre-gl": "^5.20.1",
"lerc": "^4.1.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylebarron I had to add lerc to work around

error during build:
[vite]: Rollup failed to resolve import "lerc" from "/Users/gadomski/Code/developmentseed/stac-map/node_modules/@developmentseed/geotiff/dist/codecs/lerc.js".

Should we make lerc an required dependency on deck.gl-raster? It looks like you tried to lazy-load it...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I was hoping that it would be an optional dependency. I was thinking it should only be lazy loaded if you tried at runtime to load a LERC-compressed image.

I guess we need to either make it a peer dependency or a required dependency? But in my vite examples I don't depend on lerc and it's fine... https://github.com/developmentseed/deck.gl-raster/blob/main/examples/cog-basic/package.json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javascript bundling is a deep mystery to me, but Claude thinks:

Kyle's example works because it's a monorepo and lerc happens to be available via workspace hoisting. It would break the same way if you cloned just the example into a standalone project. The real fix should be @developmentseed/geotiff declaring lerc as an optionalDependency (or peerDependency) so consumers know they need it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense to me.

"maplibre-gl": "^5.21.0",
"next-themes": "^0.4.3",
"react": "^19.2.4",
"react-dom": "^19.2.4",
Expand Down
27 changes: 8 additions & 19 deletions src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import { collectionToFeature, isGlobalBbox } from "@/utils/stac";
import { type DeckProps, Layer } from "@deck.gl/core";
import { GeoJsonLayer } from "@deck.gl/layers";
import { MapboxOverlay } from "@deck.gl/mapbox";
import { COGLayer, MosaicLayer, proj } from "@developmentseed/deck.gl-geotiff";
import {
COGLayer,
epsgResolver,
MosaicLayer,
} from "@developmentseed/deck.gl-geotiff";
import {
GeoArrowPathLayer,
GeoArrowPolygonLayer,
GeoArrowScatterplotLayer,
} from "@geoarrow/deck.gl-layers";
import bbox from "@turf/bbox";
import type { Feature, FeatureCollection } from "geojson";
import { toProj4 } from "geotiff-geokeys-to-proj4";
import "maplibre-gl/dist/maplibre-gl.css";
import { type RefObject, useEffect, useMemo, useRef, useState } from "react";
import {
Expand Down Expand Up @@ -225,7 +228,7 @@ export default function Map() {
new COGLayer({
id: "cog-" + cogHref,
geotiff: cogHref,
geoKeysParser,
epsgResolver,
})
);
else if (visualizeItems && pagedCogSources && projection === "mercator")
Expand All @@ -242,7 +245,7 @@ export default function Map() {
return new COGLayer({
id: `cog-${source.id}`,
geotiff: data,
geoKeysParser,
epsgResolver,
signal,
});
},
Expand All @@ -261,7 +264,7 @@ export default function Map() {
return new COGLayer({
id: `cog-${source.id}`,
geotiff: data,
geoKeysParser,
epsgResolver,
signal,
});
},
Expand Down Expand Up @@ -357,17 +360,3 @@ function toGeoJson(value: StacValue) {
return value as FeatureCollection;
}
}

async function geoKeysParser(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
geoKeys: Record<string, any>
): Promise<proj.ProjectionInfo> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const projDefinition = toProj4(geoKeys as any);

return {
def: projDefinition.proj4,
parsed: proj.parseCrs(projDefinition.proj4),
coordinatesUnits: projDefinition.coordinatesUnits as proj.SupportedCrsUnit,
};
}
5 changes: 3 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";
import wasm from "vite-plugin-wasm";
import tsconfigPaths from "vite-tsconfig-paths";

// https://vite.dev/config/
export default defineConfig({
base: process.env.VITE_BASE_PATH || "/stac-map/",
worker: {
format: "es",
},
plugins: [
react(),
tsconfigPaths(),
wasm(),
topLevelAwait(),
nodePolyfills({
include: ["buffer"],
}),
Expand Down
Loading