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 #8758 - Revalidate disconnected_way and impossible_oneway errors on change #8911

Merged
merged 19 commits into from
Feb 15, 2025

Conversation

andrewpmk
Copy link
Contributor

Here is a potential fix to the issue causing disconnected road and impossible one way errors to not be reset when another road or other way is connected to them (which should cause the issue to disappear). This change simply revalidates ALL issues that are either "disconnected_way" or "impossible_oneway" whenever any change is made. This will lead to unnecessary revalidation in some cases, not sure if the performance penalty of doing this is acceptable or whether we will need to find a way to filter which of these ways get revalidated somehow.

This is my first pull request to iD, so I am not that familiar with this project and there may be a better way to do this. Sorry haven't created any tests but the existing tests pass.

Fixes #8758

@tyrasd tyrasd added validation An issue with the validation or Q/A code bug A bug - let's fix this! labels Jan 28, 2022
@tyrasd tyrasd added this to the 2.21.0 milestone Jan 28, 2022
@andrewpmk
Copy link
Contributor Author

andrewpmk commented Feb 4, 2022

Added a test to test/spec/core/validator.js and another one to test/spec/validations/disconnected_way.js. The important one is the first one:

    it('removes validation issue when highway is no longer disconnected', function(done) {
        // Add a way which is disconnected from the rest of the map
        var n1 = iD.osmNode({ id: 'n-1', loc: [4, 4] });
        var n2 = iD.osmNode({ id: 'n-2', loc: [4, 5] });
        var w = iD.osmWay({ id: 'w-1', nodes: ['n-1', 'n-2'], tags: { 'highway': 'unclassified' } });
        context.perform(
            iD.actionAddEntity(n1),
            iD.actionAddEntity(n2),
            iD.actionAddEntity(w)
        );
        var validator = new iD.coreValidator(context);
        validator.init();
        var issues = validator.getIssues();
        expect(issues).to.have.lengthOf(0);
        validator.validate().then(function() {
            // Should produce disconnected way error
            issues = validator.getIssues();
            expect(issues).to.have.lengthOf(1);

            // Add new node with entrance node to simulate connection with rest of map
            var n3 = iD.osmNode({ id: 'n-3', loc: [4, 6], tags: { 'entrance': 'yes' } });
            var w2 = iD.osmWay({ id: 'w-2', nodes: ['n-2', 'n-3'], tags: { 'highway': 'unclassified' } });
            context.perform(
                iD.actionAddEntity(n3),
                iD.actionAddEntity(w2)
            );
            validator.validate().then(function() {
                // Should be no errors
                issues = validator.getIssues();
                expect(issues).to.have.lengthOf(0);
                done();
            }).catch(function(err) {
                done(err);
            });
        }).catch(function(err) {
            done(err);
        });

        window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs
    });

This test adds a way that is disconnected from the rest of the map, then adds another way with entrance=yes at the end which simulates it being connected to the map (saw some other tests which do this). This test should pass with my change to revalidate disconnected_way and impossible_oneway errors, but fail without that change.

This test would be cleaner if we used an async function, but .eslintrc is currently set to ECMAScript 6 which doesn't support async functions.

@tyrasd tyrasd self-requested a review February 4, 2022 17:43
@cicku
Copy link
Contributor

cicku commented Feb 14, 2022

Is this also the fix for #8900 and #8981?

@cicku
Copy link
Contributor

cicku commented Mar 6, 2022

FYI I also saw a similar warning when changing the waterway direction.

@tyrasd tyrasd modified the milestones: 2.21.0, 2.22.0 Jun 2, 2022
@tyrasd tyrasd modified the milestones: 2.22.0, 2.23 Oct 3, 2022
@tyrasd tyrasd modified the milestones: 2.23, 2.24 Dec 12, 2022
@tyrasd tyrasd modified the milestones: 2.24, 2.26 Mar 3, 2023
@nickrsan nickrsan added the priority A top priority issue that has a big impact or matter most to new mappers label Dec 5, 2023
@tyrasd tyrasd modified the milestones: 2.26, 2.29 Feb 28, 2024
@tyrasd tyrasd modified the milestones: 2.29, v2.32 Feb 14, 2025
…ways

example: a way can become disconnected from the rest of the road network if the only way that connects it to the rest of the network is deleted.

this also simplifies the logic in validator to be agnostic of the validation types this can affect and optimizes it slightly.
Copy link
Member

@tyrasd tyrasd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix and sorry for the delay for getting this merged.

I've changed the logic slightly and extended the fix to the inverse case of the original bug: When a way becomes disconnected, the validation also should be re-triggered to warn about the newly disconnected ways.

FYI: There is currently a bug in the test runner, meaning that the test cases here don't fully work as intended, see #10773

@tyrasd tyrasd merged commit a703895 into openstreetmap:develop Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug - let's fix this! priority A top priority issue that has a big impact or matter most to new mappers validation An issue with the validation or Q/A code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highway reachability warnings remain after being fixed
4 participants