From 261a856686910805b085467986a3832cab889727 Mon Sep 17 00:00:00 2001 From: DanielJDufour Date: Sat, 17 Jun 2023 18:40:53 -0400 Subject: [PATCH] deleted unused clusterLineSegments (it had moved to dufour-peyton-intersection), and deleted one extaneous getBoundingBox test --- src/utils/utils.module.js | 25 ------------------------- src/utils/utils.test.js | 37 ------------------------------------- 2 files changed, 62 deletions(-) diff --git a/src/utils/utils.module.js b/src/utils/utils.module.js index 1293dda..1e2b934 100644 --- a/src/utils/utils.module.js +++ b/src/utils/utils.module.js @@ -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; @@ -402,8 +379,6 @@ const utils = { cluster, - clusterLineSegments, - sum(values) { return values.reduce((a, b) => a + b); }, diff --git a/src/utils/utils.test.js b/src/utils/utils.test.js index 98d2e5a..2abf6cd 100644 --- a/src/utils/utils.test.js +++ b/src/utils/utils.test.js @@ -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); @@ -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);