Array dataArray =
Array.factory(v2.getDataType().getPrimitiveClassType(),
section.getShape());
Index dataIndex = dataArray.getIndex();
if (varname.equals("latitude") || varname.equals("longitude")) {
double[][] pixel = new double[2][1];
double[][] latLon;
double[][][] latLonValues =
new double[geoXRange.length()][geoYRange.length()][2];
// Use Range object, which calculates requested i, j
// values and incorporates stride
for (int i = 0; i < geoXRange.length(); i++) {
for (int j = 0; j < geoYRange.length(); j++) {
pixel[0][0] = (double) geoXRange.element(i);
pixel[1][0] = (double) geoYRange.element(j);
latLon = nav.toLatLon(pixel);
if (varname.equals("lat")) {
dataArray.setFloat(dataIndex.set(j, i),
(float) (latLon[0][0]));
} else {
dataArray.setFloat(dataIndex.set(j, i),
(float) (latLon[1][0]));
}
}
}
}
if (varname.equals("image")) {
try {
int[][] pixelData = new int[1][1];
if (bandRange != null) {
for (int k = 0; k < bandRange.length(); k++) {
int bandIndex = bandRange.element(k) + 1; // band numbers in McIDAS are 1 based
for (int j = 0; j < geoYRange.length(); j++) {
for (int i = 0; i < geoXRange.length(); i++) {
pixelData = af.getData(geoYRange.element(j),
geoXRange.element(i), 1, 1,
bandIndex);
dataArray.setInt(dataIndex.set(0, k, j, i),
(pixelData[0][0]));
}
}
}
} else {
for (int j = 0; j < geoYRange.length(); j++) {
for (int i = 0; i < geoXRange.length(); i++) {
pixelData = af.getData(geoYRange.element(j),
geoXRange.element(i), 1, 1);
dataArray.setInt(dataIndex.set(0, j, i),
(pixelData[0][0]));
}
}
}