mindee
Version:
Mindee Client Library for Node.js
44 lines (43 loc) • 1.27 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Polygon = void 0;
const polygonUtils_1 = require("./polygonUtils");
/** A polygon, composed of several Points. */
class Polygon extends Array {
constructor(...args) {
super(...args);
}
/**
* Get the central point (centroid) of the polygon.
*/
getCentroid() {
return (0, polygonUtils_1.getCentroid)(this);
}
/**
* Get the maximum and minimum X coordinates of the polygon.
*/
getMinMaxX() {
return (0, polygonUtils_1.getMinMaxX)(this);
}
/**
* Get the maximum and minimum Y coordinates of the polygon.
*/
getMinMaxY() {
return (0, polygonUtils_1.getMinMaxY)(this);
}
/**
* Determine if a Point is within the Polygon's X axis (same column).
*/
isPointInX(point) {
const xCoords = this.getMinMaxX();
return (0, polygonUtils_1.isPointInX)(point, xCoords.min, xCoords.max);
}
/**
* Determine if a Point is within the Polygon's Y axis (same line).
*/
isPointInY(point) {
const yCoords = this.getMinMaxY();
return (0, polygonUtils_1.isPointInY)(point, yCoords.min, yCoords.max);
}
}
exports.Polygon = Polygon;
;