Changeset 6573 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-12-31T10:56:23+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r6482 r6573 22 22 import org.openstreetmap.josm.data.validation.Test; 23 23 import org.openstreetmap.josm.data.validation.TestError; 24 import org.openstreetmap.josm.tools.Predicate; 24 25 import org.openstreetmap.josm.tools.Utils; 25 26 … … 36 37 protected static final int SOURCE_MAXSPEED_CONTEXT_MISMATCH_VS_MAXSPEED = 2705; 37 38 protected static final int SOURCE_MAXSPEED_CONTEXT_MISMATCH_VS_HIGHWAY = 2706; 39 protected static final int SOURCE_WRONG_LINK = 2707; 38 40 39 41 /** … … 104 106 testSourceMaxspeed(w, true); 105 107 } 108 testHighwayLink(w); 106 109 } 107 110 } … … 140 143 } 141 144 145 public static boolean isHighwayLinkOkay(final Way way) { 146 final String highway = way.get("highway"); 147 if (highway == null || !highway.endsWith("_link")) { 148 return true; 149 } 150 151 final HashSet<OsmPrimitive> referrers = new HashSet<OsmPrimitive>(); 152 referrers.addAll(way.firstNode().getReferrers()); 153 referrers.addAll(way.lastNode().getReferrers()); 154 155 return Utils.exists(Utils.filteredCollection(referrers, Way.class), new Predicate<Way>() { 156 @Override 157 public boolean evaluate(final Way otherWay) { 158 return !way.equals(otherWay) && otherWay.hasTag("highway", highway, highway.replaceAll("_link$", "")); 159 } 160 }); 161 } 162 163 private void testHighwayLink(final Way way) { 164 if (!isHighwayLinkOkay(way)) { 165 errors.add(new TestError(this, Severity.WARNING, 166 tr("Highway link is not linked to adequate highway/link"), SOURCE_WRONG_LINK, way)); 167 } 168 } 169 142 170 private void testMissingPedestrianCrossing(Node n) { 143 171 leftByPedestrians = false; -
trunk/src/org/openstreetmap/josm/tools/Predicates.java
r6547 r6573 1 1 package org.openstreetmap.josm.tools; 2 3 import org.openstreetmap.josm.data.osm.OsmPrimitive; 2 4 3 5 import java.util.regex.Pattern; … … 46 48 }; 47 49 } 50 51 /** 52 * Returns a {@link Predicate} executing {@link OsmPrimitive#hasTag(String, String...)}. 53 */ 54 public static Predicate<OsmPrimitive> hasTag(final String key, final String... values) { 55 return new Predicate<OsmPrimitive>() { 56 @Override 57 public boolean evaluate(OsmPrimitive p) { 58 return p.hasTag(key, values); 59 } 60 }; 61 } 48 62 }
Note:
See TracChangeset
for help on using the changeset viewer.