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

Last change on this file since 7501 was 3650, checked in by bastiK, 13 years ago

applied #5599 (patch by extropy) - Join areas speed improvement

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