Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/progress bar #37

Merged
merged 18 commits into from
Jun 18, 2024
Merged

Feat/progress bar #37

merged 18 commits into from
Jun 18, 2024

Conversation

bordoray
Copy link

@bordoray bordoray commented Jun 18, 2024

Close #34

Description(変更内容)

タイル数を進捗バーを表示
image

Manual Testing(手動テスト)

Test with various patterns:

  • Over 1000 tiles : error message and no process
  • between 100 and 999 tiles : warning message and YES: process with progress bar
  • between 100 and 999 tiles : warning message and NO: no process
  • Try to abort process from progress bar

Summary by CodeRabbit

  • 新機能
    • ElevationTileConverterクラスがQThreadを継承するように変更され、スレッド操作を処理するためのシグナルとメソッドが追加されました。
    • 新しい属性としてabort_flagnp_arrayが追加されました。
    • 進捗ダイアログを備えたカスタム進捗ダイアログが導入されました。
  • 改善
    • タイル数の計算方法がcount_tilesメソッドに変更され、タイルの検証ロジックが削除されました。

@bordoray bordoray requested a review from nbayashi June 18, 2024 04:01
Copy link

coderabbitai bot commented Jun 18, 2024

ウォークスルー

この変更セットは、複数のファイルにわたって大規模なリファクタリングと機能追加を行いました。主な変更点は、ElevationTileConverterクラスをQThreadのサブクラスに変換し、進捗バーのサポートを追加しました。また、ElevationArrayクラスから不要なメソッドと例外を削除し、UIコンポーネントの調整も行いました。

変更点

ファイル 変更内容の概要
.../elevation_tile_array.py TileQuantityExceptionUserTerminationExceptionを削除、fetch_all_tilesメソッドを削除し、count_tilesメソッドを追加
.../elevation_tile_converter.py ElevationTileConverterクラスをQThreadのサブクラスに変更、新しいシグナルとメソッドを追加
get_tiles.py QThreadとProgressDialogのインポート、進捗ダイアログと新しい方法での処理フローの統合
progress_dialog.py ProgressDialogクラス追加、進捗バーとメッセージ表示、プロセス中断の機能
progress_dialog.ui 進捗バー、ラベル、「中断」ボタンを含む新しいダイアログウィンドウ

シーケンス図

sequenceDiagram
    participant User
    participant MainThread
    participant ProgressDialog
    participant ElevationTileConverter

    User ->> MainThread: Start tile processing
    MainThread ->> ProgressDialog: Initialize and show
    MainThread ->> ElevationTileConverter: Start thread
    ElevationTileConverter ->> ProgressDialog: Update progress 
    ElevationTileConverter ->. User: Waits for completion or abort
    ProgressDialog ->> ElevationTileConverter: Abort signal (on abort)
    ElevationTileConverter -->> MainThread: Notify completion or failure
    MainThread ->> User: Show completion message
Loading

連動された問題に対する評価

