lib/geometry.js
function getBoundingBox(linearRing) {
	if (!Array.isArray(linearRing)) {
		throw new XError(XError.INVALID_ARGUMENT, 'linearRing must be an array');
	}
	let leftX = Infinity;
	let rightX = -Infinity;
	let bottomY = Infinity;
	let topY = -Infinity;

	for (let point of linearRing) {
		if (!Array.isArray(point) || point.length !== 2 || point.some((coord) => typeof coord !== 'number')) {
			throw new XError(XError.INVALID_ARGUMENT, 'invalid point in linear ring');
		}
		let [ x, y ] = point;
		if (x < leftX) leftX = x;
		if (x > rightX) rightX = x;
		if (y < bottomY) bottomY = y;
		if (y > topY) topY = y;
	}
	return {
		topLeftVertex: [ leftX, topY ],
		width: rightX - leftX,
		height: topY - bottomY
	};
}
function getBoundingBox(linearRing) {
	if (!Array.isArray(linearRing)) {
		throw new XError(XError.INVALID_ARGUMENT, 'linearRing must be an array');
	}
	let leftX = Infinity;
	let rightX = -Infinity;
	let bottomY = Infinity;
	let topY = -Infinity;

	for (let point of linearRing) {
		if (!Array.isArray(point) || point.length !== 2 || point.some((coord) => typeof coord !== 'number')) {
			throw new XError(XError.INVALID_ARGUMENT, 'invalid point in linear ring');
		}
		let [ x, y ] = point;
		if (x < leftX) leftX = x;
		if (x > rightX) rightX = x;
		if (y < bottomY) bottomY = y;
		if (y > topY) topY = y;
	}
	return {
		topLeftVertex: [ leftX, topY ],
		width: rightX - leftX,
		height: topY - bottomY
	};
}
function getBoundingBox ( linearRing ) { if ( ! Array . isArray ( linearRing ) ) { throw new XError ( XError . INVALID_ARGUMENT , 'linearRing must be an array' ) ; } let leftX = Infinity ; let rightX = - Infinity ; let bottomY = Infinity ; let topY = - Infinity ; for ( let point of linearRing ) { if ( ! Array . isArray ( point ) || point . length !== 2 || point . some ( ( coord ) => typeof coord !== 'number' ) ) { throw new XError ( XError . INVALID_ARGUMENT , 'invalid point in linear ring' ) ; } let [ x , y ] = point ; if ( x < leftX ) leftX = x ; if ( x > rightX ) rightX = x ; if ( y < bottomY ) bottomY = y ; if ( y > topY ) topY = y ; } return { topLeftVertex : [ leftX , topY ] , width : rightX - leftX , height : topY - bottomY } ; }
Get the bounding box of given linear ring

@method getBoundingBox
@param {Number[][]} linearRing - coordinates of vertexes of the linear ring
@return {Object} - return an object like this: { topLeftVertex: [ 2, 3 ], width: 1, height: 2 },
where `topLeftVertex` is the top left vertex of the bounding box
Get the bounding box of given linear ring