Skip to content

Commit

Permalink
remove categorizeIntersection
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Jun 17, 2023
1 parent 04c96fa commit 242dfb7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 82 deletions.
31 changes: 0 additions & 31 deletions src/utils/utils.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,6 @@ const utils = {

runOnTableOfValues,

categorizeIntersection(segments) {
try {
let through, xmin, xmax;

const n = segments.length;

const first = segments[0];

if (n === 1) {
through = true;
xmin = first.xmin;
xmax = first.xmax;
} /* n > 1 */ else {
const last = segments[n - 1];
through = first.direction === last.direction;
xmin = Math.min(first.xmin, last.xmin);
xmax = Math.max(first.xmax, last.xmax);
}

if (xmin === undefined || xmax === undefined || through === undefined || isNaN(xmin) || isNaN(xmax)) {
throw Error("categorizeIntersection failed with xmin", xmin, "and xmax", xmax);
}

return { xmin, xmax, through };
} catch (error) {
console.error("[categorizeIntersection] segments:", segments);
console.error("[categorizeIntersection]", error);
throw error;
}
},

convertToGeojsonIfNecessary(input, debug = false) {
if (this.isEsriJson(input, debug)) {
return this.toGeoJSON(input, debug);
Expand Down
51 changes: 0 additions & 51 deletions src/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,57 +122,6 @@ test("Test Intersections", ({ eq }) => {
//eq(intersection.y, 41.641892470257524);
});

test("Test Categorization of Intersections", ({ eq }) => {
// through
let segments = [{ xmin: -140, xmax: -140, direction: 1 }];
let actual = utils.categorizeIntersection(segments);
eq(actual.through, true);
eq(actual.xmin, -140);
eq(actual.xmax, -140);

// rebound
segments = [
{ xmin: -140, xmax: -140, direction: 1 },
{ xmin: -140, xmax: -140, direction: -1 }
];
actual = utils.categorizeIntersection(segments);
eq(actual.through, false);
eq(actual.xmin, -140);
eq(actual.xmax, -140);

// horizontal through
segments = [
{ xmin: -140, xmax: -140, direction: 1 },
{ xmin: -140, xmax: -130, direction: 0 },
{ xmin: -130, xmax: -130, direction: 1 }
];
actual = utils.categorizeIntersection(segments);
eq(actual.through, true);
eq(actual.xmin, -140);
eq(actual.xmax, -130);

// horizontal rebound
segments = [
{ xmin: -140, xmax: -140, direction: 1 },
{ xmin: -140, xmax: -130, direction: 0 },
{ xmin: -130, xmax: -130, direction: -1 }
];
actual = utils.categorizeIntersection(segments);
eq(actual.through, false);
eq(actual.xmin, -140);
eq(actual.xmax, -130);

// through with stop
segments = [
{ xmin: -140, xmax: -140, direction: 1 },
{ xmin: -140, xmax: -140, direction: 1 }
];
actual = utils.categorizeIntersection(segments);
eq(actual.through, true);
eq(actual.xmin, -140);
eq(actual.xmax, -140);
});

test("get constructor names", ({ eq }) => {
eq(utils.getConstructorName(new ArrayBuffer()), "ArrayBuffer");
});

0 comments on commit 242dfb7

Please sign in to comment.