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.time;
18
19 import org.hipparchus.CalculusFieldElement;
20
21 /** GLONASS time scale.
22 * <p>By convention, TGLONASS = UTC + 3 hours.</p>
23 * <p>The time scale is defined in <a
24 * href="http://www.spacecorp.ru/upload/iblock/1c4/cgs-aaixymyt%205.1%20ENG%20v%202014.02.18w.pdf">
25 * Global Navigation Sattelite System GLONASS - Interface Control document</a>, version 5.1 2008
26 * (the typo in the title is in the original document title).
27 * </p>
28 * <p>This is intended to be accessed thanks to {@link TimeScales},
29 * so there is no public constructor.</p>
30 * @author Luc Maisonobe
31 * @see AbsoluteDate
32 */
33 public class GLONASSScale implements TimeScale {
34
35 /** Serializable UID. */
36 private static final long serialVersionUID = 20160331L;
37
38 /** Constant offset with respect to UTC (3 hours). */
39 private static final double OFFSET = 10800;
40
41 /** UTC time scale. */
42 private final UTCScale utc;
43
44 /** Package private constructor for the factory.
45 * @param utc underlying UTC scale
46 */
47 GLONASSScale(final UTCScale utc) {
48 this.utc = utc;
49 }
50
51 /** {@inheritDoc} */
52 @Override
53 public double offsetFromTAI(final AbsoluteDate date) {
54 return OFFSET + utc.offsetFromTAI(date);
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public <T extends CalculusFieldElement<T>> T offsetFromTAI(final FieldAbsoluteDate<T> date) {
60 return utc.offsetFromTAI(date).add(OFFSET);
61 }
62
63 /** {@inheritDoc} */
64 @Override
65 public double offsetToTAI(final DateComponents date, final TimeComponents time) {
66 final DateTimeComponents utcComponents =
67 new DateTimeComponents(new DateTimeComponents(date, time), -OFFSET);
68 return utc.offsetToTAI(utcComponents.getDate(), utcComponents.getTime()) - OFFSET;
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public boolean insideLeap(final AbsoluteDate date) {
74 return utc.insideLeap(date);
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public <T extends CalculusFieldElement<T>> boolean insideLeap(final FieldAbsoluteDate<T> date) {
80 return utc.insideLeap(date);
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public int minuteDuration(final AbsoluteDate date) {
86 return utc.minuteDuration(date);
87 }
88
89 /** {@inheritDoc} */
90 @Override
91 public <T extends CalculusFieldElement<T>> int minuteDuration(final FieldAbsoluteDate<T> date) {
92 return utc.minuteDuration(date);
93 }
94
95 /** {@inheritDoc} */
96 @Override
97 public double getLeap(final AbsoluteDate date) {
98 return utc.getLeap(date);
99 }
100
101 /** {@inheritDoc} */
102 @Override
103 public <T extends CalculusFieldElement<T>> T getLeap(final FieldAbsoluteDate<T> date) {
104 return utc.getLeap(date);
105 }
106
107 /** {@inheritDoc} */
108 public String getName() {
109 return "GLONASS";
110 }
111
112 /** {@inheritDoc} */
113 public String toString() {
114 return getName();
115 }
116
117 }