-
Notifications
You must be signed in to change notification settings - Fork 28
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
base: master
Are you sure you want to change the base?
Changes from all commits
5666191
9156484
eda21e5
26993ae
9207c1c
45e1d03
664af2e
9dd5fb8
c180a9a
b89cde9
a1f5b36
f82a531
5fc1962
958810c
77146d7
dd695a5
033c9d1
cfb0771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { Point, Polygon, Feature, BBox } from "geojson"; | ||
import { Georaster } from "georaster"; | ||
|
||
// re-rexport for easy access by downstream user | ||
export { Georaster } from "georaster" | ||
|
||
type GeoblazeBBox = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, could we use |
||
xmin: number; | ||
xmax: number; | ||
ymin: number; | ||
ymax: number; | ||
}; | ||
|
||
interface HistogramOptions { | ||
scaleType: "nominal" | "ratio"; | ||
/** required for ratio scaleType */ | ||
numClasses?: number; | ||
/** required for ratio scaleType */ | ||
classType?: "equal-interval" | "quantile"; | ||
} | ||
|
||
interface Histogram { | ||
[binKey: string]: number; | ||
} | ||
|
||
// Some geoblaze methods accept a geometry, and its accepted in a variety of | ||
// forms. These types group them for easy reuse | ||
type InputPolygon = number[][][] | Polygon | Feature<Polygon>; | ||
type InputPoint = number[] | Point | Feature<Point>; | ||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like FeatureCollection is also supported according to https://github.com/GeoTIFF/geoblaze/blob/master/src/utils/utils.module.js#L236. Not documented clearly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
type InputBBox = BBox | GeoblazeBBox; | ||
|
||
export const bandArithmetic: ( | ||
raster: Georaster, | ||
operation: string | ||
) => Promise<Georaster>; | ||
|
||
export const get: ( | ||
raster: Georaster, | ||
geom: InputBBox | null | undefined, | ||
flat: boolean | ||
) => number[][] | number[][][]; | ||
|
||
export const histogram: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined, | ||
options: HistogramOptions | ||
) => Histogram[]; | ||
|
||
export const identify: ( | ||
raster: Georaster, | ||
geom: string | InputPoint | null | undefined | ||
) => number[]; | ||
|
||
export const load: (urlOrFile: object | string) => Promise<Georaster>; | ||
|
||
export const max: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined | ||
) => number[]; | ||
|
||
export const mean: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined | ||
) => number[]; | ||
|
||
export const median: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined | ||
) => number[]; | ||
|
||
export const min: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined | ||
) => number[]; | ||
|
||
export const mode: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined | ||
) => number[]; | ||
|
||
export const rasterCalculator: ( | ||
raster: Georaster, | ||
operation: ((...cellValuesPerBand: number[]) => number) | string | ||
) => Promise<Georaster>; | ||
|
||
export const sum: ( | ||
raster: Georaster, | ||
geom: string | InputPolygon | null | undefined, | ||
test?: (cellValue: number) => boolean, | ||
debug?: boolean | ||
) => number[]; | ||
|
||
// Create typed object matching default export in index.js | ||
declare const defaultExports: { | ||
bandArithmetic: typeof bandArithmetic; | ||
get: typeof get; | ||
histogram: typeof histogram; | ||
identify: typeof identify; | ||
load: typeof load; | ||
max: typeof max; | ||
mean: typeof mean; | ||
median: typeof median; | ||
min: typeof min; | ||
mode: typeof mode; | ||
rasterCalculator: typeof rasterCalculator; | ||
sum: typeof sum; | ||
}; | ||
export default defaultExports; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's super picky (and annoying), but could we use
GeoRaster
instead ofGeoraster
? We've usedGeoraster
before, but I'd like to migrate over to the new spelling. Sorry!