From 83cb9d6b90868e266145baf903798f10d4d764bd Mon Sep 17 00:00:00 2001 From: nyampire Date: Tue, 11 Aug 2026 22:50:16 +0900 Subject: [PATCH] =?UTF-8?q?fix(plateau):=20=E3=82=BF=E3=82=B0=E8=BB=A2?= =?UTF-8?q?=E8=A8=98=E3=81=A7=E3=82=82=E6=83=85=E5=A0=B1=E6=BA=90=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=82=BB=E3=83=83=E3=83=88=E3=81=AB=E6=AE=8B?= =?UTF-8?q?=E3=81=99=20(#45)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 建物を追加する経路は annotation に dataUsed を付けるが、タグ転記の経路は 付けていなかった。変更セットの source は EditSystem がこの値から組み立てる ため、転記だけで保存すると MLIT_PLATEAU も RapiD_Plateau_JP も source_ref も 付かない。報告の「タグ転記モードで既存の建物を選択してタグだけ追加すると 情報源が揃わない」はこれ。 データセットの引き当ては UiRapidInspector の受け入れ経路と同じ形にした。 catalog に無ければデータセット id そのものを使う。 --- modules/modes/HeightTransferMode.js | 13 ++++++- test/browser/modes/HeightTransferMode.test.js | 34 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/modules/modes/HeightTransferMode.js b/modules/modes/HeightTransferMode.js index e2b8cfaf1..15e3a4cca 100644 --- a/modules/modes/HeightTransferMode.js +++ b/modules/modes/HeightTransferMode.js @@ -197,13 +197,24 @@ export class HeightTransferMode extends AbstractSystem { // plateauID once committed) and calling `_recompute()` -- which re-runs `findCandidates()` // (already excludes this candidate, since `findCandidates` filters against `transferredIDs`) // and emits 'change'. That means there's no need for a second manual emit here. + // The changeset `source` is assembled from the `dataUsed` on each edit's + // annotation (see `EditSystem#_gatherSources`). Without it the transfer + // records no provenance at all -- no `MLIT_PLATEAU`, no `RapiD_Plateau_JP`, + // no `source_ref` -- while accepting a building records all three. + // Same lookup the accept path uses in `UiRapidInspector`. + const rapid = this.context.systems.rapid; + const datasetID = (candidate.plateauFeature.__datasetid__ ?? 'plateauJapan') + .replace('-conflated', ''); + const dataset = rapid?.datasets?.get(datasetID); + const action = actionTransferPlateauTags(candidate.osmFeature.id, tagsToAdd); editor.perform(action); editor.commit({ annotation: { type: action.actionName, plateauID: candidate.plateauFeature.id, - entityID: candidate.osmFeature.id + entityID: candidate.osmFeature.id, + dataUsed: dataset?.dataUsed || [datasetID] }, selectedIDs: [ candidate.osmFeature.id ] }); diff --git a/test/browser/modes/HeightTransferMode.test.js b/test/browser/modes/HeightTransferMode.test.js index c95b7ef2a..8b3c6d368 100644 --- a/test/browser/modes/HeightTransferMode.test.js +++ b/test/browser/modes/HeightTransferMode.test.js @@ -326,6 +326,40 @@ describe('HeightTransferMode', () => { }); + it('apply() records the dataset on the annotation so the changeset gets a source', () => { + // Rapid#45: 建物を追加する経路は annotation に dataUsed を付けるが、タグ転記の + // 経路は付けていなかった。変更セットの source は EditSystem がこの値から + // 組み立てるので、無いと MLIT_PLATEAU も RapiD_Plateau_JP も source_ref も付かない。 + const context = makeContext(); + context.systems.rapid.datasets = new Map([ + ['plateauJapan', { id: 'plateauJapan', dataUsed: ['osmf.jp', 'Plateau Buildings'] }] + ]); + const mode = new Rapid.HeightTransferMode(context); + mode.activate(); + + mode.apply(makeCandidate({ + plateauFeature: { id: 'p1', tags: { height: '12' }, __datasetid__: 'plateauJapan' } + })); + + const annotation = context.systems.editor.commitCalls[0].annotation; + expect(annotation.dataUsed).to.eql(['osmf.jp', 'Plateau Buildings']); + }); + + + it('apply() falls back to the dataset id when the catalog has no entry', () => { + const context = makeContext(); + const mode = new Rapid.HeightTransferMode(context); + mode.activate(); + + mode.apply(makeCandidate({ + plateauFeature: { id: 'p1', tags: { height: '12' }, __datasetid__: 'plateauJapan' } + })); + + const annotation = context.systems.editor.commitCalls[0].annotation; + expect(annotation.dataUsed).to.eql(['plateauJapan']); + }); + + it('apply() fires change exactly once per call', () => { const context = makeContext(); const mode = new Rapid.HeightTransferMode(context);