@cereusdb/global
v0.1.0
Published
Global CereusDB browser package with GEOS, PROJ, and S2 geography support
Maintainers
Readme
@cereusdb/global
Global CereusDB browser package. Everything in @cereusdb/standard, plus the opt-in S2 geography kernel family for spherical lon/lat geography operations.
Install
npm install @cereusdb/globalSQL function availability
Current runtime surface:
132runtimeST_*names0runtimeRS_*names
Included function families:
- Everything from
@cereusdb/standard: core SedonaDB functions,geofunctions, GEOS predicates/operations,ST_Transform, relation joins, distance joins, andST_KNN. - S2 geography kernels and the S2-backed
sd_orderoverride for lon/lat geography values.
Examples of S2-enabled geography functions:
ST_AreaST_DistanceST_LengthST_PerimeterST_ContainsST_IntersectsST_EqualsST_IntersectionST_DifferenceST_UnionST_SymDifferenceST_ConvexHullST_CentroidST_ClosestPointST_LineInterpolatePointST_LineLocatePointST_MaxDistanceST_ShortestLine
Not included in this package:
- Raster
RS_*functions
JS / TS API
Exports:
CereusDBCereusDBOptionsRasterFormatQueryResult
Main types:
type RasterFormat = 'geotiff' | 'tiff';
interface CereusDBOptions {
wasmUrl?: string;
wasmSource?:
| RequestInfo
| URL
| Response
| BufferSource
| WebAssembly.Module
| Promise<Response>;
}Main API:
class CereusDB {
static create(options?: CereusDBOptions): Promise<CereusDB>;
sql(query: string): Promise<Uint8Array>;
sqlJSON(query: string): Promise<Record<string, unknown>[]>;
registerRemoteParquet(name: string, url: string): Promise<void>;
registerFile(name: string, file: File): Promise<void>;
registerGeoJSON(name: string, geojson: string | object): void;
registerRaster(name: string, data: BufferSource, format: RasterFormat): void;
registerGeoTIFF(name: string, data: BufferSource): void;
dropTable(name: string): void;
tables(): string[];
version(): string;
}API notes:
sql()returns Arrow IPC bytes asUint8Array.sqlJSON()returns parsed JSON rows.registerFile()supports.parquet,.geoparquet,.geojson, and.jsonin this package.registerRaster()andregisterGeoTIFF()are part of the shared wrapper, but raster registration requires@cereusdb/full.
Example
import { CereusDB } from '@cereusdb/global';
const db = await CereusDB.create();
const rows = await db.sqlJSON(`
SELECT ST_Distance(
ST_GeogFromWKT('POINT(0 0)'),
ST_GeogFromWKT('POINT(1 0)')
) AS meters
`);
console.log(rows);