Commit 35a20bb2 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'develop' into issue-474

parents fbb873bb b44a5383
......@@ -443,12 +443,12 @@ public class AemWriter extends AbstractMessageWriter<Header, AemSegment, AemFile
case EULER_ANGLE_RATE :
writeEulerAngleRate(xmlGenerator, metadata.getEulerRotSeq(), attitude.getDate(), data);
break;
case SPIN :
writeSpin(xmlGenerator, attitude.getDate(), data);
break;
case SPIN_NUTATION :
writeSpinNutation(xmlGenerator, attitude.getDate(), data);
break;
// case SPIN :
// writeSpin(xmlGenerator, attitude.getDate(), data);
// break;
// case SPIN_NUTATION :
// writeSpinNutation(xmlGenerator, attitude.getDate(), data);
// break;
default :
// this should never happen
throw new OrekitInternalError(null);
......@@ -645,56 +645,56 @@ public class AemWriter extends AbstractMessageWriter<Header, AemSegment, AemFile
}
/** Write a spin entry in XML.
* @param xmlGenerator generator to use for producing output
* @param epoch of the entry
* @param data entry data
* @throws IOException if the output stream throws one while writing.
*/
void writeSpin(final XmlGenerator xmlGenerator, final AbsoluteDate epoch, final String[] data)
throws IOException {
// wrapping element
xmlGenerator.enterSection(AttitudeEntryKey.spin.name());
// data part
xmlGenerator.writeEntry(AttitudeEntryKey.EPOCH.name(), getTimeConverter(), epoch, true);
int i = 0;
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ALPHA.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_DELTA.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE_VEL.name(), data[i++], Units.DEG_PER_S, true);
xmlGenerator.exitSection();
}
/** Write a spin/nutation entry in XML.
* @param xmlGenerator generator to use for producing output
* @param epoch of the entry
* @param data entry data
* @throws IOException if the output stream throws one while writing.
*/
void writeSpinNutation(final XmlGenerator xmlGenerator, final AbsoluteDate epoch, final String[] data)
throws IOException {
// wrapping element
xmlGenerator.enterSection(AttitudeEntryKey.spin.name());
// data part
xmlGenerator.writeEntry(AttitudeEntryKey.EPOCH.name(), getTimeConverter(), epoch, true);
int i = 0;
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ALPHA.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_DELTA.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE_VEL.name(), data[i++], Units.DEG_PER_S, true);
xmlGenerator.writeEntry(AttitudeEntryKey.NUTATION.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.writeEntry(AttitudeEntryKey.NUTATION_PER.name(), data[i++], Unit.SECOND, true);
xmlGenerator.writeEntry(AttitudeEntryKey.NUTATION_PHASE.name(), data[i++], Unit.DEGREE, true);
xmlGenerator.exitSection();
}
// /** Write a spin entry in XML.
// * @param xmlGenerator generator to use for producing output
// * @param epoch of the entry
// * @param data entry data
// * @throws IOException if the output stream throws one while writing.
// */
// void writeSpin(final XmlGenerator xmlGenerator, final AbsoluteDate epoch, final String[] data)
// throws IOException {
//
// // wrapping element
// xmlGenerator.enterSection(AttitudeEntryKey.spin.name());
//
// // data part
// xmlGenerator.writeEntry(AttitudeEntryKey.EPOCH.name(), getTimeConverter(), epoch, true);
// int i = 0;
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ALPHA.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_DELTA.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE_VEL.name(), data[i++], Units.DEG_PER_S, true);
//
// xmlGenerator.exitSection();
//
// }
// /** Write a spin/nutation entry in XML.
// * @param xmlGenerator generator to use for producing output
// * @param epoch of the entry
// * @param data entry data
// * @throws IOException if the output stream throws one while writing.
// */
// void writeSpinNutation(final XmlGenerator xmlGenerator, final AbsoluteDate epoch, final String[] data)
// throws IOException {
//
// // wrapping element
// xmlGenerator.enterSection(AttitudeEntryKey.spin.name());
//
// // data part
// xmlGenerator.writeEntry(AttitudeEntryKey.EPOCH.name(), getTimeConverter(), epoch, true);
// int i = 0;
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ALPHA.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_DELTA.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.SPIN_ANGLE_VEL.name(), data[i++], Units.DEG_PER_S, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.NUTATION.name(), data[i++], Unit.DEGREE, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.NUTATION_PER.name(), data[i++], Unit.SECOND, true);
// xmlGenerator.writeEntry(AttitudeEntryKey.NUTATION_PHASE.name(), data[i++], Unit.DEGREE, true);
//
// xmlGenerator.exitSection();
//
// }
/** Write an angle from an Euler sequence.
* @param xmlGenerator generator to use
......
......@@ -37,7 +37,7 @@ import org.orekit.utils.units.UnitsCache;
* @author Luc Maisonobe
* @since 11.0
*/
class KvnLexicalAnalyzer implements LexicalAnalyzer {
public class KvnLexicalAnalyzer implements LexicalAnalyzer {
/** Regular expression matching blanks at start of line. */
private static final String LINE_START = "^\\p{Blank}*";
......@@ -105,7 +105,7 @@ class KvnLexicalAnalyzer implements LexicalAnalyzer {
/** Simple constructor.
* @param source source providing the data to parse
*/
KvnLexicalAnalyzer(final DataSource source) {
public KvnLexicalAnalyzer(final DataSource source) {
this.source = source;
this.cache = new UnitsCache();
}
......
......@@ -41,7 +41,7 @@ import org.xml.sax.helpers.DefaultHandler;
* @author Luc Maisonobe
* @since 11.0
*/
class XmlLexicalAnalyzer implements LexicalAnalyzer {
public class XmlLexicalAnalyzer implements LexicalAnalyzer {
/** Source providing the data to analyze. */
private final DataSource source;
......@@ -49,7 +49,7 @@ class XmlLexicalAnalyzer implements LexicalAnalyzer {
/** Simple constructor.
* @param source source providing the data to parse
*/
XmlLexicalAnalyzer(final DataSource source) {
public XmlLexicalAnalyzer(final DataSource source) {
this.source = source;
}
......@@ -77,15 +77,7 @@ class XmlLexicalAnalyzer implements LexicalAnalyzer {
// Get the content of the file
return messageParser.build();
} catch (SAXException se) {
final OrekitException oe;
if (se.getException() instanceof OrekitException) {
oe = (OrekitException) se.getException();
} else {
oe = new OrekitException(se, new DummyLocalizable(se.getMessage()));
}
throw oe;
} catch (ParserConfigurationException | IOException e) {
} catch (SAXException | ParserConfigurationException | IOException e) {
// throw caught exception as an OrekitException
throw new OrekitException(e, new DummyLocalizable(e.getMessage()));
}
......
......@@ -50,6 +50,8 @@ import org.orekit.files.ccsds.ndm.odm.UserDefined;
import org.orekit.files.ccsds.ndm.odm.oem.InterpolationMethod;
import org.orekit.files.ccsds.utils.generation.Generator;
import org.orekit.files.ccsds.utils.generation.KvnGenerator;
import org.orekit.files.ccsds.utils.lexical.KvnLexicalAnalyzer;
import org.orekit.files.ccsds.utils.lexical.XmlLexicalAnalyzer;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeScale;
import org.orekit.time.TimeScalesFactory;
......@@ -66,15 +68,26 @@ public class OcmParserTest {
}
@Test
public void testNonExistentFile() throws URISyntaxException {
public void testNonExistentKvnFile() throws URISyntaxException {
final String realName = "/ccsds/odm/ocm/OCMExample1.txt";
final String wrongName = realName + "xxxxx";
final DataSource source = new DataSource(wrongName, () -> getClass().getResourceAsStream(wrongName));
try {
new ParserBuilder().
withMu(Constants.EIGEN5C_EARTH_MU).
buildOcmParser().
parseMessage(source);
new KvnLexicalAnalyzer(source).accept(new ParserBuilder().buildOcmParser());
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.UNABLE_TO_FIND_FILE, oe.getSpecifier());
Assert.assertEquals(wrongName, oe.getParts()[0]);
}
}
@Test
public void testNonExistentXmlFile() throws URISyntaxException {
final String realName = "/ccsds/odm/ocm/OCMExample1.txt";
final String wrongName = realName + "xxxxx";
final DataSource source = new DataSource(wrongName, () -> getClass().getResourceAsStream(wrongName));
try {
new XmlLexicalAnalyzer(source).accept(new ParserBuilder().buildOcmParser());
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.UNABLE_TO_FIND_FILE, oe.getSpecifier());
......
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (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.propagation.analytical.tle;
import org.hipparchus.util.Precision;
import org.junit.Assert;
import org.junit.Test;
public class TLEConstantsTest {
@Test
public void testCoverage() {
// this test is specially awkward
// it doesn't really test anything…
// its *sole* purpose is to work around a false positive coverage in SonarQube
Assert.assertTrue(Precision.equals(1.0 / 3.0, TLEConstants.ONE_THIRD, 1));
Assert.assertTrue(Precision.equals(2.0 / 3.0, TLEConstants.TWO_THIRD, 1));
Assert.assertTrue(Precision.equals(6378.135, TLEConstants.EARTH_RADIUS, 1));
Assert.assertTrue(Precision.equals(1.0, TLEConstants.NORMALIZED_EQUATORIAL_RADIUS, 1));
Assert.assertTrue(Precision.equals(1440.0, TLEConstants.MINUTES_PER_DAY, 1));
Assert.assertTrue(Precision.equals(0.0743669161331734132, TLEConstants.XKE, 1));
Assert.assertTrue(Precision.equals(-2.53881e-6, TLEConstants.XJ3, 1));
Assert.assertTrue(Precision.equals(1.082616e-3, TLEConstants.XJ2, 1));
Assert.assertTrue(Precision.equals(-1.65597e-6, TLEConstants.XJ4, 1));
Assert.assertTrue(Precision.equals(0.5 * TLEConstants.XJ2, TLEConstants.CK2, 1));
Assert.assertTrue(Precision.equals(-0.375 * TLEConstants.XJ4, TLEConstants.CK4, 1));
Assert.assertTrue(Precision.equals(1. + 78. / TLEConstants.EARTH_RADIUS, TLEConstants.S, 1));
Assert.assertTrue(Precision.equals(1.880279159015270643865e-9, TLEConstants.QOMS2T, 1));
Assert.assertTrue(Precision.equals(-TLEConstants.XJ3 / TLEConstants.CK2, TLEConstants.A3OVK2, 1));
Assert.assertTrue(Precision.equals(1.19459E-5, TLEConstants.ZNS, 1));
Assert.assertTrue(Precision.equals(0.01675, TLEConstants.ZES, 1));
Assert.assertTrue(Precision.equals(1.5835218E-4, TLEConstants.ZNL, 1));
Assert.assertTrue(Precision.equals(0.05490, TLEConstants.ZEL, 1));
Assert.assertTrue(Precision.equals(4.3752691E-3, TLEConstants.THDT, 1));
Assert.assertTrue(Precision.equals(2.9864797E-6, TLEConstants.C1SS, 1));
Assert.assertTrue(Precision.equals(4.7968065E-7, TLEConstants.C1L, 1));
Assert.assertTrue(Precision.equals(1.7891679E-6, TLEConstants.ROOT22, 1));
Assert.assertTrue(Precision.equals(3.7393792E-7, TLEConstants.ROOT32, 1));
Assert.assertTrue(Precision.equals(7.3636953E-9, TLEConstants.ROOT44, 1));
Assert.assertTrue(Precision.equals(1.1428639E-7, TLEConstants.ROOT52, 1));
Assert.assertTrue(Precision.equals(2.1765803E-9, TLEConstants.ROOT54, 1));
Assert.assertTrue(Precision.equals(1.7891679E-6, TLEConstants.Q22, 1));
Assert.assertTrue(Precision.equals(2.1460748E-6, TLEConstants.Q31, 1));
Assert.assertTrue(Precision.equals(2.2123015E-7, TLEConstants.Q33, 1));
Assert.assertTrue(Precision.equals(0.99139134268488593, TLEConstants.C_FASX2, 1));
Assert.assertTrue(Precision.equals(0.13093206501640101, TLEConstants.S_FASX2, 1));
Assert.assertTrue(Precision.equals(0.87051638752972937, TLEConstants.C_2FASX4, 1));
Assert.assertTrue(Precision.equals(-0.49213943048915526, TLEConstants.S_2FASX4, 1));
Assert.assertTrue(Precision.equals(0.43258117585763334, TLEConstants.C_3FASX6, 1));
Assert.assertTrue(Precision.equals(0.90159499016666422, TLEConstants.S_3FASX6, 1));
Assert.assertTrue(Precision.equals(0.87051638752972937, TLEConstants.C_G22, 1));
Assert.assertTrue(Precision.equals(-0.49213943048915526, TLEConstants.S_G22, 1));
Assert.assertTrue(Precision.equals(0.57972190187001149, TLEConstants.C_G32, 1));
Assert.assertTrue(Precision.equals(0.81481440616389245, TLEConstants.S_G32, 1));
Assert.assertTrue(Precision.equals(-0.22866241528815548, TLEConstants.C_G44, 1));
Assert.assertTrue(Precision.equals(0.97350577801807991, TLEConstants.S_G44, 1));
Assert.assertTrue(Precision.equals(0.49684831179884198, TLEConstants.C_G52, 1));
Assert.assertTrue(Precision.equals(0.86783740128127729, TLEConstants.S_G52, 1));
Assert.assertTrue(Precision.equals(-0.29695209575316894, TLEConstants.C_G54, 1));
Assert.assertTrue(Precision.equals(-0.95489237761529999, TLEConstants.S_G54, 1));
}
}
\ No newline at end of file
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