Search in sources :

Example 1 with InterpolationMethod

use of org.orekit.files.ccsds.OEMWriter.InterpolationMethod in project Orekit by CS-SI.

the class OEMWriterTest method testNullFile.

@Test
public void testNullFile() throws OrekitException, IOException {
    final String ex = "/ccsds/OEMExample.txt";
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
    final OEMFile oemFile = parser.parse(inEntry, "OEMExample.txt");
    final EphemerisFile ephemerisFile = (EphemerisFile) oemFile;
    String originator = oemFile.getOriginator();
    String objectName = oemFile.getEphemeridesBlocks().get(0).getMetaData().getObjectName();
    String objectID = oemFile.getEphemeridesBlocks().get(0).getMetaData().getObjectID();
    String interpolationMethodString = oemFile.getEphemeridesBlocks().get(0).getInterpolationMethod();
    InterpolationMethod interpolationMethod = Enum.valueOf(InterpolationMethod.class, interpolationMethodString);
    OEMWriter writer = new OEMWriter(interpolationMethod, originator, objectID, objectName);
    try {
        writer.write((BufferedWriter) null, ephemerisFile);
        fail("an exception should have been thrown");
    } catch (OrekitIllegalArgumentException oiae) {
        assertEquals(OrekitMessages.NULL_ARGUMENT, oiae.getSpecifier());
        assertEquals("writer", oiae.getParts()[0]);
    }
}
Also used : InterpolationMethod(org.orekit.files.ccsds.OEMWriter.InterpolationMethod) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) EphemerisFile(org.orekit.files.general.EphemerisFile) OrekitIllegalArgumentException(org.orekit.errors.OrekitIllegalArgumentException) Test(org.junit.Test)

Example 2 with InterpolationMethod

use of org.orekit.files.ccsds.OEMWriter.InterpolationMethod in project Orekit by CS-SI.

the class OEMWriterTest method testUnfoundSpaceId.

@Test
public void testUnfoundSpaceId() throws OrekitException, IOException {
    final String ex = "/ccsds/OEMExample.txt";
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
    final OEMFile oemFile = parser.parse(inEntry, "OEMExample.txt");
    final EphemerisFile ephemerisFile = (EphemerisFile) oemFile;
    String badObjectId = "12345";
    String interpolationMethodString = oemFile.getEphemeridesBlocks().get(0).getInterpolationMethod();
    InterpolationMethod interpolationMethod = Enum.valueOf(InterpolationMethod.class, interpolationMethodString);
    String tempOEMFilePath = tempFolder.newFile("TestOEMUnfoundSpaceId.oem").toString();
    OEMWriter writer = new OEMWriter(interpolationMethod, null, badObjectId, null);
    try {
        writer.write(tempOEMFilePath, ephemerisFile);
        fail("an exception should have been thrown");
    } catch (OrekitIllegalArgumentException oiae) {
        assertEquals(OrekitMessages.VALUE_NOT_FOUND, oiae.getSpecifier());
        assertEquals(badObjectId, oiae.getParts()[0]);
    }
}
Also used : InterpolationMethod(org.orekit.files.ccsds.OEMWriter.InterpolationMethod) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) EphemerisFile(org.orekit.files.general.EphemerisFile) OrekitIllegalArgumentException(org.orekit.errors.OrekitIllegalArgumentException) Test(org.junit.Test)

Example 3 with InterpolationMethod

use of org.orekit.files.ccsds.OEMWriter.InterpolationMethod in project Orekit by CS-SI.

the class OEMWriterTest method testWriteOEM1.

@Test
public void testWriteOEM1() throws OrekitException, IOException {
    final String ex = "/ccsds/OEMExample.txt";
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
    final OEMFile oemFile = parser.parse(inEntry, "OEMExample.txt");
    final EphemerisFile ephemerisFile = (EphemerisFile) oemFile;
    String originator = oemFile.getOriginator();
    String objectName = oemFile.getEphemeridesBlocks().get(0).getMetaData().getObjectName();
    String objectID = oemFile.getEphemeridesBlocks().get(0).getMetaData().getObjectID();
    String interpolationMethodString = oemFile.getEphemeridesBlocks().get(0).getInterpolationMethod();
    InterpolationMethod interpolationMethod = Enum.valueOf(InterpolationMethod.class, interpolationMethodString);
    String tempOEMFilePath = tempFolder.newFile("TestWriteOEM1.oem").toString();
    OEMWriter writer = new OEMWriter(interpolationMethod, originator, objectID, objectName);
    writer.write(tempOEMFilePath, ephemerisFile);
    final OEMFile generatedOemFile = parser.parse(tempOEMFilePath);
    compareOemFiles(oemFile, generatedOemFile);
}
Also used : InterpolationMethod(org.orekit.files.ccsds.OEMWriter.InterpolationMethod) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) EphemerisFile(org.orekit.files.general.EphemerisFile) Test(org.junit.Test)

Aggregations

FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 Test (org.junit.Test)3 InterpolationMethod (org.orekit.files.ccsds.OEMWriter.InterpolationMethod)3 EphemerisFile (org.orekit.files.general.EphemerisFile)3 OrekitIllegalArgumentException (org.orekit.errors.OrekitIllegalArgumentException)2