Skip to content

Commit 860a701

Browse files
authored
feat: Overhaul to use our geotiff package & generic TileMatrixSet support (#208)
This is a really big PR, but unfortunately it really had to be a big PR because we effectively had to change our geotiff reader _and_ our TileMatrixSet traversal at the same time. ### Change list - Fully removes `geotiff.js` as a dependency. We now only use `@developmentseed/geotiff` and the underlying `@cogeotiff/core` for reading data. - The `TileMatrixSetTileset` now accepts an _arbitrary_, _spec-compliant_, OGC TileMatrixSet instance. This will make it much more interoperable. Closes #216. This should make it easier for Lonboard to generate a TMS from async-geotiff, pass the TMS definition to JS, and then have it auto-fetch tiles from Python according to that tiling system. - Removes `GeoTIFFLayer` from our public API for now, since our geotiff implementation doesn't support fetching the entire full-resolution image and stitching tiles together. (And it's probably a candidate to fully remove in the future in favor of `COGLayer`) - Define new projection resolver `epsgResolver`. Our default implementation caches all fetched projections in our `PROJECTION_REGISTRY` (closes #185). But users can easily override this behavior by passing a custom `epsgResolver` - Removes multiple copies of affine handling, ensuring we put all affine transformation handling into `@developmentseed/affine` - Update `cog-basic` example for latest changes. (Other examples haven't been updated yet) `@cogeotiff/core` is _very_ pleasant to use. It's nice to use Typescript Enums instead of hard-coding integer matching. ### Todo - [ ] Ensure request cancellation (needs blacha/cogeotiff#1400 upstream). Should make the deck.gl visualization quite a bit faster. - [ ] Move image decoding onto a thread pool in workers. Closes #216
1 parent cb1106e commit 860a701

48 files changed

Lines changed: 964 additions & 1940 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/cog-basic/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
"@deck.gl/layers": "^9.2.7",
1515
"@deck.gl/mapbox": "^9.2.7",
1616
"@deck.gl/mesh-layers": "^9.2.7",
17+
"@developmentseed/geotiff": "workspace:^",
1718
"@developmentseed/deck.gl-geotiff": "workspace:^",
1819
"@developmentseed/deck.gl-raster": "workspace:^",
1920
"@luma.gl/core": "9.2.6",
2021
"@luma.gl/shadertools": "9.2.6",
21-
"geotiff": "^2.1.3",
22-
"geotiff-geokeys-to-proj4": "^2024.4.13",
2322
"maplibre-gl": "^5.17.0",
2423
"proj4": "^2.20.2",
2524
"react": "^19.2.4",

examples/cog-basic/src/App.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { DeckProps } from "@deck.gl/core";
22
import { MapboxOverlay } from "@deck.gl/mapbox";
3-
import { COGLayer, proj } from "@developmentseed/deck.gl-geotiff";
4-
import { toProj4 } from "geotiff-geokeys-to-proj4";
3+
import { COGLayer } from "@developmentseed/deck.gl-geotiff";
54
import "maplibre-gl/dist/maplibre-gl.css";
65
import { useRef, useState } from "react";
76
import type { MapRef } from "react-map-gl/maplibre";
@@ -13,26 +12,14 @@ function DeckGLOverlay(props: DeckProps) {
1312
return null;
1413
}
1514

16-
async function geoKeysParser(
17-
geoKeys: Record<string, any>,
18-
): Promise<proj.ProjectionInfo> {
19-
const projDefinition = toProj4(geoKeys as any);
20-
21-
return {
22-
def: projDefinition.proj4,
23-
parsed: proj.parseCrs(projDefinition.proj4),
24-
coordinatesUnits: projDefinition.coordinatesUnits as proj.SupportedCrsUnit,
25-
};
26-
}
27-
28-
// const COG_URL =
29-
// "https://nz-imagery.s3-ap-southeast-2.amazonaws.com/new-zealand/new-zealand_2024-2025_10m/rgb/2193/CC11.tiff";
15+
const COG_URL =
16+
"https://nz-imagery.s3-ap-southeast-2.amazonaws.com/new-zealand/new-zealand_2024-2025_10m/rgb/2193/CC11.tiff";
3017

3118
// const COG_URL =
3219
// "https://ds-wheels.s3.us-east-1.amazonaws.com/m_4007307_sw_18_060_20220803.tif";
3320

34-
const COG_URL =
35-
"https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/18/T/WL/2026/1/S2B_18TWL_20260101_0_L2A/TCI.tif";
21+
// const COG_URL =
22+
// "https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/18/T/WL/2026/1/S2B_18TWL_20260101_0_L2A/TCI.tif";
3623
// const COG_URL =
3724
// "https://ds-wheels.s3.us-east-1.amazonaws.com/Annual_NLCD_LndCov_2023_CU_C1V0.tif";
3825

@@ -62,7 +49,6 @@ export default function App() {
6249
geotiff: COG_URL,
6350
debug,
6451
debugOpacity,
65-
geoKeysParser,
6652
onGeoTIFFLoad: (tiff, options) => {
6753
(window as any).tiff = tiff;
6854
const { west, south, east, north } = options.geographicBounds;

packages/affine/src/affine.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export function invert([sa, sb, sc, sd, se, sf]: Affine): Affine {
8181
const rd = -sd * idet;
8282
const re = sa * idet;
8383

84-
return [ra, rb, -sc * ra - sf * rb, rd, re, -sc * rd - sf * re];
84+
// biome-ignore format: array
85+
return [
86+
ra, rb, -sc * ra - sf * rb,
87+
rd, re, -sc * rd - sf * re
88+
];
8589
}
8690

8791
/** Get the 'a' component of an Affine transform. */

packages/deck.gl-geotiff/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@
4646
"vitest": "^4.0.18"
4747
},
4848
"dependencies": {
49+
"@cogeotiff/core": "^9.1.2",
50+
"@developmentseed/affine": "workspace:^",
4951
"@developmentseed/deck.gl-raster": "workspace:^",
52+
"@developmentseed/geotiff": "workspace:^",
53+
"@developmentseed/morecantile": "workspace:^",
5054
"@developmentseed/raster-reproject": "workspace:^",
5155
"flatbush": "^4.5.0",
52-
"geotiff": "2.1.3",
53-
"proj4": "^2.20.2"
56+
"proj4": "^2.20.2",
57+
"wkt-parser": "^1.5.2"
5458
},
5559
"peerDependencies": {
5660
"@deck.gl/core": "^9.2.7",

0 commit comments

Comments
 (0)