stations.put("Colorado Springs", new Object[]{ Position.fromDegrees(38.80305456, 255.47540844, 1911.755), fromEcef(-1248.597295e3, -4819.433239e3, 3976.500175e3)}); stations.put("Ascension", new Object[]{ Position.fromDegrees(-7.95132970, 345.58786950, 106.558), fromEcef(6118.524122e3, -1572.350853e3, -876.463990e3)}); stations.put("Diego Garcia", new Object[]{ Position.fromDegrees(-7.26984347, 72.37092177, -64.063), fromEcef(1916.197142e3, 6029.999007e3, -801.737366e3)}); stations.put("Kwajalein", new Object[]{ Position.fromDegrees(8.72250074, 167.73052625, 39.927), fromEcef(-6160.884370e3, 1339.851965e3, 960.843071e3)}); stations.put("Hawaii", new Object[]{ Position.fromDegrees(21.56149086, 201.76066922, 426.077), fromEcef(-5511.980484e3, -2200.247093e3, 2329.480952e3)}); stations.put("Cape Canaveral", new Object[]{ Position.fromDegrees(28.48373800, 279.42769549, -24.005), fromEcef(918.988120e3, -5534.552966e3, 3023.721377e3)});
/** * Tests the cartesian coordinates against values defined in the NIMA WGS specifications: * http://earth-info.nga.mil/GandG/publications/tr8350.2/Addendum%20NIMA%20TR8350.2.pdf * * @throws Exception */ @Test public void testGeographicToCartesian() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Map<String, Object[]> stations = getStations(); for (Map.Entry<String, Object[]> station : stations.entrySet()) { Position p = (Position) station.getValue()[0]; Vec3 v = (Vec3) station.getValue()[1]; Vec3 result = new Vec3(); wgs84.geographicToCartesian(globe, p.latitude, p.longitude, p.altitude, result); // Note: we must rotate the axis to match the WW coord system to the WGS coord system // WW: Y is polar axis, X and Z line on the equatorial plane with X +/-90 and Z +/-180 // WGS: Z is polar axis assertEquals(station.getKey(), v.x, result.x, 1e-3); assertEquals(station.getKey(), v.y, result.y, 1e-3); assertEquals(station.getKey(), v.z, result.z, 1e-3); } }
/** * Tests the geodetic coordinates against values defined in the NIMA WGS specifications: * http://earth-info.nga.mil/GandG/publications/tr8350.2/Addendum%20NIMA%20TR8350.2.pdf * * @throws Exception */ @Test public void testCartesianToGeographic() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Map<String, Object[]> stations = getStations(); for (Map.Entry<String, Object[]> station : stations.entrySet()) { Position p = (Position) station.getValue()[0]; Vec3 v = (Vec3) station.getValue()[1]; Position result = new Position(); // Note: we must rotate the axis to match the WW coord system to the WGS ECEF coord system // WW: Y is polar axis, X and Z line on the equatorial plane with X coincident with +/-90 and Z +/-180 wgs84.cartesianToGeographic(globe, v.x, v.y, v.z, result); assertEquals(station.getKey(), Location.normalizeLatitude(p.latitude), result.latitude, 1e-6); assertEquals(station.getKey(), Location.normalizeLongitude(p.longitude), result.longitude, 1e-6); assertEquals(station.getKey(), p.altitude, result.altitude, 1e-3); } }