Skip to content

Commit 37c9f07

Browse files
LonelyMidoriyaMaximPlusov
authored andcommitted
Add min/max checks to BoundingBox constructors
1 parent f91fef3 commit 37c9f07

File tree

2 files changed

+5
-86
lines changed

2 files changed

+5
-86
lines changed

src/main/java/org/verapdf/wcag/algorithms/entities/geometry/BoundingBox.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public BoundingBox(Integer pageNumber) {
2525
}
2626

2727
public BoundingBox(double[] bbox) {
28-
init(bbox[0], bbox[1], bbox[2], bbox[3]);
28+
init(Math.min(bbox[0], bbox[2]), Math.min(bbox[1], bbox[3]), Math.max(bbox[0], bbox[2]), Math.max(bbox[1], bbox[3]));
2929
}
3030

3131
public BoundingBox(Integer pageNumber, double[] bbox) {
@@ -34,22 +34,22 @@ public BoundingBox(Integer pageNumber, double[] bbox) {
3434
}
3535

3636
public BoundingBox(Integer pageNumber, Integer lastPageNumber, double[] bbox) {
37-
init(bbox[0], bbox[1], bbox[2], bbox[3]);
37+
init(Math.min(bbox[0], bbox[2]), Math.min(bbox[1], bbox[3]), Math.max(bbox[0], bbox[2]), Math.max(bbox[1], bbox[3]));
3838
this.pageNumber = pageNumber;
3939
this.lastPageNumber = lastPageNumber;
4040
}
4141

4242
public BoundingBox(double left, double bottom, double right, double top) {
43-
init(left, bottom, right, top);
43+
init(Math.min(left, right), Math.min(bottom, top), Math.max(left, right), Math.max(bottom, top));
4444
}
4545

4646
public BoundingBox(Integer pageNumber, double left, double bottom, double right, double top) {
47-
init(left, bottom, right, top);
47+
init(Math.min(left, right), Math.min(bottom, top), Math.max(left, right), Math.max(bottom, top));
4848
this.pageNumber = this.lastPageNumber = pageNumber;
4949
}
5050

5151
public BoundingBox(Integer pageNumber, Integer lastPageNumber, double left, double bottom, double right, double top) {
52-
init(left, bottom, right, top);
52+
init(Math.min(left, right), Math.min(bottom, top), Math.max(left, right), Math.max(bottom, top));
5353
this.pageNumber = pageNumber;
5454
this.lastPageNumber = lastPageNumber;
5555
}

src/test/resources/files/tables/PDFUA-Ref-2-06_Brochure.json

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -6702,15 +6702,6 @@
67026702
"endY":41.258148999999996,
67036703
"width":47.509
67046704
},
6705-
{
6706-
"type":"LineChunk",
6707-
"pageNumber":0,
6708-
"startX":741.7416373,
6709-
"startY":41.258148999999996,
6710-
"endX":836.7596373,
6711-
"endY":41.258148999999996,
6712-
"width":-38.007
6713-
},
67146705
{
67156706
"type":"LineChunk",
67166707
"pageNumber":0,
@@ -6738,42 +6729,6 @@
67386729
"endY":53.122648999999996,
67396730
"width":5.312
67406731
},
6741-
{
6742-
"type":"LineChunk",
6743-
"pageNumber":0,
6744-
"startX":791.1796525000001,
6745-
"startY":26.734148999999995,
6746-
"endX":791.1796525000001,
6747-
"endY":34.852149,
6748-
"width":-1.657
6749-
},
6750-
{
6751-
"type":"LineChunk",
6752-
"pageNumber":0,
6753-
"startX":791.1796525000001,
6754-
"startY":33.985149,
6755-
"endX":791.1796525000001,
6756-
"endY":37.06114899999999,
6757-
"width":-1.657
6758-
},
6759-
{
6760-
"type":"LineChunk",
6761-
"pageNumber":0,
6762-
"startX":803.7796525000001,
6763-
"startY":26.734148899999994,
6764-
"endX":803.7796525000001,
6765-
"endY":34.852148899999996,
6766-
"width":-1.657
6767-
},
6768-
{
6769-
"type":"LineChunk",
6770-
"pageNumber":0,
6771-
"startX":803.7796525000001,
6772-
"startY":33.9851489,
6773-
"endX":803.7796525000001,
6774-
"endY":37.06114889999999,
6775-
"width":-1.657
6776-
},
67776732
{
67786733
"type":"TextChunk",
67796734
"pageNumber":0,
@@ -6893,42 +6848,6 @@
68936848
"endX":319.723945716,
68946849
"endY":99.3177195654,
68956850
"width":8.096
6896-
},
6897-
{
6898-
"type":"LineChunk",
6899-
"pageNumber":0,
6900-
"startX":342.6117960947532,
6901-
"startY":59.098604222349984,
6902-
"endX":342.6117960947532,
6903-
"endY":71.47179352925,
6904-
"width":-2.525
6905-
},
6906-
{
6907-
"type":"LineChunk",
6908-
"pageNumber":0,
6909-
"startX":342.6117960947532,
6910-
"startY":70.15077331794998,
6911-
"endX":342.6117960947532,
6912-
"endY":74.83884504435,
6913-
"width":-2.525
6914-
},
6915-
{
6916-
"type":"LineChunk",
6917-
"pageNumber":0,
6918-
"startX":361.8170901312562,
6919-
"startY":59.09861942258255,
6920-
"endX":361.8170901312562,
6921-
"endY":71.47180872948256,
6922-
"width":-2.525
6923-
},
6924-
{
6925-
"type":"LineChunk",
6926-
"pageNumber":0,
6927-
"startX":361.8170901312562,
6928-
"startY":70.15078851818255,
6929-
"endX":361.8170901312562,
6930-
"endY":74.83886024458256,
6931-
"width":-2.525
69326851
}
69336852
]
69346853
},

0 commit comments

Comments
 (0)