CdmRelativeMetadataKey.java

  1. /* Copyright 2002-2023 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.cdm;

  18. import org.orekit.files.ccsds.utils.ContextBinding;
  19. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  20. import org.orekit.files.ccsds.utils.lexical.TokenType;
  21. import org.orekit.utils.units.Unit;
  22. import org.orekit.files.ccsds.definitions.PocMethodFacade;
  23. import org.orekit.files.ccsds.definitions.Units;

  24. /** Keys for {@link CdmRelativeMetadata CDM container} entries.
  25.  * @author Melina Vanel
  26.  * @since 11.2
  27.  */
  28. public enum CdmRelativeMetadataKey {

  29.     /** The Originator’s ID that uniquely identifies the conjunction to which the message refers. */
  30.     CONJUNCTION_ID((token, context, container) -> token.processAsNormalizedString(container::setConjunctionId)),

  31.     /** Date and time in UTC of the closest approach. */
  32.     TCA((token, context, container) -> token.processAsDate(container::setTca, context)),

  33.     /** Norm of relative position vector at TCA. */
  34.     MISS_DISTANCE((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  35.                                                                              container::setMissDistance)),
  36.     /** The length of the relative position vector, normalized to one-sigma dispersions of the combined error covariance
  37.      * in the direction of the relative position vector. */
  38.     MAHALANOBIS_DISTANCE((token, context, container) -> token.processAsDouble(Unit.NONE, context.getParsedUnitsBehavior(),
  39.                                                                              container::setMahalanobisDistance)),

  40.     /** Norm of relative velocity vector at TCA. */
  41.     RELATIVE_SPEED((token, context, container) -> token.processAsDouble(Units.M_PER_S, context.getParsedUnitsBehavior(),
  42.                                                                              container::setRelativeSpeed)),

  43.     /** The R component of Object2’s position relative to Object1’s position in the Radial/Transverse/Normal coordinate frame. */
  44.     RELATIVE_POSITION_R((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  45.                                                                              container::setRelativePositionR)),

  46.     /** The T component of Object2’s position relative to Object1’s position in the Radial/Transverse/Normal coordinate frame. */
  47.     RELATIVE_POSITION_T((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  48.                                                                              container::setRelativePositionT)),

  49.     /** The N component of Object2’s position relative to Object1’s position in the Radial/Transverse/Normal coordinate frame. */
  50.     RELATIVE_POSITION_N((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  51.                                                                             container::setRelativePositionN)),

  52.     /** The R component of Object2’s velocity relative to Object1’s veloity in the Radial/Transverse/Normal coordinate frame. */
  53.     RELATIVE_VELOCITY_R((token, context, container) -> token.processAsDouble(Units.M_PER_S, context.getParsedUnitsBehavior(),
  54.                                                                              container::setRelativeVelocityR)),

  55.     /** The T component of Object2’s velocity relative to Object1’s veloity in the Radial/Transverse/Normal coordinate frame. */
  56.     RELATIVE_VELOCITY_T((token, context, container) -> token.processAsDouble(Units.M_PER_S, context.getParsedUnitsBehavior(),
  57.                                                                              container::setRelativeVelocityT)),

  58.     /** The N component of Object2’s velocity relative to Object1’s veloity in the Radial/Transverse/Normal coordinate frame. */
  59.     RELATIVE_VELOCITY_N((token, context, container) -> token.processAsDouble(Units.M_PER_S, context.getParsedUnitsBehavior(),
  60.                                                                              container::setRelativeVelocityN)),

  61.     /** The approach angle computed between Objects 1 and 2 in the RTN coordinate frame relative to object 1. */
  62.     APPROACH_ANGLE((token, context, container) -> token.processAsDouble(Unit.DEGREE, context.getParsedUnitsBehavior(),
  63.                                                                          container::setApproachAngle)),

  64.     /** The start time in UTC of the screening period for the conjunction assessment. */
  65.     START_SCREEN_PERIOD((token, context, container) -> token.processAsDate(container::setStartScreenPeriod, context)),

  66.     /** The stop time in UTC of the screening period for the conjunction assessment. */
  67.     STOP_SCREEN_PERIOD((token, context, container) -> token.processAsDate(container::setStopScreenPeriod, context)),

  68.     /** Name of the Object1 centered reference frame in which the screening volume data are given. */
  69.     SCREEN_VOLUME_FRAME((token, context, container) -> token.processAsEnum(ScreenVolumeFrame.class, container::setScreenVolumeFrame)),

  70.     /** The type of screening to be used. */
  71.     SCREEN_TYPE((token, context, container) -> token.processAsEnum(ScreenType.class, container::setScreenType)),

  72.     /** Shape of the screening volume. */
  73.     SCREEN_VOLUME_SHAPE((token, context, container) -> token.processAsEnum(ScreenVolumeShape.class, container::setScreenVolumeShape)),

  74.     /** The radius of the screening volume. */
  75.     SCREEN_VOLUME_RADIUS((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  76.                                                                              container::setScreenVolumeRadius)),

  77.     /** The R or T (depending on if RTN or TVN is selected) component size of the screening volume in the SCREEN_VOLUME_FRAME. */
  78.     SCREEN_VOLUME_X((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  79.                                                                          container::setScreenVolumeX)),

  80.     /** The T or V (depending on if RTN or TVN is selected) component size of the screening volume in the SCREEN_VOLUME_FRAME. */
  81.     SCREEN_VOLUME_Y((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  82.                                                                          container::setScreenVolumeY)),

  83.     /** The N component size of the screening volume in the SCREEN_VOLUME_FRAME. */
  84.     SCREEN_VOLUME_Z((token, context, container) -> token.processAsDouble(Unit.METRE, context.getParsedUnitsBehavior(),
  85.                                                                          container::setScreenVolumeZ)),

  86.     /** The time in UTC when Object2 enters the screening volume. */
  87.     SCREEN_ENTRY_TIME((token, context, container) -> token.processAsDate(container::setScreenEntryTime, context)),

  88.     /** The time in UTC when Object2 exits the screening volume. */
  89.     SCREEN_EXIT_TIME((token, context, container) -> token.processAsDate(container::setScreenExitTime, context)),

  90.     /** The collision probability screening threshold used to identify this conjunction. */
  91.     SCREEN_PC_THRESHOLD((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  92.                                                                              container::setScreenPcThreshold)),

  93.     /** An array of 1 to n elements indicating the percentile(s) for which estimates of the collision probability are provided in the
  94.      * COLLISION_PROBABILITY variable. */
  95.     COLLISION_PERCENTILE((token, context, container) -> token.processAsIntegerArray(container::setCollisionPercentile)),

  96.     /** The probability (between 0.0 and 1.0) that Object1 and Object2 will collide. */
  97.     COLLISION_PROBABILITY((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  98.                                                                                container::setCollisionProbability)),

  99.     /** The method that was used to calculate the collision probability. */
  100.     COLLISION_PROBABILITY_METHOD((token, context, container) -> {
  101.         if (token.getType() == TokenType.ENTRY) {
  102.             container.setCollisionProbaMethod(PocMethodFacade.parse(token.getContentAsNormalizedString()));
  103.         }
  104.         return true;
  105.     }),

  106.     /** The maximum collision probability that Object1 and Object2 will collide. */
  107.     COLLISION_MAX_PROBABILITY((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  108.                                                                                container::setMaxCollisionProbability)),

  109.     /** The method that was used to calculate the maximum collision probability. */
  110.     COLLISION_MAX_PC_METHOD((token, context, container) -> {
  111.         if (token.getType() == TokenType.ENTRY) {
  112.             container.setMaxCollisionProbabilityMethod(PocMethodFacade.parse(token.getRawContent()));
  113.         }
  114.         return true;
  115.     }),

  116.     /**  The space environment fragmentation impact (SEFI) adjusted estimate of collision probability that Object1 and Object2 will collide. */
  117.     SEFI_COLLISION_PROBABILITY((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  118.                                                                                container::setSefiCollisionProbability)),

  119.     /** The method that was used to calculate the space environment fragmentation impact collision probability. */
  120.     SEFI_COLLISION_PROBABILITY_METHOD((token, context, container) -> {
  121.         if (token.getType() == TokenType.ENTRY) {
  122.             container.setSefiCollisionProbabilityMethod(PocMethodFacade.parse(token.getRawContent()));
  123.         }
  124.         return true;
  125.     }),

  126.     /** The Space environment fragmentation model used. */
  127.     SEFI_FRAGMENTATION_MODEL((token, context, container) -> token.processAsNormalizedString(container::setSefiFragmentationModel)),

  128.     /** ID of previous CDM issued for event identified by CONJUNCTION_ID. */
  129.     PREVIOUS_MESSAGE_ID((token, context, container) -> token.processAsFreeTextString(container::setPreviousMessageId)),

  130.     /** UTC epoch of the previous CDM issued for the event identified by CONJUNCTION_ID. */
  131.     PREVIOUS_MESSAGE_EPOCH((token, context, container) -> token.processAsDate(container::setPreviousMessageEpoch, context)),

  132.     /** Scheduled UTC epoch of the next CDM associated with the event identified by CONJUNCTION_ID. */
  133.     NEXT_MESSAGE_EPOCH((token, context, container) -> token.processAsDate(container::setNextMessageEpoch, context));


  134.     /** Processing method. */
  135.     private final TokenProcessor processor;

  136.     /** Simple constructor.
  137.      * @param processor processing method
  138.      */
  139.     CdmRelativeMetadataKey(final TokenProcessor processor) {
  140.         this.processor = processor;
  141.     }

  142.     /** Process one token.
  143.      * @param token token to process
  144.      * @param context context binding
  145.      * @param container container to fill
  146.      * @return true of token was accepted
  147.      */
  148.     public boolean process(final ParseToken token, final ContextBinding context, final CdmRelativeMetadata container) {
  149.         return processor.process(token, context, container);
  150.     }

  151.     /** Interface for processing one token. */
  152.     interface TokenProcessor {
  153.         /** Process one token.
  154.          * @param token token to process
  155.          * @param context context binding
  156.          * @param container container to fill
  157.          * @return true of token was accepted
  158.          */
  159.         boolean process(ParseToken token, ContextBinding context, CdmRelativeMetadata container);
  160.     }


  161. }