1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.rugged.intersection;
18
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21
22 import java.io.File;
23 import java.net.URISyntaxException;
24
25 import org.hipparchus.geometry.euclidean.threed.Rotation;
26 import org.hipparchus.geometry.euclidean.threed.Vector3D;
27 import org.hipparchus.util.FastMath;
28 import org.junit.jupiter.api.AfterEach;
29 import org.junit.jupiter.api.Assertions;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
32 import org.orekit.attitudes.Attitude;
33 import org.orekit.data.DataContext;
34 import org.orekit.data.DirectoryCrawler;
35 import org.orekit.frames.FramesFactory;
36 import org.orekit.orbits.CartesianOrbit;
37 import org.orekit.propagation.SpacecraftState;
38 import org.orekit.rugged.api.AlgorithmId;
39 import org.orekit.rugged.intersection.duvenhage.DuvenhageAlgorithm;
40 import org.orekit.rugged.raster.CheckedPatternElevationUpdater;
41 import org.orekit.rugged.raster.TileUpdater;
42 import org.orekit.rugged.utils.ExtendedEllipsoid;
43 import org.orekit.rugged.utils.NormalizedGeodeticPoint;
44 import org.orekit.time.AbsoluteDate;
45 import org.orekit.time.TimeScalesFactory;
46 import org.orekit.utils.Constants;
47 import org.orekit.utils.IERSConventions;
48 import org.orekit.utils.PVCoordinates;
49
50 public class ConstantElevationAlgorithmTest {
51
52 @Test
53 public void testDuvenhageComparison() {
54 final Vector3D los = new Vector3D(-0.626242839, 0.0124194184, -0.7795291301);
55 IntersectionAlgorithm duvenhage = new DuvenhageAlgorithm(new CheckedPatternElevationUpdater(FastMath.toRadians(1.0),
56 256, 150.0, 150.0),
57 8, false, true);
58 IntersectionAlgorithm constantElevation = new ConstantElevationAlgorithm(150.0);
59 NormalizedGeodeticPoint gpRef = duvenhage.intersection(earth, state.getPVCoordinates().getPosition(), los);
60 NormalizedGeodeticPoint gpConst = constantElevation.intersection(earth, state.getPVCoordinates().getPosition(), los);
61 Assertions.assertEquals(gpRef.getLatitude(), gpConst.getLatitude(), 1.0e-6);
62 Assertions.assertEquals(gpRef.getLongitude(), gpConst.getLongitude(), 1.0e-6);
63 Assertions.assertEquals(gpRef.getAltitude(), gpConst.getAltitude(), 1.0e-3);
64 Assertions.assertEquals(150.0, constantElevation.getElevation(0.0, 0.0), 1.0e-3);
65
66
67 NormalizedGeodeticPoint shifted =
68 constantElevation.refineIntersection(earth, state.getPVCoordinates().getPosition(), los,
69 new NormalizedGeodeticPoint(gpConst.getLatitude(),
70 gpConst.getLongitude(),
71 gpConst.getAltitude(),
72 2 * FastMath.PI));
73 Assertions.assertEquals(2 * FastMath.PI + gpConst.getLongitude(), shifted.getLongitude(), 1.0e-6);
74
75 }
76
77 @Test
78 public void testIgnoreDEMComparison() {
79 final Vector3D los = new Vector3D(-0.626242839, 0.0124194184, -0.7795291301);
80 IntersectionAlgorithm ignore = new IgnoreDEMAlgorithm();
81 IntersectionAlgorithm constantElevation = new ConstantElevationAlgorithm(0.0);
82 NormalizedGeodeticPoint gpRef = ignore.intersection(earth, state.getPVCoordinates().getPosition(), los);
83 NormalizedGeodeticPoint gpConst = constantElevation.intersection(earth, state.getPVCoordinates().getPosition(), los);
84 Assertions.assertEquals(gpRef.getLatitude(), gpConst.getLatitude(), 1.0e-6);
85 Assertions.assertEquals(gpRef.getLongitude(), gpConst.getLongitude(), 1.0e-6);
86 Assertions.assertEquals(gpRef.getAltitude(), gpConst.getAltitude(), 1.0e-3);
87 Assertions.assertEquals(0.0, constantElevation.getElevation(0.0, 0.0), 1.0e-3);
88
89
90 NormalizedGeodeticPoint shifted =
91 constantElevation.refineIntersection(earth, state.getPVCoordinates().getPosition(), los,
92 new NormalizedGeodeticPoint(gpConst.getLatitude(),
93 gpConst.getLongitude(),
94 gpConst.getAltitude(),
95 2 * FastMath.PI));
96 Assertions.assertEquals(2 * FastMath.PI + gpConst.getLongitude(), shifted.getLongitude(), 1.0e-6);
97
98
99 double elevation0 = ignore.getElevation(gpRef.getLatitude(), gpConst.getLatitude());
100 Assertions.assertEquals(elevation0, 0.0, 1.e-15);
101 }
102
103 @Test
104 public void testAlgorithmId() {
105 IntersectionAlgorithm constantElevation = new ConstantElevationAlgorithm(0.0);
106 assertEquals(AlgorithmId.CONSTANT_ELEVATION_OVER_ELLIPSOID, constantElevation.getAlgorithmId());
107
108 IntersectionAlgorithm ignore = new IgnoreDEMAlgorithm();
109 assertEquals(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID, ignore.getAlgorithmId());
110 }
111
112 @BeforeEach
113 public void setUp() throws URISyntaxException {
114 String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath();
115 DataContext.getDefault().getDataProvidersManager().addProvider(new DirectoryCrawler(new File(path)));
116 earth = new ExtendedEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
117 Constants.WGS84_EARTH_FLATTENING,
118 FramesFactory.getITRF(IERSConventions.IERS_2010, true));
119
120 AbsoluteDate crossing = new AbsoluteDate("2012-01-07T11:50:04.935272115", TimeScalesFactory.getUTC());
121 state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(new Vector3D( 412324.544397459,
122 -4325872.329311633,
123 5692124.593989491),
124 new Vector3D(-1293.174701214779,
125 -5900.764863603793,
126 -4378.671036383179)),
127 FramesFactory.getEME2000(),
128 crossing,
129 Constants.EIGEN5C_EARTH_MU),
130 new Attitude(crossing,
131 FramesFactory.getEME2000(),
132 new Rotation(-0.17806699079182878,
133 0.60143347387211290,
134 -0.73251248177468900,
135 -0.26456641385623986,
136 true),
137 new Vector3D(-4.289600857433520e-05,
138 -1.039151496480297e-03,
139 5.811423736843181e-05),
140 Vector3D.ZERO));
141
142 }
143
144 @AfterEach
145 public void tearDown() {
146 earth = null;
147 updater = null;
148 state = null;
149 }
150
151 protected ExtendedEllipsoid earth;
152 protected TileUpdater updater;
153 protected SpacecraftState state;
154
155 }