Ignore:
Timestamp:
2011-05-04T22:03:53+02:00 (13 years ago)
Author:
jttt
Message:

Fix #6161 Validating a file

Location:
trunk/src/org/openstreetmap/josm/data/validation/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java

    r3698 r4073  
    1414import org.openstreetmap.josm.command.ChangeCommand;
    1515import org.openstreetmap.josm.command.Command;
     16import org.openstreetmap.josm.data.osm.Node;
    1617import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.osm.Node;
    1818import org.openstreetmap.josm.data.osm.Way;
    1919import org.openstreetmap.josm.data.validation.Severity;
     
    4444    public Coastlines() {
    4545        super(tr("Coastlines."),
    46               tr("This test checks that coastlines are correct."));
     46                tr("This test checks that coastlines are correct."));
    4747    }
    4848
     
    6767            Node tail = c1.lastNode();
    6868
    69             if (head.equals(tail)) {
     69            if (c1.getNodesCount() == 0 || head.equals(tail)) {
    7070                continue;
    7171            }
     
    162162                if (highlight.size() > 0) {
    163163                    errors.add(new TestError(this, Severity.ERROR, tr("Unconnected coastline"),
    164                                              UNCONNECTED_COASTLINE, primitives, highlight));
     164                            UNCONNECTED_COASTLINE, primitives, highlight));
    165165                }
    166166            }
     
    191191
    192192                errors.add(new TestError(this, Severity.ERROR, tr("Unordered coastline"),
    193                                          UNORDERED_COASTLINE, primitives, highlight));
     193                        UNORDERED_COASTLINE, primitives, highlight));
    194194            }
    195195            else if (reversed) {
    196196                errors.add(new TestError(this, Severity.ERROR, tr("Reversed coastline"),
    197                                          REVERSED_COASTLINE, primitives));
     197                        REVERSED_COASTLINE, primitives));
    198198            }
    199199        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r4059 r4073  
    6060    public UnconnectedWays() {
    6161        super(tr("Unconnected ways."),
    62               tr("This test checks if a way has an endpoint very near to another way."));
     62                tr("This test checks if a way has an endpoint very near to another way."));
    6363    }
    6464
     
    8989                    }
    9090                    if ("turning_circle".equals(en.get("highway"))
    91                         || "bus_stop".equals(en.get("highway"))
    92                         || "buffer_stop".equals(en.get("railway"))
    93                         || OsmUtils.isTrue(en.get("noexit"))
    94                         || en.hasKey("barrier")) {
     91                            || "bus_stop".equals(en.get("highway"))
     92                            || "buffer_stop".equals(en.get("railway"))
     93                            || OsmUtils.isTrue(en.get("noexit"))
     94                            || en.hasKey("barrier")) {
    9595                        continue;
    9696                    }
     
    198198            this.isBoundary = !this.highway && "administrative".equals(w.get("boundary"));
    199199            line = new Line2D.Double(n1.getEastNorth().east(), n1.getEastNorth().north(),
    200                                      n2.getEastNorth().east(), n2.getEastNorth().north());
     200                    n2.getEastNorth().east(), n2.getEastNorth().north());
    201201            len = line.getP1().distance(line.getP2());
    202202            this.n1 = n1;
     
    288288            found_nodes.addAll(endnodes.search(new BBox(bounds.get(0), bounds.get(1))));
    289289
    290             if (found_nodes == null)
    291                 return Collections.emptySet();
    292 
    293290            for (Node n : found_nodes) {
    294291                if (!nearby(n, dist) ||
    295                      (ds_area != null && !ds_area.contains(n.getCoor()))) {
     292                        (ds_area != null && !ds_area.contains(n.getCoor()))) {
    296293                    continue;
    297294                }
     
    313310        public boolean isArea() {
    314311            return w.hasKey("landuse")
    315                 || w.hasKey("leisure")
    316                 || w.hasKey("amenity")
    317                 || w.hasKey("building");
     312            || w.hasKey("leisure")
     313            || w.hasKey("amenity")
     314            || w.hasKey("building");
    318315        }
    319316    }
     
    322319        List<MyWaySegment> ret = new ArrayList<MyWaySegment>();
    323320        if (!w.isUsable()
    324             || w.hasKey("barrier")
    325             || "cliff".equals(w.get("natural")))
     321                || w.hasKey("barrier")
     322                || "cliff".equals(w.get("natural")))
    326323            return ret;
    327324
     
    344341    @Override
    345342    public void visit(Way w) {
    346         ways.addAll(getWaySegments(w));
    347         QuadBuckets<Node> set = endnodes;
    348         if (w.hasKey("highway") || w.hasKey("railway")) {
    349             set = endnodes_highway;
    350         }
    351         addNode(w.firstNode(), set);
    352         addNode(w.lastNode(), set);
     343        if (w.getNodesCount() > 0) {
     344            ways.addAll(getWaySegments(w));
     345            QuadBuckets<Node> set = endnodes;
     346            if (w.hasKey("highway") || w.hasKey("railway")) {
     347                set = endnodes_highway;
     348            }
     349            addNode(w.firstNode(), set);
     350            addNode(w.lastNode(), set);
     351        }
    353352    }
    354353
Note: See TracChangeset for help on using the changeset viewer.