1   /* Copyright 2002-2024 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.Frequency;
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      /** Frequencies patterns. */
45      private final Map<Frequency, 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<Frequency, 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 frequencies.
74       * @return supported frequencies
75       * @since 10.0
76       */
77      public List<Frequency> getFrequencies() {
78          return patterns.
79                 entrySet().
80                 stream().
81                 map(e -> e.getKey()).
82                 collect(Collectors.toList());
83      }
84  
85      /** Get the phase center eccentricities.
86       * @param frequency frequency of the signal to consider
87       * @return phase center eccentricities (m)
88       */
89      public Vector3D getEccentricities(final Frequency frequency) {
90          return getPattern(frequency).getEccentricities();
91      }
92  
93      /** Get the value of the phase center variation in a signal direction.
94       * @param frequency frequency of the signal to consider
95       * @param direction signal direction in antenna reference frame
96       * @return value of the phase center variation (m)
97       */
98      public double getPhaseCenterVariation(final Frequency frequency, final Vector3D direction) {
99          return getPattern(frequency).getPhaseCenterVariation(direction);
100     }
101 
102     /** Get a frequency pattern.
103      * @param frequency frequency of the signal to consider
104      * @return pattern for this frequency
105      */
106     public FrequencyPattern getPattern(final Frequency frequency) {
107         final FrequencyPattern pattern = patterns.get(frequency);
108         if (pattern == null) {
109             throw new OrekitException(OrekitMessages.UNSUPPORTED_FREQUENCY_FOR_ANTENNA,
110                                       frequency, type);
111         }
112         return pattern;
113     }
114 
115 }