UNPKG

mindee

Version:

Mindee Client Library for Node.js

34 lines (33 loc) 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PositionField = void 0; /** * A field indicating a position or area on the document. */ class PositionField { constructor({ prediction = {}, pageId }) { this.pageId = pageId; this.boundingBox = "bounding_box" in prediction ? prediction["bounding_box"] : []; this.polygon = "polygon" in prediction ? prediction["polygon"] : []; this.quadrangle = "quadrangle" in prediction ? prediction["quadrangle"] : []; this.rectangle = "rectangle" in prediction ? prediction["rectangle"] : []; } /** * Default string representation. */ toString() { if (this.polygon && this.polygon.length > 0) return `Polygon with ${this.polygon.length} points.`; if (this.boundingBox && this.boundingBox.length > 0) { return `Polygon with ${this.boundingBox.length} points.`; } if (this.rectangle && this.rectangle.length > 0) { return `Polygon with ${this.rectangle.length} points.`; } if (this.quadrangle && this.quadrangle.length > 0) { return `Polygon with ${this.quadrangle.length} points.`; } return ""; } } exports.PositionField = PositionField;