Objective Addressed Explanation
Progress bar implementation (#34)

タイルを並べ山となり、
進捗バーが光る道。
中断ボタンも控えめに、
ユーザーのための旅路かな。
🐇✨


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Outside diff range and nitpick comments (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Line range hint 135-190: create_geotiff メソッドには、不要な int 呼び出しがあり、比較も簡略化できます。

-        if lon < -180:
-            lon = int(-180)
-        elif lon > 180:
-            lon = int(180)
+        if lon < -180:
+            lon = -180
+        elif lon > 180:
+            lon = 180

-        if not self.output_crs_id == "EPSG:3857":
+        if self.output_crs_id != "EPSG:3857":
Tools
Ruff

155-160: Combine if branches using logical or operator (SIM114)

Combine if branches


162-167: Combine if branches using logical or operator (SIM114)

Combine if branches

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ac59ed and 9a08627.

Files selected for processing (5)
  • elevation_tile_tools/elevation_array.py (2 hunks)
  • elevation_tile_tools/elevation_tile_converter.py (6 hunks)
  • get_tiles.py (6 hunks)
  • progress_dialog.py (1 hunks)
  • progress_dialog.ui (1 hunks)
Additional context used
Path-based instructions (4)
elevation_tile_tools/elevation_array.py (1)

Pattern **/*.py: - can be available more immutable approach?

progress_dialog.py (1)

Pattern **/*.py: - can be available more immutable approach?

elevation_tile_tools/elevation_tile_converter.py (1)

Pattern **/*.py: - can be available more immutable approach?

get_tiles.py (1)

Pattern **/*.py: - can be available more immutable approach?

Ruff
progress_dialog.py

40-47: Use a single if statement instead of nested if statements (SIM102)

Combine if statements using and

elevation_tile_tools/elevation_tile_converter.py

77-77: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


79-79: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


155-160: Combine if branches using logical or operator (SIM114)

Combine if branches


162-167: Combine if branches using logical or operator (SIM114)

Combine if branches


190-190: Use self.output_crs_id != "EPSG:3857" instead of not self.output_crs_id == "EPSG:3857" (SIM201)

Replace with != operator

Additional comments not posted (11)
progress_dialog.ui (1)

1-79: プログレスダイアログの UI 定義が適切に設定されています。ユーザーインタフェースのガイドラインと機能要件に沿っています。

progress_dialog.py (1)

1-74: その他のメソッドも適切に実装されており、大きな問題はありません。

Tools
Ruff

40-47: Use a single if statement instead of nested if statements (SIM102)

Combine if statements using and

elevation_tile_tools/elevation_tile_converter.py (1)

19-26: スレッディングとシグナル処理の統合が適切に行われています。

Also applies to: 60-62

get_tiles.py (8)

27-27: QThread のインポートが追加されています。これは、プログレスバーのスレッド処理を実装するために必要です。この変更は適切です。


40-40: ProgressDialog クラスのインポートが追加されています。このクラスは、ユーザーインタラクションのためのプログレスダイアログを管理します。この変更は適切です。


79-80: 処理が中断されたかどうかを追跡するための process_interrupted 属性が追加されました。この変更は、プログレスバーからの中断機能をサポートするために必要です。


91-93: set_interrupted メソッドが追加されました。これにより、プロセスが中断されたことを設定できます。このメソッドはシンプルで、その目的に合っています。


94-103: confirm_abort メソッドが追加されました。このメソッドは、ユーザーに処理の中断を確認するためのダイアログを表示します。適切なユーザーインタラクションとエラーハンドリングが含まれています。


104-109: abort_process メソッドが追加されました。このメソッドは、スレッドとダイアログの中断処理を行います。このメソッドは、プロセスが中断された場合に適切なリソースのクリーンアップを保証します。


160-172: タイルの数が多い場合に警告メッセージを表示し、ユーザーにダウンロードを続行するかどうかを尋ねるロジックが追加されました。この変更はユーザーに適切なフィードバックを提供し、不要なデータ処理を防ぐために有効です。


144-144: タイルの数が多すぎる場合にエラーメッセージを表示するロジックが追加されました。この機能は、ユーザーが大量のデータに対処する際に役立ちます。ただし、max_number_of_tilesnumber_of_tiles の属性が ElevationTileConverter クラスで定義されていることを確認する必要があります。

Also applies to: 151-157

Verification successful

タイルの数が多すぎる場合にエラーメッセージを表示するロジックが追加されました。この機能は、ユーザーが大量のデータに対処する際に役立ちます。ただし、max_number_of_tilesnumber_of_tiles の属性が ElevationTileConverter クラスで定義されていることを確認する必要があります。

  • max_number_of_tiles 属性は elevation_tile_tools/elevation_tile_converter.py ファイルで定義されています。
  • number_of_tiles 属性も同じファイルで使用されています。

これにより、レビューコメントの指摘は正しいことが確認されました。

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# クラス `ElevationTileConverter` の属性 `max_number_of_tiles` と `number_of_tiles` を確認
ast-grep --lang python --pattern $'class ElevationTileConverter { $$$ max_number_of_tiles = $_; number_of_tiles = $_; $$$ }'

Length of output: 470



Script:

#!/bin/bash
# Search for the `ElevationTileConverter` class definition
ast-grep --lang python --pattern $'class ElevationTileConverter { $$$ }'

Length of output: 532



Script:

#!/bin/bash
# Correct the pattern to locate class definitions
ast-grep --lang python --pattern $'class ElevationTileConverter:'

Length of output: 66



Script:

#!/bin/bash
# Search for the `ElevationTileConverter` class definition using `rg`
rg 'class ElevationTileConverter'

Length of output: 123



Script:

#!/bin/bash
# Search for `max_number_of_tiles` and `number_of_tiles` attributes within the `elevation_tile_tools/elevation_tile_converter.py` file
rg 'max_number_of_tiles|number_of_tiles' elevation_tile_tools/elevation_tile_converter.py

Length of output: 271

get_tiles.py Outdated Show resolved Hide resolved
get_tiles.py Outdated Show resolved Hide resolved
elevation_tile_tools/elevation_array.py Show resolved Hide resolved
progress_dialog.py Outdated Show resolved Hide resolved
elevation_tile_tools/elevation_tile_converter.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9a08627 and 2f319ea.

Files selected for processing (2)
  • get_tiles.py (6 hunks)
  • progress_dialog.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • progress_dialog.py
Additional context used
Path-based instructions (1)
get_tiles.py (1)

Pattern **/*.py: - can be available more immutable approach?

Additional comments not posted (6)
get_tiles.py (6)

27-27: 新しいスレッド処理を追加するために QThread をインポートしています。この変更は、プログレスバー機能の実装に必要です。


40-40: プログレスダイアログのインポートを追加しています。これにより、進行状況の視覚的なフィードバックが可能になります。


79-80: プロセスが中断されたかどうかを追距するための属性 process_interrupted を追加しました。この属性は、ユーザーが処理を中断したかどうかを追跡するために使用されます。


91-93: プロセスが中断されたことを示すためのフラグを設定する set_interrupted メソッドを追加しました。このメソッドは、プロセスがユーザーによって中断された際に使用されます。


155-168: タイル処理のためのスレッドを生成しており、タイルの数が上限を超えた場合にエラーメッセージを表示しています。この処理は、ユーザーが多数のタイルを要求した場合に適切なフィードバックを提供するために重要です。


171-183: タイルの数が大きい場合に警告メッセージを表示し、ユーザーに処理の続行を確認しています。この対話的なアプローチは、ユーザーが処理のリスクを理解し、意思決定を行うのに役立ちます。

get_tiles.py Show resolved Hide resolved
get_tiles.py Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Outside diff range and nitpick comments (2)
elevation_tile_tools/elevation_tile_converter.py (2)

Line range hint 138-184: create_geotiff メソッドにおいて、ピクセルサイズの計算方法が複雑で、異なる条件分岐が多く存在しています。これらの条件分岐を論理演算子 or を使用して組み合わせることで、コードの可読性を向上させることができます。

-        if upper_right_XY[0] >= 0 and lower_left_XY[0] >= 0:
-            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
-        elif upper_right_XY[0] <= 0 and lower_left_XY[0] <= 0:
-            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
-        # 片方がプラスなら絶対値を足す
-        elif upper_right_XY[0] <= 0 <= lower_left_XY[0]:
-            pixel_size_x = (abs(upper_right_XY[0]) + abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) + abs(lower_left_XY[1])) / y_length
-        elif upper_right_XY[0] >= 0 >= lower_left_XY[0]:
-            pixel_size_x = (abs(upper_right_XY[0]) + abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) + abs(lower_left_XY[1])) / y_length
+        pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
+        pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
Tools
Ruff

158-163: Combine if branches using logical or operator (SIM114)

Combine if branches


165-170: Combine if branches using logical or operator (SIM114)

Combine if branches


Line range hint 193-193: self.output_crs_id の比較に != 演算子を使用することで、コードの意図がより明確になります。

-        if not self.output_crs_id == "EPSG:3857":
+        if self.output_crs_id != "EPSG:3857":
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2f319ea and 8c5e647.

Files selected for processing (1)
  • elevation_tile_tools/elevation_tile_converter.py (6 hunks)
Additional context used
Path-based instructions (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Pattern **/*.py: - can be available more immutable approach?

Ruff
elevation_tile_tools/elevation_tile_converter.py

77-77: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


79-79: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


158-163: Combine if branches using logical or operator (SIM114)

Combine if branches


165-170: Combine if branches using logical or operator (SIM114)

Combine if branches


193-193: Use self.output_crs_id != "EPSG:3857" instead of not self.output_crs_id == "EPSG:3857" (SIM201)

Replace with != operator

elevation_tile_tools/elevation_tile_converter.py Outdated Show resolved Hide resolved
elevation_tile_tools/elevation_tile_converter.py Outdated Show resolved Hide resolved
elevation_tile_tools/elevation_tile_converter.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Line range hint 72-74: 静的解析ツールによるヒントに基づいて、いくつかのコード改善を提案します。

-        if lon < -180:
-            lon = int(-180)
-        elif lon > 180:
-            lon = int(180)
+        if lon < -180:
+            lon = -180
+        elif lon > 180:
+            lon = 180

-        if upper_right_XY[0] >= 0 && lower_left_XY[0] >= 0:
-            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
-        elif upper_right_XY[0] <= 0 && lower_left_XY[0] <= 0:
-            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
+        if upper_right_XY[0] >= 0 && lower_left_XY[0] >= 0 || upper_right_XY[0] <= 0 && lower_left_XY[0] <= 0:
+            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
+            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length

-        if not self.output_crs_id == "EPSG:3857":
+        if self.output_crs_id != "EPSG:3857":
            geotiff.reprojection("EPSG:3857", self.output_crs_id)

Also applies to: 153-158, 160-165, 188-188

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8c5e647 and 721072c.

Files selected for processing (1)
  • elevation_tile_tools/elevation_tile_converter.py (6 hunks)
Additional context used
Path-based instructions (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Pattern **/*.py: - can be available more immutable approach?

Ruff
elevation_tile_tools/elevation_tile_converter.py

72-72: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


74-74: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


153-158: Combine if branches using logical or operator (SIM114)

Combine if branches


160-165: Combine if branches using logical or operator (SIM114)

Combine if branches


188-188: Use self.output_crs_id != "EPSG:3857" instead of not self.output_crs_id == "EPSG:3857" (SIM201)

Replace with != operator

Additional comments not posted (2)
elevation_tile_tools/elevation_tile_converter.py (2)

15-23: このクラスはQThreadから継承されており、進行状況を報告するためのシグナルが多数追加されています。これらのシグナルはUIとの連携を強化し、ユーザーに対してより詳細なフィードバックを提供することができます。


55-57: count_tiles メソッドを使用してタイルの数を取得していますが、このメソッドが正確にタイル数を計算しているかの確認が必要です。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (2)
elevation_tile_tools/elevation_tile_converter.py (2)

Line range hint 76-78: 不要な int 呼び出しがあります。リテラルに置き換えてください。

-        if lon < -180:
-            lon = int(-180)
-        elif lon > 180:
-            lon = int(180)
+        if lon < -180:
+            lon = -180
+        elif lon > 180:
+            lon = 180

Line range hint 192-192: self.output_crs_id != "EPSG:3857" を使用して比較を行うほうが適切です。

-        if not self.output_crs_id == "EPSG:3857":
+        if self.output_crs_id != "EPSG:3857":
            geotiff.reprojection("EPSG:3857", self.output_crs_id)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 721072c and bf23d2d.

Files selected for processing (1)
  • elevation_tile_tools/elevation_tile_converter.py (6 hunks)
Additional context used
Path-based instructions (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Pattern **/*.py: - can be available more immutable approach?

Ruff
elevation_tile_tools/elevation_tile_converter.py

76-76: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


78-78: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


157-162: Combine if branches using logical or operator (SIM114)

Combine if branches


164-169: Combine if branches using logical or operator (SIM114)

Combine if branches


192-192: Use self.output_crs_id != "EPSG:3857" instead of not self.output_crs_id == "EPSG:3857" (SIM201)

Replace with != operator

elevation_tile_tools/elevation_tile_converter.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Outside diff range and nitpick comments (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Line range hint 191-191: self.output_crs_id の比較に != 演算子を使用することをお勧めします。これによりコードの意図がより明確になります。

-        if not self.output_crs_id == "EPSG:3857":
+        if self.output_crs_id != "EPSG:3857":
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bf23d2d and d3a0d7d.

Files selected for processing (1)
  • elevation_tile_tools/elevation_tile_converter.py (6 hunks)
Additional context used
Path-based instructions (1)
elevation_tile_tools/elevation_tile_converter.py (1)

Pattern **/*.py: - can be available more immutable approach?

Ruff
elevation_tile_tools/elevation_tile_converter.py

76-76: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


78-78: Unnecessary int call (rewrite as a literal) (UP018)

Replace with integer literal


191-191: Use self.output_crs_id != "EPSG:3857" instead of not self.output_crs_id == "EPSG:3857" (SIM201)

Replace with != operator

Additional comments not posted (1)
elevation_tile_tools/elevation_tile_converter.py (1)

157-168: if ブランチを論理 or 演算子を使用して統合することができます。これによりコードの冗長性が減少し、可読性が向上します。
[REFACTOR_Suggestion]

-        if (upper_right_XY[0] >= 0 and lower_left_XY[0] >= 0) or (
-            upper_right_XY[0] <= 0 and lower_left_XY[0] <= 0
-        ):
-            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
-        # 片方がプラスなら絶対値を足す
-        elif (upper_right_XY[0] <= 0 <= lower_left_XY[0]) or (
-            upper_right_XY[0] >= 0 >= lower_left_XY[0]
-        ):
-            pixel_size_x = (abs(upper_right_XY[0]) + abs(lower_left_XY[0])) / x_length
-            pixel_size_y = -(abs(upper_right_XY[1]) + abs(lower_left_XY[1])) / y_length
+        if upper_right_XY[0] * lower_left_XY[0] >= 0:
+            pixel_size_x = (abs(upper_right_XY[0]) - abs(lower_left_XY[0])) / x_length
+            pixel_size_y = -(abs(upper_right_XY[1]) - abs(lower_left_XY[1])) / y_length
+        else:
+            pixel_size_x = (abs(upper_right_XY[0]) + abs(lower_left_XY[0])) / x_length
+            pixel_size_y = -(abs(upper_right_XY[1]) + abs(lower_left_XY[1])) / y_length

Copy link
Contributor

@nbayashi nbayashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nbayashi nbayashi merged commit fc7370e into master Jun 18, 2024
2 checks passed
@bordoray bordoray deleted the feat/progress-bar branch June 20, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Progress bar
2 participants