Changeset 9310 in josm for trunk/src


Ignore:
Timestamp:
2016-01-04T22:17:54+01:00 (9 years ago)
Author:
simon04
Message:

fix #11773 - Saving osm files in JOSM will save the nodes in one of two orders

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r9243 r9310  
    1515import org.openstreetmap.josm.data.coor.CoordinateFormat;
    1616import org.openstreetmap.josm.data.coor.LatLon;
     17import org.openstreetmap.josm.data.osm.AbstractPrimitive;
    1718import org.openstreetmap.josm.data.osm.Changeset;
    1819import org.openstreetmap.josm.data.osm.DataSet;
     
    9394    }
    9495
    95     protected static final Comparator<OsmPrimitive> byIdComparator = new Comparator<OsmPrimitive>() {
    96         @Override public int compare(OsmPrimitive o1, OsmPrimitive o2) {
    97             return o1.getUniqueId() < o2.getUniqueId() ? -1 : (o1.getUniqueId() == o2.getUniqueId() ? 0 : 1);
     96    /**
     97     * Sorts {@code -1} &rarr; {@code -infinity}, then {@code +1} &rarr; {@code +infinity}
     98     */
     99    protected static final Comparator<AbstractPrimitive> byIdComparator = new Comparator<AbstractPrimitive>() {
     100        @Override public int compare(AbstractPrimitive o1, AbstractPrimitive o2) {
     101            final long i1 = o1.getUniqueId();
     102            final long i2 = o2.getUniqueId();
     103            if (i1 < 0 && i2 < 0) {
     104                return Long.compare(i2, i1);
     105            } else {
     106                return Long.compare(i1, i2);
     107            }
    98108        }
    99109    };
Note: See TracChangeset for help on using the changeset viewer.