HalfTrackSampler.java

  1. /* Copyright 2002-2024 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.models.earth.tessellation;

  18. import java.util.ArrayList;
  19. import java.util.List;

  20. import org.hipparchus.util.Pair;
  21. import org.orekit.bodies.GeodeticPoint;
  22. import org.orekit.bodies.OneAxisEllipsoid;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.propagation.sampling.OrekitFixedStepHandler;
  25. import org.orekit.utils.TimeStampedPVCoordinates;

  26. /** Sampler for half track span.
  27.  * @since 7.1
  28.  * @see AlongTrackAiming
  29.  * @author Luc Maisonobe
  30.  */
  31. class HalfTrackSampler implements OrekitFixedStepHandler {

  32.     /** Ellipsoid over which track is sampled. */
  33.     private final OneAxisEllipsoid ellipsoid;

  34.     /** Half track sample. */
  35.     private final List<Pair<GeodeticPoint, TimeStampedPVCoordinates>> halfTrack;

  36.     /** Simple constructor.
  37.      * @param ellipsoid ellipsoid over which track is sampled
  38.      */
  39.     HalfTrackSampler(final OneAxisEllipsoid ellipsoid) {
  40.         this.ellipsoid = ellipsoid;
  41.         this.halfTrack = new ArrayList<Pair<GeodeticPoint, TimeStampedPVCoordinates>>();
  42.     }

  43.     /** Get half track sample.
  44.      * @return half track sample
  45.      */
  46.     public List<Pair<GeodeticPoint, TimeStampedPVCoordinates>> getHalfTrack() {
  47.         return halfTrack;
  48.     }

  49.     /** {@inheritDoc} */
  50.     @Override
  51.     public void handleStep(final SpacecraftState currentState) {

  52.         // find the sliding ground point below spacecraft
  53.         final TimeStampedPVCoordinates pv       = currentState.getPVCoordinates(ellipsoid.getBodyFrame());
  54.         final TimeStampedPVCoordinates groundPV = ellipsoid.projectToGround(pv, ellipsoid.getBodyFrame());

  55.         // geodetic coordinates
  56.         final GeodeticPoint gp =
  57.                         ellipsoid.transform(groundPV.getPosition(), ellipsoid.getBodyFrame(), currentState.getDate());

  58.         halfTrack.add(new Pair<GeodeticPoint, TimeStampedPVCoordinates>(gp, groundPV));

  59.     }

  60. }