Skip to content

fix: cap index cells and make transform work without an index - #25

Merged
kochizufan merged 2 commits into
train/2026-12from
dec26/tin-index-cell-limit
Oct 30, 2026
Merged

kochizufan merged 2 commits into
train/2026-12from
dec26/tin-index-cell-limit

Conversation

@kochizufan

Copy link
Copy Markdown
Member

変更

  • addIndexedTin: 索引のセル数が三角形 1 つあたり平均 36 を超えるデータは索引を作らない。全体を覆う三角形ばかりの細工されたデータでも、索引づくりが三角形の数の 2 乗にならない
  • transform: 索引が無いときに TypeError で落ちていたのを直し、全三角形の線形探索へ進むようにした。三角形が 4 つ以下の地図もこの道を通る
  • countIndexCells と MAX_INDEX_CELLS_PER_TRIANGLE を src/geometry.ts に追加(パッケージの公開 API には足していない)

影響

  • 変換の結果は変わらない。索引の有無で同じ結果になることを試験で確かめた
  • 同梱のデータでセル数が最も多い地図でも 1 三角形あたり約 9 で、上限より十分小さい
  • Compiled・CompiledLegacy の形は変えていない

確かめたこと

  • tests/indexed-tin-limit.test.ts: 修正前の commit で 7 件が失敗し、修正後に全件が通る
  • vitest run 3882 件・typecheck・eslint が通る

🤖 Generated with Claude Code

kochizufan and others added 2 commits October 31, 2026 04:23
countIndexCells counts the cells an index would hold without building it.
The tests fail until addIndexedTin and transform use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Crafted data with triangles spanning the whole extent made building the
grid index quadratic in the triangle count. Skip the index when the cell
count exceeds 36 per triangle on average; real maps stay near 9.

transform() threw a TypeError whenever no index existed, which also hit
every map of four triangles or fewer. It now falls back to the linear
search that transformArr already has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kochizufan
kochizufan marked this pull request as ready for review October 30, 2026 19:26
@kochizufan
kochizufan merged commit 7e982b6 into train/2026-12 Oct 30, 2026
4 checks passed
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.

1 participant