Changeset 2612 in josm


Ignore:
Timestamp:
2009-12-11T22:52:54+01:00 (10 years ago)
Author:
mjulius
Message:

Fixes #4083 - exception when copying relation with incomplete node
Fixes #4141 - relax conflict detection for coordinates; API only returns 7 decimals

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r2570 r2612  
    22package org.openstreetmap.josm.data.coor;
    33
     4import static java.lang.Math.PI;
     5import static java.lang.Math.asin;
     6import static java.lang.Math.cos;
     7import static java.lang.Math.sin;
     8import static java.lang.Math.sqrt;
     9import static java.lang.Math.toRadians;
    410import static org.openstreetmap.josm.tools.I18n.tr;
    511
    612import java.text.DecimalFormat;
    713import java.text.NumberFormat;
    8 
    9 import static java.lang.Math.*;
    1014
    1115import org.openstreetmap.josm.Main;
     
    100104     */
    101105    public boolean equalsEpsilon(LatLon other) {
    102         final double p = 1/Projection.MAX_SERVER_PRECISION;
     106        final double p = Projection.MAX_SERVER_PRECISION;
    103107        return Math.abs(lat()-other.lat()) <= p && Math.abs(lon()-other.lon()) <= p;
    104108    }
     
    132136        double sinHalfLon = sin(toRadians(other.lon() - this.lon()) / 2);
    133137        double d = 2 * R * asin(
    134                             sqrt(sinHalfLat*sinHalfLat +
    135                             cos(toRadians(this.lat()))*cos(toRadians(other.lat()))*sinHalfLon*sinHalfLon));
    136         // For points opposite to each other on the sphere, 
     138                sqrt(sinHalfLat*sinHalfLat +
     139                        cos(toRadians(this.lat()))*cos(toRadians(other.lat()))*sinHalfLon*sinHalfLon));
     140        // For points opposite to each other on the sphere,
    137141        // rounding errors could make the argument of asin greater than 1
    138142        // (This should almost never happen.)
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r2578 r2612  
    136136        NodeData data = new NodeData();
    137137        saveCommonAttributes(data);
    138         data.setCoor(getCoor());
     138        if (!isIncomplete()) {
     139            data.setCoor(getCoor());
     140        }
    139141        return data;
    140142    }
     
    155157            return true;
    156158        else if (coor != null && n.coor != null)
    157             return coor.equals(n.coor);
     159            return coor.equalsEpsilon(n.coor);
    158160        else
    159161            return false;
  • trunk/src/org/openstreetmap/josm/data/projection/Projection.java

    r2511 r2612  
    1515    /**
    1616     * Minimum difference in location to not be represented as the same position.
     17     * The API returns 7 decimals.
    1718     */
    18     public static final double MAX_SERVER_PRECISION = 1e12;
     19    public static final double MAX_SERVER_PRECISION = 5e-8;
    1920
    2021    /**
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java

    r2512 r2612  
    326326        if (myCoords != null && theirCoords == null) return true;
    327327        if (myCoords == null && theirCoords == null) return false;
    328         return !myCoords.equals(theirCoords);
     328        return !myCoords.equalsEpsilon(theirCoords);
    329329    }
    330330
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    r2512 r2612  
    3131 */
    3232public class PropertiesMerger extends JPanel implements Observer {
    33     private static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000");
     33    private static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000000");
    3434
    3535    public final static Color BGCOLOR_NO_CONFLICT = new Color(234,234,234);
Note: See TracChangeset for help on using the changeset viewer.