Skip to content

Commit 93c8e3d

Browse files
committed
Merge remote-tracking branch 'k-yle/kh/mismatched-geom-error' into develop
2 parents fd967bf + c3c0e23 commit 93c8e3d

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
4343
#### :camera: Street-Level
4444
#### :white_check_mark: Validation
4545
#### :bug: Bugfixes
46+
* Fix unsolvable validator error triggered by regional presets ([#10459])
4647
#### :earth_asia: Localization
4748
* Update Sinitic languages in the Multilingual Names field ([#10488], thanks [@winstonsung])
4849
* Update the list of languages in the Wikipedia field ([#10489])
@@ -54,6 +55,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
5455
* Migrate unit tests from karma to vitest ([#10452])
5556

5657
[#10452]: https://github.com/openstreetmap/iD/pull/10452
58+
[#10459]: https://github.com/openstreetmap/iD/pull/10459
5759
[#10488]: https://github.com/openstreetmap/iD/pull/10488
5860
[#10489]: https://github.com/openstreetmap/iD/pull/10489
5961
[@winstonsung]: https://github.com/winstonsung/

modules/presets/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ export function presetIndex() {
5656
let _loadPromise;
5757

5858

59-
_this.ensureLoaded = () => {
60-
if (_loadPromise) return _loadPromise;
59+
/** @param {boolean=} bypassCache - used by unit tests */
60+
_this.ensureLoaded = (bypassCache) => {
61+
if (_loadPromise && !bypassCache) return _loadPromise;
6162

6263
return _loadPromise = Promise.all([
6364
fileFetcher.get('preset_categories'),

modules/validations/mismatched_geometry.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ export function validationMismatchedGeometry() {
244244
var asSource = presetManager.match(entity, graph);
245245

246246
var targetGeom = targetGeoms.find(nodeGeom => {
247-
var asTarget = presetManager.matchTags(entity.tags, nodeGeom);
247+
const asTarget = presetManager.matchTags(
248+
entity.tags,
249+
nodeGeom,
250+
entity.extent(graph).center(),
251+
);
248252
if (!asSource || !asTarget ||
249253
asSource === asTarget ||
250254
// sometimes there are two presets with the same tags for different geometries

test/spec/validations/mismatched_geometry.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ describe('iD.validations.mismatched_geometry', function () {
44
beforeEach(function() {
55
_savedAreaKeys = iD.osmAreaKeys;
66
context = iD.coreContext().init();
7+
iD.fileFetcher.cache().preset_presets = {
8+
library: {
9+
tags: { amenity: 'library' },
10+
geometry: ['point', 'vertex', 'line', 'area'],
11+
locationSet: { include: ['NU'] }
12+
},
13+
generic_amenity: {
14+
tags: { amenity: '*' },
15+
geometry: ['point', 'vertex', 'line', 'area']
16+
},
17+
};
718
});
819

920
afterEach(function() {
@@ -112,4 +123,11 @@ describe('iD.validations.mismatched_geometry', function () {
112123
expect(issue.entityIds[0]).to.eql('w-1');
113124
});
114125

126+
it('does not error if the best preset is limited to certain regions', async () => {
127+
await iD.presetManager.ensureLoaded(true);
128+
129+
createClosedWay({ amenity: 'library' });
130+
const issues = validate();
131+
expect(issues).to.have.lengthOf(0);
132+
});
115133
});

0 commit comments

Comments
 (0)