Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript definitions #183

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 45 additions & 27 deletions src/geoblaze.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import { Point, Polygon, Feature, BBox } from "geojson";

/** Migrate to georaster library */
export class GeoRaster {
constructor(
data: object | string | Buffer | ArrayBuffer | number[][],
metadata: any,
debug: any
);
export interface Georaster {
twelch marked this conversation as resolved.
Show resolved Hide resolved
/** array of raster bands, each of which is a 2D array of cell values */
values: number[][][];
/** raster height in units of projection */
height: number;
/** raster width in units of projection */
width: number;
/** raster height in pixels */
pixelHeight: number;
/** raster width in pixels */
pixelWidth: number;
/** Projection identifier */
projection: unknown;
twelch marked this conversation as resolved.
Show resolved Hide resolved
/** left boundary, in units of projection*/
xmin: number;
/** right boundary, in units of projection */
xmax: number;
/** top boundary (image y-axis is inverse of cartesian), in units of projection */
ymin: number;
/** bottom boundary (image y-axis is inverse of cartesian), in units of projection */
ymax: number;
/** cell value representing "no data" in raster */
noDataValue: number;
/** number of bands in raster */
numberOfRasters: number;
}

export type GeoblazeBBox = {
Expand All @@ -31,62 +49,62 @@ export type InputPoint = number[] | Point | Feature<Point>;
export type InputBBox = BBox | GeoblazeBBox;

export function bandArithmetic(
raster: GeoRaster,
raster: Georaster,
operation: string
): Promise<GeoRaster>;
): Promise<Georaster>;

export function get(
raster: GeoRaster,
raster: Georaster,
geom: InputBBox | null | undefined,
flat: boolean
): Promise<GeoRaster>;
): Promise<Georaster>;

// Done
export function histogram(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null | undefined,
options: HistogramOptions
): Histogram[];

export function identify(
raster: GeoRaster,
raster: Georaster,
geom?: string | InputPoint | null
): number[];

export function load(urlOrFile: object | string): Promise<GeoRaster>;
export function load(urlOrFile: object | string): Promise<Georaster>;

export function max(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null
): Promise<GeoRaster>;
): Promise<Georaster>;

export function mean(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null
): Promise<GeoRaster>;
): Promise<Georaster>;

export function median(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null
): Promise<GeoRaster>;
): Promise<Georaster>;

export function min(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null
): Promise<GeoRaster>;
): Promise<Georaster>;

export function mode(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null
): Promise<GeoRaster>;
): Promise<Georaster>;

export function rasterCalculator(
raster: GeoRaster,
raster: Georaster,
operation: (() => unknown) | string
): GeoRaster;
): Georaster;

export function sum(
raster: GeoRaster,
raster: Georaster,
geom: string | InputPolygon | null,
test?: (cellValue: unknown) => boolean,
debug?: boolean
Expand Down