Skip to content

Commit

Permalink
fix: blur in grid calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
neocarto committed Oct 21, 2022
1 parent ed22e25 commit 5104b0f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 280 deletions.
23 changes: 18 additions & 5 deletions src/helpers/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ export function grid({
output = "dots", // dots or squares
blur = 0, // blur value with d3.blur2()
} = {}) {

// ---------------
// Build empty grid
// ---------------

let x = d3.range(0 + step / 2, width, step);
let y = d3.range(0 + step / 2, height, step).reverse();
const grid_width = x.length;
const grid_height = y.length;
const grid_height = x.length;
const grid_width = y.length;

// Dot grid
let grid = x.map((x, i) => y.map((y) => [x, y])).flat();
Expand Down Expand Up @@ -95,6 +94,22 @@ export function grid({

let squarevalues = [];

// squaregrid.forEach((square) => {
// let squareval = [];
// dots.forEach((dot) => {
// if (
// turf.booleanPointInPolygon(
// { type: "Point", coordinates: dot[1] },
// { type: "Polygon", coordinates: [square] }
// )
// ) {
// squareval.push(val.get(dot[0]));
// }
// });

// squarevalues.push(d3.sum(squareval));
// });

squaregrid.forEach((square) => {
let squareval = [];
let squareval_a = [];
Expand All @@ -112,15 +127,13 @@ export function grid({
} else {
squareval.push(val.get(dot[0]));
}
squareval.push(val.get(dot[0]));
}
});
if (ratio) {
squarevalues.push(d3.sum(squareval_a) / d3.sum(squareval_b));
} else {
squarevalues.push(d3.sum(squareval));
}
squarevalues.push(d3.sum(squareval));
});

const squarevalues2 = d3.blur2(
Expand Down
275 changes: 0 additions & 275 deletions src/helpers/grid_save.js

This file was deleted.

0 comments on commit 5104b0f

Please sign in to comment.