Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Orekit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaëtan Pierre
Orekit
Commits
c2d67e8d
Commit
c2d67e8d
authored
3 years ago
by
Bryan Cazabonne
Browse files
Options
Downloads
Patches
Plain Diff
Fixed deserialization of TLE caused by the bStarParameterDriver.
Fixes #851
parent
08563720
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/orekit/propagation/analytical/tle/TLE.java
+42
-0
42 additions, 0 deletions
src/main/java/org/orekit/propagation/analytical/tle/TLE.java
src/test/java/org/orekit/propagation/analytical/tle/TLETest.java
+39
-0
39 additions, 0 deletions
...t/java/org/orekit/propagation/analytical/tle/TLETest.java
with
81 additions
and
0 deletions
src/main/java/org/orekit/propagation/analytical/tle/TLE.java
+
42
−
0
View file @
c2d67e8d
...
@@ -1014,4 +1014,46 @@ public class TLE implements TimeStamped, Serializable {
...
@@ -1014,4 +1014,46 @@ public class TLE implements TimeStamped, Serializable {
return
Collections
.
singletonList
(
bStarParameterDriver
);
return
Collections
.
singletonList
(
bStarParameterDriver
);
}
}
/** Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
*/
private
Object
writeReplace
()
{
return
new
DataTransferObject
(
line1
,
line2
,
utc
);
}
/** Internal class used only for serialization. */
private
static
class
DataTransferObject
implements
Serializable
{
/** Serializable UID. */
private
static
final
long
serialVersionUID
=
-
1596648022319057689L
;
/** First line. */
private
String
line1
;
/** Second line. */
private
String
line2
;
/** The UTC scale. */
private
final
TimeScale
utc
;
/** Simple constructor.
* @param line1 the first element (69 char String)
* @param line2 the second element (69 char String)
* @param utc the UTC time scale
*/
DataTransferObject
(
final
String
line1
,
final
String
line2
,
final
TimeScale
utc
)
{
this
.
line1
=
line1
;
this
.
line2
=
line2
;
this
.
utc
=
utc
;
}
/** Replace the deserialized data transfer object with a {@link TLE}.
* @return replacement {@link TLE}
*/
private
Object
readResolve
()
{
return
new
TLE
(
line1
,
line2
,
utc
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/org/orekit/propagation/analytical/tle/TLETest.java
+
39
−
0
View file @
c2d67e8d
...
@@ -18,9 +18,13 @@ package org.orekit.propagation.analytical.tle;
...
@@ -18,9 +18,13 @@ package org.orekit.propagation.analytical.tle;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
org.hipparchus.geometry.euclidean.threed.Vector3D
;
import
org.hipparchus.geometry.euclidean.threed.Vector3D
;
...
@@ -28,7 +32,9 @@ import org.hipparchus.util.CombinatoricsUtils;
...
@@ -28,7 +32,9 @@ import org.hipparchus.util.CombinatoricsUtils;
import
org.hipparchus.util.FastMath
;
import
org.hipparchus.util.FastMath
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
org.orekit.Utils
;
import
org.orekit.Utils
;
import
org.orekit.errors.OrekitException
;
import
org.orekit.errors.OrekitException
;
import
org.orekit.errors.OrekitMessages
;
import
org.orekit.errors.OrekitMessages
;
...
@@ -48,6 +54,9 @@ import org.orekit.utils.TimeStampedPVCoordinates;
...
@@ -48,6 +54,9 @@ import org.orekit.utils.TimeStampedPVCoordinates;
public
class
TLETest
{
public
class
TLETest
{
@Rule
public
TemporaryFolder
tempFolder
=
new
TemporaryFolder
();
private
TLE
geoTLE
;
private
TLE
geoTLE
;
private
TLE
leoTLE
;
private
TLE
leoTLE
;
...
@@ -648,6 +657,36 @@ public class TLETest {
...
@@ -648,6 +657,36 @@ public class TLETest {
Assert
.
assertEquals
(
tleISS
.
getLine2
(),
rebuilt
.
getLine2
());
Assert
.
assertEquals
(
tleISS
.
getLine2
(),
rebuilt
.
getLine2
());
}
}
@Test
public
void
testIssue851
()
throws
IOException
,
ClassNotFoundException
{
// Initialize TLE
final
TLE
tleISS
=
new
TLE
(
"1 25544U 98067A 21035.14486477 .00001026 00000-0 26816-4 0 9998"
,
"2 25544 51.6455 280.7636 0002243 335.6496 186.1723 15.48938788267977"
);
String
filename
=
tempFolder
.
newFile
(
"file.ser"
).
toString
();
// Serialization
FileOutputStream
fileSer
=
new
FileOutputStream
(
filename
);
ObjectOutputStream
outSer
=
new
ObjectOutputStream
(
fileSer
);
outSer
.
writeObject
(
tleISS
);
outSer
.
close
();
fileSer
.
close
();
// Deserialization
TLE
rebuilt
=
null
;
FileInputStream
file
=
new
FileInputStream
(
filename
);
ObjectInputStream
in
=
new
ObjectInputStream
(
file
);
rebuilt
=
(
TLE
)
in
.
readObject
();
in
.
close
();
file
.
close
();
// Verify
Assert
.
assertEquals
(
tleISS
.
getLine1
(),
rebuilt
.
getLine1
());
Assert
.
assertEquals
(
tleISS
.
getLine2
(),
rebuilt
.
getLine2
());
Assert
.
assertEquals
(
tleISS
.
getBStar
(),
rebuilt
.
getBStar
(),
1.0
e
-
15
);
}
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
Utils
.
setDataRoot
(
"regular-data"
);
Utils
.
setDataRoot
(
"regular-data"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment