Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix erroneous mismatched_geometry warning for preset-less tags #10523

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/validations/mismatched_geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export function validationMismatchedGeometry() {
return null;
}

if (asLine.isFallback() && asArea.isFallback() && !deepEqual(tagSuggestingArea, { area: 'yes' })) {
// if the entity matches the fallback preset, regardless of the
// geometry, then changing the geometry will not help.
return null;
}

return tagSuggestingArea;
}

Expand Down
18 changes: 17 additions & 1 deletion test/spec/validations/mismatched_geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ describe('iD.validations.mismatched_geometry', function () {
_savedAreaKeys = iD.osmAreaKeys;
context = iD.coreContext().init();
iD.fileFetcher.cache().preset_presets = {
'Line': { geometry: ['line'], fallback: true, tags: {} },
'Area': { geometry: ['area'], fallback: true, tags: { area: 'yes' } },
'Building': { geometry: ['area'], tags: { building: '*' } },
library: {
tags: { amenity: 'library' },
geometry: ['point', 'vertex', 'line', 'area'],
Expand Down Expand Up @@ -98,7 +101,8 @@ describe('iD.validations.mismatched_geometry', function () {
expect(issues).to.have.lengthOf(0);
});

it('flags open way with area tag', function() {
it('flags open way with area tag', async () => {
await iD.presetManager.ensureLoaded(true);
iD.osmSetAreaKeys({ building: {} });
createOpenWay({ building: 'yes' });
var issues = validate();
Expand All @@ -123,6 +127,18 @@ describe('iD.validations.mismatched_geometry', function () {
expect(issue.entityIds[0]).to.eql('w-1');
});

it('does not flag cases whether the entity matches the generic preset, regardless of geometry', async () => {
// in this test case, waterway=dam is allowed as an area,
// and there is no preset for waterway=security_lock, so it
// uses to the fallback preset for all geometries.
await iD.presetManager.ensureLoaded(true);
iD.osmSetAreaKeys({ waterway: { dam: true } });

createOpenWay({ 'disused:waterway': 'security_lock' });
const issues = validate();
expect(issues).to.have.lengthOf(0);
});

it('does not error if the best preset is limited to certain regions', async () => {
await iD.presetManager.ensureLoaded(true);

Expand Down
Loading