Ticket #20013: 20013.patch
File 20013.patch, 2.1 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/actions/corrector/ReverseWayTagCorrector.java
13 13 import java.util.function.Function; 14 14 import java.util.regex.Matcher; 15 15 import java.util.regex.Pattern; 16 import java.util.stream.Collectors; 16 17 17 18 import org.openstreetmap.josm.command.Command; 18 19 import org.openstreetmap.josm.data.correction.RoleCorrection; … … 24 25 import org.openstreetmap.josm.data.osm.Relation; 25 26 import org.openstreetmap.josm.data.osm.RelationMember; 26 27 import org.openstreetmap.josm.data.osm.Tag; 27 import org.openstreetmap.josm.data.osm.TagCollection;28 28 import org.openstreetmap.josm.data.osm.Tagged; 29 29 import org.openstreetmap.josm.data.osm.Way; 30 30 import org.openstreetmap.josm.tools.Logging; … … 173 173 /** 174 174 * Tests whether way can be reversed without semantic change, i.e., whether tags have to be changed. 175 175 * Looks for keys like oneway, oneway:bicycle, cycleway:right:oneway, left/right. 176 * Also tests the nodes, e.g. a highway=stop with direction, see #20013. 176 177 * @param way way to test 177 178 * @return false if tags should be changed to keep semantic, true otherwise. 178 179 */ 179 180 public static boolean isReversible(Way way) { 180 for (Tag tag : TagCollection.from(way)) { 181 if (!tag.equals(TagSwitcher.apply(tag))) { 182 return false; 183 } 184 } 185 return true; 181 return getTagCorrectionsMap(way).isEmpty(); 186 182 } 187 183 188 184 /** … … 192 188 * @see #isReversible(Way) 193 189 */ 194 190 public static List<Way> irreversibleWays(List<Way> ways) { 195 List<Way> newWays = new ArrayList<>(ways); 196 for (Way way : ways) { 197 if (isReversible(way)) { 198 newWays.remove(way); 199 } 200 } 201 return newWays; 191 return ways.stream().filter(w -> !isReversible(w)).collect(Collectors.toList()); 202 192 } 203 193 204 194 /**