RSS-265: Fixed problem in sorting positions across pages

This commit is contained in:
deiflaender 2022-11-28 09:25:15 +01:00
parent 0d353f99cd
commit b0fc3c3d71
2 changed files with 6 additions and 5 deletions

View File

@ -222,14 +222,10 @@ public class SearchableText {
var quickSorted = new ArrayList<>(sequences); var quickSorted = new ArrayList<>(sequences);
QuickSort.sort(quickSorted, new TextPositionSequenceComparator()); QuickSort.sort(quickSorted, new TextPositionSequenceComparator());
var sorted = quickSorted.stream()
.sorted(Comparator.comparing(a -> a.getPage()))
.collect(Collectors.toList());
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
TextPositionSequence previous = null; TextPositionSequence previous = null;
for (TextPositionSequence word : sorted) { for (TextPositionSequence word : quickSorted) {
if (previous != null) { if (previous != null) {
if (Math.abs(previous.getMaxYDirAdj() - word.getMaxYDirAdj()) > word.getTextHeight()) { if (Math.abs(previous.getMaxYDirAdj() - word.getMaxYDirAdj()) > word.getTextHeight()) {

View File

@ -14,6 +14,11 @@ public class TextPositionSequenceComparator implements Comparator<TextPositionSe
return cmp1; return cmp1;
} }
int page = Integer.compare(pos1.getPage(), pos2.getPage());
if (page != 0){
return page;
}
// get the text direction adjusted coordinates // get the text direction adjusted coordinates
float x1 = pos1.getMinXDirAdj(); float x1 = pos1.getMinXDirAdj();
float x2 = pos2.getMinXDirAdj(); float x2 = pos2.getMinXDirAdj();