@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
58 lines • 1.76 kB
JavaScript
import { describe, test, expect } from "vitest";
import { cleanCoords } from "./cleanCoords.js";
import { feature, featureCollection } from "@turf/turf";
describe("cleanCoords", () => {
test("cleanCoords Polygon", async () => {
const poly = feature({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const result = cleanCoords(poly);
// 182 should be cleaned to -178 and -92 should be cleaned to 88
expect(result.geometry.coordinates).toEqual([
[
[],
[-178, 88],
[-178, -15],
[],
[],
],
]);
});
test("cleanCoords FeatureCollection", async () => {
const poly = feature({
type: "Polygon",
coordinates: [
[
[],
[],
[],
[],
[],
],
],
});
const fc = featureCollection([poly]);
const result = cleanCoords(fc);
expect(result.type).toBe("FeatureCollection");
expect(result.features.length).toBe(1);
expect(result.features[0].geometry.coordinates).toEqual([
[
[],
[-178, 88],
[-178, -15],
[],
[],
],
]);
});
});
//# sourceMappingURL=cleanCoords.test.js.map