Changeset 33475 in osm for applications/editors


Ignore:
Timestamp:
2017-07-27T18:55:55+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] #josm15082

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java

    r33467 r33475  
    88import java.util.Collection;
    99import java.util.List;
     10import java.util.Map.Entry;
    1011
    1112import org.openstreetmap.josm.command.ChangeCommand;
     
    102103    protected boolean performFromToTagsTest() {
    103104
    104         String from = relation.get("from");
    105         String to = relation.get("to");
     105        String from = relation.get("from").toLowerCase();
     106        String to = relation.get("to").toLowerCase();
    106107        if (from == null || to == null || manager.getPTStopCount() == 0) {
    107108            return false;
     
    180181    //given a PTStop and a name, check whether one of its primitives have a
    181182    //different name from the one passed. if so, it returns the primitive.
     183    //it compares not only the name tag but all the name:* names
    182184    //it returns null if the names match
    183185    private OsmPrimitive checkPTStopName(PTStop stop, String name) {
    184186        OsmPrimitive primitive = null;
    185         String toCheck = null;
     187        List<String> toCheck = new ArrayList<>();
    186188        if (stop.getPlatform() != null) {
    187             toCheck = stop.getPlatform().getName();
    188189            primitive = stop.getPlatform();
    189         }
    190         if (toCheck == null && stop.getStopPosition() != null) {
    191             toCheck = stop.getStopPosition().getName();
     190            toCheck.addAll(getPrimitiveNameTags(primitive));
     191        }
     192        if (toCheck.isEmpty() && stop.getStopPosition() != null) {
    192193            primitive = stop.getStopPosition();
    193         }
    194 
    195         if (toCheck != null && !toCheck.equals(name))
    196             return primitive;
     194            toCheck.addAll(getPrimitiveNameTags(primitive));
     195        }
     196
     197        for (String value : toCheck) {
     198            if (value.equals(name)) {
     199                return primitive;
     200            }
     201        }
    197202
    198203        return null;
     204    }
     205
     206    private List<String> getPrimitiveNameTags(OsmPrimitive primitive) {
     207        List<String> ret = new ArrayList<>();
     208        for (Entry<String, String> entry : primitive.getInterestingTags().entrySet()) {
     209            if ("name".equals(entry.getKey())
     210                    || entry.getKey().contains("name:")) {
     211                ret.add(entry.getValue().toLowerCase());
     212            }
     213        }
     214        return ret;
    199215    }
    200216
Note: See TracChangeset for help on using the changeset viewer.