1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.orekit.frames;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.orekit.errors.OrekitException;
24 import org.orekit.errors.OrekitExceptionWrapper;
25 import org.orekit.time.AbsoluteDate;
26 import org.orekit.utils.GenericTimeStampedCache;
27 import org.orekit.utils.TimeStampedGenerator;
28
29
30
31
32
33
34 public class TransformGenerator implements TimeStampedGenerator<Transform> {
35
36
37 private int neighborsSize;
38
39
40 private final TransformProvider provider;
41
42
43 private final double step;
44
45
46
47
48
49
50 public TransformGenerator(final int neighborsSize,
51 final TransformProvider provider,
52 final double step) {
53 this.neighborsSize = neighborsSize;
54 this.provider = provider;
55 this.step = step;
56 }
57
58
59 public List<Transform> generate(final AbsoluteDate existingDate, final AbsoluteDate date) {
60
61 try {
62 final List<Transform> generated = new ArrayList<>();
63
64 if (existingDate == null) {
65
66
67 for (int i = 0; i < neighborsSize; ++i) {
68 generated.add(provider.getTransform(date.shiftedBy(i * step)));
69 }
70
71 } else {
72
73
74
75 AbsoluteDate t = existingDate;
76 if (date.compareTo(t) > 0) {
77
78 do {
79 t = t.shiftedBy(step);
80 generated.add(generated.size(), provider.getTransform(t));
81 } while (t.compareTo(date) <= 0);
82 } else {
83
84 do {
85 t = t.shiftedBy(-step);
86 generated.add(0, provider.getTransform(t));
87 } while (t.compareTo(date) >= 0);
88 }
89
90 }
91
92
93 return generated;
94 } catch (OrekitException oe) {
95 throw new OrekitExceptionWrapper(oe);
96 }
97
98 }
99
100 }