Ticket #4141: CoordinateConflictPrecision.patch

File CoordinateConflictPrecision.patch, 3.5 KB (added by mjulius, 12 years ago)
  • src/org/openstreetmap/josm/data/coor/LatLon.java

  • src/org/openstreetmap/josm/data/osm/Node.java

    @ -99,7 +103,7 @@
          * 1 / {@link org.openstreetmap.josm.data.projection.Projection#MAX_SERVER_PRECISION MAX_SERVER_PRECISION}.
          */
         public boolean equalsEpsilon(LatLon other) {
    -        final double p = 1/Projection.MAX_SERVER_PRECISION;
    +        final double p = Projection.MAX_SERVER_PRECISION;
             return Math.abs(lat()-other.lat()) <= p && Math.abs(lon()-other.lon()) <= p;
         }
     
     
    135135    @Override public NodeData save() {
    136136        NodeData data = new NodeData();
    137137        saveCommonAttributes(data);
    138         data.setCoor(getCoor());
     138        if (!isIncomplete()) {
     139            data.setCoor(getCoor());
     140        }
    139141        return data;
    140142    }
    141143
     
    154156        if (coor == null && n.coor == null)
    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;
    160162    }
  • src/org/openstreetmap/josm/data/projection/Projection.java

     
    1414public interface Projection {
    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    /**
    2122     * List of all available projections.
  • src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java

     
    325325        if (myCoords == null && theirCoords != null) return true;
    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
    331331    /**
  • src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

     
    3030 *
    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);
    3636    public final static Color BGCOLOR_UNDECIDED = new Color(255,197,197);