Repository navigation
perf(proj): resolve common EPSG codes without a request, share in-flight ones - #760
Merged
Merged
Conversation
…ght ones The default epsgResolver asked epsg.io for every code before a layer could load its first tile, including 4326, 3857 and 4269, which proj4 already knows, and it asked once per caller: the three sources of a MultiCOGLayer or the 112 sources of a mosaic each made their own request for the same code (measured: three parallel 210 ms requests for EPSG:32718 on the sentinel-2 example), because PROJECTION_REGISTRY only fills after the first one resolves. Ship PROJJSON for 4326, 3857 and 4269 (copied from epsg.io) and resolve them from that table, and keep one in-flight promise per code so concurrent callers share a request. A failed request is not cached: the next caller retries. Fixes #211. Co-Authored-By: Claude Fable 5.1 <[email protected]>
kylebarron
commented
Oct 21, 2026
Review follow-up: drop the hard-coded PROJJSON table. proj4 already ships definitions for 4326, 4269, 3857 and every UTM zone; `proj4.defs` says whether it knows a code and `new proj4.Proj(code)` fills in the ellipsoid axes that layers read as `a`. Resolve those without a request. Merge the in-flight map into PROJECTION_REGISTRY by storing promises, so there is one registry; a rejected entry is removed so the next caller retries. Add registerProjection(epsg, wktOrProjjson) for applications that bundle their own definitions. Accept "degrees" (proj4's spelling) in metersPerUnit. proj4 becomes a dependency of @developmentseed/proj. Co-Authored-By: Claude Fable 5.1 <[email protected]>
kylebarron
commented
Oct 21, 2026
kylebarron
commented
Oct 21, 2026
kylebarron
commented
Oct 21, 2026
| "vitest": "^5.0.2" | ||
| }, | ||
| "dependencies": { | ||
| "proj4": "^2.22.0", |
Member
Author
There was a problem hiding this comment.
hmm, originally I was thinking the proj library could be independent of a specific projection library (in case users wanted to use a wasm-based proj or similar in the future) but that's something we could revisit down the line
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This was referenced Oct 22, 2026
kylebarron
added a commit
that referenced
this pull request
Oct 22, 2026
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Bumps `version` to `0.9.0-beta.3` in the root `package.json` and in every `packages/*/package.json`, ready for a third beta release. The publish workflow sees `beta` in the version and publishes to npm under the `beta` dist-tag, so `latest` stays on 0.8.1. `CHANGELOG.md` gets a `v0.9.0-beta.3` section listing the 16 PRs merged since v0.9.0-beta.2. Two of them change the API in ways that break existing code: - #769 renames `CachedTags` to `CachedPrimaryImageTags` in `@developmentseed/geotiff`, and `cachedTags` to `cachedPrimaryImageTags` on `GeoTIFF` and `Overview`. - #760 isn't marked breaking, but `PROJECTION_REGISTRY` in `@developmentseed/proj` now holds `Promise<ProjectionDefinition>` values, so code that sets entries directly should call `registerProjection` instead. `@developmentseed/proj` also depends on proj4 now. Once this is merged, tag the merge commit `v0.9.0-beta.3` and push the tag. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Oct 22, 2026
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. The deck.gl-geotiff quick start doesn't build with a default Vite config. The GeoTIFF decoder worker uses top-level await and dynamic imports, and Vite bundles workers in `iife` format by default, so `vite build` fails: - Vite 8: `Top-level await is currently not supported with the 'iife' output format` - Vite 7: `Invalid value "iife" for option "worker.format" - UMD and IIFE output formats are not supported for code-splitting builds.` `vite dev` doesn't bundle workers, so this only shows up in production builds. Every example sets `worker: { format: "es" }`, but no README mentioned it. ### Changes - **deck.gl-geotiff README:** a "Using Vite" section after the quick start, with the config and both error messages, so searching for either finds it. - **geotiff README:** - The same setting under the worker pool section. - Fixes for three snippets that didn't compile: - `registry` is exported as `DECODER_REGISTRY`. The `pool/worker` doc comment had the same mistake. - `GeoTIFF.open` takes `{ headerSource, dataSource }`. The example now reads the header through the chunked, cached source and tile data straight from HTTP, as `GeoTIFF.fromUrl` does. - `data` exists only on pixel-interleaved arrays, so the example checks `layout` before reading it. - It also finishes a sentence that was cut off, and says a decoder can return decoded pixels as well as bytes. - It links `Decoder` in the API docs instead of `./src/decode.ts`, which 404s on the docs site. - **proj README:** it said the package doesn't depend on proj4, which stopped being true in #760. ### Checked - A Vite app whose `main.ts` is the quick start fails `vite build` on Vite 8.3.5 and 7.3.7 with the default config. With the README's config, copied verbatim, it builds on both and emits the worker chunk. - With `strict` on, every `ts` block in the two READMEs except the Vite config typechecks against this branch's build. Before, three failed: `TS2305` (`registry`), `TS2739` (`GeoTIFF.open`) and `TS2339` (`data`). - The docs site builds, and the three API pages show the new text. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Closes #211
The default
epsgResolverasked epsg.io for every EPSG code before a layer could load its first tile, including codes proj4 already ships, and it asked once per caller:PROJECTION_REGISTRYonly filled after the first request resolved, so the three sources of aMultiCOGLayeror the 112 sources of aMosaicLayereach made their own request for the same code. Measured on the sentinel-2 example: three parallel 210 ms requests for EPSG:32718 before the first tile.Changes in
packages/proj:proj4.defs("EPSG:<code>")says whether proj4 has a definition (4326, 4269, 3857, 900913 and every UTM zone 326xx/327xx), andnew proj4.Proj(code)fills in what the proj string leaves out, such as the ellipsoid axes that the layers read asato size degree units. No hard-coded table; proj4 becomes a dependency of@developmentseed/proj(it was a dev dependency; every consumer already depends on it).PROJECTION_REGISTRYnow holdsPromise<ProjectionDefinition>perEPSG:<code>, so concurrent callers share one in-flight request and there is no second map. A rejected entry is removed, so the next caller retries instead of inheriting the failure.registerProjection(epsg, wktOrProjjson)lets an application bundle its own definitions (WKT or PROJJSON) so the resolver never fetches them. TheepsgResolverprop still allows a fully custom resolver, asland-coveruses with the@developmentseed/epsgdatabase.metersPerUnitaccepts"degrees", proj4's spelling, next to wkt-parser's"degree".Tests (
packages/proj/tests/registry.test.ts)fetchstubbed to throw, exposeunitsandathe way the layers read them, and project a point to within 1 mm of proj4's own code.Part of the October 2026 performance research (
dev-docs/perf-research-2026-10.md, area G1).🤖 Written by Claude Code