ObservationsBlock.java

  1. /* Copyright 2002-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.files.ccsds.ndm.tdm;

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

  20. import org.orekit.files.ccsds.section.CommentsContainer;
  21. import org.orekit.files.ccsds.section.Data;
  22. import org.orekit.time.AbsoluteDate;

  23. /** The Observations Block class contain metadata and the list of observation data lines.<p>
  24.  * The reason for which the observations have been separated into blocks is that the different
  25.  * data blocks in a TDM file usually refers to different types of observations.<p>
  26.  * An observation block is associated with a TDM metadata object and contains a list of observations.<p>
  27.  * At this level, an observation is not an Orekit object, it is a custom object containing:<p>
  28.  *  - a keyword, the type of the observation;<p>
  29.  *  - a timetag, the date of the observation;<p>
  30.  *  - a measurement, the value of the observation.
  31.  * @author Maxime Journot
  32.  */
  33. public class ObservationsBlock extends CommentsContainer implements Data {

  34.     /** Current observation epoch. */
  35.     private AbsoluteDate currentObservationEpoch;

  36.     /** List of observations data lines. */
  37.     private List<Observation> observations;

  38.     /** ObservationsBlock constructor. */
  39.     public ObservationsBlock() {
  40.         observations = new ArrayList<>();
  41.     }

  42.     /** Add the epoch of current observation.
  43.      * @param epoch current observation epoch
  44.      * @return alwaus return {@code true}
  45.      */
  46.     boolean addObservationEpoch(final AbsoluteDate epoch) {
  47.         refuseFurtherComments();
  48.         currentObservationEpoch = epoch;
  49.         return true;
  50.     }

  51.     /** Get current observation epoch if set.
  52.      * @return current observation epoch, or null if not set
  53.      */
  54.     AbsoluteDate getCurrentObservationEpoch() {
  55.         return currentObservationEpoch;
  56.     }

  57.     /** Add the value of current observation.
  58.      * @param type type of the observation
  59.      * @param measurement measurement of the observation
  60.      */
  61.     void addObservationValue(final ObservationType type, final double measurement) {
  62.         addObservation(type, currentObservationEpoch, measurement);
  63.         currentObservationEpoch = null;
  64.     }

  65.     /** Get the list of Observations data lines.
  66.      * @return a reference to the internal list of Observations data lines
  67.      */
  68.     public List<Observation> getObservations() {
  69.         return this.observations;
  70.     }

  71.     /** Set the list of Observations Data Lines.
  72.      * @param observations the list of Observations Data Lines to set
  73.      */
  74.     public void setObservations(final List<Observation> observations) {
  75.         refuseFurtherComments();
  76.         this.observations = new ArrayList<>(observations);
  77.     }

  78.     /** Adds an observation data line.
  79.      * @param observation the observation to add to the list
  80.      */
  81.     public void addObservation(final Observation observation) {
  82.         refuseFurtherComments();
  83.         this.observations.add(observation);
  84.     }

  85.     /** Adds an observation data line.
  86.      * @param type type of the observation
  87.      * @param epoch the timetag
  88.      * @param measurement the measurement
  89.      */
  90.     public void addObservation(final ObservationType type,
  91.                                final AbsoluteDate epoch,
  92.                                final double measurement) {
  93.         this.addObservation(new Observation(type, epoch, measurement));
  94.     }

  95. }