Antenna.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.gnss.antenna;

  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.stream.Collectors;

  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.orekit.errors.OrekitException;
  23. import org.orekit.errors.OrekitMessages;
  24. import org.orekit.gnss.Frequency;

  25. /**
  26.  * GNSS antenna model.
  27.  *
  28.  * @author Luc Maisonobe
  29.  * @since 9.2
  30.  * @see <a href="ftp://www.igs.org/pub/station/general/antex14.txt">ANTEX: The Antenna Exchange Format, Version 1.4</a>
  31.  *
  32.  */
  33. public class Antenna {

  34.     /** Type of the antenna. */
  35.     private final String type;

  36.     /** Sinex code. */
  37.     private final String sinexCode;

  38.     /** Frequencies patterns. */
  39.     private final Map<Frequency, FrequencyPattern> patterns;

  40.     /** Simple constructor.
  41.      * @param type antenna type
  42.      * @param sinexCode sinex code
  43.      * @param patterns frequencies patterns
  44.      */
  45.     protected Antenna(final String type, final String sinexCode,
  46.                       final Map<Frequency, FrequencyPattern> patterns) {
  47.         this.type      = type;
  48.         this.sinexCode = sinexCode;
  49.         this.patterns  = patterns;
  50.     }

  51.     /** Get the type of the antenna.
  52.      * @return type of the antenna
  53.      */
  54.     public String getType() {
  55.         return type;
  56.     }

  57.     /** Get the sinex code of the antenna.
  58.      * @return sinex code of the antenna
  59.      */
  60.     public String getSinexCode() {
  61.         return sinexCode;
  62.     }

  63.     /** Get supported frequencies.
  64.      * @return supported frequencies
  65.      * @since 10.0
  66.      */
  67.     public List<Frequency> getFrequencies() {
  68.         return patterns.
  69.                entrySet().
  70.                stream().
  71.                map(e -> e.getKey()).
  72.                collect(Collectors.toList());
  73.     }

  74.     /** Get the phase center eccentricities.
  75.      * @param frequency frequency of the signal to consider
  76.      * @return phase center eccentricities (m)
  77.      */
  78.     public Vector3D getEccentricities(final Frequency frequency) {
  79.         return getPattern(frequency).getEccentricities();
  80.     }

  81.     /** Get the value of the phase center variation in a signal direction.
  82.      * @param frequency frequency of the signal to consider
  83.      * @param direction signal direction in antenna reference frame
  84.      * @return value of the phase center variation (m)
  85.      */
  86.     public double getPhaseCenterVariation(final Frequency frequency, final Vector3D direction) {
  87.         return getPattern(frequency).getPhaseCenterVariation(direction);
  88.     }

  89.     /** Get a frequency pattern.
  90.      * @param frequency frequency of the signal to consider
  91.      * @return pattern for this frequency
  92.      */
  93.     private FrequencyPattern getPattern(final Frequency frequency) {
  94.         final FrequencyPattern pattern = patterns.get(frequency);
  95.         if (pattern == null) {
  96.             throw new OrekitException(OrekitMessages.UNSUPPORTED_FREQUENCY_FOR_ANTENNA,
  97.                                       frequency, type);
  98.         }
  99.         return pattern;
  100.     }

  101. }