HalfTrackSpanHandler.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 org.hipparchus.ode.events.Action;
  19. import org.orekit.propagation.SpacecraftState;
  20. import org.orekit.propagation.events.EventDetector;
  21. import org.orekit.propagation.events.handlers.EventHandler;
  22. import org.orekit.time.AbsoluteDate;

  23. /** Event handler for half track span.
  24.  * @since 7.1
  25.  * @see AlongTrackAiming
  26.  * @author Luc Maisonobe
  27.  */
  28. class HalfTrackSpanHandler implements EventHandler {

  29.     /** Indicator for zone tiling with respect to ascending or descending orbits. */
  30.     private final boolean isAscending;

  31.     /** Halftrack start date. */
  32.     private AbsoluteDate start;

  33.     /** Halftrack end date. */
  34.     private AbsoluteDate end;

  35.     /** Simple constructor.
  36.      * @param isAscending indicator for zone tiling with respect to ascending
  37.      * or descending orbits
  38.      */
  39.     HalfTrackSpanHandler(final boolean isAscending) {
  40.         this.isAscending = isAscending;
  41.         this.start       = null;
  42.         this.end         = null;
  43.     }

  44.     /** Get the start date of the half track.
  45.      * @return start date of the half track
  46.      */
  47.     public AbsoluteDate getStart() {
  48.         return start;
  49.     }

  50.     /** Get the end date of the half track.
  51.      * @return end date of the half track
  52.      */
  53.     public AbsoluteDate getEnd() {
  54.         return end;
  55.     }

  56.     /** {@inheritDoc} */
  57.     @Override
  58.     public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
  59.         if (increasing ^ isAscending) {
  60.             // we have found an end event
  61.             if (start == null) {
  62.                 // we don't have the start event yet,
  63.                 // so we ignore this and wait for the next orbit
  64.                 return Action.CONTINUE;
  65.             } else {
  66.                 end = s.getDate();
  67.                 return Action.STOP;
  68.             }
  69.         } else {
  70.             // we have found the start of the span
  71.             start = s.getDate();
  72.             return Action.CONTINUE;
  73.         }
  74.     }

  75. }