LERC for iOS
v4.2.0iOSLERC 4.2.0 for React Native apps on iOS, precompiled for arm64 devices and simulators as @crossbind/port-lerc-ios.
npm install @crossbind/port-lerc-ios@betaInstall
The whole flow, including Expo, is in the React Native playbook.
Usage
The examples the WebAssembly page runs, as iOS compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Compress heights to within 1 cm
LERC's main job: lerc_encode stores a float raster so that no value moves by more than the error you allow, and lerc_decode reads it back. The example checks the bound on every one of the 65,536 heights.
LERC 4.2.0: 262144 B of float32 heights -> 94775 B largest error 0.0099 m, within 1 cm: true
Read a blob's header without decoding it
lerc_getBlobInfo answers from the header alone: size, data type, bands, valid pixels, the value range and the largest error the encoder allowed. A tile viewer uses it to size its buffers, or to skip an empty tile, before decoding. The blob comes from the codec in the first example, which asks for one float32 step less than 10 cm.
Lerc2 v6: 256x256, 1 band of float32, 65536 valid pixels, 67591 B heights 1032.268 to 1500.945 m, stored within 0.099878 m
Keep integer data exact
Class maps and sensor counts must not change at all. With a maxZError of 0, LERC stores integers exactly (it raises 0 to 0.5, which rounds back to the same whole number) and float32 bit for bit. Here, a 12-bit sensor band in 16-bit pixels.
uint16, 256x256: 131072 B -> 59091 B identical: true
Leave out pixels that have no data
Rasters mark gaps with a NoData value such as -9999. Stored as a height, it stretches the value range of every block it lands in. Passed as the validity mask (pValidBytes in lerc_encode and lerc_decode), it costs at most a bit per pixel, and decoding hands the mask back.
-9999 stored as a height: 147759 B -9999 as missing pixels: 98308 B 1273 gaps come back as -9999, largest error elsewhere 0.0099 m
What is different on iOS
pod installcompiles your headers with the library through the plugin's podspec, and the app build links the result.- Named imports from
./native/<header>.hwork as on the web:await initNative()once, then call the classes. - There is no
m.FSand no/memfs: files live in the app's own storage, and your C++ takes their paths. - No Worker and no COOP or COEP:
runtime: 'mt'uses pthreads directly.
Other platforms
- LERC overview: the apps, every platform's setup and the packages.
- LERC for WebAssembly: browsers, Node.js and edge runtimes.
- LERC for Android: React Native apps on Android.
- LERC for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.