Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在encode0方法中的每次循环,对于经度(对应 box[0][0] 和 box[0][1])和纬度(对应 box[1][0] 和 box[1][1])这两个维度,都是按照相同的逻辑去不断地二等分范围。
每一次循环迭代,都是通过计算当前维度范围的中间值 mid,然后根据坐标值与 mid 的比较结果来更新该维度范围的边界(也就是 box 中对应维度的两个值)。这种二等分的更新方式是完全对称的操作,在经过相同次数的迭代(由 bitSize 决定迭代次数)后,经度和纬度这两个维度的范围缩小比例是一样的,所以最终它们的范围差值(也就是 box[0][1] - box[0][0] 和 box[1][1] - box[1][0])会相同,即height和width相同。
由于后续内容对于height和width的使用是对称的,尽管逻辑与正常的经纬度计算逻辑不一致,但是并不影响最终结果。