Changeset 8692 in osm for applications/editors/josm


Ignore:
Timestamp:
2008-07-03T18:03:34+02:00 (16 years ago)
Author:
stoecker
Message:

applied path of josm bug 799

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java

    r6302 r8692  
    2121        /** All way segments, grouped by cells */
    2222        Map<Point2D,List<ExtendedSegment>> cellSegments;
    23     /** The already detected errors */
     23        /** The already detected errors */
    2424        HashSet<WaySegment> errorSegments;
     25        /** The already detected ways in error */
     26        Map<List<Way>, List<WaySegment>> ways_seen;
     27
    2528       
    2629        /**
     
    3841        {
    3942                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);
    4145        }
    4246
     
    4650                cellSegments = null;
    4751                errorSegments = null;
     52                ways_seen = null;
    4853        }
    4954
     
    5156        public void visit(Way w)
    5257        {
    53         if( w.deleted || w.incomplete )
    54             return;
    55        
    56         String coastline1 = w.get("natural");
    57         boolean isCoastline1 = coastline1 != null && (coastline1.equals("water") || coastline1.equals("coastline"));
    58         String railway1 = w.get("railway");
    59         boolean isSubway1 = railway1 != null && railway1.equals("subway");
    60         if( w.get("highway") == null && w.get("waterway") == null && !isSubway1 && !isCoastline1)
    61                 return;
    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");
    6469
    6570                int nodesSize = w.nodes.size();
    6671                for (int i = 0; i < nodesSize - 1; i++) {
    6772                        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
    7482                                        if (errorSegments.contains(ws) && errorSegments.contains(es2.ws))
    75                                 continue;
    76                        
    77                         String layer2 = es2.layer;
    78                         String railway2 = es2.railway;
    79                         String coastline2 = es2.coastline;
     83                                                continue;
     84
     85                                        String layer2 = es2.layer;
     86                                        String railway2 = es2.railway;
     87                                        String coastline2 = es2.coastline;
    8088                                        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
    98120        /**
    99      * Returns all the cells this segment crosses.  Each cell contains the list
    100      * of segments already processed
    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        */
    106128        public List<List<ExtendedSegment>> getSegments(Node n1, Node n2)
    107129        {
Note: See TracChangeset for help on using the changeset viewer.