Skip to content

Commit

Permalink
deleted unused clusterLineSegments (it had moved to dufour-peyton-int…
Browse files Browse the repository at this point in the history
…ersection), and deleted one extaneous getBoundingBox test
  • Loading branch information
DanielJDufour committed Jun 17, 2023
1 parent 049fee0 commit 261a856
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
25 changes: 0 additions & 25 deletions src/utils/utils.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,6 @@ function cluster(items, newClusterTest) {
}
}

function clusterLineSegments(lineSegments, numberOfEdges, debug = false) {
try {
const clusters = cluster(lineSegments, s => s.endsOffLine);

const numberOfClusters = clusters.length;

if (numberOfClusters >= 2) {
const firstCluster = clusters[0];
const firstSegment = firstCluster[0];
const lastCluster = _.last(clusters);
const lastSegment = _.last(lastCluster);

if (lastSegment.index === numberOfEdges - 1 && firstSegment.index === 0 && lastSegment.endsOnLine) {
clusters[0] = clusters.pop().concat(firstCluster);
}
}

return clusters;
} catch (error) {
console.error("[clusterLineSegments]", error);
}
}

const utils = {
// This function takes in an array with an even number of elements and
// returns an array that couples every two consecutive elements;
Expand Down Expand Up @@ -402,8 +379,6 @@ const utils = {

cluster,

clusterLineSegments,

sum(values) {
return values.reduce((a, b) => a + b);
},
Expand Down
37 changes: 0 additions & 37 deletions src/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ test("Get Bounding when Bounding Box when Bigger Than Raster and with Negative V
eq(actualBbox.ymin < actualBbox.ymax, true);
});

test("Get Bounding Box of GeoJSON that has MultiPolygon Geometry (i.e., multiple rings)", async ({ eq }) => {
const country = await fetchJson(urlToGeojson);
const bbox = utils.getBoundingBox(country.geometry.coordinates);
eq(typeof bbox.xmin, "number");
eq(typeof bbox.xmax, "number");
eq(typeof bbox.ymin, "number");
eq(typeof bbox.ymax, "number");
eq(bbox.xmin, 32.76010131835966);
eq(bbox.xmax, 33.92147445678711);
eq(bbox.ymin, 34.56208419799816);
eq(bbox.ymax, 35.118995666503906);
});

test("Test Forcing Within", ({ eq }) => {
eq(utils.forceWithin(10, 1, 11), 10);
eq(utils.forceWithin(-10, 1, 11), 1);
Expand Down Expand Up @@ -81,30 +68,6 @@ test("Get Depth For Multipolygon", async ({ eq }) => {
}
});

test("Clustering Of Line Segments: For array of objects holding information about intersections: Got Correct Split", ({ eq }) => {
let segments, computed, computedNumberOfClusters;

segments = [{ endsOffLine: true }, { endsOffLine: false }, { endsOffLine: false }, { endsOffLine: true }];
computed = utils.cluster(segments, s => s.endsOffLine);
computedNumberOfClusters = computed.length;
eq(computedNumberOfClusters, 2);
eq(computed[0].length, 1);
eq(computed[1].length, 3);

segments = [{ endsOffLine: true, index: 0 }, { endsOffLine: false }, { endsOffLine: false }, { endsOffLine: false, index: 99 }];
computed = utils.cluster(segments, s => s.endsOffLine);
computedNumberOfClusters = computed.length;
eq(computedNumberOfClusters, 2);
eq(computed[0].length, 1);
eq(computed[1].length, 3);

segments = [{ endsOffLine: true, index: 0 }, { endsOffLine: false }, { endsOffLine: false }, { endsOffLine: false, endsOnLine: true, index: 99 }];
computed = utils.clusterLineSegments(segments, 100, true);
computedNumberOfClusters = computed.length;
eq(computedNumberOfClusters, 1);
eq(computed[0].length, 4);
});

test("Test Coupling", ({ eq }) => {
const items = [0, 1, 18, 77, 99, 103];
const actual = utils.couple(items);
Expand Down

0 comments on commit 261a856

Please sign in to comment.