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
14fbeea4
Commit
14fbeea4
authored
3 years ago
by
Luc Maisonobe
Browse files
Options
Downloads
Patches
Plain Diff
Return added Span in TimeSpanMap.
parent
8c3c9e6c
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/utils/TimeSpanMap.java
+12
-3
12 additions, 3 deletions
src/main/java/org/orekit/utils/TimeSpanMap.java
src/test/java/org/orekit/utils/TimeSpanMapTest.java
+9
-3
9 additions, 3 deletions
src/test/java/org/orekit/utils/TimeSpanMapTest.java
with
21 additions
and
6 deletions
src/main/java/org/orekit/utils/TimeSpanMap.java
+
12
−
3
View file @
14fbeea4
...
...
@@ -141,9 +141,10 @@ public class TimeSpanMap<T> {
* @param latestValidityDate date before which the entry is valid
* @param erasesEarlier if true, the entry erases all existing transitions
* that are earlier than {@code latestValidityDate}
* @return span with added entry
* @since 11.1
*/
public
synchronized
void
addValidBefore
(
final
T
entry
,
final
AbsoluteDate
latestValidityDate
,
final
boolean
erasesEarlier
)
{
public
synchronized
Span
<
T
>
addValidBefore
(
final
T
entry
,
final
AbsoluteDate
latestValidityDate
,
final
boolean
erasesEarlier
)
{
// update current reference to transition date
locate
(
latestValidityDate
);
...
...
@@ -185,6 +186,8 @@ public class TimeSpanMap<T> {
// we consider the last added transition as the new current one
current
=
span
;
return
span
;
}
/** Add an entry valid after a limit date.
...
...
@@ -229,9 +232,10 @@ public class TimeSpanMap<T> {
* @param earliestValidityDate date after which the entry is valid
* @param erasesLater if true, the entry erases all existing transitions
* that are later than {@code earliestValidityDate}
* @return span with added entry
* @since 11.1
*/
public
synchronized
void
addValidAfter
(
final
T
entry
,
final
AbsoluteDate
earliestValidityDate
,
final
boolean
erasesLater
)
{
public
synchronized
Span
<
T
>
addValidAfter
(
final
T
entry
,
final
AbsoluteDate
earliestValidityDate
,
final
boolean
erasesLater
)
{
// update current reference to transition date
locate
(
earliestValidityDate
);
...
...
@@ -267,6 +271,8 @@ public class TimeSpanMap<T> {
// we consider the last added transition as the new current one
current
=
span
;
return
span
;
}
/** Add an entry valid between two limit dates.
...
...
@@ -277,9 +283,10 @@ public class TimeSpanMap<T> {
* @param entry entry to add
* @param earliestValidityDate date after which the entry is valid
* @param latestValidityDate date before which the entry is valid
* @return span with added entry
* @since 11.1
*/
public
synchronized
void
addValidBetween
(
final
T
entry
,
final
AbsoluteDate
earliestValidityDate
,
final
AbsoluteDate
latestValidityDate
)
{
public
synchronized
Span
<
T
>
addValidBetween
(
final
T
entry
,
final
AbsoluteDate
earliestValidityDate
,
final
AbsoluteDate
latestValidityDate
)
{
// locate spans at earliest and latest dates
locate
(
earliestValidityDate
);
...
...
@@ -315,6 +322,8 @@ public class TimeSpanMap<T> {
// we consider the last added transition as the new current one
current
=
span
;
return
span
;
}
/** Get the entry valid at a specified date.
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/orekit/utils/TimeSpanMapTest.java
+
9
−
3
View file @
14fbeea4
...
...
@@ -53,7 +53,9 @@ public class TimeSpanMapTest {
TimeSpanMap
<
Integer
>
map
=
new
TimeSpanMap
<>(
Integer
.
valueOf
(
0
));
checkCountConsistency
(
map
);
for
(
int
i
=
1
;
i
<
100
;
++
i
)
{
map
.
addValidAfter
(
Integer
.
valueOf
(
i
),
ref
.
shiftedBy
(
i
),
false
);
Integer
entry
=
Integer
.
valueOf
(
i
);
TimeSpanMap
.
Span
<
Integer
>
span
=
map
.
addValidAfter
(
entry
,
ref
.
shiftedBy
(
i
),
false
);
Assert
.
assertSame
(
entry
,
span
.
getData
());
checkCountConsistency
(
map
);
}
Assert
.
assertEquals
(
0
,
map
.
get
(
ref
.
shiftedBy
(-
1000.0
)).
intValue
());
...
...
@@ -88,7 +90,9 @@ public class TimeSpanMapTest {
TimeSpanMap
<
Integer
>
map
=
new
TimeSpanMap
<>(
Integer
.
valueOf
(
0
));
checkCountConsistency
(
map
);
for
(
int
i
=
-
1
;
i
>
-
100
;
--
i
)
{
map
.
addValidBefore
(
Integer
.
valueOf
(
i
),
ref
.
shiftedBy
(
i
),
false
);
Integer
entry
=
Integer
.
valueOf
(
i
);
TimeSpanMap
.
Span
<
Integer
>
span
=
map
.
addValidBefore
(
entry
,
ref
.
shiftedBy
(
i
),
false
);
Assert
.
assertSame
(
entry
,
span
.
getData
());
checkCountConsistency
(
map
);
}
Assert
.
assertEquals
(
0
,
map
.
get
(
ref
.
shiftedBy
(
1000.0
)).
intValue
());
...
...
@@ -270,7 +274,9 @@ public class TimeSpanMapTest {
map
.
addValidAfter
(
4
,
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
4
),
false
);
map
.
addValidAfter
(
5
,
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
5
),
false
);
Assert
.
assertEquals
(
6
,
map
.
getSpansNumber
());
map
.
addValidBetween
(-
1
,
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
1.5
),
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
4.5
));
Integer
entry
=
Integer
.
valueOf
(-
1
);
TimeSpanMap
.
Span
<
Integer
>
span
=
map
.
addValidBetween
(
entry
,
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
1.5
),
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
4.5
));
Assert
.
assertSame
(
entry
,
span
.
getData
());
Assert
.
assertEquals
(
5
,
map
.
getSpansNumber
());
Assert
.
assertEquals
(
0
,
map
.
get
(
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
0.75
)).
intValue
());
Assert
.
assertEquals
(
1
,
map
.
get
(
AbsoluteDate
.
ARBITRARY_EPOCH
.
shiftedBy
(
1.25
)).
intValue
());
...
...
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