Changeset 19162 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/SharpAngles.java
r18619 r19162 6 6 import java.util.Arrays; 7 7 import java.util.Collection; 8 import java.util.Collections; 8 9 import java.util.TreeSet; 9 10 … … 17 18 import org.openstreetmap.josm.data.validation.Test; 18 19 import org.openstreetmap.josm.data.validation.TestError; 20 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 21 import org.openstreetmap.josm.spi.preferences.Config; 19 22 import org.openstreetmap.josm.tools.Geometry; 20 23 import org.openstreetmap.josm.tools.bugreport.BugReport; … … 28 31 private static final int SHARPANGLESCODE = 3800; 29 32 /** The code for a sharp angle */ 30 private static final int SHARP_ANGLES = SHARPANGLESCODE + 0;31 /** The maximum angle for sharp angles */32 private double maxAngle = 45.0; // degrees33 /** The length that at least one way segment must be shorter than */34 private double maxLength = 10.0; // meters33 private static final int SHARP_ANGLES = SHARPANGLESCODE; 34 /** The maximum angle for sharp angles (degrees) */ 35 private double maxAngle; 36 /** The length that at least one way segment must be shorter than (meters) */ 37 private double maxLength; 35 38 /** Specific highway types to ignore */ 36 private final Collection<String> ignoreHighways = new TreeSet<>( 37 Arrays.asList("platform", "rest_area", "services", "via_ferrata")); 39 private Collection<String> ignoreHighways = Collections.emptyList(); 40 /** Specific railway types to ignore */ 41 private Collection<String> ignoreRailway = Collections.emptyList(); 38 42 39 43 /** … … 41 45 */ 42 46 public SharpAngles() { 43 super(tr("Sharp angles"), tr("Check for sharp angles on roads")); 47 super(tr("Sharp angles"), tr("Check for sharp angles on man made transportation ways")); 48 } 49 50 @Override 51 public void startTest(ProgressMonitor progressMonitor) { 52 super.startTest(progressMonitor); 53 this.maxLength = Config.getPref().getDouble("validator.sharpangles.maxlength", 10.0); // meters 54 this.maxAngle = Config.getPref().getDouble("validator.sharpangles.maxangle", 45.0); // degrees 55 this.ignoreRailway = Collections.unmodifiableCollection(new TreeSet<>( 56 Config.getPref().getList("validator.sharpangles.ignorerailway", 57 Arrays.asList("crossing_box", "loading_ramp", "platform", "roundhouse", "signal_box", "station", 58 "traverser", "wash", "workshop")))); 59 // TODO make immutable when addIgnoredHighway is removed 60 this.ignoreHighways = new TreeSet<>( 61 Config.getPref().getList("validator.sharpangles.ignorehighway", 62 Arrays.asList("platform", "rest_area", "services", "via_ferrata")) 63 ); 44 64 } 45 65 … … 57 77 58 78 /** 59 * Check whether or nota way should be checked for sharp angles79 * Check whether a way should be checked for sharp angles 60 80 * @param way The way that needs to be checked 61 81 * @return {@code true} if the way should be checked. 62 82 */ 63 83 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"))); 84 return !way.hasTag("area", "yes") && 85 ((way.hasKey("highway") && !way.hasKey("via_ferrata_scale") && !ignoreHighways.contains(way.get("highway"))) 86 || (way.hasKey("railway") && !ignoreRailway.contains(way.get("railway")))); 66 87 } 67 88 … … 144 165 * Add a highway to ignore 145 166 * @param highway The highway type to ignore (e.g., if you want to ignore residential roads, use "residential") 167 * @since 19162 (deprecated) 168 * @deprecated Not known to be used. Please use config preference "validator.sharpangles.ignorehighway" instead. 146 169 */ 170 @Deprecated(since = "19162", forRemoval = true) 147 171 public void addIgnoredHighway(String highway) { 172 // Don't forget to make ignoreHighways immutable when this method is removed 148 173 ignoreHighways.add(highway); 149 174 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/SharpAnglesTest.java
r18853 r19162 18 18 import org.openstreetmap.josm.data.osm.Node; 19 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 20 21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 21 22 import org.openstreetmap.josm.testutils.annotations.Projection; … … 37 38 angles = new SharpAngles(); 38 39 angles.initialize(); 40 angles.startTest(NullProgressMonitor.INSTANCE); 39 41 } 40 42
Note:
See TracChangeset
for help on using the changeset viewer.