Ticket #23715: 23715.patch

File 23715.patch, 4.3 KB (added by GerdP, 5 months ago)

I think this patch will fix the issue (and some similar).

  • src/relcontext/relationfix/BoundaryFixer.java

     
    6363            members = rel.getMembers();
    6464        }
    6565        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);
    7170    }
    7271
    7372    /**
    7473     * Possibly change roles of non-way members.
    7574     * @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
    7776     */
    7877    private static List<RelationMember> fixBoundaryRoles(List<RelationMember> origMembers) {
    7978        List<RelationMember> members = origMembers;
  • src/relcontext/relationfix/MultipolygonFixer.java

     
    4949    @Override
    5050    public Command fixRelation(Relation rel) {
    5151        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);
    5756    }
    5857
    5958    /**
  • src/relcontext/relationfix/PublicTransportFixer.java

     
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    66import java.util.ArrayList;
     7import java.util.Collections;
    78import java.util.List;
    89
    910import org.openstreetmap.josm.command.ChangeMembersCommand;
     
    5051    @Override
    5152    public Command fixRelation(Relation rel) {
    5253        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());
    5858    }
    5959
    6060    /**
     
    6464     */
    6565    private static List<RelationMember> fixStopPlatformRole(List<RelationMember> origMembers) {
    6666        List<RelationMember> members = origMembers;
     67        boolean fixed = false;
    6768        for (int i = 0; i < members.size(); i++) {
    6869            RelationMember m = members.get(i);
    6970            String role = PublicTransportHelper.getRoleByMember(m);
     
    7374                    members = new ArrayList<>(origMembers);
    7475                }
    7576                members.set(i, new RelationMember(role, m.getMember()));
     77                fixed = true;
    7678            }
    7779        }
    78         return members;
     80        return fixed ? members : Collections.emptyList();
    7981    }
    8082}