Commit c09ad8d7 authored by Luc Maisonobe's avatar Luc Maisonobe

Improved test coverage.

parent 0471bc74
......@@ -684,7 +684,7 @@ public class RinexLoader {
timeScale = TimeScalesFactory.getBDT();
break;
case IRNSS:
timeScale = TimeScalesFactory.getIRNSST();
timeScale = TimeScalesFactory.getIRNSS();
break;
case MIXED:
//in Case of Mixed data, Timescale must be specified in the Time of First line
......@@ -701,7 +701,7 @@ public class RinexLoader {
} else if (timeScaleStr.equals(BDT)) {
timeScale = TimeScalesFactory.getBDT();
} else if (timeScaleStr.equals(IRN)) {
timeScale = TimeScalesFactory.getIRNSST();
timeScale = TimeScalesFactory.getIRNSS();
} else {
throw new OrekitException(OrekitMessages.UNSUPPORTED_FILE_FORMAT, name);
}
......
......@@ -19,6 +19,13 @@ package org.orekit.time;
import org.hipparchus.RealFieldElement;
/** IRNSS time scale (also called IRNWT for IRNSS NetWork Time).
* <p>By convention, TIRNSS = TAI - 19 s.</p>
* <p>This is intended to be accessed thanks to the {@link TimeScalesFactory} class,
* so there is no public constructor.</p>
* @author Luc Maisonobe
* @see AbsoluteDate
*/
public class IRNSSScale implements TimeScale {
/** Serializable UID. */
......
......@@ -391,7 +391,7 @@ public class TimeScalesFactory implements Serializable {
/** Get the Indian Regional Navigation Satellite System time scale.
* @return Indian Regional Navigation Satellite System time scale
*/
public static IRNSSScale getIRNSST() {
public static IRNSSScale getIRNSS() {
synchronized (TimeScalesFactory.class) {
if (irnss == null) {
......
/* 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 IRNSSScaleTest {
@Test
public void testArbitrary() throws OrekitException {
AbsoluteDate tIRNSS =
new AbsoluteDate(new DateComponents(1999, 3, 4), TimeComponents.H00, TimeScalesFactory.getIRNSS());
AbsoluteDate tUTC =
new AbsoluteDate(new DateComponents(1999, 3, 3), new TimeComponents(23, 59, 47),
TimeScalesFactory.getUTC());
Assert.assertEquals(tUTC, tIRNSS);
}
@Test
public void testConstant() {
TimeScale scale = TimeScalesFactory.getIRNSS();
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 testSymmetry() {
TimeScale scale = TimeScalesFactory.getIRNSS();
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);
}
}
@Test
public void testDuringLeap() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final TimeScale scale = TimeScalesFactory.getIRNSS();
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);
}
@Before
public void setUp() {
Utils.setDataRoot("regular-data");
}
}
/* 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.utils;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.util.Decimal64;
import org.hipparchus.util.Decimal64Field;
import org.junit.Assert;
import org.junit.Test;
import org.orekit.errors.OrekitException;
import org.orekit.frames.Frame;
import org.orekit.frames.FramesFactory;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
public class ExtendedPVCoordinatesTest {
@Test
public void testConversion() throws OrekitException {
final ExtendedPVCoordinatesProvider provider = new ExtendedPVCoordinatesProvider() {
@Override
public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
return null;
}
@Override
public <T extends RealFieldElement<T>> TimeStampedFieldPVCoordinates<T>
getPVCoordinates(final FieldAbsoluteDate<T> date, final Frame frame)
throws OrekitException {
return new TimeStampedFieldPVCoordinates<>(date,
FieldVector3D.getPlusI(date.getField()),
FieldVector3D.getPlusJ(date.getField()),
FieldVector3D.getPlusK(date.getField()));
}
};
Field<Decimal64> field = Decimal64Field.getInstance();
final FieldPVCoordinatesProvider<Decimal64> converted =
provider.toFieldPVCoordinatesProvider(field);
FieldPVCoordinates<Decimal64> pv = converted.getPVCoordinates(FieldAbsoluteDate.getJ2000Epoch(field),
FramesFactory.getGCRF());
Assert.assertEquals(0.0, FieldVector3D.distance(pv.getPosition(),FieldVector3D.getPlusI(field)).getReal(), 1.0e-15);
Assert.assertEquals(0.0, FieldVector3D.distance(pv.getVelocity(),FieldVector3D.getPlusJ(field)).getReal(), 1.0e-15);
Assert.assertEquals(0.0, FieldVector3D.distance(pv.getAcceleration(),FieldVector3D.getPlusK(field)).getReal(), 1.0e-15);
}
}
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