Skip to content
Snippets Groups Projects
Commit f26bab6a authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

ConstantRefraction does not really need to implement Comparable.

parent d4c7f865
No related branches found
No related tags found
No related merge requests found
......@@ -19,8 +19,9 @@ package org.orekit.rugged.refraction;
/**
* Class that represents a constant refraction layer to be used with {@link MultiLayerModel}.
* @author Sergio Esteves
* @since 2.0
*/
public class ConstantRefractionLayer implements Comparable<ConstantRefractionLayer> {
public class ConstantRefractionLayer {
/** lowest altitude of this layer. */
private final Double lowestAltitude;
......@@ -45,30 +46,4 @@ public class ConstantRefractionLayer implements Comparable<ConstantRefractionLay
return refractiveIndex;
}
@Override
public int compareTo(final ConstantRefractionLayer o) {
return lowestAltitude.compareTo(o.lowestAltitude);
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final ConstantRefractionLayer that = (ConstantRefractionLayer) o;
if (Double.compare(that.refractiveIndex, refractiveIndex) != 0) return false;
return lowestAltitude != null ? lowestAltitude.equals(that.lowestAltitude) : that.lowestAltitude == null;
}
@Override
public int hashCode() {
int result;
long temp;
result = lowestAltitude != null ? lowestAltitude.hashCode() : 0;
temp = Double.doubleToLongBits(refractiveIndex);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}
......@@ -33,6 +33,7 @@ import java.util.List;
/**
* Multi layer model for atmospheric refraction.
* @author Sergio Esteves, Luc Maisonobe
* @since 2.0
*/
public class MultiLayerModel implements AtmosphericRefraction {
......@@ -73,13 +74,14 @@ public class MultiLayerModel implements AtmosphericRefraction {
/** Simple constructor.
* @param ellipsoid the ellipsoid to be used.
* @param refractionLayers the refraction layers to be used with this model.
* @param refractionLayers the refraction layers to be used with this model (layers can be in any order).
*/
public MultiLayerModel(final ExtendedEllipsoid ellipsoid, final List<ConstantRefractionLayer> refractionLayers) {
this.ellipsoid = ellipsoid;
this.refractionLayers = refractionLayers;
Collections.sort(this.refractionLayers, Collections.<ConstantRefractionLayer>reverseOrder());
atmosphereLowestAltitude = refractionLayers.get(refractionLayers.size() - 1).getLowestAltitude();
this.refractionLayers = new ArrayList<>(refractionLayers);
Collections.sort(this.refractionLayers,
(l1, l2) -> Double.compare(l2.getLowestAltitude(), l1.getLowestAltitude()));
atmosphereLowestAltitude = this.refractionLayers.get(this.refractionLayers.size() - 1).getLowestAltitude();
}
/** {@inheritDoc} */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment