/** * Returns {@code true} if the specified object is also a {@linkplain DirectPosition direct * position} with equals {@linkplain #getCoordinate coordinate} and {@linkplain * #getCoordinateReferenceSystem CRS}. * * @param object The object to compare with this position. * @return {@code true} if the given object is equals to this position. */ @Override public boolean equals(final Object object) { if (object instanceof DirectPosition) { final DirectPosition that = (DirectPosition) object; final int dimension = getDimension(); if (dimension == that.getDimension()) { for (int i = 0; i < dimension; i++) { if (!Utilities.equals(this.getOrdinate(i), that.getOrdinate(i))) { return false; } } if (Utilities.equals( this.getCoordinateReferenceSystem(), that.getCoordinateReferenceSystem())) { assert hashCode() == that.hashCode() : this; return true; } } } return false; }