Changeset 6240 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
- Timestamp:
- 2013-09-20T22:44:07+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r5902 r6240 53 53 @Override 54 54 public void visit(Way w) { 55 if (w.isUsable()) { 56 if (w.hasKey("highway") && w.hasKey("junction") && w.get("junction").equals("roundabout")) { 57 Map<String, List<Way>> map = new HashMap<String, List<Way>>(); 58 // Count all highways (per type) connected to this roundabout 59 // As roundabouts are closed ways, take care of not processing the first/last node twice 60 for (Node n : new HashSet<Node>(w.getNodes())) { 61 for (Way h : Utils.filteredCollection(n.getReferrers(), Way.class)) { 62 if (h != w && h.hasKey("highway")) { 63 List<Way> list = map.get(h.get("highway")); 64 if (list == null) { 65 map.put(h.get("highway"), list = new ArrayList<Way>()); 66 } 67 list.add(h); 55 if (w.isUsable() && w.hasKey("highway") && w.hasKey("junction") && w.get("junction").equals("roundabout")) { 56 Map<String, List<Way>> map = new HashMap<String, List<Way>>(); 57 // Count all highways (per type) connected to this roundabout 58 // As roundabouts are closed ways, take care of not processing the first/last node twice 59 for (Node n : new HashSet<Node>(w.getNodes())) { 60 for (Way h : Utils.filteredCollection(n.getReferrers(), Way.class)) { 61 if (h != w && h.hasKey("highway")) { 62 List<Way> list = map.get(h.get("highway")); 63 if (list == null) { 64 map.put(h.get("highway"), list = new ArrayList<Way>()); 68 65 } 66 list.add(h); 69 67 } 70 68 } 71 // The roundabout should carry the highway tag of its two biggest highways 72 for (String s : CLASSIFIED_HIGHWAYS) { 73 List<Way> list = map.get(s); 74 if (list != null && list.size() >= 2) { 75 // Except when a single road is connected, but with two oneway segments 76 Boolean oneway1 = OsmUtils.getOsmBoolean(list.get(0).get("oneway")); 77 Boolean oneway2 = OsmUtils.getOsmBoolean(list.get(1).get("oneway")); 78 if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) { 79 // Error when the highway tags do not match 80 if (!w.get("highway").equals(s)) { 81 errors.add(new TestError(this, Severity.WARNING, 82 tr("Incorrect roundabout (highway: {0} instead of {1})", w.get("highway"), s), 83 WRONG_ROUNDABOUT_HIGHWAY, w)); 84 } 85 break; 69 } 70 // The roundabout should carry the highway tag of its two biggest highways 71 for (String s : CLASSIFIED_HIGHWAYS) { 72 List<Way> list = map.get(s); 73 if (list != null && list.size() >= 2) { 74 // Except when a single road is connected, but with two oneway segments 75 Boolean oneway1 = OsmUtils.getOsmBoolean(list.get(0).get("oneway")); 76 Boolean oneway2 = OsmUtils.getOsmBoolean(list.get(1).get("oneway")); 77 if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) { 78 // Error when the highway tags do not match 79 if (!w.get("highway").equals(s)) { 80 errors.add(new TestError(this, Severity.WARNING, 81 tr("Incorrect roundabout (highway: {0} instead of {1})", w.get("highway"), s), 82 WRONG_ROUNDABOUT_HIGHWAY, w)); 86 83 } 84 break; 87 85 } 88 86 }
Note:
See TracChangeset
for help on using the changeset viewer.
