use of org.orekit.errors.OrekitException in project Orekit by CS-SI.
the class FieldIntegratedEphemeris method basicPropagate.
/**
* {@inheritDoc}
*/
@Override
protected FieldSpacecraftState<T> basicPropagate(final FieldAbsoluteDate<T> date) throws OrekitException {
try {
final FieldODEStateAndDerivative<T> os = getInterpolatedState(date);
FieldSpacecraftState<T> state = mapper.mapArrayToState(mapper.mapDoubleToDate(os.getTime(), date), os.getPrimaryState(), os.getPrimaryDerivative(), meanFieldOrbit);
for (Map.Entry<String, T[]> initial : unmanaged.entrySet()) {
state = state.addAdditionalState(initial.getKey(), initial.getValue());
}
return state;
} catch (OrekitExceptionWrapper oew) {
throw new OrekitException(oew.getException());
}
}
use of org.orekit.errors.OrekitException in project Orekit by CS-SI.
the class FieldOfView method buildDihedra.
/**
* Build a dihedra.
* @param factory factory for regions
* @param tolerance tolerance below which points are considered equal
* @param center Direction of the FOV center, in spacecraft frame
* @param axis FOV dihedral axis, in spacecraft frame
* @param halfAperture FOV dihedral half aperture angle,
* must be less than π/2, i.e. full dihedra must be smaller then
* an hemisphere
* @return dihedra
* @exception OrekitException if half aperture is larger than π/2
*/
private Region<Sphere2D> buildDihedra(final RegionFactory<Sphere2D> factory, final double tolerance, final Vector3D center, final Vector3D axis, final double halfAperture) throws OrekitException {
if (halfAperture > 0.5 * FastMath.PI) {
throw new OrekitException(LocalizedCoreFormats.OUT_OF_RANGE_SIMPLE, halfAperture, 0.0, 0.5 * FastMath.PI);
}
final Rotation r = new Rotation(axis, halfAperture, RotationConvention.VECTOR_OPERATOR);
final Vector3D normalCenterPlane = Vector3D.crossProduct(axis, center);
final Vector3D normalSidePlus = r.applyInverseTo(normalCenterPlane);
final Vector3D normalSideMinus = r.applyTo(normalCenterPlane.negate());
return factory.intersection(new SphericalPolygonsSet(normalSidePlus, tolerance), new SphericalPolygonsSet(normalSideMinus, tolerance));
}
use of org.orekit.errors.OrekitException in project Orekit by CS-SI.
the class CelestialBodyFactory method getBody.
/**
* Get a celestial body.
* <p>
* If no {@link CelestialBodyLoader} has been added by calling {@link
* #addCelestialBodyLoader(String, CelestialBodyLoader)
* addCelestialBodyLoader} or if {@link #clearCelestialBodyLoaders(String)
* clearCelestialBodyLoaders} has been called afterwards,
* the {@link #addDefaultCelestialBodyLoader(String, String)
* addDefaultCelestialBodyLoader} method will be called automatically,
* once with the default name for JPL DE ephemerides and once with the
* default name for IMCCE INPOP files.
* </p>
* @param name name of the celestial body
* @return celestial body
* @exception OrekitException if the celestial body cannot be built
*/
public static CelestialBody getBody(final String name) throws OrekitException {
synchronized (CELESTIAL_BODIES_MAP) {
CelestialBody body = CELESTIAL_BODIES_MAP.get(name);
if (body == null) {
synchronized (LOADERS_MAP) {
List<CelestialBodyLoader> loaders = LOADERS_MAP.get(name);
if ((loaders == null) || loaders.isEmpty()) {
addDefaultCelestialBodyLoader(name, JPLEphemeridesLoader.DEFAULT_DE_SUPPORTED_NAMES);
addDefaultCelestialBodyLoader(name, JPLEphemeridesLoader.DEFAULT_INPOP_SUPPORTED_NAMES);
loaders = LOADERS_MAP.get(name);
}
OrekitException delayedException = null;
for (CelestialBodyLoader loader : loaders) {
try {
body = loader.loadCelestialBody(name);
if (body != null) {
break;
}
} catch (OrekitException oe) {
delayedException = oe;
}
}
if (body == null) {
throw (delayedException != null) ? delayedException : new OrekitException(OrekitMessages.NO_DATA_LOADED_FOR_CELESTIAL_BODY, name);
}
}
// save the body
CELESTIAL_BODIES_MAP.put(name, body);
}
return body;
}
}
use of org.orekit.errors.OrekitException in project Orekit by CS-SI.
the class ClasspathCrawler method feed.
/**
* {@inheritDoc}
*/
public boolean feed(final Pattern supported, final DataLoader visitor) throws OrekitException {
try {
OrekitException delayedException = null;
boolean loaded = false;
for (final String name : listElements) {
try {
if (visitor.stillAcceptsData()) {
if (ZIP_ARCHIVE_PATTERN.matcher(name).matches()) {
// browse inside the zip/jar file
final DataProvider zipProvider = new ZipJarCrawler(name);
loaded = zipProvider.feed(supported, visitor) || loaded;
} else {
// remove suffix from gzip files
final Matcher gzipMatcher = GZIP_FILE_PATTERN.matcher(name);
final String baseName = gzipMatcher.matches() ? gzipMatcher.group(1) : name;
if (supported.matcher(baseName).matches()) {
final InputStream stream = classLoader.getResourceAsStream(name);
final URI uri = classLoader.getResource(name).toURI();
// visit the current file
if (gzipMatcher.matches()) {
visitor.loadData(new GZIPInputStream(stream), uri.toString());
} else {
visitor.loadData(stream, uri.toString());
}
stream.close();
loaded = true;
}
}
}
} catch (OrekitException oe) {
// maybe the next path component will be able to provide data
// wait until all components have been tried
delayedException = oe;
} catch (URISyntaxException use) {
// this should bever happen
throw new OrekitException(use, LocalizedCoreFormats.SIMPLE_MESSAGE, use.getMessage());
}
}
if (!loaded && delayedException != null) {
throw delayedException;
}
return loaded;
} catch (IOException ioe) {
throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage()));
} catch (ParseException pe) {
throw new OrekitException(pe, new DummyLocalizable(pe.getMessage()));
}
}
use of org.orekit.errors.OrekitException in project Orekit by CS-SI.
the class DirectoryCrawler method feed.
/**
* Feed a data file loader by browsing a directory hierarchy.
* @param supported pattern for file names supported by the visitor
* @param visitor data file visitor to feed
* @param directory current directory
* @exception OrekitException if some data is missing, duplicated
* or can't be read
* @return true if something has been loaded
* @exception IOException if data cannot be read
* @exception ParseException if data cannot be read
*/
private boolean feed(final Pattern supported, final DataLoader visitor, final File directory) throws OrekitException, IOException, ParseException {
// search in current directory
final File[] list = directory.listFiles();
Arrays.sort(list, new Comparator<File>() {
@Override
public int compare(final File o1, final File o2) {
return o1.compareTo(o2);
}
});
OrekitException delayedException = null;
boolean loaded = false;
for (int i = 0; i < list.length; ++i) {
try {
if (visitor.stillAcceptsData()) {
if (list[i].isDirectory()) {
// recurse in the sub-directory
loaded = feed(supported, visitor, list[i]) || loaded;
} else if (ZIP_ARCHIVE_PATTERN.matcher(list[i].getName()).matches()) {
// browse inside the zip/jar file
final DataProvider zipProvider = new ZipJarCrawler(list[i]);
loaded = zipProvider.feed(supported, visitor) || loaded;
} else {
// remove suffix from gzip files
final Matcher gzipMatcher = GZIP_FILE_PATTERN.matcher(list[i].getName());
final String baseName = gzipMatcher.matches() ? gzipMatcher.group(1) : list[i].getName();
if (supported.matcher(baseName).matches()) {
// visit the current file
InputStream input = new FileInputStream(list[i]);
if (gzipMatcher.matches()) {
input = new GZIPInputStream(input);
}
visitor.loadData(input, list[i].getPath());
input.close();
loaded = true;
}
}
}
} catch (OrekitException oe) {
delayedException = oe;
}
}
if (!loaded && delayedException != null) {
throw delayedException;
}
return loaded;
}
Aggregations