1   /* Copyright 2002-2025 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  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import org.hipparchus.util.Pair;
23  import org.orekit.bodies.GeodeticPoint;
24  import org.orekit.bodies.OneAxisEllipsoid;
25  import org.orekit.propagation.SpacecraftState;
26  import org.orekit.propagation.sampling.OrekitFixedStepHandler;
27  import org.orekit.utils.TimeStampedPVCoordinates;
28  
29  /** Sampler for half track span.
30   * @since 7.1
31   * @see AlongTrackAiming
32   * @author Luc Maisonobe
33   */
34  class HalfTrackSampler implements OrekitFixedStepHandler {
35  
36      /** Ellipsoid over which track is sampled. */
37      private final OneAxisEllipsoid ellipsoid;
38  
39      /** Half track sample. */
40      private final List<Pair<GeodeticPoint, TimeStampedPVCoordinates>> halfTrack;
41  
42      /** Simple constructor.
43       * @param ellipsoid ellipsoid over which track is sampled
44       */
45      HalfTrackSampler(final OneAxisEllipsoid ellipsoid) {
46          this.ellipsoid = ellipsoid;
47          this.halfTrack = new ArrayList<>();
48      }
49  
50      /** Get half track sample.
51       * @return half track sample
52       */
53      public List<Pair<GeodeticPoint, TimeStampedPVCoordinates>> getHalfTrack() {
54          return halfTrack;
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public void handleStep(final SpacecraftState currentState) {
60  
61          // find the sliding ground point below spacecraft
62          final TimeStampedPVCoordinates pv       = currentState.getPVCoordinates(ellipsoid.getBodyFrame());
63          final TimeStampedPVCoordinates groundPV = ellipsoid.projectToGround(pv, ellipsoid.getBodyFrame());
64  
65          // geodetic coordinates
66          final GeodeticPoint gp =
67                          ellipsoid.transform(groundPV.getPosition(), ellipsoid.getBodyFrame(), currentState.getDate());
68  
69          halfTrack.add(new Pair<>(gp, groundPV));
70  
71      }
72  
73  }