Ticket #23715: 23715.patch
File 23715.patch, 4.3 KB (added by , 5 months ago) |
---|
-
src/relcontext/relationfix/BoundaryFixer.java
63 63 members = rel.getMembers(); 64 64 } 65 65 members = fixBoundaryRoles(members); 66 if (!members.equals(rel.getMembers())) { 67 final DataSet ds = Utils.firstNonNull(rel.getDataSet(), MainApplication.getLayerManager().getEditDataSet()); 68 return new ChangeMembersCommand(ds, rel, members); 69 } 70 return null; 66 if (members.isEmpty() || members.equals(rel.getMembers())) 67 return null; 68 final DataSet ds = Utils.firstNonNull(rel.getDataSet(), MainApplication.getLayerManager().getEditDataSet()); 69 return new ChangeMembersCommand(ds, rel, members); 71 70 } 72 71 73 72 /** 74 73 * Possibly change roles of non-way members. 75 74 * @param origMembers original list of relation members 76 * @return either the original and unmodified list or a new one with at least one new item 75 * @return either the original and unmodified list or a new one with at least one new item or empty list if not a valid boundary 77 76 */ 78 77 private static List<RelationMember> fixBoundaryRoles(List<RelationMember> origMembers) { 79 78 List<RelationMember> members = origMembers; -
src/relcontext/relationfix/MultipolygonFixer.java
49 49 @Override 50 50 public Command fixRelation(Relation rel) { 51 51 List<RelationMember> members = fixMultipolygonRoles(rel.getMembers()); 52 if (!members.equals(rel.getMembers())) { 53 final DataSet ds = Utils.firstNonNull(rel.getDataSet(), MainApplication.getLayerManager().getEditDataSet()); 54 return new ChangeMembersCommand(ds, rel, members); 55 } 56 return null; 52 if (members.isEmpty() || members.equals(rel.getMembers())) 53 return null; 54 final DataSet ds = Utils.firstNonNull(rel.getDataSet(), MainApplication.getLayerManager().getEditDataSet()); 55 return new ChangeMembersCommand(ds, rel, members); 57 56 } 58 57 59 58 /** -
src/relcontext/relationfix/PublicTransportFixer.java
4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.util.ArrayList; 7 import java.util.Collections; 7 8 import java.util.List; 8 9 9 10 import org.openstreetmap.josm.command.ChangeMembersCommand; … … 50 51 @Override 51 52 public Command fixRelation(Relation rel) { 52 53 List<RelationMember> members = fixStopPlatformRole(rel.getMembers()); 53 if (!members.equals(rel.getMembers())) { 54 final DataSet ds = Utils.firstNonNull(rel.getDataSet(), MainApplication.getLayerManager().getEditDataSet()); 55 return new ChangeMembersCommand(ds, rel, rel.getMembers()); 56 } 57 return null; 54 if (members.isEmpty() || members.equals(rel.getMembers())) 55 return null; 56 final DataSet ds = Utils.firstNonNull(rel.getDataSet(), MainApplication.getLayerManager().getEditDataSet()); 57 return new ChangeMembersCommand(ds, rel, rel.getMembers()); 58 58 } 59 59 60 60 /** … … 64 64 */ 65 65 private static List<RelationMember> fixStopPlatformRole(List<RelationMember> origMembers) { 66 66 List<RelationMember> members = origMembers; 67 boolean fixed = false; 67 68 for (int i = 0; i < members.size(); i++) { 68 69 RelationMember m = members.get(i); 69 70 String role = PublicTransportHelper.getRoleByMember(m); … … 73 74 members = new ArrayList<>(origMembers); 74 75 } 75 76 members.set(i, new RelationMember(role, m.getMember())); 77 fixed = true; 76 78 } 77 79 } 78 return members;80 return fixed ? members : Collections.emptyList(); 79 81 } 80 82 }