oxigdal-wasm
WebAssembly bindings for OxiGDAL - geospatial processing in the browser.
Overview
oxigdal-wasm enables client-side geospatial processing in the browser:
- COG Viewer - Display Cloud Optimized GeoTIFFs without a backend
- Tile Caching - LRU cache for optimal performance
- Web Workers - Parallel tile loading
- Image Processing - Contrast enhancement, color manipulation
- Zero Server - All processing happens client-side
Features
- ✅ Browser-based COG viewing
- ✅ HTTP range request support
- ✅ Tile pyramid navigation
- ✅ Viewport management (pan/zoom)
- ✅ Image enhancement
- ✅ Statistics computation
- ✅ GeoJSON export
Building
# Install wasm-pack
|
# Build
Installation (when published)
Quick Start
Basic COG Viewing
COG Viewer
Advanced Viewer with Caching
import from './pkg/oxigdal_wasm.js';
const viewer = ;
// Open with 50MB cache
await viewer.;
// Set viewport
viewer.;
viewer.;
// Pan and zoom
viewer.;
viewer.;
// Read with caching
const imageData = await viewer.;
// Check cache stats
const stats = JSON.;
console.log;
Interactive Map
// Usage
const map = ;
await map.;
Image Enhancement
// Read tile with contrast enhancement
const imageData = await viewer.;
// Compute statistics
const stats = JSON.;
console.log;
// Compute histogram
const hist = JSON.;
Batch Tile Loading
import from './pkg/oxigdal_wasm.js';
const loader = ; // 4 parallel requests
await loader.;
const coords = ;
const results = await loader.;
results.;
Web Workers
import from './pkg/oxigdal_wasm.js';
const pool = ;
await pool.;
await pool.;
const tasks = ;
const results = await Promise.;
pool.;
API Reference
WasmCogViewer
Basic COG viewer:
open(url)- Open a COG filewidth()- Get image widthheight()- Get image heighttile_width()- Get tile widthtile_height()- Get tile heightband_count()- Get number of bandsoverview_count()- Get number of overviewsepsg_code()- Get EPSG coderead_tile(level, x, y)- Read tile bytesread_tile_as_image_data(level, x, y)- Read as ImageData
AdvancedCogViewer
Advanced viewer with caching and viewport:
open(url, cache_size_mb)- Open with cachesetViewportSize(width, height)- Set viewportfitToImage()- Fit viewport to imagepan(dx, dy)- Pan viewportzoomIn()/zoomOut()- Zoom controlssetZoom(level)- Set zoom levelreadTileAsImageData(level, x, y)- Read with cachereadTileWithContrast(level, x, y, method)- Read with enhancementcomputeStats(level, x, y)- Compute statisticsgetCacheStats()- Get cache statisticsclearCache()- Clear cache
Demo Application
A complete COG viewer demo is available in demo/cog-viewer/:
Browser Support
| Browser | Minimum Version |
|---|---|
| Chrome | 87+ |
| Firefox | 89+ |
| Safari | 15+ |
| Edge | 87+ |
Requires WebAssembly, ES6 modules, and Fetch API.
Performance Tips
- Enable caching - Use AdvancedCogViewer with appropriate cache size
- Use overviews - Read from appropriate zoom level
- Batch requests - Use BatchTileLoader for parallel fetching
- Prefetch - Set prefetch strategy for smoother navigation
- Web Workers - Offload processing to background threads
COOLJAPAN Policies
- ✅ Pure Rust (compiles to WASM)
- ✅ No unwrap() - Safe error handling
- ✅ Zero external dependencies
- ✅ Production ready
License
Licensed under Apache-2.0.
Copyright © 2025 COOLJAPAN OU (Team Kitasan)