case WorldWind.ABSOLUTE: if (this.globe != null) { return this.globe.geographicToCartesian(latitude, longitude, altitude * this.verticalExaggeration, result); } else if (this.globe != null) { return this.globe.geographicToCartesian(latitude, longitude, 0, result); } else if (this.globe != null) { return this.globe.geographicToCartesian(latitude, longitude, altitude, result);
/** * Transforms a geographic position to Android screen coordinates. The resultant screen point is in Android screen * pixels relative to this View. * <p/> * This stores the converted point in the result argument, and returns a boolean value indicating whether or not the * converted is successful. This returns false if the Cartesian point is clipped by either of the WorldWindow's * near clipping plane or far clipping plane. * * @param latitude the position's latitude in degrees * @param longitude the position's longitude in degrees * @param altitude the position's altitude in meters * @param result a pre-allocated {@link PointF} in which to return the screen point * * @return true if the transformation is successful, otherwise false * * @throws IllegalArgumentException If the result is null */ public boolean geographicToScreenPoint(double latitude, double longitude, double altitude, PointF result) { if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "WorldWindow", "geographicToScreenPoint", "missingResult")); } // Convert the position from geographic coordinates to Cartesian coordinates. this.globe.geographicToCartesian(latitude, longitude, altitude, this.scratchPoint); // Convert the position from Cartesian coordinates to screen coordinates. return this.cartesianToScreenPoint(this.scratchPoint.x, this.scratchPoint.y, this.scratchPoint.z, result); }
rc.globe.geographicToCartesian(tile.sector.centroidLatitude(), tile.sector.centroidLongitude(), 0, origin); rc.globe.geographicToCartesianGrid(tile.sector, tileWidth, tileHeight, heights, (float) verticalExaggeration, origin, points, rowStride + 3, rowStride); rc.globe.geographicToCartesianBorder(tile.sector, tileWidth + 2, tileHeight + 2, borderHeight, origin, points);
@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); }
case WorldWind.ABSOLUTE: if (rc.globe != null) { rc.globe.geographicToCartesian(lat, lon, alt * rc.verticalExaggeration, this.centerPoint);
@Test public void testDistanceTo() throws Exception { BoundingBox boundingBox = new BoundingBox(); double radius = globe.getEquatorialRadius(); float minElevation = 0; float maxElevation = 1000; Sector sector = Sector.fromDegrees(-0.5, -0.5, 1d, 1d); boundingBox.setToSector(sector, globe, minElevation, maxElevation); Vec3 point = globe.geographicToCartesian(0, 0, 0, new Vec3()); double result = boundingBox.distanceTo(point); assertEquals(boundingBox.center.z - radius, result, 1e-3); }
this.rc.horizonDistance = this.globe.horizonDistance(this.navigator.getAltitude()); this.rc.camera = this.navigator.getAsCamera(this.globe, this.rc.camera); this.rc.cameraPoint = this.globe.geographicToCartesian(this.rc.camera.latitude, this.rc.camera.longitude, this.rc.camera.altitude, this.rc.cameraPoint); this.rc.renderResourceCache = this.renderResourceCache; this.rc.renderResourceCache.setResources(this.getContext().getResources());
@Test public void testSetToSector() throws Exception { BoundingBox boundingBox = new BoundingBox(); double centerLat = 0; double centerLon = 0; // Create a very, very small sector. Sector smallSector = sectorFromCentroid(centerLat, centerLon, 0.0001, 0.0001); // Create a large sector. Sector largeSector = sectorFromCentroid(centerLat, centerLon, 1d, 1d); // Create a point coincident with the sectors' centroids Vec3 point = globe.geographicToCartesian(centerLat, centerLon, 0, new Vec3()); // Set the bounding box to the small sector with no elevation. // We expect the center of the bounding box to be very close to our point and the // z value should be half of the min/max elevation delta. float minElevation = 0; float maxElevation = 100; boundingBox.setToSector(smallSector, globe, minElevation, maxElevation); assertEquals("small center x", point.x, boundingBox.center.x, 1e-1); assertEquals("small center y", point.y, boundingBox.center.y, 1e-1); assertEquals("small center z", point.z + maxElevation / 2, boundingBox.center.z, 1e-1); // Set the bounding box to the large sector with no elevation. // We expect the center x,y of the bounding box to be close to the point // whereas the z value will be less due to the curvature of the sector's surface. minElevation = 0; maxElevation = 0; boundingBox.setToSector(largeSector, globe, minElevation, maxElevation); assertEquals("large center x", point.x, boundingBox.center.x, 1e-1); assertEquals("large center y", point.y, boundingBox.center.y, 1e-1); assertEquals("large center z", point.z, boundingBox.center.z, 300); }