Ticket #18127: 18127.14.patch

File 18127.14.patch, 2.6 KB (added by taylor.smock, 6 months ago)

Ignore ways with via_ferrata_scale, since it is much more likely to be a false positive

  • src/org/openstreetmap/josm/data/validation/tests/SharpAngles.java

     
    1515import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1616import org.openstreetmap.josm.data.osm.Way;
    1717import org.openstreetmap.josm.data.osm.WaySegment;
     18import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    1819import org.openstreetmap.josm.data.validation.Severity;
    1920import org.openstreetmap.josm.data.validation.Test;
    2021import org.openstreetmap.josm.data.validation.TestError;
     
    5152    @Override
    5253    public void visit(Way way) {
    5354        if (!way.isUsable()) return;
    54         if (way.hasKey("highway") && !way.hasTag("area", "yes") &&
    55                     !ignoreHighways.contains(way.get("highway"))) {
     55        if (shouldBeTestedForSharpAngles(way)) {
    5656            try {
    5757                checkWayForSharpAngles(way);
    5858            } catch (Exception e) {
     
    6363    }
    6464
    6565    /**
     66     * Check whether or not a way should be checked for sharp angles
     67     * @param way The way that needs to be checked
     68     * @return {@code true} if the way should be checked.
     69     */
     70    public boolean shouldBeTestedForSharpAngles(Way way) {
     71        return (way.hasKey("highway") && !way.hasTag("area", "yes") && !way.hasKey("via_ferrata_scale") &&
     72                !ignoreHighways.contains(way.get("highway")));
     73    }
     74
     75    /**
    6676     * Check nodes in a way for sharp angles
    6777     * @param way A way to check for sharp angles
    6878     */
     
    108118    }
    109119
    110120    private void createNearlyOverlappingError(double angle, Way way, OsmPrimitive primitive) {
    111         TestError.Builder testError = TestError.builder(this, getSeverity(angle), SHARP_ANGLES)
    112                 .primitives(way)
    113                 .highlight(primitive)
    114                 .message(tr("Sharp angle"));
    115         errors.add(testError.build());
     121        Severity severity = getSeverity(angle);
     122        if ((ValidatorPrefHelper.PREF_OTHER.get() || ValidatorPrefHelper.PREF_OTHER_UPLOAD.get()) || !severity.equals(Severity.OTHER)) {
     123            int addCode = severity.equals(Severity.OTHER) ? 1 : 0;
     124            TestError.Builder testError = TestError.builder(this, severity, SHARP_ANGLES + addCode)
     125                    .primitives(way)
     126                    .highlight(primitive)
     127                    .message(tr("Sharp angle"));
     128            errors.add(testError.build());
     129        }
    116130    }
    117131
    118132    private Severity getSeverity(double angle) {