Skip to content

Commit

Permalink
Merge branch 'main' into LGD-564/optimize_a_above_b_sidebar_extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
lhaibach committed Jan 27, 2025
2 parents c6ab8b6 + a31eafa commit abc93fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/stratigraphy/data_extractor/data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ def get_lines_near_key(self, lines, key_line: TextLine) -> list[TextLine]:
feature_lines.insert(0, key_line)
feature_lines = list(dict.fromkeys(feature_lines))

# Sort by vertical distance between the top of the feature line and the top of key_line
feature_lines_sorted = sorted(feature_lines, key=lambda line: abs(line.rect.y0 - key_line.rect.y0))
# Sort by
# - vertical distance between the top of the feature line and the top of key_line
# - horizontal position (left-first) for lines with identical vertical position
feature_lines_sorted = sorted(
feature_lines, key=lambda line: (abs(line.rect.y0 - key_line.rect.y0), line.rect.x0)
)

return feature_lines_sorted

Expand Down

0 comments on commit abc93fd

Please sign in to comment.