ProjectionWgs84 implements GeographicProjection { @Override public float[] geographicToCartesianGrid(Globe globe, Sector sector, int numLat, int numLon, float[] height, float verticalExaggeration, Vec3 origin, float[] result, int offset, int rowStride) { if (globe == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ProjectionWgs84", "geographicToCartesianGrid", "missingGlobe")); } if (sector == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ProjectionWgs84", "geographicToCartesianGrid", "missingSector")); } if (numLat < 1 || numLon < 1) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ProjectionWgs84", "geographicToCartesianGrid", "Number of latitude or longitude locations is less than one")); } int numPoints = numLat * numLon; if (height != null && height.length < numPoints) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ProjectionWgs84", "geographicToCartesianGrid", "missingArray")); } if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ProjectionWgs84", "geographicToCartesianGrid", "missingResult")); } double minLat = Math.toRadians(sector.minLatitude()); double maxLat = Math.toRadians(sector.maxLatitude()); double minLon = Math.toRadians(sector.minLongitude()); double maxLon = Math.toRadians(sector.maxLongitude()); double deltaLat = (maxLat - minLat) / (numLat > 1 ? numLat - 1 : 1); double deltaLon = (maxLon - minLon) / (numLon > 1 ? numLon - 1 : 1); double eqr = globe.getEquatorialRadius(); double ec2 = globe.getEccentricitySquared(); double cosLat, sinLat, rpm; double[] cosLon = new double[numLon]; double[] sinLon = new double[numLon]; int latIndex, lonIndex, elevIndex = 0; double lat, lon, hgt; double xOffset = (origin != null) ? -origin.x : 0; double yOffset = (origin != null) ? -origin.y : 0; double zOffset = (origin != null) ? -origin.z : 0; for (lonIndex = 0, lon = minLon; lonIndex < numLon; lonIndex++, lon += deltaLon) { if (lonIndex == numLon - 1) { lon = maxLon; } cosLon[lonIndex] = Math.cos(lon); sinLon[lonIndex] = Math.sin(lon); } int rowIndex = offset; if (rowStride == 0) { rowStride = numLon * 3; } for (latIndex = 0, lat = minLat; latIndex < numLat; latIndex++, lat += deltaLat) { if (latIndex == numLat - 1) { lat = maxLat; } cosLat = Math.cos(lat); sinLat = Math.sin(lat); rpm = eqr / Math.sqrt(1.0 - ec2 * sinLat * sinLat); int colIndex = rowIndex; for (lonIndex = 0; lonIndex < numLon; lonIndex++) { hgt = (height != null) ? height[elevIndex++] * verticalExaggeration : 0; result[colIndex++] = (float) ((hgt + rpm) * cosLat * sinLon[lonIndex] + xOffset); result[colIndex++] = (float) ((hgt + rpm * (1.0 - ec2)) * sinLat + yOffset); result[colIndex++] = (float) ((hgt + rpm) * cosLat * cosLon[lonIndex] + zOffset); } rowIndex += rowStride; } return result; } ProjectionWgs84(); @Override String getDisplayName(); @Override Vec3 geographicToCartesian(Globe globe, double latitude, double longitude, double altitude, Vec3 result); @Override Vec3 geographicToCartesianNormal(Globe globe, double latitude, double longitude, Vec3 result); @Override Matrix4 geographicToCartesianTransform(Globe globe, double latitude, double longitude, double altitude, Matrix4 result); @Override float[] geographicToCartesianGrid(Globe globe, Sector sector, int numLat, int numLon, float[] height, float verticalExaggeration,
                                             Vec3 origin, float[] result, int offset, int rowStride); float[] geographicToCartesianBorder(Globe globe, Sector sector, int numLat, int numLon, float height,
                                               Vec3 origin, float[] result); @SuppressWarnings({"UnnecessaryLocalVariable", "SuspiciousNameCombination"}) @Override Position cartesianToGeographic(Globe globe, double x, double y, double z, Position result); @Override Matrix4 cartesianToLocalTransform(Globe globe, double x, double y, double z, Matrix4 result); @Override boolean intersect(Globe globe, Line line, Vec3 result);  }
@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."); }