@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
215 lines • 5.92 kB
JavaScript
import { genSampleSketch } from "../../helpers/index.js";
import { feature, featureCollection, multiPolygon, polygon, area, bbox, } from "@turf/turf";
const tiny = feature({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const twoByPoly = feature({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
}, { width: 2 });
const twoByPolyArea = area(twoByPoly);
const fourByPoly = feature({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
}, { width: 4 });
const fourByPolyArea = area(fourByPoly);
// fully inside outer
const insideTwoByPoly = polygon([
[
[],
[],
[],
[],
[],
],
], { width: 1 });
const insideTwoByMultiPoly = multiPolygon([
insideTwoByPoly.geometry.coordinates,
]);
const insideTwoByMultipolySketch = genSampleSketch(insideTwoByMultiPoly.geometry, "sketchMultiPoly1");
const insideTwoByPolySketch = genSampleSketch(insideTwoByPoly.geometry, "insideTwoByPolySketch");
// half inside outer
const halfInsideTwoByPoly = polygon([
[
[],
[],
[],
[],
[],
],
], { width: 2 });
const fullyInsideTwoPoly = polygon([
[
[],
[],
[],
[],
[],
],
], { width: 1 });
const halfInsideTwoBySketchPoly = genSampleSketch(halfInsideTwoByPoly.geometry, "halfInsideTwoBySketchPoly");
// fully outside outer top right
const outsideTwoByPolyTopRight = polygon([
[
[],
[],
[],
[],
[],
],
], { width: 1 });
const outsideTwoByPolyTopRightSketch = genSampleSketch(outsideTwoByPolyTopRight.geometry, "outsideTwoByPolyTopRightSketch");
// fully outside outer bottom right
const outsideTwoByPolyBottomRight = polygon([
[
[],
[],
[],
[],
[],
],
], { width: 1 });
const outsideTwoByPolyBottomRightSketch = genSampleSketch(outsideTwoByPolyBottomRight.geometry, "outsideTwoByPolyBottomRightSketch");
// fully outside outer bottom right
const outsideTwoByPolyTopLeft = polygon([
[
[],
[],
[],
[],
[],
],
], { width: 1 });
const outsideTwoByPolyTopLeftSketch = genSampleSketch(outsideTwoByPolyTopLeft.geometry, "outsideTwoByPolyTopLeftSketch");
const collectionId = "CCCC";
const sketchCollection = {
type: "FeatureCollection",
properties: {
id: collectionId,
name: "Collection 1",
updatedAt: "2021-11-20T00:00:34.269Z",
createdAt: "2021-11-19T23:34:12.889Z",
sketchClassId: "615b65a2aac8c8285d50d9f3",
isCollection: true,
userAttributes: [],
},
bbox: bbox(featureCollection([
insideTwoByPolySketch,
halfInsideTwoBySketchPoly,
outsideTwoByPolyTopRightSketch,
])),
features: [
insideTwoByPolySketch,
halfInsideTwoBySketchPoly,
outsideTwoByPolyTopRightSketch,
],
};
const mixedCollectionId = "MMMM";
const mixedPolySketchCollection = {
type: "FeatureCollection",
properties: {
id: mixedCollectionId,
name: "Collection 1",
updatedAt: "2021-11-20T00:00:34.269Z",
createdAt: "2021-11-19T23:34:12.889Z",
sketchClassId: "615b65a2aac8c8285d50d9f3",
isCollection: true,
userAttributes: [],
},
bbox: bbox(featureCollection([
insideTwoByPolySketch,
insideTwoByMultiPoly,
])),
features: [insideTwoByPolySketch, insideTwoByMultipolySketch],
};
const scArea = area(sketchCollection);
/** 2nd and 3rd sketches are the same */
const overlapCollection = {
type: "FeatureCollection",
properties: {
id: collectionId,
name: "Collection 1",
updatedAt: "2021-11-20T00:00:34.269Z",
createdAt: "2021-11-19T23:34:12.889Z",
sketchClassId: "615b65a2aac8c8285d50d9f3",
isCollection: true,
userAttributes: [],
},
bbox: bbox(featureCollection([insideTwoByPolySketch, halfInsideTwoBySketchPoly])),
features: [
insideTwoByPolySketch,
halfInsideTwoBySketchPoly,
halfInsideTwoBySketchPoly,
],
};
/** One sketch is inside twoByPoly, one is outside twoByPoly */
const insideOutsideCollection = {
type: "FeatureCollection",
properties: {
id: "inside-out-coll",
name: "Collection 1",
updatedAt: "2021-11-20T00:00:34.269Z",
createdAt: "2021-11-19T23:34:12.889Z",
sketchClassId: "615b65a2aac8c8285d50d9f3",
isCollection: true,
userAttributes: [],
},
bbox: bbox(featureCollection([
insideTwoByPolySketch,
outsideTwoByPolyBottomRightSketch,
])),
features: [insideTwoByPolySketch, outsideTwoByPolyBottomRightSketch],
};
export default {
tiny,
twoByPoly,
twoByPolyArea,
fourByPoly,
fourByPolyArea,
insideTwoByPoly,
insideTwoByMultiPoly,
insideTwoByPolySketch,
insideTwoByMultipolySketch,
halfInsideTwoByPoly,
fullyInsideTwoPoly,
halfInsideTwoBySketchPoly,
outsideTwoByPolyTopRight,
outsideTwoByPolyTopRightSketch,
outsideTwoByPolyBottomRight,
outsideTwoByPolyBottomRightSketch,
outsideTwoByPolyTopLeft,
outsideTwoByPolyTopLeftSketch,
collectionId,
mixedCollectionId,
sketchCollection,
mixedPolySketchCollection,
overlapCollection,
insideOutsideCollection,
scArea,
};
//# sourceMappingURL=squareSketches.js.map