@walkthru-earth/objex 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +11 -2
  2. package/dist/components/browser/FileBrowser.svelte +41 -54
  3. package/dist/components/browser/FileTreeSidebar.svelte +43 -7
  4. package/dist/components/layout/ConnectionDialog.svelte +100 -1
  5. package/dist/components/layout/Sidebar.svelte +43 -25
  6. package/dist/components/viewers/CodeViewer.svelte +23 -0
  7. package/dist/components/viewers/CogControls.svelte +208 -0
  8. package/dist/components/viewers/CogControls.svelte.d.ts +12 -0
  9. package/dist/components/viewers/CogViewer.svelte +353 -1160
  10. package/dist/components/viewers/CogViewer.svelte.d.ts +1 -1
  11. package/dist/components/viewers/DatabaseViewer.svelte +345 -37
  12. package/dist/components/viewers/MarkdownViewer.svelte +1 -1
  13. package/dist/components/viewers/TableViewer.svelte +123 -41
  14. package/dist/components/viewers/ZarrMapViewer.svelte +29 -0
  15. package/dist/components/viewers/ZarrViewer.svelte +1 -4
  16. package/dist/constants.d.ts +6 -2
  17. package/dist/constants.js +6 -2
  18. package/dist/file-icons/index.d.ts +1 -1
  19. package/dist/file-icons/index.js +12 -2
  20. package/dist/i18n/ar.js +24 -0
  21. package/dist/i18n/en.js +24 -0
  22. package/dist/i18n/index.svelte.d.ts +0 -1
  23. package/dist/i18n/index.svelte.js +0 -3
  24. package/dist/index.d.ts +11 -0
  25. package/dist/index.js +10 -0
  26. package/dist/query/engine.d.ts +20 -4
  27. package/dist/query/index.d.ts +2 -1
  28. package/dist/query/index.js +1 -0
  29. package/dist/query/source.d.ts +30 -0
  30. package/dist/query/source.js +37 -0
  31. package/dist/query/wasm.d.ts +7 -5
  32. package/dist/query/wasm.js +138 -85
  33. package/dist/storage/providers.d.ts +47 -0
  34. package/dist/storage/providers.js +160 -0
  35. package/dist/stores/connections.svelte.js +5 -31
  36. package/dist/stores/files.svelte.d.ts +2 -8
  37. package/dist/stores/files.svelte.js +5 -38
  38. package/dist/stores/query-history.svelte.js +3 -25
  39. package/dist/stores/settings.svelte.d.ts +1 -0
  40. package/dist/stores/settings.svelte.js +10 -30
  41. package/dist/stores/tabs.svelte.d.ts +9 -2
  42. package/dist/stores/tabs.svelte.js +11 -2
  43. package/dist/types.d.ts +11 -0
  44. package/dist/utils/cloud-url.d.ts +27 -0
  45. package/dist/utils/cloud-url.js +61 -0
  46. package/dist/utils/cog.d.ts +244 -0
  47. package/dist/utils/cog.js +1039 -0
  48. package/dist/utils/deck.d.ts +0 -18
  49. package/dist/utils/deck.js +0 -36
  50. package/dist/utils/export.d.ts +22 -2
  51. package/dist/utils/export.js +35 -10
  52. package/dist/utils/file-sort.d.ts +20 -0
  53. package/dist/utils/file-sort.js +41 -0
  54. package/dist/utils/geometry-type.d.ts +52 -0
  55. package/dist/utils/geometry-type.js +76 -0
  56. package/dist/utils/local-storage.d.ts +16 -0
  57. package/dist/utils/local-storage.js +37 -0
  58. package/dist/utils/markdown-sql.d.ts +1 -1
  59. package/dist/utils/markdown-sql.js +3 -4
  60. package/dist/utils/pmtiles-tile.d.ts +0 -2
  61. package/dist/utils/pmtiles-tile.js +0 -8
  62. package/dist/utils/url-state.d.ts +6 -0
  63. package/dist/utils/url-state.js +34 -26
  64. package/dist/utils/url.d.ts +13 -25
  65. package/dist/utils/url.js +17 -78
  66. package/dist/utils/zarr-tab.d.ts +22 -0
  67. package/dist/utils/zarr-tab.js +30 -0
  68. package/dist/utils/zarr.d.ts +0 -2
  69. package/dist/utils/zarr.js +73 -44
  70. package/package.json +50 -46
  71. package/dist/components/ui/tabs/index.d.ts +0 -5
  72. package/dist/components/ui/tabs/index.js +0 -7
  73. package/dist/components/ui/tabs/tabs-content.svelte +0 -17
  74. package/dist/components/ui/tabs/tabs-content.svelte.d.ts +0 -4
  75. package/dist/components/ui/tabs/tabs-list.svelte +0 -16
  76. package/dist/components/ui/tabs/tabs-list.svelte.d.ts +0 -4
  77. package/dist/components/ui/tabs/tabs-trigger.svelte +0 -20
  78. package/dist/components/ui/tabs/tabs-trigger.svelte.d.ts +0 -4
  79. package/dist/components/ui/tabs/tabs.svelte +0 -19
  80. package/dist/components/ui/tabs/tabs.svelte.d.ts +0 -4
  81. package/dist/components/viewers/MapViewer.svelte +0 -234
  82. package/dist/components/viewers/MapViewer.svelte.d.ts +0 -7
  83. package/dist/components/viewers/StyleEditorOverlay.svelte +0 -27
  84. package/dist/components/viewers/StyleEditorOverlay.svelte.d.ts +0 -7
