001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.osm; 003 004import java.io.Serializable; 005import java.util.Comparator; 006 007/** 008 * Provides some node order , based on coordinates, nodes with equal coordinates are equal. 009 * 010 * @author viesturs 011 */ 012public class NodePositionComparator implements Comparator<Node>, Serializable { 013 014 private static final long serialVersionUID = 1L; 015 016 @Override 017 public int compare(Node n1, Node n2) { 018 019 if (n1.getCoor().equalsEpsilon(n2.getCoor())) 020 return 0; 021 022 int dLat = Double.compare(n1.lat(), n2.lat()); 023 return dLat != 0 ? dLat : Double.compare(n1.lon(), n2.lon()); 024 } 025}