@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
186 lines (171 loc) • 3.4 kB
text/typescript
import {
Polygon,
Sketch,
MultiPolygon,
SketchCollection,
FeatureCollection,
} from "../../types/index.js";
import {
genSampleSketch,
genSampleSketchCollection,
genSampleSketchCollectionFromSketches,
} from "../../helpers/index.js";
/**
* Zero polygon geometry sketch. Generated by functions like clipToGeography in place of creating a null geometry
*/
const zero: Sketch<Polygon> = genSampleSketch({
type: "Polygon",
coordinates: [
[
[],
[],
[],
],
],
});
const outer: Sketch<Polygon> = genSampleSketch({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const bottomLeftPoly: Sketch<Polygon> = genSampleSketch({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const topRightPoly: Sketch<Polygon> = genSampleSketch({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const twoPolyInsideFC: FeatureCollection<MultiPolygon | Polygon> = {
type: "FeatureCollection",
features: [bottomLeftPoly, topRightPoly],
};
const twoPolyInsideSC: SketchCollection<MultiPolygon | Polygon> =
genSampleSketchCollection(twoPolyInsideFC);
const wholePoly: Sketch<Polygon> = genSampleSketch({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const wholeMultipoly: Sketch<MultiPolygon> = genSampleSketch({
type: "MultiPolygon",
coordinates: [
[
[
[],
[],
[],
[],
[],
],
],
],
});
const wholeMixedFC: FeatureCollection<MultiPolygon | Polygon> = {
type: "FeatureCollection",
features: [wholePoly, wholeMultipoly],
};
const wholeMixedSC: SketchCollection<MultiPolygon | Polygon> =
genSampleSketchCollection(wholeMixedFC);
// hole in bottom left
const holeBlPoly: Sketch<Polygon> = genSampleSketch(
{
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
[
[],
[],
[],
[],
[],
],
],
},
"holeBotLeft",
);
// hole in top right
const holeTrMultipoly: Sketch<MultiPolygon> = genSampleSketch(
{
type: "MultiPolygon",
coordinates: [
[
[
[],
[],
[],
[],
[],
],
[
[],
[],
[],
[],
[],
],
],
],
},
"holeTopRight",
);
/**
* Sketch collection with a whole polygon with a hole in the bottom left and a whole multipolygon with a hole in the top-right
* These two features have 100% overlap except for their holes which don't overlap at all.
*/
const holeMixedSC: SketchCollection<MultiPolygon | Polygon> =
genSampleSketchCollectionFromSketches<Polygon | MultiPolygon>(
[],
"holeSC",
);
export default {
zero,
outer,
bottomLeftPoly,
topRightPoly,
twoPolyInsideFC,
twoPolyInsideSC,
wholePoly,
wholeMultipoly,
wholeMixedFC,
wholeMixedSC,
holeBlPoly,
holeTrMultipoly,
holeMixedSC,
};