mirror of
https://github.com/Turfjs/turf.git
synced 2025-12-08 20:26:16 +00:00
* Converting bench.js and test.js to Typescript. Adding along as a named export as well as the default. * Converting bench.js and test.js to Typescript and ESM import. Adding angle as a named export as well as the default. * Converting bench.js and test.js to Typescript and ESM import. Adding area as a named export as well as the default. * Making turf last-checks a bit more flexible as we will have a mix of JS and TS test files for a while. * Converting bench.js and test.js to Typescript and ESM import, and adding named exports as well as the default export for modules: bbox bboxCliip bboxPolygon bearing bezierSpline booleanClockwise booleanConcave booleanContains booleanCrosses booleanDisjoint booleanEqual booleanIntersect booleanOverlap booleanParallel booleanPointInPolygon booleanPointOnLine booleanTouches booleanValid booleanWithin * Converting bench.js and test.js to Typescript and ESM import for remaining Typescript modules. Also adding named exports in addition to the default export for those same modules. * Proceeding with migrating remaining tests to Typescript. Still a few to do - waiting for PR #2543 to merge first to avoid conflicts. * Converting bench.js and test.js to Typescript and ESM import for some more Typescript modules (postponed until recent PRs merged). Also adding named exports in addition to the default export for those same modules. * Banishing a couple more require() calls from module code. * Retiring custom rollup typescript plugin. Problem it was designed to address probably fixed by a previous typescript upgrade. Removing redundant es5 checking script that hasn't been used for a while as well.
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import { glob } from "glob";
|
|
import path from "path";
|
|
import test from "tape";
|
|
import { loadJsonFileSync } from "load-json-file";
|
|
import { lineString } from "@turf/helpers";
|
|
import { booleanClockwise as isClockwise } from "./index";
|
|
|
|
test("isClockwise#fixtures", (t) => {
|
|
// True Fixtures
|
|
glob
|
|
.sync(path.join(__dirname, "test", "true", "*.geojson"))
|
|
.forEach((filepath) => {
|
|
const name = path.parse(filepath).name;
|
|
const geojson = loadJsonFileSync(filepath);
|
|
const feature = geojson.features[0];
|
|
t.true(isClockwise(feature), "[true] " + name);
|
|
});
|
|
// False Fixtures
|
|
glob
|
|
.sync(path.join(__dirname, "test", "false", "*.geojson"))
|
|
.forEach((filepath) => {
|
|
const name = path.parse(filepath).name;
|
|
const geojson = loadJsonFileSync(filepath);
|
|
const feature = geojson.features[0];
|
|
t.false(isClockwise(feature), "[false] " + name);
|
|
});
|
|
t.end();
|
|
});
|
|
|
|
test("isClockwise", (t) => {
|
|
const cwArray = [
|
|
[0, 0],
|
|
[1, 1],
|
|
[1, 0],
|
|
[0, 0],
|
|
];
|
|
const ccwArray = [
|
|
[0, 0],
|
|
[1, 0],
|
|
[1, 1],
|
|
[0, 0],
|
|
];
|
|
|
|
t.equal(isClockwise(cwArray), true, "[true] clockwise array input");
|
|
t.equal(
|
|
isClockwise(ccwArray),
|
|
false,
|
|
"[false] counter-clockwise array input"
|
|
);
|
|
|
|
t.end();
|
|
});
|
|
|
|
test("isClockwise -- Geometry types", (t) => {
|
|
const line = lineString([
|
|
[0, 0],
|
|
[1, 1],
|
|
[1, 0],
|
|
[0, 0],
|
|
]);
|
|
|
|
t.equal(isClockwise(line), true, "Feature");
|
|
t.equal(isClockwise(line.geometry), true, "Geometry Object");
|
|
|
|
t.end();
|
|
});
|
|
|
|
// test('isClockwise -- throws', t => {
|
|
// const pt = point([-10, -33]);
|
|
// t.throws(() => isClockwise(pt), 'feature geometry not supported');
|
|
|
|
// t.end();
|
|
// });
|