@@ -0,0 +1,244 @@
1
+ import type { GetTileDataOptions, MinimalDataT } from '@developmentseed/deck.gl-geotiff';
2
+ import type { RenderTileResult } from '@developmentseed/deck.gl-raster';
3
+ import type { GeoTIFF as GeoTIFFType, Overview } from '@developmentseed/geotiff';
4
+ import { GeoTIFF } from '@developmentseed/geotiff';
5
+ import type { EpsgResolver } from '@developmentseed/proj';
6
+ import type maplibregl from 'maplibre-gl';
7
+ /** SampleFormat tag value → human label. */
8
+ export declare const SF_LABELS: Record<number, string>;
9
+ export type ColorRampId = 'grayscale' | 'terrain' | 'viridis' | 'magma' | 'turbo' | 'spectral';
10
+ export declare const COLOR_RAMP_STOPS: Record<ColorRampId, [number, number, number][]>;
11
+ /** Interpolate a normalized value (0..1) into an RGB color from a ramp. */
12
+ export declare function interpolateRamp(stops: [number, number, number][], t: number): [number, number, number];
13
+ /** Generate a CSS linear-gradient string for a color ramp. */
14
+ export declare function rampToGradientCss(id: ColorRampId): string;
15
+ export interface BandConfig {
16
+ mode: 'rgb' | 'single';
17
+ /** 0-indexed band indices for RGB channels */
18
+ rBand: number;
19
+ gBand: number;
20
+ bBand: number;
21
+ /** 0-indexed band index for single-band mode */
22
+ band: number;
23
+ colorRamp: ColorRampId;
24
+ }
25
+ /** Create a sensible default band config based on COG metadata. */
26
+ export declare function defaultBandConfig(bandCount: number, sampleFormat: number): BandConfig;
27
+ /** Check if the config matches the default for this COG (no user changes). */
28
+ export declare function isDefaultBandConfig(config: BandConfig, bandCount: number, sampleFormat: number): boolean;
29
+ export interface CogTagInfo {
30
+ /** TIFF SampleFormat[0] value. 1=uint, 2=int, 3=float. Defaults to 1 when absent. */
31
+ sampleFormat: number;
32
+ /** True when SampleFormat[0] === 1 (unsigned integer). */
33
+ isUint: boolean;
34
+ /**
35
+ * True when Photometric === 3 (Palette) and the ColorMap tag is present.
36
+ * These COGs should defer to the library's default Colormap GPU module,
37
+ * not our custom JS pipeline, so the embedded palette renders correctly.
38
+ */
39
+ isPaletteIndexed: boolean;
40
+ }
41
+ /**
42
+ * Inspect the TIFF tags that drive pipeline selection. Centralizes the
43
+ * Photometric.Palette === 3 magic number and the SampleFormat fallback in one
44
+ * place so viewers don't reimplement raw tag reads. Photometric values come
45
+ * from the @cogeotiff/core Photometric enum.
46
+ */
47
+ export declare function inspectCogTags(geotiff: GeoTIFFType): CogTagInfo;
48
+ /**
49
+ * Check if a given band config requires a custom pipeline (vs library default).
50
+ * Library default only works for uint with standard RGB band order, or for
51
+ * palette-indexed uint COGs where the embedded ColorMap tag auto-renders.
52
+ */
53
+ export declare function needsCustomPipelineForConfig(geotiff: GeoTIFFType, config: BandConfig): boolean;
54
+ /**
55
+ * Min/max rescale values applied via the `LinearRescale` shader module. Values
56
+ * are in normalized shader space [0, 1]. Default `{ min: 0, max: 1 }` is a
57
+ * no-op and the library-default pipeline is used as-is.
58
+ */
59
+ export interface RescaleConfig {
60
+ min: number;
61
+ max: number;
62
+ }
63
+ export declare const DEFAULT_RESCALE: RescaleConfig;
64
+ /** True when the rescale values would produce a visible change on the GPU. */
65
+ export declare function isRescaleActive(cfg: RescaleConfig): boolean;
66
+ /**
67
+ * Build a `getTileData` + `renderTile` pair that reuses the library-default
68
+ * uint pipeline (via `inferRenderPipeline`) and appends `LinearRescale` to the
69
+ * returned render pipeline. Only safe to use when the default pipeline would
70
+ * have been chosen anyway, i.e. `needsCustomPipelineForConfig(geotiff, cfg)`
71
+ * is false. For non-uint or custom band configs the custom JS pipeline already
72
+ * bakes RGBA in CPU and a GPU rescale would be cosmetic.
73
+ *
74
+ * `inferRenderPipeline` needs the GPU `Device` which arrives in the first
75
+ * tile's `GetTileDataOptions`, so the pipeline is built lazily on first call.
76
+ */
77
+ export declare function createRescaledPipeline(geotiff: GeoTIFFType, rescale: RescaleConfig): {
78
+ getTileData: (image: GeoTIFFType | Overview, options: GetTileDataOptions) => Promise<MinimalDataT>;
79
+ renderTile: (data: MinimalDataT) => RenderTileResult;
80
+ };
81
+ /**
82
+ * Apply the two upstream-bug workarounds a GeoTIFF needs before being handed
83
+ * to `COGLayer`:
84
+ * 1. Strip oversized overviews (image smaller than tile size). These produce
85
+ * out-of-domain proj4 NaN during pre-flight reprojection.
86
+ * 2. Clamp EPSG:4326 bbox to Web Mercator's safe range. Global 4326 COGs with
87
+ * ±90° extents crash the tile matrix generator.
88
+ *
89
+ * Mutates the GeoTIFF in place. Safe to call repeatedly. Kept out of the
90
+ * Svelte component so MultiCOG/Mosaic can apply the same fix per sub-COG.
91
+ */
92
+ export declare function normalizeCogGeotiff(geotiff: GeoTIFFType): void;
93
+ /**
94
+ * Resolved COGLayer data props. Empty object means "library default pipeline".
95
+ * Spread into `new COGLayer({ ..., ...resolved })` to activate.
96
+ *
97
+ * COGLayer's data-prop types are a discriminated XOR and the four pipelines we
98
+ * dispatch to return different DataT shapes (`CustomTileData`, `MinimalDataT`).
99
+ * Typing this as `Record<string, any>` matches the `customProps` pattern
100
+ * already used at the COGLayer boundary and keeps the dispatch site simple.
101
+ */
102
+ export type ResolvedCogPipeline = Record<string, any>;
103
+ export interface SelectCogPipelineOptions {
104
+ /** Active band/color config, or null/undefined when not yet resolved. */
105
+ bandConfig?: BandConfig | null;
106
+ /** Linear rescale GPU module values. No-op when omitted or at defaults. */
107
+ rescale?: RescaleConfig;
108
+ }
109
+ /**
110
+ * Decide which getTileData/renderTile pair COGLayer should use for a GeoTIFF.
111
+ * Four outcomes, in priority order:
112
+ *
113
+ * 1. Custom configurable (band swap, color ramp) — when bandConfig is active
114
+ * and needsCustomPipelineForConfig is true (non-uint, mode=single, or
115
+ * non-standard RGB band order).
116
+ * 2. Custom non-uint (Int/Float source) — when no bandConfig yet but the
117
+ * GeoTIFF itself forces custom handling.
118
+ * 3. Library default + LinearRescale — uint path is fine AND the user moved
119
+ * the rescale slider away from defaults.
120
+ * 4. Library default — returns `{}`, caller spreads into COGLayer props.
121
+ *
122
+ * Pure dispatch. Kept separate from the Svelte component so MultiCOG/Mosaic
123
+ * viewers can call it per sub-COG without re-implementing the decision tree.
124
+ */
125
+ export declare function selectCogPipeline(geotiff: GeoTIFFType, opts?: SelectCogPipelineOptions): ResolvedCogPipeline;
126
+ export interface GeoBounds {
127
+ west: number;
128
+ south: number;
129
+ east: number;
130
+ north: number;
131
+ }
132
+ export interface CogInfo {
133
+ width: number;
134
+ height: number;
135
+ bandCount: number;
136
+ dataType: string;
137
+ bounds: GeoBounds;
138
+ downsampled?: boolean;
139
+ }
140
+ /** Safely clamp a number to a range, treating NaN/Infinity as the fallback. */
141
+ export declare function safeClamp(v: number, lo: number, hi: number, fallback: number): number;
142
+ /** Clamp geographic bounds to valid MapLibre web-Mercator range. */
143
+ export declare function clampBounds(b: GeoBounds): GeoBounds;
144
+ /**
145
+ * Build a data-type label from GeoTIFF sample format and bits per sample.
146
+ * e.g. "uint8", "float32", "int16"
147
+ */
148
+ export declare function buildDataTypeLabel(sampleFormat: number, bitsPerSample: number): string;
149
+ /**
150
+ * Query the GPU's MAX_TEXTURE_SIZE from MapLibre's WebGL context.
151
+ * Falls back to 4096 (lowest common denominator for mobile GPUs).
152
+ */
153
+ export declare function getMaxTextureSize(map: maplibregl.Map): number;
154
+ /**
155
+ * Fit the map to COG bounds with responsive padding.
156
+ * Uses smaller padding on mobile to zoom in closer, ensuring overviews load
157
+ * properly instead of appearing black at very low zoom levels.
158
+ * After fitting, bumps zoom +2 when the viewport settles at a very low level.
159
+ */
160
+ export declare function fitCogBounds(map: maplibregl.Map, b: GeoBounds): void;
161
+ /** Remove the native bitmap source/layer from the map (idempotent). */
162
+ export declare function cleanupNativeBitmap(map: maplibregl.Map): void;
163
+ /**
164
+ * Render a non-tiled GeoTIFF as a MapLibre native image source (bitmap).
165
+ * Opens the file with @developmentseed/geotiff, reads band 0, normalizes
166
+ * to grayscale RGBA, and adds to the map as a raster layer.
167
+ *
168
+ * Returns CogInfo for the metadata panel.
169
+ */
170
+ export declare function renderNonTiledBitmap(options: {
171
+ url: string;
172
+ map: maplibregl.Map;
173
+ signal: AbortSignal;
174
+ geotiff?: GeoTIFF;
175
+ }): Promise<CogInfo>;
176
+ /** Result type returned by our custom getTileData. */
177
+ export interface CustomTileData {
178
+ imageData: ImageData;
179
+ width: number;
180
+ height: number;
181
+ }
182
+ /**
183
+ * Check whether a GeoTIFF needs a custom render pipeline.
184
+ * v0.3's inferRenderPipeline only supports unsigned integers (SampleFormat 1).
185
+ * Signed int (2) and float (3) need custom getTileData/renderTile.
186
+ */
187
+ export declare function needsCustomPipeline(geotiff: GeoTIFFType): boolean;
188
+ /**
189
+ * Create custom getTileData for non-uint COGs.
190
+ * Reads band 0, normalizes using GDAL statistics / per-tile adaptive stretch,
191
+ * applies terrain color ramp for single-band data.
192
+ */
193
+ export declare function createCustomGetTileData(geotiff: GeoTIFFType): (image: GeoTIFFType | Overview, options: {
194
+ x: number;
195
+ y: number;
196
+ pool: unknown;
197
+ signal?: AbortSignal;
198
+ }) => Promise<CustomTileData>;
199
+ /**
200
+ * Custom renderTile for non-uint COGs.
201
+ * v0.5 RasterLayer requires a RenderTileResult with `image` or `renderPipeline`.
202
+ * We produce an ImageData and pass it through the `image` slot. deck.gl manages
203
+ * the texture lifecycle and prepends a CreateTexture module automatically.
204
+ */
205
+ export declare function customRenderTile(data: CustomTileData): {
206
+ image: ImageData;
207
+ };
208
+ /**
209
+ * Create a configurable getTileData that respects BandConfig.
210
+ * Supports both RGB mode (multi-band → R,G,B) and single-band mode (color ramp).
211
+ */
212
+ export declare function createConfigurableGetTileData(geotiff: GeoTIFFType, config: BandConfig): (image: GeoTIFFType | Overview, options: {
213
+ x: number;
214
+ y: number;
215
+ pool: unknown;
216
+ signal?: AbortSignal;
217
+ }) => Promise<CustomTileData>;
218
+ export interface PixelValue {
219
+ lng: number;
220
+ lat: number;
221
+ values: number[];
222
+ row: number;
223
+ col: number;
224
+ }
225
+ /**
226
+ * Create an async EPSG resolver for `@developmentseed/deck.gl-geotiff`.
227
+ * Looks up the numeric EPSG code in the bundled WKT database and returns the
228
+ * `ProjectionDefinition` produced by `parseWkt`. Throws a clear error when the
229
+ * code is not present in the database.
230
+ */
231
+ export declare function createEpsgResolver(): EpsgResolver;
232
+ /**
233
+ * Resolve a proj4-compatible definition for a CRS read from a GeoTIFF.
234
+ * For numeric EPSG codes this returns the WKT string from the bundled EPSG
235
+ * database, which `proj4()` accepts directly. For ProjJSON it falls back to a
236
+ * JSON string. Returns null for EPSG:4326 (no conversion needed) or when the
237
+ * code is not present in the database.
238
+ */
239
+ export declare function resolveProj4Def(crs: number | unknown, _signal: AbortSignal): Promise<string | null>;
240
+ /**
241
+ * Read pixel values at a given lng/lat from a GeoTIFF.
242
+ * Converts WGS84 → source CRS → pixel coords, fetches the tile, reads all bands.
243
+ */
244
+ export declare function readPixelAtLngLat(geotiff: GeoTIFFType, lng: number, lat: number, proj4Def: string | null, pool: any, signal?: AbortSignal): Promise<PixelValue | null>;