Changeset 8692 in osm for applications/editors/josm
- Timestamp:
- 2008-07-03T18:03:34+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java
r6302 r8692 21 21 /** All way segments, grouped by cells */ 22 22 Map<Point2D,List<ExtendedSegment>> cellSegments; 23 23 /** The already detected errors */ 24 24 HashSet<WaySegment> errorSegments; 25 /** The already detected ways in error */ 26 Map<List<Way>, List<WaySegment>> ways_seen; 27 25 28 26 29 /** … … 38 41 { 39 42 cellSegments = new HashMap<Point2D,List<ExtendedSegment>>(1000); 40 errorSegments = new HashSet<WaySegment>(); 43 errorSegments = new HashSet<WaySegment>(); 44 ways_seen = new HashMap<List<Way>, List<WaySegment>>(50); 41 45 } 42 46 … … 46 50 cellSegments = null; 47 51 errorSegments = null; 52 ways_seen = null; 48 53 } 49 54 … … 51 56 public void visit(Way w) 52 57 { 53 54 55 56 57 58 59 60 if( w.get("highway") == null && w.get("waterway") == null && !isSubway1&& !isCoastline1)61 62 63 String layer1 = w.get("layer");58 if( w.deleted || w.incomplete ) 59 return; 60 61 String coastline1 = w.get("natural"); 62 boolean isCoastline1 = coastline1 != null && (coastline1.equals("water") || coastline1.equals("coastline")); 63 String railway1 = w.get("railway"); 64 boolean isSubway1 = railway1 != null && railway1.equals("subway"); 65 if( w.get("highway") == null && w.get("waterway") == null && (railway1 == null || isSubway1) && !isCoastline1) 66 return; 67 68 String layer1 = w.get("layer"); 64 69 65 70 int nodesSize = w.nodes.size(); 66 71 for (int i = 0; i < nodesSize - 1; i++) { 67 72 WaySegment ws = new WaySegment(w, i); 68 ExtendedSegment es1 = new ExtendedSegment(ws, layer1, railway1, coastline1); 69 List<List<ExtendedSegment>> cellSegments = getSegments(es1.n1, es1.n2); 70 for( List<ExtendedSegment> segments : cellSegments) 71 { 72 for( ExtendedSegment es2 : segments) 73 { 73 ExtendedSegment es1 = new ExtendedSegment(ws, layer1, railway1, coastline1); 74 List<List<ExtendedSegment>> cellSegments = getSegments(es1.n1, es1.n2); 75 for( List<ExtendedSegment> segments : cellSegments) 76 { 77 for( ExtendedSegment es2 : segments) 78 { 79 List<Way> prims; 80 List<WaySegment> highlight; 81 74 82 if (errorSegments.contains(ws) && errorSegments.contains(es2.ws)) 75 76 77 78 79 83 continue; 84 85 String layer2 = es2.layer; 86 String railway2 = es2.railway; 87 String coastline2 = es2.coastline; 80 88 if (layer1 == null ? layer2 != null : !layer1.equals(layer2)) 81 continue; 82 83 if( !es1.intersects(es2) ) continue; 84 if( isSubway1 && "subway".equals(railway2)) continue; 85 86 boolean isCoastline2 = coastline2 != null && (coastline2.equals("water") || coastline2.equals("coastline")); 87 if( isCoastline1 != isCoastline2 ) continue; 88 89 errors.add(new TestError(this, Severity.WARNING, tr("Crossing ways"), 90 Arrays.asList(es1.ws.way, es2.ws.way), 91 Arrays.asList(es1.ws, es2.ws))); 92 } 93 segments.add(es1); 94 } 95 } 96 } 97 89 continue; 90 91 if( !es1.intersects(es2) ) continue; 92 if( isSubway1 && "subway".equals(railway2)) continue; 93 94 boolean isCoastline2 = coastline2 != null && (coastline2.equals("water") || coastline2.equals("coastline")); 95 if( isCoastline1 != isCoastline2 ) continue; 96 97 prims = Arrays.asList(es1.ws.way, es2.ws.way); 98 if ((highlight = ways_seen.get(prims)) == null) 99 { 100 highlight = new ArrayList<WaySegment>(); 101 highlight.add(es1.ws); 102 highlight.add(es2.ws); 103 104 errors.add(new TestError(this, Severity.WARNING, tr("Crossing ways"), 105 prims, 106 highlight)); 107 ways_seen.put(prims, highlight); 108 } 109 else 110 { 111 highlight.add(es1.ws); 112 highlight.add(es2.ws); 113 } 114 } 115 segments.add(es1); 116 } 117 } 118 } 119 98 120 /** 99 100 101 * 102 * @param n1 The first node. 103 * @param n2 The second node. 104 * @return A list with all the cells the segment crosses. 105 121 * Returns all the cells this segment crosses. Each cell contains the list 122 * of segments already processed 123 * 124 * @param n1 The first node 125 * @param n2 The second node 126 * @return A list with all the cells the segment crosses 127 */ 106 128 public List<List<ExtendedSegment>> getSegments(Node n1, Node n2) 107 129 {
Note:
See TracChangeset
for help on using the changeset viewer.