Commit 98f205f1 authored by Luc Maisonobe's avatar Luc Maisonobe

fixed numerous findbugs errors

parent c3b34de8
This diff is collapsed.
......@@ -6,10 +6,14 @@
-->
<FindBugsFilter>
<!-- the following inner class serialization pattern is intentional -->
<!-- the inner class and the enclosing class should be serialized together -->
<!-- the following inner classes serialization pattern are intentional -->
<!-- the inner classes and the enclosing classes should be serialized together -->
<Match>
<Class name="fr.cs.orekit.propagation.numerical.forces.maneuvers.ConstantThrustManeuver" />
<Or>
<Class name="~.*\.ConstantThrustManeuver\$\w+Switch$" />
<Class name="~.*\.SolarRadiationPressure\$\w+Switch$" />
<Class name="~.*\.NumericalPropagator\$MappingSwitchingFunction$" />
</Or>
<Bug pattern="SE_INNER_CLASS" />
</Match>
......
......@@ -167,14 +167,14 @@ public class NumericalPropagation {
AbsoluteDate finalDate = new AbsoluteDate(initialDate, 500);
SpacecraftState finalState =
propagator.propagate(initialState, finalDate, 100, new tutorialStepHandler());
propagator.propagate(initialState, finalDate, 100, new TutorialStepHandler());
System.out.println(" Final state : " +
finalState.getParameters());
}
private static class tutorialStepHandler extends OrekitFixedStepHandler {
private static class TutorialStepHandler extends OrekitFixedStepHandler {
private tutorialStepHandler() {
private TutorialStepHandler() {
//private constructor
}
......
......@@ -48,6 +48,7 @@ public abstract class IERSFileCrawler {
*/
public void visit(File file)
throws OrekitException {
BufferedReader reader = null;
try {
this.file = file;
InputStream is = new FileInputStream(file);
......@@ -55,13 +56,21 @@ public abstract class IERSFileCrawler {
// add the decompression filter
is = new GZIPInputStream(is);
}
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
reader = new BufferedReader(new InputStreamReader(is));
visit(reader);
reader.close();
} catch (IOException ioe) {
throw new OrekitException(ioe.getMessage(), ioe);
} catch (ParseException pe) {
throw new OrekitException(pe.getMessage(), pe);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ioe) {
throw new OrekitException(ioe.getMessage(), ioe);
}
}
}
}
......
......@@ -135,6 +135,7 @@ public class DTM2000Atmosphere {
private static double[] az = null;
private static double[] t0 = null;
private static double[] tp = null;
/** Partial derivatives. */
private static double[] dtt = null;
private static double[] dh = null;
......@@ -255,7 +256,7 @@ public class DTM2000Atmosphere {
public double getDensity(int day, double alti, double lon, double lat,
double hl, double f, double fbar,
double akp3, double akp24) throws OrekitException {
if(alti<120000) {
if (alti < 120000) {
throw new OrekitException(" Altitude is below the minimal range of 120000 m : {0}" ,
new Object[] { new Double(alti) });
}
......@@ -273,7 +274,7 @@ public class DTM2000Atmosphere {
}
/** Computes output vales once tne inputs are set. */
/** Computes output vales once the inputs are set. */
private void computation() {
ro=0.;
......@@ -331,11 +332,11 @@ public class DTM2000Atmosphere {
kleq = 0; //equinox
if((day<59) || (day>284)) {
kleq=-1; //hiver nord
if ((day < 59) || (day > 284)) {
kleq=-1; // hiver nord
}
if((day>99) & (day<244)) {
kleq= 1; //ete nord
if ((day > 99) && (day < 244)) {
kleq= 1; // ete nord
}
final double gdelt0 = gFunction(t0,dt0,0,kleq);
......@@ -627,7 +628,7 @@ public class DTM2000Atmosphere {
/** Store the DTM model elements coefficients in internal arrays
* @exception OrekitException if some resource file reading error occurs
*/
private void readcoefficients() throws OrekitException {
private static void readcoefficients() throws OrekitException {
tt = new double[nlatm+1];
h = new double[nlatm+1];
......@@ -661,8 +662,7 @@ public class DTM2000Atmosphere {
dtp[j] = Double.NaN;
}
final Class c = getClass();
final InputStream in = c.getResourceAsStream(dtm2000);
final InputStream in = DTM2000Atmosphere.class.getResourceAsStream(dtm2000);
if (in == null) {
throw new OrekitException("unable to find dtm 2000 model data file {0}",
new Object[] { dtm2000 });
......
......@@ -397,7 +397,7 @@ public class JB2006Atmosphere {
double FEX = 1.;
if ((satAlt>=1000.)&(satAlt<1500.)) {
if ((satAlt >= 1000.) && (satAlt < 1500.)) {
final double ZETA = (satAlt - 1000.) * 0.002;
final double ZETA2 = ZETA * ZETA;
final double ZETA3 = ZETA * ZETA2;
......@@ -439,7 +439,7 @@ public class JB2006Atmosphere {
double sum;
// Calculates dTc
if ((satAlt>=120)&(satAlt<=200)) {
if ((satAlt >= 120) && (satAlt <= 200)) {
final double DTC200 = CdtSub[17] + CdtSub[18]*tx*ycs + CdtSub[19]*tx2*ycs +
CdtSub[20]*tx3*ycs + CdtSub[21]*f*ycs + CdtSub[22]*tx*f*ycs +
CdtSub[23]*tx2*f*ycs;
......@@ -455,7 +455,7 @@ public class JB2006Atmosphere {
dTc = CC*ZP*ZP + DD*ZP*ZP*ZP;
}
if (satAlt>200.0&satAlt<=240.0) {
if ((satAlt > 200.0) && (satAlt <= 240.0)) {
h = (satAlt - 200.)/50.;
sum = CdtSub[1]*h + BdtSub[2]*f*h + CdtSub[3]*tx*f*h + CdtSub[4]*tx2*f*h +
CdtSub[5]*tx3*f*h + CdtSub[6]*tx4*f*h + CdtSub[7]*tx5*f*h +
......@@ -468,7 +468,7 @@ public class JB2006Atmosphere {
dTc = sum;
}
if (satAlt>240.0&satAlt<=300.0) {
if ((satAlt > 240.0) && (satAlt <= 300.0)) {
h = 40./50.;
sum = CdtSub[1]*h + BdtSub[2]*f*h + CdtSub[3]*tx*f*h + CdtSub[4]*tx2*f*h +
CdtSub[5]*tx3*f*h + CdtSub[6]*tx4*f*h + CdtSub[7]*tx5*f*h +
......@@ -502,7 +502,7 @@ public class JB2006Atmosphere {
dTc = AA + BB*ZP + CC*ZP*ZP + DD*ZP*ZP*ZP;
}
if (satAlt>300.0&satAlt<=600.0) {
if ((satAlt > 300.0) && (satAlt <= 600.0)) {
h = satAlt/100.;
sum = BdtSub[1] + BdtSub[2]*f + BdtSub[3]*tx*f + BdtSub[4]*tx2*f +
BdtSub[5]*tx3*f + BdtSub[6]*tx4*f + BdtSub[7]*tx5*f +
......@@ -513,7 +513,7 @@ public class JB2006Atmosphere {
dTc = sum;
}
if (satAlt>600.0&satAlt<=800.0) {
if ((satAlt > 600.0) && (satAlt <= 800.0)) {
final double ZP = (satAlt - 600.)/100.;
final double HP = 600./100.;
final double AA = BdtSub[1] + BdtSub[2]*f + BdtSub[3]*tx*f + BdtSub[4]*tx2*f +
......
......@@ -81,7 +81,7 @@ public class NumericalPropagator
implements FirstOrderDifferentialEquations, AttitudePropagator, Serializable {
/** Serializable UID. */
private static final long serialVersionUID = -7625270037622308823L;
private static final long serialVersionUID = -6846133368177983360L;
/** Attitude provider */
private AttitudeKinematicsProvider akProvider;
......
......@@ -147,7 +147,7 @@ public class ConstantThrustManeuver implements ForceModel {
}
/** Gets the swithching functions related to start and stop passes.
/** Gets the switching functions related to start and stop passes.
* @return start / stop switching functions
*/
public OrekitSwitchingFunction[] getSwitchingFunctions() {
......
......@@ -170,13 +170,13 @@ public class SolarRadiationPressure implements ForceModel {
* @return umbra/penumbra switching functions
*/
public OrekitSwitchingFunction[] getSwitchingFunctions() {
return new OrekitSwitchingFunction[] { new Umbraswitch(), new Penumbraswitch() };
return new OrekitSwitchingFunction[] { new UmbraSwitch(), new PenumbraSwitch() };
}
/** This class defines the Umbra switching function.
* It triggers when the satellite enters the umbra zone.
*/
private class Umbraswitch implements OrekitSwitchingFunction {
private class UmbraSwitch implements OrekitSwitchingFunction {
/** Serializable UID. */
private static final long serialVersionUID = 8164370576237170346L;
......@@ -205,16 +205,19 @@ public class SolarRadiationPressure implements ForceModel {
return sunEarthAngle - alphaEarth;
}
/** {@inheritDoc} */
public double getMaxCheckInterval() {
// we accept losing umbra passes shorter than one minute
return 60.0;
}
/** {@inheritDoc} */
public double getThreshold() {
// convergence threshold in seconds for umbra events
return 1.0e-3;
}
/** {@inheritDoc} */
public int getMaxIterationCount() {
return 100;
}
......@@ -224,11 +227,12 @@ public class SolarRadiationPressure implements ForceModel {
/** This class defines the penumbra switching function.
* It triggers when the satellite enters the penumbra zone.
*/
private class Penumbraswitch implements OrekitSwitchingFunction {
private class PenumbraSwitch implements OrekitSwitchingFunction {
/** Serializable UID. */
private static final long serialVersionUID = -8548885301322210937L;
/** {@inheritDoc} */
public void eventOccurred(SpacecraftState s, double mu) {
// do nothing
}
......@@ -254,16 +258,19 @@ public class SolarRadiationPressure implements ForceModel {
return sunEarthAngle - alphaEarth - alphaSun;
}
/** {@inheritDoc} */
public double getMaxCheckInterval() {
// we accept losing penumbra passes shorter than one minute
return 60.0;
}
/** {@inheritDoc} */
public double getThreshold() {
// convergence threshold in seconds for penumbra events
return 1.0e-3;
}
/** {@inheritDoc} */
public int getMaxIterationCount() {
return 100;
}
......
......@@ -140,7 +140,7 @@ public class TLE implements Comparable {
protected TLE(AbsoluteDate date) {
epoch = date;
satelliteNumber = 0;
internationalDesignator = new String();
internationalDesignator = "";
bStar = 0;
ephemerisType = 0;
elementNumber = 0;
......@@ -264,7 +264,8 @@ public class TLE implements Comparable {
*/
public static boolean isFormatOK(String line1, String line2) throws OrekitException {
if (line1.length() != 69 || line2.length() != 69) {
if (line1 == null || line1.length() != 69 ||
line2 == null || line2.length() != 69) {
return false;
}
......
......@@ -34,11 +34,11 @@ DTM2000InputParameters {
private SolarInputs97to05() throws OrekitException {
data = new TreeSet();
InputStream in = getClass().getResourceAsStream("/atmosphere/JB_All_97-05.txt");
InputStream in = SolarInputs97to05.class.getResourceAsStream("/atmosphere/JB_All_97-05.txt");
BufferedReader rFlux = new BufferedReader(new InputStreamReader(in));
in = getClass().getResourceAsStream("/atmosphere/NOAA_ap_97-05.dat.txt");
in = SolarInputs97to05.class.getResourceAsStream("/atmosphere/NOAA_ap_97-05.dat.txt");
BufferedReader rAp = new BufferedReader(new InputStreamReader(in));
try {
......@@ -77,27 +77,33 @@ DTM2000InputParameters {
AbsoluteDate date = null;
boolean first = true;
for(String lineFlux = rFlux.readLine(); lineFlux!=null; lineFlux = rFlux.readLine()) {
for (String lineFlux = rFlux.readLine(); lineFlux != null; lineFlux = rFlux.readLine()) {
flux = lineFlux.trim().split("\\s+");
lineAp = rAp.readLine();
flux = lineFlux.trim().split("\\s+") ;
ap = lineAp.trim().split("\\s+") ;
if (lineAp == null) {
throw new OrekitException("inconsistent JB2006 and geomagnetic indices files",
new Object[0]);
}
ap = lineAp.trim().split("\\s+");
int year = Integer.parseInt(flux[0]);
int day = Integer.parseInt(flux[1]);
int fluxYear = Integer.parseInt(flux[0]);
int fluxDay = Integer.parseInt(flux[1]);
int apYear = Integer.parseInt(ap[11]);
if (day != Integer.parseInt(ap[0])) {
if (fluxDay != Integer.parseInt(ap[0])) {
throw new OrekitException("inconsistent JB2006 and geomagnetic indices files",
new Object[0]);
}
int y = Integer.parseInt(ap[11]);
if (((year < 2000) && ((year - 1900) != y)) ||
((year >= 2000) && ((year - 2000) != y))) {
if (((fluxYear < 2000) && ((fluxYear - 1900) != apYear)) ||
((fluxYear >= 2000) && ((fluxYear - 2000) != apYear))) {
throw new OrekitException("inconsistent JB2006 and geomagnetic indices files",
new Object[0]);
}
cal.set(Calendar.YEAR, year);
cal.set(Calendar.DAY_OF_YEAR, day);
cal.set(Calendar.YEAR, fluxYear);
cal.set(Calendar.DAY_OF_YEAR, fluxDay);
date = new AbsoluteDate(cal.getTime(), UTCScale.getInstance());
......@@ -132,7 +138,7 @@ DTM2000InputParameters {
private void findClosestLine(AbsoluteDate date) throws OrekitException {
if(date.minus(firstDate)<0 || date.minus(lastDate)>86400) {
if ((date.minus(firstDate) < 0) || (date.minus(lastDate) > 86400)) {
throw new OrekitException("out of range" , new Object[0]);
}
......@@ -146,7 +152,6 @@ DTM2000InputParameters {
// search starting from entries a few steps before the target date
SortedSet tailSet = data.tailSet(before);
if (tailSet != null) {
currentParam = (LineParameters)tailSet.first();
if(currentParam.date.minus(date)==-86400) {
......@@ -208,18 +213,16 @@ DTM2000InputParameters {
public double getAp(AbsoluteDate date) {
double[] tab = null;
double result = Double.NaN;
try {
findClosestLine(date);
tab=currentParam.ap;
Calendar cal = new GregorianCalendar();
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
cal.setTime(date.toDate(UTCScale.getInstance()));
int hour = cal.get(Calendar.HOUR_OF_DAY);
for(int i= 0; i<8; i++) {
if(hour>=i*3 & hour<(i+1)*3) {
result = tab[i];
if ((hour >= (i * 3)) && (hour < ((i + 1) * 3))) {
result = currentParam.ap[i];
}
}
}
......
......@@ -94,17 +94,17 @@ public class DTM2000AtmosphereTest extends TestCase {
// ro= 1.3150282384722D-16
// tz= 793.65487014559
// tinf= 793.65549802348
roTestCase = 1.3150282384722E-16;
tzTestCase= 793.65487014559;
tinfTestCase= 793.65549802348;
// roTestCase = 1.3150282384722E-16;
// tzTestCase= 793.65487014559;
// tinfTestCase= 793.65549802348;
myRo = atm.getDensity(15, 500*1000, 0, Math.toRadians(-70), 16*Math.PI/12, 70, 70, 0, 0);
atm.getDensity(15, 500*1000, 0, Math.toRadians(-70), 16*Math.PI/12, 70, 70, 0, 0);
// IDEM., alt=800.
// ro= 1.9556768571305D-18
// tz= 793.65549797919
// tinf= 793.65549802348
myRo = atm.getDensity(15, 800*1000, 0, Math.toRadians(-70), 16*Math.PI/12, 70, 70, 0, 0);
atm.getDensity(15, 800*1000, 0, Math.toRadians(-70), 16*Math.PI/12, 70, 70, 0, 0);
}
......
......@@ -13,7 +13,7 @@ public class EGMFormatReaderTest extends TestCase {
public void testRead() throws OrekitException, IOException {
InputStream in =
getClass().getResourceAsStream("/potential/egm-format/egm96_to5.ascii.gz");
EGMFormatReaderTest.class.getResourceAsStream("/potential/egm-format/egm96_to5.ascii.gz");
PotentialReaderFactory factory = new PotentialReaderFactory();
PotentialCoefficientsReader reader = factory.getPotentialReader(in);
......@@ -50,7 +50,7 @@ public class EGMFormatReaderTest extends TestCase {
int c = 0;
try {
InputStream in =
getClass().getResourceAsStream("/potential/egm-format-corrupted/fakegm1");
EGMFormatReaderTest.class.getResourceAsStream("/potential/egm-format-corrupted/fakegm1");
factory.getPotentialReader(in);
} catch (OrekitException e) {
c++;
......@@ -58,7 +58,7 @@ public class EGMFormatReaderTest extends TestCase {
}
try {
InputStream in =
getClass().getResourceAsStream("/potential/egm-format-corrupted/fakegm2");
EGMFormatReaderTest.class.getResourceAsStream("/potential/egm-format-corrupted/fakegm2");
factory.getPotentialReader(in);
} catch (OrekitException e) {
c++;
......
......@@ -15,7 +15,7 @@ public class SHMFormatReaderTest extends TestCase {
public void testRead() throws OrekitException, IOException {
InputStream in =
getClass().getResourceAsStream("/potential/shm-format/g003_eigen-cg01c_coef");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format/g003_eigen-cg01c_coef");
PotentialReaderFactory factory = new PotentialReaderFactory();
PotentialCoefficientsReader reader = factory.getPotentialReader(in);
reader.read();
......@@ -30,7 +30,7 @@ public class SHMFormatReaderTest extends TestCase {
assertEquals(0.6378136460E+07 ,reader.getAe(), 0);
in =
getClass().getResourceAsStream("/potential/shm-format/eigen_cg03c_coef");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format/eigen_cg03c_coef");
reader = factory.getPotentialReader(in);
reader.read();
C = reader.getC(5, 5, true);;
......@@ -47,7 +47,7 @@ public class SHMFormatReaderTest extends TestCase {
public void testReadCompressed() throws OrekitException, IOException {
InputStream in =
getClass().getResourceAsStream("/potential/shm-format-compressed/eigen-cg01c_coef.gz");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format-compressed/eigen-cg01c_coef.gz");
PotentialReaderFactory factory = new PotentialReaderFactory();
PotentialCoefficientsReader reader = factory.getPotentialReader(in);
reader.read();
......@@ -62,7 +62,7 @@ public class SHMFormatReaderTest extends TestCase {
assertEquals(0.6378136460E+07 ,reader.getAe(), 0);
in =
getClass().getResourceAsStream("/potential/shm-format-compressed/eigen_cg03c_coef.gz");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format-compressed/eigen_cg03c_coef.gz");
reader = factory.getPotentialReader(in);
reader.read();
C = reader.getC(5, 5, true);;
......@@ -84,7 +84,7 @@ public class SHMFormatReaderTest extends TestCase {
PotentialReaderFactory factory = new PotentialReaderFactory();
try {
InputStream in =
getClass().getResourceAsStream("/potential/shm-format-corrupted/fakeeigen1");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format-corrupted/fakeeigen1");
reader = factory.getPotentialReader(in);
} catch (OrekitException e) {
c++;
......@@ -92,7 +92,7 @@ public class SHMFormatReaderTest extends TestCase {
}
try {
InputStream in =
getClass().getResourceAsStream("/potential/shm-format-corrupted/fakeeigen2");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format-corrupted/fakeeigen2");
reader = factory.getPotentialReader(in);
} catch (OrekitException e) {
c++;
......@@ -100,7 +100,7 @@ public class SHMFormatReaderTest extends TestCase {
}
try {
InputStream in =
getClass().getResourceAsStream("/potential/shm-format-corrupted/fakeeigen3");
SHMFormatReaderTest.class.getResourceAsStream("/potential/shm-format-corrupted/fakeeigen3");
reader = factory.getPotentialReader(in);
} catch (OrekitException e) {
c++;
......
......@@ -20,7 +20,7 @@ import fr.cs.orekit.time.ChunkedTime;
import fr.cs.orekit.time.UTCScale;
import fr.cs.orekit.utils.PVCoordinates;
public class tleTest extends TestCase {
public class TleTest extends TestCase {
public void testTLEFormat() throws OrekitException, ParseException {
......@@ -64,7 +64,7 @@ public class tleTest extends TestCase {
public void testTLESeriesFormat() throws IOException, OrekitException, ParseException {
InputStream in =
getClass().getResourceAsStream("/tle/regular-data/spot-5.txt");
TleTest.class.getResourceAsStream("/tle/regular-data/spot-5.txt");
TLESeries series = new TLESeries(in);
assertEquals(0,
series.getFirstDate().minus(new AbsoluteDate(new ChunkedDate(2002, 05, 04),
......@@ -117,11 +117,11 @@ public class tleTest extends TestCase {
boolean printResults = false;
InputStream inEntry =
getClass().getResourceAsStream("/tle/extrapolationTest-data/SatCode-entry");
TleTest.class.getResourceAsStream("/tle/extrapolationTest-data/SatCode-entry");
BufferedReader rEntry = new BufferedReader(new InputStreamReader(inEntry));
InputStream inResults =
getClass().getResourceAsStream("/tle/extrapolationTest-data/SatCode-results");
TleTest.class.getResourceAsStream("/tle/extrapolationTest-data/SatCode-results");
BufferedReader rResults = new BufferedReader(new InputStreamReader(inResults));
double cumulated = 0; // sum of all differences between test cases and OREKIT results
......@@ -134,12 +134,12 @@ public class tleTest extends TestCase {
String[] title = rline.split(" ");
if(title[0].matches("r")) {
if (title[0].matches("r")) {
String eline;
int count = 0;
String[] header = new String[4];
for (eline = rEntry.readLine(); eline.charAt(0)=='#'; eline = rEntry.readLine()) {
for (eline = rEntry.readLine(); (eline != null) && (eline.charAt(0)=='#'); eline = rEntry.readLine()) {
header[count++] = eline;
}
String line1 = eline;
......@@ -221,7 +221,7 @@ public class tleTest extends TestCase {
}
public static Test suite() {
return new TestSuite(tleTest.class);
return new TestSuite(TleTest.class);
}
......
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