- Timestamp:
- 2016-01-19T13:28:25+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/corrector/ReverseWayNoTagCorrector.java
r8919 r9539 6 6 7 7 import java.util.Arrays; 8 import java.util.Map; 8 9 9 10 import javax.swing.JOptionPane; 10 11 11 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 14 import org.openstreetmap.josm.data.osm.Tag; 13 15 import org.openstreetmap.josm.data.osm.TagCollection; 16 import org.openstreetmap.josm.data.osm.Tagged; 14 17 import org.openstreetmap.josm.data.osm.Way; 15 18 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; … … 34 37 * Tags that imply a semantic meaning from the way direction and cannot be changed. 35 38 */ 36 p ublicstatic final TagCollection directionalTags = new TagCollection(Arrays.asList(new Tag[]{39 private static final TagCollection directionalTags = new TagCollection(Arrays.asList(new Tag[]{ 37 40 new Tag("natural", "coastline"), 38 41 new Tag("natural", "cliff"), … … 41 44 new Tag("barrier", "retaining_wall"), 42 45 new Tag("man_made", "embankment"), 43 new Tag("waterway", "stream"),44 new Tag("waterway", "river"),45 new Tag("waterway", "ditch"),46 new Tag("waterway", "drain"),47 new Tag("waterway", "canal")48 46 })); 49 47 … … 53 51 * @return tags that imply a semantic meaning from <code>way</code> direction and cannot be changed 54 52 */ 55 public static TagCollection getDirectionalTags(Way way) { 56 return directionalTags.intersect(TagCollection.from(way)); 53 public static TagCollection getDirectionalTags(Tagged way) { 54 final TagCollection collection = new TagCollection(); 55 for (Map.Entry<String, String> entry : way.getKeys().entrySet()) { 56 final Tag tag = new Tag(entry.getKey(), entry.getValue()); 57 final boolean isDirectional = directionalTags.contains(tag) || OsmPrimitive.directionalKeyPredicate.evaluate(tag); 58 if (isDirectional) { 59 final boolean cannotBeCorrected = ReverseWayTagCorrector.getTagCorrections(tag).isEmpty(); 60 if (cannotBeCorrected) { 61 collection.add(tag); 62 } 63 } 64 } 65 return collection; 57 66 } 58 67 … … 63 72 * @return false if the semantic meaning change if the way is reversed, true otherwise. 64 73 */ 65 public static boolean isReversible( Wayway) {74 public static boolean isReversible(Tagged way) { 66 75 return getDirectionalTags(way).isEmpty(); 67 }68 69 protected static String getHTML(TagCollection tags) {70 if (tags.size() == 1) {71 return tags.iterator().next().toString();72 } else if (tags.size() > 1) {73 return Utils.joinAsHtmlUnorderedList(tags);74 } else {75 return "";76 }77 76 } 78 77 … … 89 88 tags.size(), 90 89 way.getDisplayName(DefaultNameFormatter.getInstance()), 91 getHTML(tags)90 Utils.joinAsHtmlUnorderedList(tags) 92 91 ); 93 92 int ret = ConditionalOptionPaneUtil.showOptionDialog( -
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r8919 r9539 20 20 import org.openstreetmap.josm.data.osm.Tag; 21 21 import org.openstreetmap.josm.data.osm.TagCollection; 22 import org.openstreetmap.josm.data.osm.Tagged; 22 23 import org.openstreetmap.josm.data.osm.Way; 23 24 import org.openstreetmap.josm.tools.UserCancelException; … … 202 203 } 203 204 204 @Override 205 public Collection<Command> execute(Way oldway, Way way) throws UserCancelException { 206 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = new HashMap<>(); 207 205 static List<TagCorrection> getTagCorrections(Tagged way) { 208 206 List<TagCorrection> tagCorrections = new ArrayList<>(); 209 207 for (String key : way.keySet()) { … … 225 223 } 226 224 } 227 if (!tagCorrections.isEmpty()) { 228 tagCorrectionsMap.put(way, tagCorrections); 229 } 230 231 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap = new HashMap<>(); 225 return tagCorrections; 226 } 227 228 static List<RoleCorrection> getRoleCorrections(Way oldway) { 232 229 List<RoleCorrection> roleCorrections = new ArrayList<>(); 233 230 … … 263 260 } 264 261 } 262 return roleCorrections; 263 } 264 265 @Override 266 public Collection<Command> execute(Way oldway, Way way) throws UserCancelException { 267 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = new HashMap<>(); 268 List<TagCorrection> tagCorrections = getTagCorrections(way); 269 if (!tagCorrections.isEmpty()) { 270 tagCorrectionsMap.put(way, tagCorrections); 271 } 272 273 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap = new HashMap<>(); 274 List<RoleCorrection> roleCorrections = getRoleCorrections(oldway); 265 275 if (!roleCorrections.isEmpty()) { 266 276 roleCorrectionMap.put(way, roleCorrections); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r9538 r9539 238 238 @Override public boolean evaluate(OsmPrimitive primitive) { 239 239 return true; 240 } 241 }; 242 243 public static final Predicate<Tag> directionalKeyPredicate = new Predicate<Tag>() { 244 @Override 245 public boolean evaluate(Tag tag) { 246 return directionKeys.match(tag); 240 247 } 241 248 }; … … 803 810 String reversedDirectionDefault = "oneway=\"-1\""; 804 811 805 String directionDefault = "oneway? | (aerialway=* aerialway!=station) | "+812 String directionDefault = "oneway? | (aerialway=* -aerialway=station) | "+ 806 813 "waterway=stream | waterway=river | waterway=ditch | waterway=wadi | waterway=drain | "+ 807 814 "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+
Note:
See TracChangeset
for help on using the changeset viewer.