source: josm/trunk/src/org/openstreetmap/josm/data/osm/NodePositionComparator.java@ 13082

Last change on this file since 13082 was 12161, checked in by michael2402, 7 years ago

See #13415: Add the ILatLon interface, unify handling of Nodes and CachedLatLon

  • Property svn:eol-style set to native
File size: 675 bytes
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.io.Serializable;
5import java.util.Comparator;
6
7/**
8 * Provides some node order , based on coordinates, nodes with equal coordinates are equal.
9 *
10 * @author viesturs
11 */
12public class NodePositionComparator implements Comparator<Node>, Serializable {
13
14 private static final long serialVersionUID = 1L;
15
16 @Override
17 public int compare(Node n1, Node n2) {
18
19 if (n1.getCoor().equalsEpsilon(n2.getCoor()))
20 return 0;
21
22 int dLat = Double.compare(n1.lat(), n2.lat());
23 return dLat != 0 ? dLat : Double.compare(n1.lon(), n2.lon());
24 }
25}
Note: See TracBrowser for help on using the repository browser.