Considering the following:
var dataset = [
{X: 0, Y: 0, ApiKey: "Something"},
{X: 100, Y: 0, ApiKey: "Something"},
{X: 1500, Y: 200, ApiKey: "Something"},
{X: 1600, Y: 850, ApiKey: "Something"},
{X: 0, Y: 750, ApiKey: "Something"},
{X: 0, Y: 800, ApiKey: "Something"},
];
I'm in need of generating a new array to demonstrate the number of incidents within specific ranges:
var output = [
{fromX: 0, ToX: 500, incidents: 4},
{fromX: 1500, ToX: 2000, incidents: 2}
];
I came up with an iterative approach, but the processing time goes up to 8-12 minutes when the dataset contains 15000 objects in Node.js. Does anyone have any suggestions for a more efficient solution?