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.gnss.antenna;
18  
19  import java.util.List;
20  import java.util.Map;
21  import java.util.stream.Collectors;
22  
23  import org.hipparchus.geometry.euclidean.threed.Vector3D;
24  import org.orekit.errors.OrekitException;
25  import org.orekit.errors.OrekitMessages;
26  import org.orekit.gnss.RadioWave;
27  
28  /**
29   * GNSS antenna model.
30   *
31   * @author Luc Maisonobe
32   * @since 9.2
33   * @see <a href="ftp://www.igs.org/pub/station/general/antex14.txt">ANTEX: The Antenna Exchange Format, Version 1.4</a>
34   *
35   */
36  public class Antenna {
37  
38      /** Type of the antenna. */
39      private final String type;
40  
41      /** Sinex code. */
42      private final String sinexCode;
43  
44      /** Radio waves patterns. */
45      private final Map<RadioWave, FrequencyPattern> patterns;
46  
47      /** Simple constructor.
48       * @param type antenna type
49       * @param sinexCode sinex code
50       * @param patterns frequencies patterns
51       */
52      protected Antenna(final String type, final String sinexCode,
53                        final Map<RadioWave, FrequencyPattern> patterns) {
54          this.type      = type;
55          this.sinexCode = sinexCode;
56          this.patterns  = patterns;
57      }
58  
59      /** Get the type of the antenna.
60       * @return type of the antenna
61       */
62      public String getType() {
63          return type;
64      }
65  
66      /** Get the sinex code of the antenna.
67       * @return sinex code of the antenna
68       */
69      public String getSinexCode() {
70          return sinexCode;
71      }
72  
73      /** Get supported radio waves.
74       * @return supported radio waves
75       * @since 13.0
76       */
77      public List<RadioWave> getRadioWaves() {
78          return patterns.
79                 entrySet().
80                 stream().
81                 map(Map.Entry::getKey).
82                 collect(Collectors.toList());
83      }
84  
85      /**
86       * Get the phase center eccentricities.
87       *
88       * @param radioWave radio wave of the signal to consider
89       * @return phase center eccentricities (m)
90       */
91      public Vector3D getEccentricities(final RadioWave radioWave) {
92          return getPattern(radioWave).getEccentricities();
93      }
94  
95      /**
96       * Get the value of the phase center variation in a signal direction.
97       *
98       * @param radioWave radio wave of the signal to consider
99       * @param direction signal direction in antenna reference frame
100      * @return value of the phase center variation (m)
101      */
102     public double getPhaseCenterVariation(final RadioWave radioWave, final Vector3D direction) {
103         return getPattern(radioWave).getPhaseCenterVariation(direction);
104     }
105 
106     /**
107      * Get a frequency pattern.
108      *
109      * @param radioWave radio wave of the signal to consider
110      * @return pattern for this frequency
111      */
112     public FrequencyPattern getPattern(final RadioWave radioWave) {
113         final FrequencyPattern pattern = patterns.get(radioWave);
114         if (pattern == null) {
115             throw new OrekitException(OrekitMessages.UNSUPPORTED_FREQUENCY_FOR_ANTENNA, radioWave, type);
116         }
117         return pattern;
118     }
119 
120 }