UserRangeAccuracy.java

  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. import org.hipparchus.util.FastMath;

  19. /** User Range Accuracy.
  20.  * @see "IS-GPS-200K, 4 March 2016, Section 20.3.3.3.1.3"
  21.  * @author Luc Maisonobe
  22.  * @author Bryan Cazabonne
  23.  * @since 11.0
  24.  */
  25. public class UserRangeAccuracy implements AccuracyProvider {

  26.     /** User Range Accuracy indicator. */
  27.     private final int uraIndex;

  28.     /**
  29.      * Simple constructor.
  30.      * @param index integer value of the user range accuracy
  31.      */
  32.     public UserRangeAccuracy(final int index) {
  33.         this.uraIndex = index;
  34.     }

  35.     /** {@inheritDoc} */
  36.     @Override
  37.     public double getAccuracy() {
  38.         // Cast index to a double value
  39.         final double id = (double) uraIndex;
  40.         // Compute accuracy
  41.         if (uraIndex < 7) {
  42.             if (uraIndex == 1) {
  43.                 return 2.8;
  44.             } else if (uraIndex == 3) {
  45.                 return 5.7;
  46.             } else if (uraIndex == 5) {
  47.                 return 11.3;
  48.             } else {
  49.                 return FastMath.pow(2.0, 0.5 * id + 1.0);
  50.             }
  51.         } else if (uraIndex < 15) {
  52.             return FastMath.pow(2.0, id - 2.0);
  53.         } else {
  54.             // Data shall not be used
  55.             return 8192.0;
  56.         }
  57.     }

  58. }