/** * Simply tests that the reciprocal method will regenerate the original value. * * @throws Exception */ @Test public void testCartesianToGeographic_Reciprocal() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); double x = -4610466.9131683465; // KOXR airport double y = 3565379.0227454384; double z = -2576702.8642047923; Vec3 vec = new Vec3(); Position pos = new Position(); wgs84.cartesianToGeographic(globe, x, y, z, pos); wgs84.geographicToCartesian(globe, pos.latitude, pos.longitude, pos.altitude, vec); assertEquals("x", x, vec.x, 1e-6); assertEquals("y", y, vec.y, 1e-6); assertEquals("z", z, vec.z, 1e-6); }
/** * Simple test ensures the computed normal aligns to an expected result. * * @throws Exception */ @Test public void testGeographicToCartesianNormal() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); double lat = 34.2; // KOXR airport double lon = -119.2; double latRad = Math.toRadians(lat); Vec3 result = wgs84.geographicToCartesianNormal(globe, lat, lon, new Vec3()); double theta = Math.toDegrees(Math.asin(result.y)); double lambda = Math.toDegrees(Math.atan2(result.x, result.z)); assertEquals("latitude: ", theta, lat, 1e-6); assertEquals("longitude: ", lambda, lon, 1e-6); }
@Test public void testGetDisplayName() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); String string = wgs84.getDisplayName(); assertEquals("WGS84 name string", "WGS84", string); }
/** * This test case was provided by the COE EMP team. Visually, it is obvious the Line in this examples has a * direction and origin that will not intersect the ellipsoid. * * @throws Exception */ @Test public void testEmpBackwardInstance() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Line ray = new Line(new Vec3(990474.8037403631, 3007310.9566306924, 5583923.602748461), new Vec3(-0.1741204769506282, 0.9711294099374702, -0.16306357245254538)); boolean intersection = wgs84.intersect(this.globe, ray, new Vec3()); assertFalse("EMP backward intersection", intersection); }
/** * 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); } }
Position pos = this.cartesianToGeographic(globe, x, y, z, this.scratchPos); double radLat = Math.toRadians(pos.latitude); double radLon = Math.toRadians(pos.longitude);
/** * 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); } }
@Before public void setUp() throws Exception { // To accommodate WorldWind exception handling, we must mock all // the static methods in Logger to avoid calls to android.util.log PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
@Ignore("not implemented yet.") @Test public void testGeographicToCartesianGrid() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); int stride = 5; int numLat = 17; int numLon = 33; int count = numLat * numLon * stride; float[] elevations = new float[count]; float verticalExaggeration = 1.0f; Sector sector = new Sector(); Vec3 referencePoint = new Vec3(); Vec3 offset = new Vec3(); float[] result = new float[count]; wgs84.geographicToCartesianGrid(globe, sector, numLat, numLon, elevations, verticalExaggeration, referencePoint, result, stride, 0); fail("The test case is a stub."); }
ProjectionWgs84 wgs84 = new ProjectionWgs84(); double lat = 34.2; double lon = -119.2; expected.multiplyByTranslation(0, 0, Rn); Matrix4 result = wgs84.geographicToCartesianTransform(globe, lat, lon, alt, new Matrix4());
/** * An instance which is easily visualized for understanding the forwards intersection instance. * * @throws Exception */ @Test public void testSimpleIntersection() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(0.8, 0.8, 0.0), new Vec3(0.0, -1.0, 0.0)); boolean intersection = wgs84.intersect(mockedGlobe, ray, new Vec3()); assertTrue("simple intersection", intersection); }
@Before public void setUp() { // Mock all the static methods in Logger PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
/** * Simply tests that the reciprocal method will regenerate the original value. * * @throws Exception */ @Test public void testGeographicToCartesian_Reciprocal() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); double lat = 34.2; // KOXR airport double lon = -119.2; double alt = 1000; Vec3 vec = new Vec3(); Position pos = new Position(); wgs84.geographicToCartesian(globe, lat, lon, alt, vec); wgs84.cartesianToGeographic(globe, vec.x, vec.y, vec.z, pos); assertEquals("lat", lat, pos.latitude, 1e-6); assertEquals("lon", lon, pos.longitude, 1e-6); assertEquals("alt", alt, pos.altitude, 1e-6); }
/** * An instance which is easily visualized for understanding the backwards intersection instance. * * @throws Exception */ @Test public void testSimpleBackwardsIntersection() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(0.8, 0.8, 0.0), new Vec3(0.0, 1.0, 0.0)); boolean intersection = wgs84.intersect(mockedGlobe, ray, new Vec3()); assertFalse("simple backwards intersection", intersection); }
@Before public void setUp() throws Exception { // To accommodate WorldWind exception handling, we must mock all // the static methods in Logger to avoid calls to android.util.log PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
/** * An instance which demonstrates two intersections with a ray originating within the ellipsoid. * * @throws Exception */ @Test public void testSimpleTwoIntersectionInternal() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(-0.8, 0, 0.0), new Vec3(1.0, 0.0, 0.0).normalize()); Vec3 result = new Vec3(); double errorThreshold = 1e-9; boolean intersection = wgs84.intersect(mockedGlobe, ray, result); assertTrue("simple internal intersection", intersection); assertEquals("forward calculated intersection x", 1.0, result.x, errorThreshold); assertEquals("forward calculated intersection y", 0.0, result.y, errorThreshold); }
@Before public void setUp() throws Exception { // To accommodate WorldWind exception handling, we must mock all // the static methods in Logger to avoid calls to android.util.log PowerMockito.mockStatic(Logger.class); // Create a globe with a WGS84 definition. this.globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
/** * An instance which demonstrates two intersections, but the closest, or first surface intersection position is * desired. * * @throws Exception */ @Test public void testSimpleTwoIntersection() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(-1.0, 2.0, 0.0), new Vec3(1.0, -1.0, 0.0).normalize()); Vec3 result = new Vec3(); double errorThreshold = 1e-9; boolean intersection = wgs84.intersect(mockedGlobe, ray, result); assertTrue("simple intersection", intersection); assertEquals("nearest calculated intersection x", 0.0, result.x, errorThreshold); assertEquals("nearest calculated intersection y", 1.0, result.y, errorThreshold); }
@Test public void testConstructor() { ProjectionWgs84 wgs84 = new ProjectionWgs84(); assertNotNull(wgs84); }
@Before public void setUp() { // Mock all the static methods in Logger PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test this.globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); // Create the terrain object used by the test this.terrain = new BasicTerrain(); // Add a terrain tile used to the mocked terrain LevelSet levelSet = new LevelSet(new Sector().setFullSphere(), 1.0, 1, 5, 5); // tiles with 5x5 vertices TerrainTile tile = new TerrainTile(new Sector(0, 0, 1, 1), levelSet.firstLevel(), 90, 180); ((BasicTerrain) this.terrain).addTile(tile); // Populate the terrain tile's geometry int tileWidth = tile.level.tileWidth; int tileHeight = tile.level.tileHeight; int rowStride = (tileWidth + 2) * 3; float[] points = new float[(tileWidth + 2) * (tileHeight + 2) * 3]; Vec3 tileOrigin = this.globe.geographicToCartesian(0.5, 0.5, 0.0, new Vec3()); this.globe.geographicToCartesianGrid(tile.sector, tileWidth, tileHeight, null, 1.0f, tileOrigin, points, rowStride + 3, rowStride); this.globe.geographicToCartesianBorder(tile.sector, tileWidth + 2, tileHeight + 2, 0.0f, tileOrigin, points); tile.setOrigin(tileOrigin); tile.setPoints(points); }