diff --git a/src/geometry/boundingBox.ts b/src/geometry/boundingBox.ts index e55c2e555..717716dde 100644 --- a/src/geometry/boundingBox.ts +++ b/src/geometry/boundingBox.ts @@ -1,4 +1,5 @@ import { Point } from "./point"; +import { Polygon } from "./polygon"; /** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */ export class BBox { @@ -16,4 +17,8 @@ export class BBox { } /** A bounding box defined by 4 points. */ -export type BoundingBox = [Point, Point, Point, Point]; +export class BoundingBox extends Polygon { + constructor(topLeft: Point, topRight: Point, bottomRight: Point, bottomLeft: Point) { + super(topLeft, topRight, bottomRight, bottomLeft); + } +} diff --git a/src/geometry/boundingBoxUtils.ts b/src/geometry/boundingBoxUtils.ts index 66dc17819..4e8e89763 100644 --- a/src/geometry/boundingBoxUtils.ts +++ b/src/geometry/boundingBoxUtils.ts @@ -13,12 +13,12 @@ export function getBoundingBox(polygon: Polygon): BoundingBox { * Given a BBox, generate the associated bounding box. */ export function getBoundingBoxFromBBox(bbox: BBox): BoundingBox { - return [ + return new BoundingBox( [bbox.xMin, bbox.yMin], [bbox.xMax, bbox.yMin], [bbox.xMax, bbox.yMax], [bbox.xMin, bbox.yMax], - ]; + ); } /** diff --git a/src/geometry/polygon.ts b/src/geometry/polygon.ts index d23f3cf57..29b306fbe 100644 --- a/src/geometry/polygon.ts +++ b/src/geometry/polygon.ts @@ -1,4 +1,9 @@ import { Point } from "./point"; /** A polygon, composed of several Points. */ -export class Polygon extends Array {} +export class Polygon extends Array { + + constructor(...args: Point[]) { + super(...args); + } +} diff --git a/src/parsing/custom/listField.ts b/src/parsing/custom/listField.ts index c56eba370..f961fa21a 100644 --- a/src/parsing/custom/listField.ts +++ b/src/parsing/custom/listField.ts @@ -1,5 +1,5 @@ import { BaseFieldConstructor } from "../standard"; -import { Polygon, getBoundingBox } from "../../geometry"; +import { Polygon, getBoundingBox, BoundingBox } from "../../geometry"; import { StringDict } from "../common"; export class ListFieldValue { @@ -14,12 +14,12 @@ export class ListFieldValue { * Contains exactly 4 relative vertices coordinates (points) of a right * rectangle containing the word in the document. */ - bbox: Polygon = []; + bbox?: BoundingBox; /** * Contains the relative vertices coordinates (points) of a polygon containing * the word in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); /** The document page on which the information was found. */ pageId?: number; diff --git a/src/parsing/standard/field.ts b/src/parsing/standard/field.ts index e9fd85c8c..2fe81230c 100644 --- a/src/parsing/standard/field.ts +++ b/src/parsing/standard/field.ts @@ -14,7 +14,7 @@ export class Field extends BaseField { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); /** The confidence score of the prediction. */ confidence: number; diff --git a/src/product/billOfLading/billOfLadingV1Carrier.ts b/src/product/billOfLading/billOfLadingV1Carrier.ts index 73a0247c7..4506be109 100644 --- a/src/product/billOfLading/billOfLadingV1Carrier.ts +++ b/src/product/billOfLading/billOfLadingV1Carrier.ts @@ -19,7 +19,7 @@ export class BillOfLadingV1Carrier { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.name = prediction["name"]; diff --git a/src/product/billOfLading/billOfLadingV1CarrierItem.ts b/src/product/billOfLading/billOfLadingV1CarrierItem.ts index da341951c..045d63ded 100644 --- a/src/product/billOfLading/billOfLadingV1CarrierItem.ts +++ b/src/product/billOfLading/billOfLadingV1CarrierItem.ts @@ -26,7 +26,7 @@ export class BillOfLadingV1CarrierItem { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.description = prediction["description"]; diff --git a/src/product/billOfLading/billOfLadingV1Consignee.ts b/src/product/billOfLading/billOfLadingV1Consignee.ts index 73fbc90b2..5807ca799 100644 --- a/src/product/billOfLading/billOfLadingV1Consignee.ts +++ b/src/product/billOfLading/billOfLadingV1Consignee.ts @@ -21,7 +21,7 @@ export class BillOfLadingV1Consignee { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/billOfLading/billOfLadingV1NotifyParty.ts b/src/product/billOfLading/billOfLadingV1NotifyParty.ts index 8089df3b4..f1dd05d3d 100644 --- a/src/product/billOfLading/billOfLadingV1NotifyParty.ts +++ b/src/product/billOfLading/billOfLadingV1NotifyParty.ts @@ -21,7 +21,7 @@ export class BillOfLadingV1NotifyParty { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/billOfLading/billOfLadingV1Shipper.ts b/src/product/billOfLading/billOfLadingV1Shipper.ts index f5fe11905..de70a1c80 100644 --- a/src/product/billOfLading/billOfLadingV1Shipper.ts +++ b/src/product/billOfLading/billOfLadingV1Shipper.ts @@ -21,7 +21,7 @@ export class BillOfLadingV1Shipper { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/financialDocument/financialDocumentV1LineItem.ts b/src/product/financialDocument/financialDocumentV1LineItem.ts index 762701753..dc5caa642 100644 --- a/src/product/financialDocument/financialDocumentV1LineItem.ts +++ b/src/product/financialDocument/financialDocumentV1LineItem.ts @@ -30,7 +30,7 @@ export class FinancialDocumentV1LineItem { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.description = prediction["description"]; diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts b/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts index 3f5abc4fc..6f464d633 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts +++ b/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts @@ -21,7 +21,7 @@ export class BankAccountDetailsV2Bban { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.bbanBankCode = prediction["bban_bank_code"]; diff --git a/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts b/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts index cec108fec..ceb202eed 100644 --- a/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts +++ b/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts @@ -17,7 +17,7 @@ export class EnergyBillV1EnergyConsumer { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/fr/energyBill/energyBillV1EnergySupplier.ts b/src/product/fr/energyBill/energyBillV1EnergySupplier.ts index 7da991c7c..badfdf7e8 100644 --- a/src/product/fr/energyBill/energyBillV1EnergySupplier.ts +++ b/src/product/fr/energyBill/energyBillV1EnergySupplier.ts @@ -17,7 +17,7 @@ export class EnergyBillV1EnergySupplier { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/fr/energyBill/energyBillV1EnergyUsage.ts b/src/product/fr/energyBill/energyBillV1EnergyUsage.ts index ced1c9faf..d2e90d2af 100644 --- a/src/product/fr/energyBill/energyBillV1EnergyUsage.ts +++ b/src/product/fr/energyBill/energyBillV1EnergyUsage.ts @@ -30,7 +30,7 @@ export class EnergyBillV1EnergyUsage { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/fr/energyBill/energyBillV1MeterDetail.ts b/src/product/fr/energyBill/energyBillV1MeterDetail.ts index 19f43d11f..db04ab240 100644 --- a/src/product/fr/energyBill/energyBillV1MeterDetail.ts +++ b/src/product/fr/energyBill/energyBillV1MeterDetail.ts @@ -19,7 +19,7 @@ export class EnergyBillV1MeterDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.meterNumber = prediction["meter_number"]; diff --git a/src/product/fr/energyBill/energyBillV1Subscription.ts b/src/product/fr/energyBill/energyBillV1Subscription.ts index 1e3be1be3..43c470ddc 100644 --- a/src/product/fr/energyBill/energyBillV1Subscription.ts +++ b/src/product/fr/energyBill/energyBillV1Subscription.ts @@ -26,7 +26,7 @@ export class EnergyBillV1Subscription { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.description = prediction["description"]; diff --git a/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts b/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts index 5ad799451..97b377abf 100644 --- a/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts +++ b/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts @@ -26,7 +26,7 @@ export class EnergyBillV1TaxesAndContribution { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.description = prediction["description"]; diff --git a/src/product/fr/payslip/payslipV2BankAccountDetail.ts b/src/product/fr/payslip/payslipV2BankAccountDetail.ts index 4c2d32b0e..033f531be 100644 --- a/src/product/fr/payslip/payslipV2BankAccountDetail.ts +++ b/src/product/fr/payslip/payslipV2BankAccountDetail.ts @@ -19,7 +19,7 @@ export class PayslipV2BankAccountDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.bankName = prediction["bank_name"]; diff --git a/src/product/fr/payslip/payslipV2Employee.ts b/src/product/fr/payslip/payslipV2Employee.ts index bdd9464fa..3c0faf613 100644 --- a/src/product/fr/payslip/payslipV2Employee.ts +++ b/src/product/fr/payslip/payslipV2Employee.ts @@ -27,7 +27,7 @@ export class PayslipV2Employee { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/fr/payslip/payslipV2Employer.ts b/src/product/fr/payslip/payslipV2Employer.ts index 355203fe6..a499595b8 100644 --- a/src/product/fr/payslip/payslipV2Employer.ts +++ b/src/product/fr/payslip/payslipV2Employer.ts @@ -27,7 +27,7 @@ export class PayslipV2Employer { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/fr/payslip/payslipV2Employment.ts b/src/product/fr/payslip/payslipV2Employment.ts index 5120cce38..14dacdc32 100644 --- a/src/product/fr/payslip/payslipV2Employment.ts +++ b/src/product/fr/payslip/payslipV2Employment.ts @@ -27,7 +27,7 @@ export class PayslipV2Employment { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.category = prediction["category"]; diff --git a/src/product/fr/payslip/payslipV2PayDetail.ts b/src/product/fr/payslip/payslipV2PayDetail.ts index cb524a528..c5486b945 100644 --- a/src/product/fr/payslip/payslipV2PayDetail.ts +++ b/src/product/fr/payslip/payslipV2PayDetail.ts @@ -35,7 +35,7 @@ export class PayslipV2PayDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/fr/payslip/payslipV2PayPeriod.ts b/src/product/fr/payslip/payslipV2PayPeriod.ts index b228c3c7f..a1d82acff 100644 --- a/src/product/fr/payslip/payslipV2PayPeriod.ts +++ b/src/product/fr/payslip/payslipV2PayPeriod.ts @@ -23,7 +23,7 @@ export class PayslipV2PayPeriod { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.endDate = prediction["end_date"]; diff --git a/src/product/fr/payslip/payslipV2Pto.ts b/src/product/fr/payslip/payslipV2Pto.ts index f9c31d070..bd604f977 100644 --- a/src/product/fr/payslip/payslipV2Pto.ts +++ b/src/product/fr/payslip/payslipV2Pto.ts @@ -21,7 +21,7 @@ export class PayslipV2Pto { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/fr/payslip/payslipV2SalaryDetail.ts b/src/product/fr/payslip/payslipV2SalaryDetail.ts index 87f8402e1..630bca80b 100644 --- a/src/product/fr/payslip/payslipV2SalaryDetail.ts +++ b/src/product/fr/payslip/payslipV2SalaryDetail.ts @@ -22,7 +22,7 @@ export class PayslipV2SalaryDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/fr/payslip/payslipV3BankAccountDetail.ts b/src/product/fr/payslip/payslipV3BankAccountDetail.ts index 66af8889a..3ec0f2b1c 100644 --- a/src/product/fr/payslip/payslipV3BankAccountDetail.ts +++ b/src/product/fr/payslip/payslipV3BankAccountDetail.ts @@ -19,7 +19,7 @@ export class PayslipV3BankAccountDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.bankName = prediction["bank_name"]; diff --git a/src/product/fr/payslip/payslipV3Employee.ts b/src/product/fr/payslip/payslipV3Employee.ts index 003b9f341..b93f3c7ab 100644 --- a/src/product/fr/payslip/payslipV3Employee.ts +++ b/src/product/fr/payslip/payslipV3Employee.ts @@ -27,7 +27,7 @@ export class PayslipV3Employee { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/fr/payslip/payslipV3Employer.ts b/src/product/fr/payslip/payslipV3Employer.ts index a7dd79677..118dc30c7 100644 --- a/src/product/fr/payslip/payslipV3Employer.ts +++ b/src/product/fr/payslip/payslipV3Employer.ts @@ -27,7 +27,7 @@ export class PayslipV3Employer { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.address = prediction["address"]; diff --git a/src/product/fr/payslip/payslipV3Employment.ts b/src/product/fr/payslip/payslipV3Employment.ts index 89c395709..7b2bf817e 100644 --- a/src/product/fr/payslip/payslipV3Employment.ts +++ b/src/product/fr/payslip/payslipV3Employment.ts @@ -27,7 +27,7 @@ export class PayslipV3Employment { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.category = prediction["category"]; diff --git a/src/product/fr/payslip/payslipV3PaidTimeOff.ts b/src/product/fr/payslip/payslipV3PaidTimeOff.ts index b088f87ee..c8fd1bc28 100644 --- a/src/product/fr/payslip/payslipV3PaidTimeOff.ts +++ b/src/product/fr/payslip/payslipV3PaidTimeOff.ts @@ -24,7 +24,7 @@ export class PayslipV3PaidTimeOff { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/fr/payslip/payslipV3PayDetail.ts b/src/product/fr/payslip/payslipV3PayDetail.ts index 4b50007fd..1dfb45f86 100644 --- a/src/product/fr/payslip/payslipV3PayDetail.ts +++ b/src/product/fr/payslip/payslipV3PayDetail.ts @@ -35,7 +35,7 @@ export class PayslipV3PayDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/fr/payslip/payslipV3PayPeriod.ts b/src/product/fr/payslip/payslipV3PayPeriod.ts index 8fb5b8b31..418308d2f 100644 --- a/src/product/fr/payslip/payslipV3PayPeriod.ts +++ b/src/product/fr/payslip/payslipV3PayPeriod.ts @@ -23,7 +23,7 @@ export class PayslipV3PayPeriod { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.endDate = prediction["end_date"]; diff --git a/src/product/fr/payslip/payslipV3SalaryDetail.ts b/src/product/fr/payslip/payslipV3SalaryDetail.ts index 38f63ddf2..2194467d6 100644 --- a/src/product/fr/payslip/payslipV3SalaryDetail.ts +++ b/src/product/fr/payslip/payslipV3SalaryDetail.ts @@ -24,7 +24,7 @@ export class PayslipV3SalaryDetail { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/invoice/invoiceV4LineItem.ts b/src/product/invoice/invoiceV4LineItem.ts index f7f3d0049..ebfa4a9b5 100644 --- a/src/product/invoice/invoiceV4LineItem.ts +++ b/src/product/invoice/invoiceV4LineItem.ts @@ -30,7 +30,7 @@ export class InvoiceV4LineItem { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.description = prediction["description"]; diff --git a/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts b/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts index 8685098a0..ad99026b8 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts +++ b/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts @@ -15,7 +15,7 @@ export class InvoiceSplitterV1InvoicePageGroup { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.pageIndexes = prediction["page_indexes"]; diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts index b240278b6..1a915c83b 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1AddedSugar { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts index cd172e47e..e9d800c74 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1Calorie { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts index e47a5a4fa..3dac26312 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1Cholesterol { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts index 5b422f7e2..0c2318bec 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1DietaryFiber { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts index cc4c6eea5..fb0522e8e 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts @@ -24,7 +24,7 @@ export class NutritionFactsLabelV1Nutrient { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts index f7d903c85..4420d7b3c 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1Protein { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts index d8465f8c8..c2e18d05e 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1SaturatedFat { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts index 70e1f4845..bcd7dbc64 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts @@ -19,7 +19,7 @@ export class NutritionFactsLabelV1ServingSize { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts index 08bbcd72e..81416e35f 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts @@ -23,7 +23,7 @@ export class NutritionFactsLabelV1Sodium { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts index 7dc98926d..cbf2358fa 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1TotalCarbohydrate { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts index ecacce453..e805f5943 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1TotalFat { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts index 0023b4a7c..9aacdf540 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1TotalSugar { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts index 07e833ff9..ddbcc2974 100644 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts +++ b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts @@ -21,7 +21,7 @@ export class NutritionFactsLabelV1TransFat { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/receipt/receiptV5LineItem.ts b/src/product/receipt/receiptV5LineItem.ts index 5940a65e5..7cb6e5c68 100644 --- a/src/product/receipt/receiptV5LineItem.ts +++ b/src/product/receipt/receiptV5LineItem.ts @@ -22,7 +22,7 @@ export class ReceiptV5LineItem { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.description = prediction["description"]; diff --git a/src/product/resume/resumeV1Certificate.ts b/src/product/resume/resumeV1Certificate.ts index 38bf2c3a4..b501ecf41 100644 --- a/src/product/resume/resumeV1Certificate.ts +++ b/src/product/resume/resumeV1Certificate.ts @@ -23,7 +23,7 @@ export class ResumeV1Certificate { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.grade = prediction["grade"]; diff --git a/src/product/resume/resumeV1Education.ts b/src/product/resume/resumeV1Education.ts index c69cfd814..9c7a0bcac 100644 --- a/src/product/resume/resumeV1Education.ts +++ b/src/product/resume/resumeV1Education.ts @@ -29,7 +29,7 @@ export class ResumeV1Education { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.degreeDomain = prediction["degree_domain"]; diff --git a/src/product/resume/resumeV1Language.ts b/src/product/resume/resumeV1Language.ts index 8af9735a0..e008c9e6c 100644 --- a/src/product/resume/resumeV1Language.ts +++ b/src/product/resume/resumeV1Language.ts @@ -19,7 +19,7 @@ export class ResumeV1Language { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.language = prediction["language"]; diff --git a/src/product/resume/resumeV1ProfessionalExperience.ts b/src/product/resume/resumeV1ProfessionalExperience.ts index 0bbafd21c..2d62f8195 100644 --- a/src/product/resume/resumeV1ProfessionalExperience.ts +++ b/src/product/resume/resumeV1ProfessionalExperience.ts @@ -33,7 +33,7 @@ export class ResumeV1ProfessionalExperience { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.contractType = prediction["contract_type"]; diff --git a/src/product/resume/resumeV1SocialNetworksUrl.ts b/src/product/resume/resumeV1SocialNetworksUrl.ts index 516fb59ae..bca348ff9 100644 --- a/src/product/resume/resumeV1SocialNetworksUrl.ts +++ b/src/product/resume/resumeV1SocialNetworksUrl.ts @@ -19,7 +19,7 @@ export class ResumeV1SocialNetworksUrl { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.name = prediction["name"]; diff --git a/src/product/us/healthcareCard/healthcareCardV1Copay.ts b/src/product/us/healthcareCard/healthcareCardV1Copay.ts index ffb487e7a..b2492a0ee 100644 --- a/src/product/us/healthcareCard/healthcareCardV1Copay.ts +++ b/src/product/us/healthcareCard/healthcareCardV1Copay.ts @@ -18,7 +18,7 @@ export class HealthcareCardV1Copay { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { if ( diff --git a/src/product/us/usMail/usMailV2RecipientAddress.ts b/src/product/us/usMail/usMailV2RecipientAddress.ts index 5f6fc9bb7..903b97603 100644 --- a/src/product/us/usMail/usMailV2RecipientAddress.ts +++ b/src/product/us/usMail/usMailV2RecipientAddress.ts @@ -29,7 +29,7 @@ export class UsMailV2RecipientAddress { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.city = prediction["city"]; diff --git a/src/product/us/usMail/usMailV2SenderAddress.ts b/src/product/us/usMail/usMailV2SenderAddress.ts index cef1e81b7..2fbed516c 100644 --- a/src/product/us/usMail/usMailV2SenderAddress.ts +++ b/src/product/us/usMail/usMailV2SenderAddress.ts @@ -23,7 +23,7 @@ export class UsMailV2SenderAddress { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.city = prediction["city"]; diff --git a/src/product/us/usMail/usMailV3RecipientAddress.ts b/src/product/us/usMail/usMailV3RecipientAddress.ts index 80f5c0e30..32b6aee0c 100644 --- a/src/product/us/usMail/usMailV3RecipientAddress.ts +++ b/src/product/us/usMail/usMailV3RecipientAddress.ts @@ -31,7 +31,7 @@ export class UsMailV3RecipientAddress { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.city = prediction["city"]; diff --git a/src/product/us/usMail/usMailV3SenderAddress.ts b/src/product/us/usMail/usMailV3SenderAddress.ts index 4072be969..9567a1eba 100644 --- a/src/product/us/usMail/usMailV3SenderAddress.ts +++ b/src/product/us/usMail/usMailV3SenderAddress.ts @@ -23,7 +23,7 @@ export class UsMailV3SenderAddress { * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ - polygon: Polygon = []; + polygon: Polygon = new Polygon(); constructor({ prediction = {} }: StringDict) { this.city = prediction["city"]; diff --git a/tests/geometry.spec.ts b/tests/geometry.spec.ts index 1c0025b54..234a051f8 100644 --- a/tests/geometry.spec.ts +++ b/tests/geometry.spec.ts @@ -4,32 +4,32 @@ import { expect } from "chai"; describe("Geometry functions", () => { // 90° rectangle, overlaps polygonB function polygonA(): geometry.Polygon { - return [ + return new geometry.Polygon( [0.123, 0.53], [0.175, 0.53], [0.175, 0.546], [0.123, 0.546], - ]; + ); } // 90° rectangle, overlaps polygonA function polygonB(): geometry.Polygon { - return [ + return new geometry.Polygon( [0.124, 0.535], [0.19, 0.535], [0.19, 0.546], [0.124, 0.546], - ]; + ); } // not 90° rectangle, doesn't overlap any polygons function polygonC(): geometry.Polygon { - return [ + return new geometry.Polygon( [0.205, 0.407], [0.379, 0.407], [0.381, 0.43], [0.207, 0.43], - ]; + ); } it("should get a polygon's bbox", () => {