Changeset 6623 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2014-01-04T06:39:00+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r6316 r6623 209 209 } 210 210 211 public HistoryOsmPrimitive get(int idx) {211 public HistoryOsmPrimitive get(int idx) throws IndexOutOfBoundsException { 212 212 if (idx < 0 || idx >= versions.size()) 213 213 throw new IndexOutOfBoundsException(MessageFormat.format("Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx)); … … 231 231 } 232 232 233 public boolean isEmpty() { 233 /** 234 * Returns true if this history contains no version. 235 * @return {@code true} if this history contains no version, {@code false} otherwise 236 */ 237 public final boolean isEmpty() { 234 238 return versions.isEmpty(); 235 239 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r6608 r6623 156 156 double enlargeEast = Math.min(maxEnlargePercent - 10*Math.log(diffEast), 1)/100; 157 157 double enlargeNorth = Math.min(maxEnlargePercent - 10*Math.log(diffNorth), 1)/100; 158 System.out.println(enlargeEast);159 158 160 159 visit(bounds.getMin().add(-enlargeEast/2, -enlargeNorth/2)); 161 160 visit(bounds.getMax().add(+enlargeEast/2, +enlargeNorth/2)); 162 161 } 163 164 162 165 163 /** -
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r6591 r6623 34 34 * @author frsantos 35 35 */ 36 public class Test extends AbstractVisitor 37 { 36 public class Test extends AbstractVisitor { 37 38 38 /** Name of the test */ 39 39 protected final String name; … … 90 90 * A test that forwards all primitives to {@link #check(OsmPrimitive)}. 91 91 */ 92 public static abstract class TagTest extends Test { 92 public abstract static class TagTest extends Test { 93 /** 94 * Constructs a new {@code TagTest} with given name and description. 95 * @param name The test name 96 * @param description The test description 97 */ 93 98 public TagTest(String name, String description) { 94 99 super(name, description); 95 100 } 96 101 102 /** 103 * Constructs a new {@code TagTest} with given name. 104 * @param name The test name 105 */ 97 106 public TagTest(String name) { 98 107 super(name); 99 108 } 100 109 110 /** 111 * Checks the tags of the given primitive. 112 * @param p The primitive to test 113 */ 101 114 public abstract void check(final OsmPrimitive p); 102 115 … … 163 176 * actions and destroy the used structures. 164 177 * <p> 165 * If you override this method, don't forget to cleanup {@ link #progressMonitor}178 * If you override this method, don't forget to cleanup {@code progressMonitor} 166 179 * (most overrides call {@code super.endTest()} to do this). 167 180 */ … … 191 204 } 192 205 206 /** 207 * Determines if the primitive is usable for tests. 208 * @param p The primitive 209 * @return {@code true} if the primitive can be tested, {@code false} otherwise 210 */ 193 211 public boolean isPrimitiveUsable(OsmPrimitive p) { 194 212 return p.isUsable() && (!(p instanceof Way) || (((Way) p).getNodesCount() > 1)); // test only Ways with at least 2 nodes … … 222 240 /** 223 241 * Called when the used submits the preferences 242 * @return {@code true} if restart is required, {@code false} otherwise 224 243 */ 225 244 public boolean ok() { … … 265 284 } 266 285 286 /** 287 * Returns the test name. 288 * @return The test name 289 */ 267 290 public String getName() { 268 291 return name; 269 292 } 270 293 294 /** 295 * Determines if the test has been canceled. 296 * @return {@code true} if the test has been canceled, {@code false} otherwise 297 */ 271 298 public boolean isCanceled() { 272 299 return progressMonitor.isCanceled(); -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r6581 r6623 33 33 public abstract class CrossingWays extends Test { 34 34 protected static final int CROSSING_WAYS = 601; 35 36 private static final String HIGHWAY = "highway"; 37 private static final String RAILWAY = "railway"; 38 private static final String WATERWAY = "waterway"; 35 39 36 40 /** All way segments, grouped by cells */ … … 47 51 return super.isPrimitiveUsable(w) 48 52 && !isProposedOrAbandoned(w) 49 && (w.hasKey( "highway")50 || w.hasKey( "waterway")51 || (w.hasKey( "railway") && !isSubwayOrTram(w))53 && (w.hasKey(HIGHWAY) 54 || w.hasKey(WATERWAY) 55 || (w.hasKey(RAILWAY) && !isSubwayOrTram(w)) 52 56 || isCoastline(w) 53 57 || isBuilding(w)); … … 59 63 return true; 60 64 } 61 if (w1.hasKey( "highway") && w2.hasKey("highway") && !Utils.equal(w1.get("level"), w2.get("level"))) {65 if (w1.hasKey(HIGHWAY) && w2.hasKey(HIGHWAY) && !Utils.equal(w1.get("level"), w2.get("level"))) { 62 66 return true; 63 67 } … … 68 72 return true; 69 73 } 70 if ((w1.hasTag( "waterway", "river") && w2.hasTag("waterway", "riverbank"))71 || (w2.hasTag( "waterway", "river") && w1.hasTag("waterway", "riverbank"))) {74 if ((w1.hasTag(WATERWAY, "river") && w2.hasTag(WATERWAY, "riverbank")) 75 || (w2.hasTag(WATERWAY, "river") && w1.hasTag(WATERWAY, "riverbank"))) { 72 76 return true; 73 77 } … … 82 86 if (isBuilding(w1)) { 83 87 return ("Crossing buildings"); 84 } else if (w1.hasKey( "waterway") && w2.hasKey("waterway")) {88 } else if (w1.hasKey(WATERWAY) && w2.hasKey(WATERWAY)) { 85 89 return tr("Crossing waterways"); 86 } else if ((w1.hasKey( "highway") && w2.hasKey("waterway"))87 || (w2.hasKey( "highway") && w1.hasKey("waterway"))) {90 } else if ((w1.hasKey(HIGHWAY) && w2.hasKey(WATERWAY)) 91 || (w2.hasKey(HIGHWAY) && w1.hasKey(WATERWAY))) { 88 92 return tr("Crossing waterway/highway"); 89 93 } else { … … 207 211 208 212 static boolean isSubwayOrTram(OsmPrimitive w) { 209 return w.hasTag( "railway", "subway", "tram");213 return w.hasTag(RAILWAY, "subway", "tram"); 210 214 } 211 215 212 216 static boolean isProposedOrAbandoned(OsmPrimitive w) { 213 return w.hasTag( "highway", "proposed") || w.hasTag("railway", "proposed", "abandoned");217 return w.hasTag(HIGHWAY, "proposed") || w.hasTag(RAILWAY, "proposed", "abandoned"); 214 218 } 215 219 -
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r6605 r6623 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.command.ChangePropertyCommand; 19 import org.openstreetmap.josm.data.osm.Node;20 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.data.osm.Relation;22 import org.openstreetmap.josm.data.osm.Way;23 20 import org.openstreetmap.josm.data.validation.FixableTestError; 24 21 import org.openstreetmap.josm.data.validation.Severity; … … 194 191 return Collections.emptyList(); 195 192 } 193 final List<OpeningHoursTestError> errors = new ArrayList<OpeningHoursTestError>(); 196 194 try { 197 195 final Object r = parse(value, mode); 198 final List<OpeningHoursTestError> errors = new ArrayList<OpeningHoursTestError>();199 196 String prettifiedValue = null; 200 197 try { … … 212 209 errors.add(new OpeningHoursTestError(tr("opening_hours value can be prettified"), Severity.OTHER, prettifiedValue)); 213 210 } 214 return errors; 215 } catch (final Exception ex) { 216 throw new RuntimeException(ex); 217 } 211 } catch (ScriptException ex) { 212 Main.error(ex); 213 } catch (NoSuchMethodException ex) { 214 Main.error(ex); 215 } 216 return errors; 218 217 } 219 218
Note:
See TracChangeset
for help on using the changeset viewer.