From d8aa5a9ab84944e0f830074fafc9ba5bb665810f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 16 Sep 2026 00:43:02 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E3=83=9C=E3=83=BC?= =?UTF-8?q?=E3=83=8A=E3=82=B9=E3=81=AE=E4=B8=8A=E9=99=90=E3=82=92=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=81=AE=E3=83=AA=E3=83=86=E3=83=A9=E3=83=AB?= =?UTF-8?q?=E3=81=A7=E5=9B=BA=E5=AE=9A=E3=81=97=E5=AE=9A=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E5=85=AC=E9=96=8B=E3=82=92=E3=82=84=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KuvCXLRytCryvexood76po --- src/utils/accuracyBonus.test.ts | 15 ++++++++++----- src/utils/accuracyBonus.ts | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/utils/accuracyBonus.test.ts b/src/utils/accuracyBonus.test.ts index 7eaf98b8f..eb358af0c 100644 --- a/src/utils/accuracyBonus.test.ts +++ b/src/utils/accuracyBonus.test.ts @@ -1,14 +1,19 @@ -import { getAccuracyBonus, MAX_ACCURACY_BONUS } from './accuracyBonus'; +import { getAccuracyBonus } from './accuracyBonus'; describe('getAccuracyBonus', () => { it('精度の半分を補正として返す', () => { expect(getAccuracyBonus(100)).toBe(50); }); - it('上限で頭打ちになる', () => { - // 地下の粗い測位(精度2000m)でも、判定圏が無制限に広がらないようにする - expect(getAccuracyBonus(2000)).toBe(MAX_ACCURACY_BONUS); - expect(getAccuracyBonus(300)).toBe(MAX_ACCURACY_BONUS); + // 上限はリテラルで固定する。実装側の定数と突き合わせるとトートロジーになり、 + // 上限を 150m から動かしてもテストが通ってしまう。 + it('補正の上限は150mで、精度300mで頭打ちになる', () => { + // 頭打ちの境界(精度300m → 半分が上限ちょうど) + expect(getAccuracyBonus(300)).toBe(150); + // 境界の手前では半分のまま + expect(getAccuracyBonus(299)).toBe(149.5); + // 地下の粗い測位でも上限を超えない + expect(getAccuracyBonus(2000)).toBe(150); }); it('精度が無い・不正・非正の値では補正しない', () => { diff --git a/src/utils/accuracyBonus.ts b/src/utils/accuracyBonus.ts index 8a50b9d69..2561dc3f6 100644 --- a/src/utils/accuracyBonus.ts +++ b/src/utils/accuracyBonus.ts @@ -1,5 +1,7 @@ -/** GPS精度に応じた閾値補正の上限(m) */ -export const MAX_ACCURACY_BONUS = 150; +// GPS精度に応じた閾値補正の上限(m)。公開しない: 値そのものは +// accuracyBonus.test.ts がリテラルで固定しており、外から突き合わせる用途は無い。 +// 公開して突き合わせに使うと、値を変えてもテストが通るトートロジーになる。 +const MAX_ACCURACY_BONUS = 150; /** * GPS精度に応じて到着圏・接近圏へ加える補正(m)を返す。 From 04d42a8b12efd7074a925a531a8e0693777711bf Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 16 Sep 2026 00:52:12 +0000 Subject: [PATCH 2/2] =?UTF-8?q?GPX=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E3=83=9C=E3=83=BC=E3=83=8A=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E5=86=99=E3=81=97=E3=82=92=E5=85=B1=E6=9C=89=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97=E3=81=B8=E7=BD=AE?= =?UTF-8?q?=E3=81=8D=E6=8F=9B=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KuvCXLRytCryvexood76po --- src/store/atoms/location.gpxEtaAssist.test.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/store/atoms/location.gpxEtaAssist.test.ts b/src/store/atoms/location.gpxEtaAssist.test.ts index aa7aad722..edd6e04f8 100644 --- a/src/store/atoms/location.gpxEtaAssist.test.ts +++ b/src/store/atoms/location.gpxEtaAssist.test.ts @@ -26,6 +26,7 @@ import { ARRIVED_MIN_THRESHOLD, BAD_ACCURACY_THRESHOLD, } from '~/constants/threshold'; +import { getAccuracyBonus } from '~/utils/accuracyBonus'; import { getEtaPhaseNow } from '~/utils/etaPhaseNow'; import { clamp, @@ -57,9 +58,6 @@ jest.mock('~/lib/remoteConfig', () => ({ isForceNotArrivedOnLowAccuracyEnabled: () => true, })); -// useRefreshStation のプライベート定数と同値。到着圏へ加える精度ボーナスの上限(m)。 -const MAX_ACCURACY_BONUS = 150; - type Condition = { label: string; accuracy: number; @@ -223,9 +221,9 @@ const replay = ( ARRIVED_MIN_THRESHOLD, ARRIVED_MAX_THRESHOLD ); - // 到着圏はGPS精度だけで決まる(ETAは到着判定へ介入しない) - const arrivedRadius = - arrivedThreshold + Math.min(accuracy * 0.5, MAX_ACCURACY_BONUS); + // 到着圏はGPS精度だけで決まる(ETAは到着判定へ介入しない)。精度ボーナスは + // useRefreshStation と同じ関数で求める(式を写すと判定とずれても気付けない) + const arrivedRadius = arrivedThreshold + getAccuracyBonus(accuracy); const arrived = nearestDistance <= arrivedRadius; if (arrived && firstDetection[nearestIdx] === null) {