dufour-peyton-intersection
Version:
Reference Implementation of the Dufour-Peyton Intersection Algorithm. Calculates the Intersections of Arbitrary Polygons with a Geospatial Raster.
13 lines (12 loc) • 376 B
JavaScript
/**
* @name overlaps
* @description check if two ranges overlap
* @param {Range} a
* @param {Range} b
* @returns {Boolean} result
*/
module.exports = function overlaps(a, b) {
if (!Array.isArray(a)) throw new Error("[overlaps] a is not an array");
if (!Array.isArray(b)) throw new Error("[overlaps] b is not an array");
return a[0] <= b[1] && b[0] <= a[1];
};