Commit d4821a81 authored by Luc Maisonobe's avatar Luc Maisonobe

BDS -> BDT.

parent ee779351
......@@ -19,7 +19,13 @@ package org.orekit.time;
import org.hipparchus.RealFieldElement;
public class BDSScale implements TimeScale {
/** Beidou system time scale.
* <p>By convention, BDT = UTC on January 1st 2006.</p>
* <p>This is intended to be accessed thanks to the {@link TimeScalesFactory} class,
* so there is no public constructor.</p>
* @see AbsoluteDate
*/
public class BDTScale implements TimeScale {
/** Serializable UID. */
private static final long serialVersionUID = 20180323L;
......@@ -29,7 +35,7 @@ public class BDSScale implements TimeScale {
/** Package private constructor for the factory.
*/
BDSScale() {
BDTScale() {
}
/** {@inheritDoc} */
......@@ -52,7 +58,7 @@ public class BDSScale implements TimeScale {
/** {@inheritDoc} */
public String getName() {
return "BDS";
return "BDT";
}
/** {@inheritDoc} */
......
......@@ -86,7 +86,7 @@ public class TimeScalesFactory implements Serializable {
private static IRNSSScale irnss = null;
/** BDS System Time scale. */
private static BDSScale bds = null;
private static BDTScale bds = null;
/** Private constructor.
......@@ -406,11 +406,11 @@ public class TimeScalesFactory implements Serializable {
/** Get the BeiDou Navigation Satellite System time scale.
* @return BeiDou Navigation Satellite System time scale
*/
public static BDSScale getBDT() {
public static BDTScale getBDT() {
synchronized (TimeScalesFactory.class) {
if (bds == null) {
bds = new BDSScale();
bds = new BDTScale();
}
return bds;
......
/* Copyright 2002-2018 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.time;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.orekit.Utils;
import org.orekit.errors.OrekitException;
import org.orekit.utils.Constants;
public class BDSScaleTest {
@Test
public void testT0() throws OrekitException {
TimeScale scale = TimeScalesFactory.getBDT();
Assert.assertEquals("BDT", scale.toString());
AbsoluteDate t0 =
new AbsoluteDate(new DateComponents(2006, 1, 1), new TimeComponents(0, 0, 13), scale);
Assert.assertEquals(new AbsoluteDate(new DateComponents(2006, 1, 1), new TimeComponents(0, 0, 13),
TimeScalesFactory.getUTC()),
t0);
}
@Test
public void test2010() throws OrekitException {
AbsoluteDate tBDT =
new AbsoluteDate(new DateComponents(2010, 1, 2), TimeComponents.H00, TimeScalesFactory.getBDT());
AbsoluteDate tUTC =
new AbsoluteDate(new DateComponents(2010, 1, 1), new TimeComponents(23, 59, 59.0),
TimeScalesFactory.getUTC());
Assert.assertEquals(tUTC, tBDT);
}
@Test
public void testDuringLeap() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final TimeScale scale = TimeScalesFactory.getBDT();
final AbsoluteDate before = new AbsoluteDate(new DateComponents(1983, 06, 30),
new TimeComponents(23, 59, 59),
utc);
final AbsoluteDate during = before.shiftedBy(1.25);
Assert.assertEquals(61, utc.minuteDuration(during));
Assert.assertEquals(1.0, utc.getLeap(during), 1.0e-10);
Assert.assertEquals(60, scale.minuteDuration(during));
Assert.assertEquals(0.0, scale.getLeap(during), 1.0e-10);
}
@Test
public void testConstant() {
TimeScale scale = TimeScalesFactory.getBDT();
double reference = scale.offsetFromTAI(AbsoluteDate.J2000_EPOCH);
for (double dt = -10000; dt < 10000; dt += 123.456789) {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt * Constants.JULIAN_DAY);
Assert.assertEquals(reference, scale.offsetFromTAI(date), 1.0e-15);
}
}
@Test
public void testAwayFromGPS() {
TimeScale bdt = TimeScalesFactory.getBDT();
TimeScale gps = TimeScalesFactory.getGPS();
for (double dt = -10000; dt < 10000; dt += 123.456789) {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(7 * Constants.JULIAN_YEAR + dt * Constants.JULIAN_DAY);
Assert.assertEquals(gps.offsetFromTAI(date) - 14, bdt.offsetFromTAI(date), 1.0e-15);
}
}
@Test
public void testSymmetry() {
TimeScale scale = TimeScalesFactory.getBDT();
for (double dt = -10000; dt < 10000; dt += 123.456789) {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt * Constants.JULIAN_DAY);
double dt1 = scale.offsetFromTAI(date);
DateTimeComponents components = date.getComponents(scale);
double dt2 = scale.offsetToTAI(components.getDate(), components.getTime());
Assert.assertEquals( 0.0, dt1 + dt2, 1.0e-10);
}
}
@Before
public void setUp() {
Utils.setDataRoot("regular-data");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment