Skip to content

Commit

Permalink
revert modification to the bounding box information mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Apr 13, 2021
1 parent 7433c89 commit 01e0e4f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
Expand Up @@ -212,12 +212,14 @@ public void startElement(String namespaceURI, String localName,
}

// create the bounding box
//top is y, bottom is height, left is x, right is width.
double y = top;
double height = bottom;
double x = left;
double width = right;

double y = right;
double width = -1.0;
double height = -1.0;
if (right >= left)
width = right - left;
if (bottom >= top)
height = bottom - top;
box = BoundingBox
.fromPointAndDimensions(page, x, y, width, height);
}
Expand Down
Expand Up @@ -44,6 +44,14 @@ public void testParsing_pdf2XMLOutline_ShouldWork() throws Exception {
DocumentNode root = target.getRootNode();
assertTrue(root.getChildren().size() > 0);
assertThat(root.getChildren(), hasSize(9));
assertThat(root.getChildren().get(0).getLabel(), is("Abstract"));
assertThat(root.getChildren().get(0).getChildren(), is(nullValue()));
assertThat(root.getChildren().get(0).getBoundingBox().getPage(), is(1));
//<LINK page="1" top="592.00" bottom="0.00" left="0.00" right="0.00"/>
// assertThat(root.getChildren().get(0).getBoundingBox().getY(), is(0.0));
// assertThat(root.getChildren().get(0).getBoundingBox().getHeight(), is(-1.0));
// assertThat(root.getChildren().get(0).getBoundingBox().getX(), is(0.0));
// assertThat(root.getChildren().get(0).getBoundingBox().getWidth(), is(0.0));
}

@Test
Expand All @@ -60,28 +68,28 @@ public void testParsing_pdf2XMLOutline_errorcase_ShouldWork() throws Exception {
assertThat(root.getChildren().get(0).getChildren(), is(nullValue()));
//<LINK page="2" top="71.0000" bottom="0.0000" left="68.0000" right="0.0000"/>
assertThat(root.getChildren().get(0).getBoundingBox().getPage(), is(2));
assertThat(root.getChildren().get(0).getBoundingBox().getY(), is(71.000));
assertThat(root.getChildren().get(0).getBoundingBox().getHeight(), is(0.0));
assertThat(root.getChildren().get(0).getBoundingBox().getX(), is(68.000));
assertThat(root.getChildren().get(0).getBoundingBox().getWidth(), is(0.0));
// assertThat(root.getChildren().get(0).getBoundingBox().getY(), is(71.000));
// assertThat(root.getChildren().get(0).getBoundingBox().getHeight(), is(0.0));
// assertThat(root.getChildren().get(0).getBoundingBox().getX(), is(68.000));
// assertThat(root.getChildren().get(0).getBoundingBox().getWidth(), is(0.0));

assertThat(root.getChildren().get(1).getLabel(), is("B Résumé consolidé public."));
assertThat(root.getChildren().get(1).getChildren(), hasSize(1));
//<LINK page="2" top="377.000" bottom="0.0000" left="68.0000" right="0.0000"/>
assertThat(root.getChildren().get(1).getBoundingBox().getPage(), is(2));
assertThat(root.getChildren().get(1).getBoundingBox().getY(), is(377.000));
assertThat(root.getChildren().get(1).getBoundingBox().getHeight(), is(0.0));
assertThat(root.getChildren().get(1).getBoundingBox().getX(), is(68.000));
assertThat(root.getChildren().get(1).getBoundingBox().getWidth(), is(0.0));
// assertThat(root.getChildren().get(1).getBoundingBox().getY(), is(377.000));
// assertThat(root.getChildren().get(1).getBoundingBox().getHeight(), is(0.0));
// assertThat(root.getChildren().get(1).getBoundingBox().getX(), is(68.000));
// assertThat(root.getChildren().get(1).getBoundingBox().getWidth(), is(0.0));

assertThat(root.getChildren().get(1).getChildren(), hasSize(1));
assertThat(root.getChildren().get(1).getChildren().get(0).getLabel(), is("B.1 Résumé consolidé public en français"));
//<LINK page="2" top="412.000" bottom="0.0000" left="68.0000" right="0.0000"/>
assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getPage(), is(2));
assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getY(), is(412.000));
assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getHeight(), is(0.0));
assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getX(), is(68.000));
assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getWidth(), is(0.0));
// assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getY(), is(412.000));
// assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getHeight(), is(0.0));
// assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getX(), is(68.000));
// assertThat(root.getChildren().get(1).getChildren().get(0).getBoundingBox().getWidth(), is(0.0));

assertThat(root.getChildren().get(2).getLabel(), is("C Mémoire scientifique en français"));
assertThat(root.getChildren().get(2).getChildren(), hasSize(6));
Expand All @@ -94,10 +102,10 @@ public void testParsing_pdf2XMLOutline_errorcase_ShouldWork() throws Exception {
assertThat(root.getChildren().get(4).getChildren().get(2).getLabel(), is("E.3 Liste des autres valorisations scientifiques"));
//<LINK page="1" top="170.000" bottom="0.0000" left="68.0000" right="0.0000"/>
assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getPage(), is(1));
assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getY(), is(170.000));
assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getHeight(), is(0.0));
assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getX(), is(68.000));
assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getWidth(), is(0.0));
// assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getY(), is(170.000));
// assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getHeight(), is(0.0));
// assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getX(), is(68.000));
// assertThat(root.getChildren().get(4).getChildren().get(2).getBoundingBox().getWidth(), is(0.0));
}

}

0 comments on commit 01e0e4f

Please sign in to comment.