Ticket #21333: 21333.2.patch

File 21333.2.patch, 3.4 KB (added by taylor.smock, 5 years ago)

Blacklist "crossing_box", "loading_ramp", "platform", "roundhouse", "signal_box", "station", "traverser", "wash", "workshop"

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

    diff --git a/src/org/openstreetmap/josm/data/validation/tests/SharpAngles.java b/src/org/openstreetmap/josm/data/validation/tests/SharpAngles.java
    index 676eb47f10..ecbe50d25a 100644
    a b import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;  
    1616import org.openstreetmap.josm.data.validation.Severity;
    1717import org.openstreetmap.josm.data.validation.Test;
    1818import org.openstreetmap.josm.data.validation.TestError;
     19import org.openstreetmap.josm.spi.preferences.Config;
    1920import org.openstreetmap.josm.tools.Geometry;
    2021import org.openstreetmap.josm.tools.bugreport.BugReport;
    2122
    public class SharpAngles extends Test {  
    2829    private static final int SHARPANGLESCODE = 3800;
    2930    /** The code for a sharp angle */
    3031    private static final int SHARP_ANGLES = SHARPANGLESCODE + 0;
    31     /** The maximum angle for sharp angles */
    32     private double maxAngle = 45.0; // degrees
    33     /** The length that at least one way segment must be shorter than */
    34     private double maxLength = 10.0; // meters
     32    /** The maximum angle for sharp angles (degrees) */
     33    private double maxAngle;
     34    /** The length that at least one way segment must be shorter than (meters) */
     35    private double maxLength;
    3536    /** Specific highway types to ignore */
    3637    private final Collection<String> ignoreHighways = new TreeSet<>(
    3738            Arrays.asList("platform", "rest_area", "services", "via_ferrata"));
     39    /** Specific railway types to ignore */
     40    private final Collection<String> ignoreRailway = new TreeSet<>(
     41            Arrays.asList("crossing_box", "loading_ramp", "platform", "roundhouse", "signal_box", "station",
     42                    "traverser", "wash", "workshop")
     43    );
    3844
    3945    /**
    4046     * Construct a new {@code IntersectionIssues} object
    4147     */
    4248    public SharpAngles() {
    43         super(tr("Sharp angles"), tr("Check for sharp angles on roads"));
     49        super(tr("Sharp angles"), tr("Check for sharp angles on man made transportation ways"));
     50        this.maxLength = Config.getPref().getDouble("validator.sharpangles.maxlength", 10.0); // meters
     51        this.maxAngle = Config.getPref().getDouble("validator.sharpangles.maxlength", 45.0); // degrees
    4452    }
    4553
    4654    @Override
    public class SharpAngles extends Test {  
    6169     * @return {@code true} if the way should be checked.
    6270     */
    6371    public boolean shouldBeTestedForSharpAngles(Way way) {
    64         return (way.hasKey("highway") && !way.hasTag("area", "yes") && !way.hasKey("via_ferrata_scale") &&
    65                 !ignoreHighways.contains(way.get("highway")));
     72        return !way.hasTag("area", "yes") &&
     73                ((way.hasKey("highway") && !way.hasKey("via_ferrata_scale") && !ignoreHighways.contains(way.get("highway")))
     74                    || (way.hasKey("railway") && !ignoreRailway.contains(way.get("railway"))));
    6675    }
    6776
    6877    /**
    public class SharpAngles extends Test {  
    144153        ignoreHighways.add(highway);
    145154    }
    146155
     156    /**
     157     * Add a railway to ignore
     158     * @param railway The highway type to ignore (e.g., if you want to ignore miniature railways, use "miniature")
     159     * @since xxx
     160     */
     161    public void addIgnoredRailway(String railway) {
     162        ignoreRailway.add(railway);
     163    }
     164
    147165    /**
    148166     * Set the maximum angle
    149167     * @param angle The maximum angle in degrees.