1   /* Copyright 2002-2020 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  
18  package org.orekit.estimation.common;
19  
20  import java.util.Map;
21  
22  import org.hipparchus.util.FastMath;
23  import org.orekit.estimation.measurements.AngularAzEl;
24  import org.orekit.estimation.measurements.ObservableSatellite;
25  import org.orekit.estimation.measurements.Range;
26  import org.orekit.estimation.measurements.modifiers.Bias;
27  
28  /** Parser for azimuth-elevation measurements.
29   * @author Luc Maisonobe
30   */
31  class AzElParser extends MeasurementsParser<AngularAzEl> {
32      /** {@inheritDoc} */
33      @Override
34      public AngularAzEl parseFields(final String[] fields,
35                                 final Map<String, StationData> stations,
36                                 final PVData pvData,
37                                 final ObservableSatellite satellite,
38                                 final Bias<Range> satRangeBias,
39                                 final Weights weights,
40                                 final String line,
41                                 final int lineNumber,
42                                 final String fileName) {
43          checkFields(5, fields, line, lineNumber, fileName);
44          final StationData stationData = getStationData(fields[2], stations, line, lineNumber, fileName);
45          final AngularAzEl azEl = new AngularAzEl(stationData.getStation(),
46                                                   getDate(fields[0], line, lineNumber, fileName),
47                                                   new double[] {
48                                                         FastMath.toRadians(Double.parseDouble(fields[3])),
49                                                         FastMath.toRadians(Double.parseDouble(fields[4]))
50                                                   },
51                                                   stationData.getAzElSigma(),
52                                                   weights.getAzElBaseWeight(),
53                                                   satellite);
54          if (stationData.getRefractionCorrection() != null) {
55              azEl.addModifier(stationData.getRefractionCorrection());
56          }
57          if (stationData.getAzELBias() != null) {
58              azEl.addModifier(stationData.getAzELBias());
59          }
60          return azEl;
61      }
62  }