Example #1
0
  /**
   * Update state by adding all additional states.
   *
   * @param original original state
   * @return updated state, with all additional states included
   * @exception PropagationException if one of the providers throws one
   * @see #addAdditionalStateProvider(AdditionalStateProvider)
   */
  protected SpacecraftState updateAdditionalStates(final SpacecraftState original)
      throws PropagationException {

    // start with original state,
    // which may already contain additional states, for example in interpolated ephemerides
    SpacecraftState updated = original;

    if (initialState != null) {
      // there is an initial state
      // (null initial states occur for example in interpolated ephemerides)
      // copy the additional states present in initialState but otherwise not managed
      for (final Map.Entry<String, double[]> initial :
          initialState.getAdditionalStates().entrySet()) {
        if (!isAdditionalStateManaged(initial.getKey())) {
          // this additional state was in the initial state, but is unknown to the propagator
          // we simply copy its initial value as is
          updated = updated.addAdditionalState(initial.getKey(), initial.getValue());
        }
      }
    }

    // update the additional states managed by providers
    for (final AdditionalStateProvider provider : additionalStateProviders) {
      updated =
          updated.addAdditionalState(provider.getName(), provider.getAdditionalState(updated));
    }

    return updated;
  }
Example #2
0
 /** {@inheritDoc} */
 public boolean isAdditionalStateManaged(final String name) {
   for (final AdditionalStateProvider provider : additionalStateProviders) {
     if (provider.getName().equals(name)) {
       return true;
     }
   }
   return false;
 }
Example #3
0
  /** {@inheritDoc} */
  public void addAdditionalStateProvider(final AdditionalStateProvider additionalStateProvider)
      throws OrekitException {

    // check if the name is already used
    if (isAdditionalStateManaged(additionalStateProvider.getName())) {
      // this additional state is already registered, complain
      throw new OrekitException(
          OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE, additionalStateProvider.getName());
    }

    // this is really a new name, add it
    additionalStateProviders.add(additionalStateProvider);
  }