DateDriver.java

  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.utils;

  18. import org.orekit.time.AbsoluteDate;
  19. import org.orekit.time.TimeStamped;


  20. /** {@link ParameterDriver Parameter driver} allowing to drive a date.
  21.  * @author Luc Maisonobe
  22.  * @since 11.1
  23.  */
  24. public class DateDriver extends ParameterDriver implements TimeStamped {

  25.     /** Base date corresponding to shift = 0. */
  26.     private final AbsoluteDate base;

  27.     /** Indicator for start date. */
  28.     private boolean start;

  29.     /** Simple constructor.
  30.      * <p>
  31.      * At construction, the parameter is configured as <em>not</em> selected,
  32.      * the reference date is set to {@code null}, the value (i.e. the date offset)
  33.      * is set to 0, the scale is set to 1 and the minimum and maximum values are
  34.      * set to negative and positive infinity respectively.
  35.      * </p>
  36.      * @param base base date corresponding to shift = 0
  37.      * @param name name of the parameter
  38.      * @param start if true, the driver corresponds to a start date
  39.      */
  40.     public DateDriver(final AbsoluteDate base, final String name, final boolean start) {
  41.         super(name, 0.0, 1.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
  42.         this.base  = base;
  43.         this.start = start;
  44.     }

  45.     /** Get the base (unshifted) date.
  46.      * @return base (unshifted) date
  47.      */
  48.     public AbsoluteDate getBaseDate() {
  49.         return base;
  50.     }

  51.     /** Check if driver corresponds to a start date.
  52.      * @return true if driver corresponds to a start date
  53.      */
  54.     public boolean isStart() {
  55.         return start;
  56.     }

  57.     /** Get the shifted date.
  58.      * @return shifted date
  59.      */
  60.     public AbsoluteDate getDate() {
  61.         // date driver has no validity period, only 1 value is estimated
  62.         // over the all interval so there is no problem for calling getValue with null argument
  63.         // or any date, it would give the same result as there is only 1 span on the valueSpanMap
  64.         // of the driver
  65.         return base.shiftedBy(getValue(base));
  66.     }

  67. }