Skip to content

Commit

Permalink
updated sum to require opt-in to virtual resampling
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Aug 4, 2024
1 parent 0e6211d commit c2441dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ import stat from "../stat";
* // results is sum of all interesecting pixels at or above sea level
* [2131]
*/
export default function sum(georaster, geometry, test) {
return stat(georaster, geometry, "sum", test, { rescale: true, vrm: "minimal" });
export default function sum(georaster, geometry, test, { rescale, vrm } = {}) {
return stat(georaster, geometry, "sum", test, { rescale, vrm });
}
19 changes: 17 additions & 2 deletions src/sum/sum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,21 @@ test("Virtual Resampling", async ({ eq }) => {
await fetchJson(`http://localhost:${port}/data/virtual-resampling/virtual-resampling-one.geojson`)
];
const [georaster, geojson] = values;
const results = await sum(georaster, geojson, undefined);
eq(results, [0.30158730158730157]);

let msg;
try {
await sum(georaster, geojson, undefined);
} catch (error) {
msg = error.toString();
}
eq(msg, "No Values were found in the given geometry");

const results_minimal = await sum(georaster, geojson, undefined, { vrm: "minimal", rescale: true });
eq(results_minimal, [0.30158730158730157]);

const results_100 = await sum(georaster, geojson, undefined, { vrm: [100, 100], rescale: true });
eq(results_100, [0.3952]);

const results_1000 = await sum(georaster, geojson, undefined, { vrm: [10_000, 10_000], rescale: true });
eq(results_1000, [0.41278374]);
});

0 comments on commit c2441dd

Please sign in to comment.