Changeset 7828 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-12-19T01:52:29+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #10855 - fix NPE - better handling of nodes without coordinates

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/DistributeAction.java

    r7005 r7828  
    155155        for (Iterator<Node> it = col.iterator(); it.hasNext();) {
    156156            Node n = it.next();
    157             if (n.getCoor() == null) {
     157            if (!n.isLatLonKnown()) {
    158158                it.remove();
    159159                result.add(n);
  • trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java

    r7146 r7828  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.actions;
     3
     4import java.awt.event.ActionEvent;
     5import java.util.ArrayList;
     6import java.util.Collection;
     7import java.util.TreeMap;
    38
    49import org.openstreetmap.josm.Main;
     
    1116import org.openstreetmap.josm.data.osm.Way;
    1217import org.openstreetmap.josm.tools.Geometry;
    13 
    14 import java.awt.event.ActionEvent;
    15 import java.util.ArrayList;
    16 import java.util.Collection;
    17 import java.util.TreeMap;
    1818
    1919/**
     
    7272
    7373    /**
    74      * Select a polygon or multipolgon by an internal point.
     74     * Select a polygon or multipolygon by an internal point.
    7575     *
    7676     * @param internalPoint the internal point.
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r7502 r7828  
    9292        long startTime = System.currentTimeMillis();
    9393        for (Node node : dataSet.getNodes()) {
    94             if (!node.isIncomplete() && node.isVisible() && (node.getCoor() == null || node.getEastNorth() == null)) {
     94            if (!node.isIncomplete() && node.isVisible() && !node.isLatLonKnown()) {
    9595                printError("COMPLETE WITHOUT COORDINATES", "%s is not incomplete but has null coordinates", node);
    9696            }
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r6830 r7828  
    3535    private double north = Double.NaN;
    3636
    37     private boolean isLatLonKnown() {
     37    /**
     38     * Determines if this node has valid coordinates.
     39     * @return {@code true} if this node has valid coordinates
     40     * @since 7828
     41     */
     42    public final boolean isLatLonKnown() {
    3843        return !Double.isNaN(lat) && !Double.isNaN(lon);
    3944    }
     
    198203    void setDataset(DataSet dataSet) {
    199204        super.setDataset(dataSet);
    200         if (!isIncomplete() && isVisible() && (getCoor() == null || getEastNorth() == null))
     205        if (!isIncomplete() && isVisible() && !isLatLonKnown())
    201206            throw new DataIntegrityProblemException("Complete node with null coordinates: " + toString());
    202207    }
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r7796 r7828  
    601601            if (Main.pref.getBoolean("debug.checkNullCoor", true)) {
    602602                for (Node n: nodes) {
    603                     if (n.isVisible() && !n.isIncomplete() && (n.getCoor() == null || n.getEastNorth() == null))
     603                    if (n.isVisible() && !n.isIncomplete() && !n.isLatLonKnown())
    604604                        throw new DataIntegrityProblemException("Complete visible node with null coordinates: " + toString(),
    605605                                "<html>" + tr("Complete node {0} with null coordinates in way {1}",
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r7792 r7828  
    314314    /**
    315315     * Finds the intersection of two lines of infinite length.
    316      * 
     316     *
    317317     * @param p1 first point on first line
    318318     * @param p2 second point on first line
     
    328328        CheckParameterUtil.ensureValidCoordinates(p3, "p3");
    329329        CheckParameterUtil.ensureValidCoordinates(p4, "p4");
    330        
     330
    331331        if (!p1.isValid()) throw new IllegalArgumentException();
    332332
     
    575575        Node oldPoint = polygonNodes.get(polygonNodes.size() - 1);
    576576
     577        if (!oldPoint.isLatLonKnown()) {
     578            return false;
     579        }
     580
    577581        for (Node newPoint : polygonNodes) {
    578582            //skip duplicate points
    579583            if (newPoint.equals(oldPoint)) {
    580584                continue;
     585            }
     586
     587            if (!newPoint.isLatLonKnown()) {
     588                return false;
    581589            }
    582590
     
    733741            result -= 2 * Math.PI;
    734742        }
    735        
     743
    736744        return result;
    737745    }
Note: See TracChangeset for help on using the changeset viewer.