UNPKG

@seasketch/geoprocessing

Version:

Geoprocessing and reporting framework for SeaSketch 2.0

43 lines 1.51 kB
// Zero polygon geometry is generated by functions like clipToGeography in place of creating a null geometry // because libraries like turf and @types/geojson don't really support null geometries completely // using a zero polygon geometry allows us to still calculate metrics like area and overlap // without having to worry about null geometries. This should work out unless we do planning // on null island /** * Returns a zero polygon geometry (three [0,0] coordinates) * @param sketch */ export function zeroPolygon() { return { type: "Polygon", coordinates: [[[0, 0]], [[0, 0]], [[0, 0]]], }; } /** * Given sketch, returns the mutated sketch with a zero polygon geometry (three [0,0] coordinates) * @param sketch */ export function zeroSketch(sketch) { return { ...sketch, geometry: zeroPolygon(), }; } /** * Given sketch array, returns the mutated sketches with a zero polygon geometry (three [0,0] coordinates) * @param sketch */ export function zeroSketchArray(sketches) { return sketches.map((sketch) => zeroSketch(sketch)); } /** * Given sketch collection, returns the mutated collection with all child sketches switched to have zero polygon geometry (three [0,0] coordinates) * @param sketchCollection */ export function zeroSketchCollection(sketchCollection) { return { ...sketchCollection, features: sketchCollection.features.map((sketch) => zeroSketch(sketch)), }; } //# sourceMappingURL=zeroGeometry.js.map