@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
39 lines (34 loc) • 826 B
text/typescript
import {
Sketch,
SketchCollection,
Polygon,
MultiPolygon,
GeoprocessingHandler,
} from "@seasketch/geoprocessing";
import { area } from "@turf/turf";
export interface SimpleResults {
/** area of sketch within geography in square meters */
area: number;
}
/**
* Simple geoprocessing function with custom result payload
*/
async function simpleFunction(
sketch:
| Sketch<Polygon | MultiPolygon>
| SketchCollection<Polygon | MultiPolygon>,
): Promise<SimpleResults> {
// Add analysis code
const sketchArea = area(sketch);
// Custom return type
return {
area: sketchArea,
};
}
export default new GeoprocessingHandler(simpleFunction, {
title: "simpleFunction",
description: "Function description",
timeout: 60, // seconds
memory: 1024, // megabytes
executionMode: "async",
});