Changeset 26288 in osm for applications/editors
- Timestamp:
- 2011-07-10T07:14:30+02:00 (13 years ago)
- 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 20 20 21 21 public class ModelContainer { 22 private static final ModelContainer EMPTY = new ModelContainer(Collections.<Node> emptySet(), Collections23 .<Way> emptySet(), false);22 private static final ModelContainer EMPTY = new ModelContainer(Collections.<Node> emptySet(), 23 Collections.<Way> emptySet(), false); 24 24 25 25 public static ModelContainer create(Iterable<Node> primaryNodes, Iterable<Way> primaryWays) { … … 46 46 for (Way w : Utils.filterRoads(n.getReferrers())) { 47 47 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); 50 49 } 51 50 } 52 51 53 52 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) { 61 60 boolean closed = true; 62 61 … … 67 66 68 67 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)) { 70 69 closed &= close(closedNodes, closedWays, r); 71 70 } … … 297 296 return empty; 298 297 } 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 } 299 306 } -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Turn.java
r26182 r26288 56 56 final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO); 57 57 58 if (!c.hasRoad(from) || !c.hasRoad(to)) { 59 return Collections.emptySet(); 60 } 61 58 62 final List<Way> tmp = Utils.getMemberWays(r, Constants.TURN_ROLE_VIA); 59 63 final LinkedList<Road> via = new LinkedList<Road>(); … … 65 69 while (it.hasNext()) { 66 70 final Way w = it.next(); 71 if (!c.hasRoad(w)) { 72 return Collections.emptySet(); 73 } 74 67 75 final Road v = c.getRoad(w); 68 76 via.add(v); … … 119 127 final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO); 120 128 129 if (!c.hasRoad(from) || !c.hasJunction(via) || !c.hasRoad(to)) { 130 return Collections.emptySet(); 131 } 132 121 133 final Junction j = c.getJunction(via); 122 134 … … 126 138 final Set<Turn> result = new HashSet<Turn>(); 127 139 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)); 131 141 } 132 142 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 109 109 110 110 for (Relation r : OsmPrimitive.getFilteredList(dataSet.allPrimitives(), Relation.class)) { 111 if (!r.isUsable()) { 112 continue; 113 } 114 111 115 final String type = r.get("type"); 112 113 116 if (Constants.TYPE_LENGTHS.equals(type)) { 114 117 lenghts.add(r); … … 127 130 if (lanes.unreferenced() > 0) { 128 131 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()))); 130 133 } 131 134 } … … 172 175 if (tooLong > 0) { 173 176 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.")); 175 178 } 176 179 … … 186 189 187 190 private void putIncomingLanes(Route route, List<Double> left, List<Double> right, 188 Map<IncomingLanes.Key, IncomingLanes> incomingLanes) {191 Map<IncomingLanes.Key, IncomingLanes> incomingLanes) { 189 192 final Node end = route.getLastSegment().getEnd(); 190 193 final Way way = route.getLastSegment().getWay(); … … 196 199 if (old != null) { 197 200 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 } 225 205 } 226 206 … … 230 210 if (ways.isEmpty()) { 231 211 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 + "\".")); 233 213 return null; 234 214 } … … 255 235 if (!ends.add(current)) { 256 236 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).")); 258 238 return null; 259 239 }
Note:
See TracChangeset
for help on using the changeset viewer.