Вы можете объединить все сокращения только в одном и вернуть массив [ [lat_min, lon_min], [lat_max, lon_max] ]
следующим образом:
const bounds = [
[ [ 0.0, 0.1 ], [ 0.6, 0.7 ] ],
[ [ 0.2, 0.3 ], [ 0.8, 0.9 ] ],
[ [ 0.4, 0.5 ], [ 0.1, 0.2 ] ]
];
const minMax = bounds.reduce((current, box) => {
const minLat = box[0][0] < current[0][0] ? box[0][0] : current[0][0];
const minLon = box[0][1] < current[0][1] ? box[0][1] : current[0][1];
const maxLat = box[1][0] > current[1][0] ? box[1][0] : current[1][0];
const maxLon = box[1][1] > current[1][1] ? box[1][1] : current[1][1];
return [ [ minLat, minLon ], [ maxLat, maxLon ] ]
}, bounds[0]);
console.log('combined reduce:', minMax);
Ниже приведен ваш код для справки:
const bounds = [
[ [ 0.0, 0.1 ], [ 0.6, 0.7 ] ],
[ [ 0.2, 0.3 ], [ 0.8, 0.9 ] ],
[ [ 0.4, 0.5 ], [ 0.1, 0.2 ] ]
];
const x1 = bounds.reduce((min, box) => {
return box[0][0] < min ? box[0][0] : min;
}, bounds[0][0][0]);
const y1 = bounds.reduce((min, box) => {
return box[0][1] < min ? box[0][1] : min;
}, bounds[0][0][1]);
const x2 = bounds.reduce((max, box) => {
return box[1][0] > max ? box[1][0] : max;
}, bounds[0][1][0]);
const y2 = bounds.reduce((max, box) => {
return box[1][1] > max ? box[1][1] : max;
}, bounds[0][1][1]);
console.log('separate reduce:', [ [ x1, y1 ], [ x2, y2 ] ]);