Skip to content

Commit

Permalink
Added Typescript declaration file (index.d.ts)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugra9 committed Mar 28, 2022
1 parent caf27a7 commit 492c5d0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
],
"files": [
"dist/package/gdal3WebAssembly.data",
"dist/package/gdal3WebAssembly.wasm"
"dist/package/gdal3WebAssembly.wasm",
"dist/package/gdal3.dev.js",
"src",
"build/package/gdal3WebAssembly.js"
],
"main": "dist/package/gdal3.js",
"types": "src/index.d.ts",
"scripts": {
"lint": "eslint .",
"build": "yarn run build-native && yarn run build-src && yarn run build-spec && yarn run build-gui && yarn run build-docs",
Expand Down
69 changes: 69 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
interface FileInfo {
path: string;
size: number;
}

interface FilePath {
local: string;
real: string;
}

interface Dataset {
pointer: number;
path: string;
type: string;
}

interface DatasetList {
datasets: Array<Dataset>;
errors: Array<string>;
}

interface Layer {
name: string;
featureCount: number;
}

interface DatasetInfo {
type: string;
dsName: string;
driverName: string;
bandCount?: number;
width?: number;
height?: number;
projectionWkt?: string;
coordinateTransform?: Array<number>;
corners?: Array<Array<number>>;
layerCount?: number;
featureCount?: number;
layers?: Array<Layer>;
}

interface Drivers {
raster: Object;
vector: Object;
}

interface Gdal {
ogr2ogr(dataset: Dataset, options: Array<string>): Promise<FilePath>;
gdal_translate(dataset: Dataset, options: Array<string>): Promise<FilePath>;
gdal_rasterize(dataset: Dataset, options: Array<string>): Promise<FilePath>;
gdalwarp(dataset: Dataset, options: Array<string>): Promise<FilePath>;
gdaltransform(coords: Array<Array<number>>, options: Array<string>): Promise<Array<Array<number>>>;
open(fileOrFiles: FileList|File|Array<string>|string): Promise<DatasetList>;
close(dataset: Dataset): Promise<void>;
getInfo(dataset: Dataset): Promise<DatasetInfo>;
getOutputFiles(): Promise<Array<FileInfo>>;
getFileBytes(filePath: string|FilePath): Promise<Uint8Array>;
drivers: Drivers;
}

interface Config {
path?: string;
dest?: string;
useWorker?: boolean;
}

declare module 'gdal3.js' {
export default function initGdalJs(config?: Config): Promise<Gdal>;
}

0 comments on commit 492c5d0

Please sign in to comment.