Changeset 26288 in osm for applications/editors


Ignore:
Timestamp:
2011-07-10T07:14:30+02:00 (13 years ago)
Author:
benshu
Message:
  • fix: Validator did not ignore Relations which were setDeleted(true)
  • fix: Tagging a junction next to another junction
Location:
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/ModelContainer.java

    r26192 r26288  
    2020
    2121public class ModelContainer {
    22     private static final ModelContainer EMPTY = new ModelContainer(Collections.<Node> emptySet(), Collections
    23             .<Way> emptySet(), false);
     22    private static final ModelContainer EMPTY = new ModelContainer(Collections.<Node> emptySet(),
     23            Collections.<Way> emptySet(), false);
    2424   
    2525    public static ModelContainer create(Iterable<Node> primaryNodes, Iterable<Way> primaryWays) {
     
    4646                for (Way w : Utils.filterRoads(n.getReferrers())) {
    4747                    if (w.isFirstLastNode(n)) {
    48                         closed &= close(closedNodes, closedWays, w, Constants.TURN_ROLE_FROM);
    49                         closed &= close(closedNodes, closedWays, w, Constants.TURN_ROLE_TO);
     48                        closed &= close(closedNodes, closedWays, w);
    5049                    }
    5150                }
    5251               
    5352                for (Way w : new ArrayList<Way>(closedWays)) {
    54                     closed &= close(closedNodes, closedWays, w, Constants.TURN_ROLE_VIA);
    55                 }
    56             }
    57         }
    58     }
    59    
    60     private static boolean close(Set<Node> closedNodes, Set<Way> closedWays, Way w, String role) {
     53                    closed &= close(closedNodes, closedWays, w);
     54                }
     55            }
     56        }
     57    }
     58   
     59    private static boolean close(Set<Node> closedNodes, Set<Way> closedWays, Way w) {
    6160        boolean closed = true;
    6261       
     
    6766           
    6867            for (RelationMember m : r.getMembers()) {
    69                 if (m.getRole().equals(role) && m.getMember().equals(w)) {
     68                if (m.getRole().equals(Constants.TURN_ROLE_VIA) && m.getMember().equals(w)) {
    7069                    closed &= close(closedNodes, closedWays, r);
    7170                }
     
    297296        return empty;
    298297    }
     298   
     299    public boolean hasRoad(Way w) {
     300        return roads.containsKey(w);
     301    }
     302   
     303    public boolean hasJunction(Node n) {
     304        return junctions.containsKey(n);
     305    }
    299306}
  • applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Turn.java

    r26182 r26288  
    5656        final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO);
    5757       
     58        if (!c.hasRoad(from) || !c.hasRoad(to)) {
     59            return Collections.emptySet();
     60        }
     61       
    5862        final List<Way> tmp = Utils.getMemberWays(r, Constants.TURN_ROLE_VIA);
    5963        final LinkedList<Road> via = new LinkedList<Road>();
     
    6569        while (it.hasNext()) {
    6670            final Way w = it.next();
     71            if (!c.hasRoad(w)) {
     72                return Collections.emptySet();
     73            }
     74           
    6775            final Road v = c.getRoad(w);
    6876            via.add(v);
     
    119127        final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO);
    120128       
     129        if (!c.hasRoad(from) || !c.hasJunction(via) || !c.hasRoad(to)) {
     130            return Collections.emptySet();
     131        }
     132       
    121133        final Junction j = c.getJunction(via);
    122134       
     
    126138        final Set<Turn> result = new HashSet<Turn>();
    127139        for (int i : indices(r, Constants.TURN_KEY_LANES)) {
    128             result
    129                     .add(new Turn(r, fromRoadEnd.getLane(Lane.Kind.REGULAR, i), Collections.<Road> emptyList(),
    130                             toRoadEnd));
     140            result.add(new Turn(r, fromRoadEnd.getLane(Lane.Kind.REGULAR, i), Collections.<Road> emptyList(), toRoadEnd));
    131141        }
    132142        for (int i : indices(r, Constants.TURN_KEY_EXTRA_LANES)) {
  • applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Validator.java

    r26154 r26288  
    109109       
    110110        for (Relation r : OsmPrimitive.getFilteredList(dataSet.allPrimitives(), Relation.class)) {
     111            if (!r.isUsable()) {
     112                continue;
     113            }
     114           
    111115            final String type = r.get("type");
    112            
    113116            if (Constants.TYPE_LENGTHS.equals(type)) {
    114117                lenghts.add(r);
     
    127130            if (lanes.unreferenced() > 0) {
    128131                issues.add(Issue.newWarning(Arrays.asList(lanes.key.junction, lanes.key.from),
    129                     tr("{0} lanes are not referenced in any turn-relation.", lanes.unreferenced())));
     132                        tr("{0} lanes are not referenced in any turn-relation.", lanes.unreferenced())));
    130133            }
    131134        }
     
    172175            if (tooLong > 0) {
    173176                issues.add(Issue.newError(r, end, "The lengths-relation specifies " + tooLong
    174                     + " extra-lanes which are longer than its ways."));
     177                        + " extra-lanes which are longer than its ways."));
    175178            }
    176179           
     
    186189   
    187190    private void putIncomingLanes(Route route, List<Double> left, List<Double> right,
    188         Map<IncomingLanes.Key, IncomingLanes> incomingLanes) {
     191            Map<IncomingLanes.Key, IncomingLanes> incomingLanes) {
    189192        final Node end = route.getLastSegment().getEnd();
    190193        final Way way = route.getLastSegment().getWay();
     
    196199        if (old != null) {
    197200            incomingLanes.put(
    198                 key,
    199                 new IncomingLanes(key, Math.max(lanes.extraLeft, old.extraLeft), Math.max(lanes.regular, old.regular), Math
    200                     .max(lanes.extraRight, old.extraRight)));
    201         }
    202        
    203         // TODO this tends to produce a bunch of useless errors
    204         // turn lanes really should not span from one junction past another, remove??
    205         //      final double length = route.getLastSegment().getLength();
    206         //      final List<Double> newLeft = reduceLengths(left, length);
    207         //      final List<Double> newRight = new ArrayList<Double>(right.size());
    208         //     
    209         //      if (route.getSegments().size() > 1) {
    210         //          final Route subroute = route.subRoute(0, route.getSegments().size() - 1);
    211         //          putIncomingLanes(subroute, newLeft, newRight, incomingLanes);
    212         //      }
    213     }
    214    
    215     private List<Double> reduceLengths(List<Double> lengths, double length) {
    216         final List<Double> newLengths = new ArrayList<Double>(lengths.size());
    217        
    218         for (double l : lengths) {
    219             if (l > length) {
    220                 newLengths.add(l - length);
    221             }
    222         }
    223        
    224         return newLengths;
     201                    key,
     202                    new IncomingLanes(key, Math.max(lanes.extraLeft, old.extraLeft), Math.max(lanes.regular,
     203                            old.regular), Math.max(lanes.extraRight, old.extraRight)));
     204        }
    225205    }
    226206   
     
    230210        if (ways.isEmpty()) {
    231211            issues.add(Issue.newError(r, "A lengths-relation requires at least one member-way with role \""
    232                 + Constants.LENGTHS_ROLE_WAYS + "\"."));
     212                    + Constants.LENGTHS_ROLE_WAYS + "\"."));
    233213            return null;
    234214        }
     
    255235            if (!ends.add(current)) {
    256236                issues.add(Issue.newError(r, ways, "The " + role + " of the " + type
    257                     + "-relation are unordered (and contain cycles)."));
     237                        + "-relation are unordered (and contain cycles)."));
    258238                return null;
    259239            }
Note: See TracChangeset for help on using the changeset viewer.