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.metric.messages.common;
18  
19  import org.hipparchus.util.FastMath;
20  
21  /** User Range Accuracy.
22   * @see "IS-GPS-200K, 4 March 2016, Section 20.3.3.3.1.3"
23   * @author Luc Maisonobe
24   * @author Bryan Cazabonne
25   * @since 11.0
26   */
27  public class UserRangeAccuracy implements AccuracyProvider {
28  
29      /** User Range Accuracy indicator. */
30      private final int uraIndex;
31  
32      /**
33       * Simple constructor.
34       * @param index integer value of the user range accuracy
35       */
36      public UserRangeAccuracy(final int index) {
37          this.uraIndex = index;
38      }
39  
40      /** {@inheritDoc} */
41      @Override
42      public double getAccuracy() {
43          // Cast index to a double value
44          final double id = (double) uraIndex;
45          // Compute accuracy
46          if (uraIndex < 7) {
47              if (uraIndex == 1) {
48                  return 2.8;
49              } else if (uraIndex == 3) {
50                  return 5.7;
51              } else if (uraIndex == 5) {
52                  return 11.3;
53              } else {
54                  return FastMath.pow(2.0, 0.5 * id + 1.0);
55              }
56          } else if (uraIndex < 15) {
57              return FastMath.pow(2.0, id - 2.0);
58          } else {
59              // Data shall not be used
60              return 8192.0;
61          }
62      }
63  
64  }