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

Last change on this file since 9827 was 8393, checked in by Don-vip, 9 years ago

see #11447 - partial revert of r8384

  • Property svn:eol-style set to native
File size: 844 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 double dLat = n1.getCoor().lat() - n2.getCoor().lat();
23 if (dLat > 0)
24 return 1;
25 if (dLat < 0)
26 return -1;
27 double dLon = n1.getCoor().lon() - n2.getCoor().lon();
28 if (dLon == 0)
29 return 0;
30 return dLon > 0 ? 1 : -1;
31 }
32}
Note: See TracBrowser for help on using the repository browser.