Ignore:
Timestamp:
2016-06-24T09:10:57+02:00 (9 years ago)
Author:
donvip
Message:

checkstyle, update to JOSM 10279

Location:
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java

    r30738 r32395  
     1// License: GPL. For details, see LICENSE file.
    12package relcontext.relationfix;
    23
     
    4647        // check that all street members have same name as relation (???)
    4748        String streetName = rel.get("name");
    48         if (streetName == null) streetName = "";
     49        if (streetName == null) {
     50            streetName = "";
     51        }
    4952        for (RelationMember m : rel.getMembers()) {
    5053            if ("street".equals(m.getRole()) && !streetName.equals(m.getWay().get("name"))) {
     
    101104        // fill relation name
    102105        Map<String, Integer> streetNames = new HashMap<>();
    103         for (RelationMember m : rel.getMembers())
     106        for (RelationMember m : rel.getMembers()) {
    104107            if ("street".equals(m.getRole()) && m.isWay()) {
    105108                String name = m.getWay().get("name");
    106                 if (name == null || name.isEmpty()) continue;
     109                if (name == null || name.isEmpty()) {
     110                    continue;
     111                }
    107112
    108113                Integer count = streetNames.get(name);
    109114
    110                 streetNames.put(name, count != null? count + 1 : 1);
     115                streetNames.put(name, count != null ? count + 1 : 1);
    111116            }
     117        }
    112118        String commonName = "";
    113119        Integer commonCount = 0;
     
    146152                commandList.add(new ChangeCommand(oldWay, newWay));
    147153            }
    148         */
     154         */
    149155        // return results
    150156        if (commandList.size() == 0)
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/BoundaryFixer.java

    r30738 r32395  
     1// License: GPL. For details, see LICENSE file.
    12package relcontext.relationfix;
    23
     
    3233    @Override
    3334    public boolean isRelationGood(Relation rel) {
    34         for( RelationMember m : rel.getMembers() ) {
     35        for (RelationMember m : rel.getMembers()) {
    3536            if (m.getType().equals(OsmPrimitiveType.RELATION) && !"subarea".equals(m.getRole())) {
    3637                setWarningMessage(tr("Relation without ''subarea'' role found"));
     
    6768    }
    6869
    69     private Relation fixBoundaryRoles( Relation source ) {
     70    private Relation fixBoundaryRoles(Relation source) {
    7071        Relation r = new Relation(source);
    7172        boolean fixed = false;
    72         for( int i = 0; i < r.getMembersCount(); i++ ) {
     73        for (int i = 0; i < r.getMembersCount(); i++) {
    7374            RelationMember m = r.getMember(i);
    7475            String role = null;
    75             if( m.isRelation() )
     76            if (m.isRelation()) {
    7677                role = "subarea";
    77             else if( m.isNode() ) {
    78                 Node n = (Node)m.getMember();
    79                 if( !n.isIncomplete() ) {
    80                     if( n.hasKey("place") ) {
     78            } else if (m.isNode()) {
     79                Node n = (Node) m.getMember();
     80                if (!n.isIncomplete()) {
     81                    if (n.hasKey("place")) {
    8182                        String place = n.get("place");
    8283                        if (place.equals("state") || place.equals("country") ||
     
    8687                            role = "admin_centre";
    8788                        }
    88                     } else
     89                    } else {
    8990                        role = "label";
     91                    }
    9092                }
    9193            }
    92             if( role != null && !role.equals(m.getRole()) ) {
     94            if (role != null && !role.equals(m.getRole())) {
    9395                r.setMember(i, new RelationMember(role, m.getMember()));
    9496                fixed = true;
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java

    r30738 r32395  
     1// License: GPL. For details, see LICENSE file.
    12package relcontext.relationfix;
    23
     
    3031    }
    3132
    32 
    3333    @Override
    3434    public boolean isRelationGood(Relation rel) {
    35         for (RelationMember m : rel.getMembers())
     35        for (RelationMember m : rel.getMembers()) {
    3636            if (m.getType().equals(OsmPrimitiveType.WAY) && !("outer".equals(m.getRole()) || "inner".equals(m.getRole()))) {
    3737                setWarningMessage(tr("Way without ''inner'' or ''outer'' role found"));
    3838                return false;
    3939            }
     40        }
    4041        clearWarningMessage();
    4142        return true;
     
    4546    public Command fixRelation(Relation rel) {
    4647        Relation rr = fixMultipolygonRoles(rel);
    47         return rr != null? new ChangeCommand(rel, rr) : null;
     48        return rr != null ? new ChangeCommand(rel, rr) : null;
    4849    }
    4950
     
    5152     * Basically, created multipolygon from scratch, and if successful, replace roles with new ones.
    5253     */
    53     protected Relation fixMultipolygonRoles( Relation source ) {
     54    protected Relation fixMultipolygonRoles(Relation source) {
    5455        Collection<Way> ways = new ArrayList<>();
    55         for( OsmPrimitive p : source.getMemberPrimitives() )
    56             if( p instanceof Way )
    57                 ways.add((Way)p);
     56        for (OsmPrimitive p : source.getMemberPrimitives()) {
     57            if (p instanceof Way) {
     58                ways.add((Way) p);
     59            }
     60        }
    5861        MultipolygonBuilder mpc = new MultipolygonBuilder();
    5962        String error = mpc.makeFromWays(ways);
    60         if( error != null )
     63        if (error != null)
    6164            return null;
    6265
     
    6467        boolean fixed = false;
    6568        Set<Way> outerWays = new HashSet<>();
    66         for( MultipolygonBuilder.JoinedPolygon poly : mpc.outerWays )
    67             for( Way w : poly.ways )
     69        for (MultipolygonBuilder.JoinedPolygon poly : mpc.outerWays) {
     70            for (Way w : poly.ways) {
    6871                outerWays.add(w);
     72            }
     73        }
    6974        Set<Way> innerWays = new HashSet<>();
    70         for( MultipolygonBuilder.JoinedPolygon poly : mpc.innerWays )
    71             for( Way w : poly.ways )
     75        for (MultipolygonBuilder.JoinedPolygon poly : mpc.innerWays) {
     76            for (Way w : poly.ways) {
    7277                innerWays.add(w);
    73         for( int i = 0; i < r.getMembersCount(); i++ ) {
     78            }
     79        }
     80        for (int i = 0; i < r.getMembersCount(); i++) {
    7481            RelationMember m = r.getMember(i);
    75             if( m.isWay() ) {
     82            if (m.isWay()) {
    7683                String role = null;
    77                 if( outerWays.contains((Way)m.getMember()) )
     84                if (outerWays.contains(m.getMember())) {
    7885                    role = "outer";
    79                 else if( innerWays.contains((Way)m.getMember()) )
     86                } else if (innerWays.contains(m.getMember())) {
    8087                    role = "inner";
    81                 if( role != null && !role.equals(m.getRole()) ) {
     88                }
     89                if (role != null && !role.equals(m.getRole())) {
    8290                    r.setMember(i, new RelationMember(role, m.getMember()));
    8391                    fixed = true;
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/NothingFixer.java

    r30738 r32395  
     1// License: GPL. For details, see LICENSE file.
    12package relcontext.relationfix;
    23
     
    1213        super("");
    1314    }
     15
    1416    @Override
    1517    public boolean isFixerApplicable(Relation rel) {
    1618        return true;
    1719    }
     20
    1821    @Override
    1922    public boolean isRelationGood(Relation rel) {
     
    2528        return null;
    2629    }
    27 
    2830}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/PublicTransportFixer.java

    r30841 r32395  
     1// License: GPL. For details, see LICENSE file.
    12package relcontext.relationfix;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    25
    36import org.openstreetmap.josm.command.ChangeCommand;
     
    69import org.openstreetmap.josm.data.osm.Relation;
    710import org.openstreetmap.josm.data.osm.RelationMember;
    8 import static org.openstreetmap.josm.tools.I18n.tr;
     11
    912import relcontext.actions.PublicTransportHelper;
    1013
     
    1821 */
    1922public class PublicTransportFixer extends RelationFixer {
    20        
     23
    2124    public PublicTransportFixer() {
    2225        super("route", "public_transport");
     
    3033    public boolean isRelationGood(Relation rel) {
    3134        for (RelationMember m : rel.getMembers()) {
    32             if (m.getType().equals(OsmPrimitiveType.NODE) 
     35            if (m.getType().equals(OsmPrimitiveType.NODE)
    3336                    && !(m.getRole().startsWith(PublicTransportHelper.STOP) || m.getRole().startsWith(PublicTransportHelper.PLATFORM))) {
    3437                setWarningMessage(tr("Node without ''stop'' or ''platform'' role found"));
     
    6265        return fixed ? new ChangeCommand(rel, r) : null;
    6366    }
    64    
     67
    6568    private Relation fixStopPlatformRole(Relation source) {
    6669        Relation r = new Relation(source);
    6770        boolean fixed = false;
    68         for( int i = 0; i < r.getMembersCount(); i++ ) {
     71        for (int i = 0; i < r.getMembersCount(); i++) {
    6972            RelationMember m = r.getMember(i);
    7073            String role = PublicTransportHelper.getRoleByMember(m);
     
    7578            }
    7679        }
    77         return fixed ? r : null;           
     80        return fixed ? r : null;
    7881    }
    7982}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java

    r30738 r32395  
     1// License: GPL. For details, see LICENSE file.
    12package relcontext.relationfix;
    23
     
    2021    /**
    2122     * Construct new RelationFixer by a list of applicable types
    22      * @param types
     23     * @param types types
    2324     */
    2425    public RelationFixer(String... types) {
    2526        applicableTypes = new ArrayList<>();
    26         for(String type: types) {
     27        for (String type: types) {
    2728            applicableTypes.add(type);
    2829        }
     
    3334     * and then check desired relation properties.
    3435     * Note that this only verifies if current RelationFixer can be used to check and fix given relation
    35      * Deeper relation checking is at {@link isRelationGood}
     36     * Deeper relation checking is at {@link #isRelationGood}
    3637     *
    3738     * @param rel Relation to check
     
    4546
    4647        String type = rel.get("type");
    47         for(String oktype: applicableTypes)
     48        for (String oktype: applicableTypes) {
    4849            if (oktype.equals(type))
    4950                return true;
     51        }
    5052
    5153        return false;
     
    7375        this.sortAndFixAction = sortAndFixAction;
    7476    }
     77
    7578    protected void setWarningMessage(String text) {
    7679        if (text == null) {
     
    8083        }
    8184    }
     85
    8286    protected void clearWarningMessage() {
    8387        sortAndFixAction.putValue(Action.SHORT_DESCRIPTION, tr("Fix roles of the chosen relation members"));
    8488    }
    85 
    8689}
Note: See TracChangeset for help on using the changeset viewer.