ConstantElevationAlgorithm.java

  1. /* Copyright 2013-2022 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.rugged.intersection;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.bodies.GeodeticPoint;
  20. import org.orekit.rugged.api.AlgorithmId;
  21. import org.orekit.rugged.errors.DumpManager;
  22. import org.orekit.rugged.utils.ExtendedEllipsoid;
  23. import org.orekit.rugged.utils.NormalizedGeodeticPoint;

  24. /** Intersection ignoring Digital Elevation Model.
  25.  * <p>
  26.  * This implementation uses a constant elevation over the ellipsoid.
  27.  * </p>
  28.  * @author Luc Maisonobe
  29.  * @author Guylaine Prat
  30.  */
  31. public class ConstantElevationAlgorithm implements IntersectionAlgorithm {

  32.     /** Constant elevation over ellipsoid. */
  33.     private final double constantElevation;

  34.     /** Algorithm Id.
  35.      * @since 2.2 */
  36.     private final AlgorithmId algorithmId;

  37.     /** Simple constructor.
  38.      * @param constantElevation constant elevation over ellipsoid
  39.      */
  40.     public ConstantElevationAlgorithm(final double constantElevation) {
  41.         this.constantElevation = constantElevation;
  42.         this.algorithmId = AlgorithmId.CONSTANT_ELEVATION_OVER_ELLIPSOID;
  43.     }

  44.     /** {@inheritDoc} */
  45.     @Override
  46.     public NormalizedGeodeticPoint intersection(final ExtendedEllipsoid ellipsoid,
  47.                                                 final Vector3D position, final Vector3D los) {
  48.         DumpManager.dumpAlgorithm(this.algorithmId, constantElevation);
  49.         final Vector3D      p  = ellipsoid.pointAtAltitude(position, los, constantElevation);
  50.         final GeodeticPoint gp = ellipsoid.transform(p, ellipsoid.getFrame(), null);
  51.         return new NormalizedGeodeticPoint(gp.getLatitude(), gp.getLongitude(), gp.getAltitude(), 0.0);
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public NormalizedGeodeticPoint refineIntersection(final ExtendedEllipsoid ellipsoid,
  56.                                                       final Vector3D position, final Vector3D los,
  57.                                                       final NormalizedGeodeticPoint closeGuess) {
  58.         DumpManager.dumpAlgorithm(this.algorithmId, constantElevation);
  59.         final Vector3D      p  = ellipsoid.pointAtAltitude(position, los, constantElevation);
  60.         final GeodeticPoint gp = ellipsoid.transform(p, ellipsoid.getFrame(), null);
  61.         return new NormalizedGeodeticPoint(gp.getLatitude(), gp.getLongitude(), gp.getAltitude(),
  62.                 closeGuess.getLongitude());
  63.     }

  64.     /** {@inheritDoc}
  65.      * <p>
  66.      * As this algorithm uses a constant elevation,
  67.      * this method always returns the same value.
  68.      * </p>
  69.      */
  70.     @Override
  71.     public double getElevation(final double latitude, final double longitude) {
  72.         DumpManager.dumpAlgorithm(this.algorithmId, constantElevation);
  73.         return constantElevation;
  74.     }

  75.     /** {@inheritDoc} */
  76.     @Override
  77.     public AlgorithmId getAlgorithmId() {
  78.         return this.algorithmId;
  79.     }
  80. }