Ticket #7259: validations.diff

File validations.diff, 9.1 KB (added by oldtopos, 12 years ago)

diff file for validation test changes

  • src/org/openstreetmap/josm/data/validation/tests/OverlappingAreas.java

     
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
     5import java.util.ArrayList;
    56import java.util.Collection;
    67import java.util.Collections;
     8
    79import org.openstreetmap.josm.data.osm.QuadBuckets;
    810import org.openstreetmap.josm.data.osm.Way;
    911import org.openstreetmap.josm.data.validation.Severity;
     
    3941
    4042                        @Override
    4143                        public boolean evaluate(Way wi) {
    42                             if (w.equals(wi)) {
     44                            if (w.equals(wi))
    4345                                return false;
    44                             } else {
     46                            else
    4547                                return Geometry.polygonIntersection(w.getNodes(), wi.getNodes())
    46                                         == Geometry.PolygonIntersection.CROSSING;
    47                             }
     48                                == Geometry.PolygonIntersection.CROSSING;
    4849                        }
    4950                    });
    5051            if (!overlaps.isEmpty()) {
    51                 errors.add(new TestError(this, Severity.OTHER, tr("Overlapping Areas"),
    52                         OVERLAPPING_AREAS, Collections.singletonList(w), overlaps));
     52                Collection<Way> overlapsWater = new ArrayList<Way>( 8 );
     53                Collection<Way> overlapsOther = new ArrayList<Way>( 8 );
     54
     55                System.out.println( "Overlapping areas for id:" + w.getId() );
     56                String natural1 = w.get("natural");
     57                String landuse1 = w.get("landuse");
     58                boolean isWaterArea = "water".equals(natural1) || "wetland".equals(natural1) || "coastline".equals(natural1) || "reservoir".equals(landuse1);
     59                boolean isWaterArea2 = false;
     60
     61                for( Way wayOther : overlaps ) {
     62                    String natural2 = wayOther.get("natural");
     63                    String landuse2 = wayOther.get("landuse");
     64                    boolean isWaterAreaTest = "water".equals(natural2) || "wetland".equals(natural2) || "coastline".equals(natural2) || "reservoir".equals(landuse2);
     65
     66                    if( ! isWaterArea2 ) {
     67                        isWaterArea2 = isWaterAreaTest;
     68                    }
     69
     70                    if( isWaterArea && isWaterAreaTest ) {
     71                        overlapsWater.add( wayOther );
     72                    } else {
     73                        overlapsOther.add( wayOther );
     74                    }
     75                }
     76
     77                if( ! overlapsWater.isEmpty() ) {
     78                    errors.add(new TestError(this, Severity.WARNING, tr("Overlapping Water Areas"),
     79                            OVERLAPPING_AREAS, Collections.singletonList(w), overlapsWater));
     80                }
     81
     82                if( ! overlapsOther.isEmpty() ) {
     83                    errors.add(new TestError(this, Severity.OTHER, tr("Overlapping Areas"),
     84                            OVERLAPPING_AREAS, Collections.singletonList(w), overlapsOther));
     85                }
    5386            }
    5487        }
    5588    }
  • src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

     
    4242     */
    4343    public CrossingWays() {
    4444        super(tr("Crossing ways."),
    45               tr("This test checks if two roads, railways, waterways or buildings crosses in the same layer, but are not connected by a node."));
     45                tr("This test checks if two roads, railways, waterways or buildings crosses in the same layer, but are not connected by a node."));
    4646    }
    4747
    4848    @Override
     
    8181            return;
    8282
    8383        String layer1 = w.get("layer");
    84         if ("0".equals(layer1)) layer1 = null; //0 is default value
     84        if ("0".equals(layer1))
     85        {
     86            layer1 = null; //0 is default value
     87        }
    8588
    8689        int nodesSize = w.getNodesCount();
    8790        for (int i = 0; i < nodesSize - 1; i++) {
     
    9396                    List<Way> prims;
    9497                    List<WaySegment> highlight;
    9598
    96                     if (errorSegments.contains(ws) && errorSegments.contains(es2.ws))
     99                    if (errorSegments.contains(ws) && errorSegments.contains(es2.ws)) {
    97100                        continue;
     101                    }
    98102
    99103                    String layer2 = es2.layer;
    100104                    String railway2 = es2.railway;
    101105                    boolean isCoastline2 = es2.coastline;
    102                     if (layer1 == null ? layer2 != null : !layer1.equals(layer2))
     106                    if (layer1 == null ? layer2 != null : !layer1.equals(layer2)) {
    103107                        continue;
     108                    }
    104109
    105                     if (!es1.intersects(es2) ) continue;
    106                     if (isSubway1 && "subway".equals(railway2)) continue;
    107                     if (isTram1 && "tram".equals(railway2)) continue;
     110                    if (!es1.intersects(es2) ) {
     111                        continue;
     112                    }
     113                    if (isSubway1 && "subway".equals(railway2)) {
     114                        continue;
     115                    }
     116                    if (isTram1 && "tram".equals(railway2)) {
     117                        continue;
     118                    }
    108119
    109                     if (isCoastline1 != isCoastline2) continue;
     120                    if (isCoastline1 != isCoastline2) {
     121                        continue;
     122                    }
    110123                    if (("river".equals(waterway1) && "riverbank".equals(es2.waterway))
    111                             || ("riverbank".equals(waterway1) && "river".equals(es2.waterway))) continue;
     124                            || ("riverbank".equals(waterway1) && "river".equals(es2.waterway))) {
     125                        continue;
     126                    }
    112127
    113128                    if ((es1.railway != null && es1.railway.equals("abandoned"))
    114                             || (railway2 != null && railway2.equals("abandoned"))) continue;
     129                            || (railway2 != null && railway2.equals("abandoned"))) {
     130                        continue;
     131                    }
    115132
    116133                    prims = Arrays.asList(es1.ws.way, es2.ws.way);
    117134                    if ((highlight = ways_seen.get(prims)) == null) {
     
    122139                        String message;
    123140                        if (isBuilding) {
    124141                            message = tr("Crossing buildings");
     142                        } else if ((es1.waterway != null && es2.waterway != null)) {
     143                            message = tr("Crossing waterways");
    125144                        } else if ((es1.waterway != null && es2.ws.way.get("highway") != null)
    126145                                || (es2.waterway != null && es1.ws.way.get("highway") != null)) {
    127146                            message = tr("Crossing waterway/highway");
     
    130149                        }
    131150
    132151                        errors.add(new TestError(this, Severity.WARNING,
    133                             message,
    134                             CROSSING_WAYS,
    135                             prims,
    136                             highlight));
     152                                message,
     153                                CROSSING_WAYS,
     154                                prims,
     155                                highlight));
    137156                        ways_seen.put(prims, highlight);
    138157                    } else {
    139158                        highlight.add(es1.ws);
     
    146165    }
    147166
    148167    /**
    149     * Returns all the cells this segment crosses.  Each cell contains the list
    150     * of segments already processed
    151     *
    152     * @param n1 The first node
    153     * @param n2 The second node
    154     * @return A list with all the cells the segment crosses
    155     */
     168     * Returns all the cells this segment crosses.  Each cell contains the list
     169     * of segments already processed
     170     *
     171     * @param n1 The first node
     172     * @param n2 The second node
     173     * @return A list with all the cells the segment crosses
     174     */
    156175    public List<List<ExtendedSegment>> getSegments(Node n1, Node n2) {
    157176
    158177        List<List<ExtendedSegment>> cells = new ArrayList<List<ExtendedSegment>>();
     
    217236                return false;
    218237
    219238            return Line2D.linesIntersect(
    220                 n1.getEastNorth().east(), n1.getEastNorth().north(),
    221                 n2.getEastNorth().east(), n2.getEastNorth().north(),
    222                 s2.n1.getEastNorth().east(), s2.n1.getEastNorth().north(),
    223                 s2.n2.getEastNorth().east(), s2.n2.getEastNorth().north());
     239                    n1.getEastNorth().east(), n1.getEastNorth().north(),
     240                    n2.getEastNorth().east(), n2.getEastNorth().north(),
     241                    s2.n1.getEastNorth().east(), s2.n1.getEastNorth().north(),
     242                    s2.n2.getEastNorth().east(), s2.n2.getEastNorth().north());
    224243        }
    225244    }
    226245}