Changeset 52 in josm for src/org/openstreetmap/josm/data


Ignore:
Timestamp:
2006-02-14T00:52:11+01:00 (18 years ago)
Author:
imi
Message:
  • fixed data merge (sometime set modified unnecessary)
  • fixed rounding (now compare with epsilon instead of round everything)
  • Fix: upload does not clear all changes if only some thing got uploaded
Location:
src/org/openstreetmap/josm/data
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/GeoPoint.java

    r41 r52  
    8080
    8181        /**
     82         * @return <code>true</code>, if the other GeoPoint has almost the same lat/lon
     83         * values, only differ by no more than 1/Projection.MAX_SERVER_PRECISION.
     84         */
     85        public boolean equalsLatLonEpsilon(GeoPoint other) {
     86                final double p = 1/Projection.MAX_SERVER_PRECISION;
     87                return Math.abs(lat-other.lat) <= p && Math.abs(lon-other.lon) <= p &&
     88                                !Double.isNaN(lat) && !Double.isNaN(lon);
     89        }
     90
     91        /**
    8292         * @return <code>true</code>, if the coordinate is outside the world, compared
    8393         * by using lat/lon.
  • src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r50 r52  
    4242                        if (myNode.modified && !otherNode.modified)
    4343                                return;
    44                         if (!myNode.coor.equalsLatLon(otherNode.coor)) {
     44                        if (!myNode.coor.equalsLatLonEpsilon(otherNode.coor)) {
    4545                                myNode.coor = otherNode.coor;
    4646                                myNode.modified = otherNode.modified;
     
    5151        /**
    5252         * Merge the line segment if id matches or if both nodes are the same (and the
    53          * id is zero of either segment). Nodes are equal when they @see match
     53         * id is zero of either segment). Nodes are the "same" when they @see match
    5454         */
    5555        public void visit(LineSegment otherLs) {
     
    120120        private boolean match(Node n1, Node n2) {
    121121                if (n1.id == 0 || n2.id == 0)
    122                         return n1.coor.equalsLatLon(n2.coor);
     122                        return n1.coor.equalsLatLonEpsilon(n2.coor);
    123123                return n1.id == n2.id;
    124124        }
     
    153153         */
    154154        private void mergeCommon(OsmPrimitive myOsm, OsmPrimitive otherOsm) {
    155                 if (otherOsm.modified)
    156                         myOsm.modified = true;
    157155                if (otherOsm.isDeleted())
    158156                        myOsm.setDeleted(true);
    159157                if (!myOsm.modified || otherOsm.modified) {
    160                         if (otherOsm.id != 0 && myOsm.id == 0)
     158                        if (myOsm.id == 0 && otherOsm.id != 0)
    161159                                myOsm.id = otherOsm.id; // means not ncessary the object is now modified
     160                        else if (myOsm.id != 0 && otherOsm.id != 0 && otherOsm.modified)
     161                                myOsm.modified = true;
    162162                }
    163163                if (myOsm.modifiedProperties && !otherOsm.modifiedProperties)
    164164                        return;
    165                 if (myOsm.keys != null && !myOsm.keys.equals(otherOsm.keys)) {
    166                         if (myOsm.keys == null)
    167                                 myOsm.keys = otherOsm.keys;
    168                         else if (otherOsm.keys != null)
    169                                 myOsm.keys.putAll(otherOsm.keys);
    170                         myOsm.modifiedProperties = true;
    171                 }
     165                if (otherOsm.keys == null)
     166                        return;
     167                if (myOsm.keys != null && myOsm.keys.entrySet().containsAll(otherOsm.keys.entrySet()))
     168                        return;
     169                if (myOsm.keys == null)
     170                        myOsm.keys = otherOsm.keys;
     171                else
     172                        myOsm.keys.putAll(otherOsm.keys);
     173                myOsm.modifiedProperties = true;
    172174        }
    173175}
  • src/org/openstreetmap/josm/data/projection/Epsg4263.java

    r51 r52  
    1616
    1717        public void xy2latlon(GeoPoint p) {
    18                 p.lat = Math.round(p.y*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;
    19                 p.lon = Math.round(p.x*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;
     18                p.lat = p.y;
     19                p.lon = p.x;
    2020        }
    2121
  • src/org/openstreetmap/josm/data/projection/Mercator.java

    r51 r52  
    2222                p.lon = p.x*180/Math.PI;
    2323                p.lat = Math.atan(Math.sinh(p.y))*180/Math.PI;
    24                 // round values to maximum server precision
    25                 p.lon = Math.round(p.lon*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;
    26                 p.lat = Math.round(p.lat*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;
    2724        }
    2825
Note: See TracChangeset for help on using the changeset viewer.