change public variables of GridData class to protected

This commit is contained in:
wyq 2021-05-07 19:07:45 +08:00
parent eaa8233400
commit c2b56e5264
30 changed files with 670 additions and 712 deletions

View File

@ -3138,15 +3138,15 @@ public class GraphicFactory {
Object[] ccs = LegendManage.getContoursAndColors(ls);
double[] cValues = (double[]) ccs[0];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] x = gridData.xArray;
double[] y = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] x = gridData.getXArray();
double[] y = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(x);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(y);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, x, y, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, x, y, gridData.getDoubleMissingValue(), S1);
List<PolyLine> ContourLines = (List<PolyLine>) cbs[0];
if (ContourLines.isEmpty()) {
@ -3227,15 +3227,15 @@ public class GraphicFactory {
Object[] ccs = LegendManage.getContoursAndColors(ls);
double[] cValues = (double[]) ccs[0];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] x = gridData.xArray;
double[] y = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] x = gridData.getXArray();
double[] y = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(x);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(y);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, x, y, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, x, y, gridData.getDoubleMissingValue(), S1);
List<PolyLine> ContourLines = (List<PolyLine>) cbs[0];
if (ContourLines.isEmpty()) {
@ -3319,15 +3319,15 @@ public class GraphicFactory {
Object[] ccs = LegendManage.getContoursAndColors(ls);
double[] cValues = (double[]) ccs[0];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] xArray = gridData.xArray;
double[] yArray = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(xArray);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(yArray);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, xArray, yArray, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, xArray, yArray, gridData.getDoubleMissingValue(), S1);
List<PolyLine> ContourLines = (List<PolyLine>) cbs[0];
if (ContourLines.isEmpty()) {
@ -3431,22 +3431,22 @@ public class GraphicFactory {
maxData = maxmin[0];
minData = maxmin[1];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] xArray = gridData.xArray;
double[] yArray = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(xArray);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(yArray);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, xArray, yArray, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, xArray, yArray, gridData.getDoubleMissingValue(), S1);
List<PolyLine> contourLines = (List<PolyLine>) cbs[0];
List<wcontour.global.Border> borders = (List<wcontour.global.Border>) cbs[1];
if (isSmooth) {
contourLines = Contour.smoothLines(contourLines);
}
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues);
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(gridData.getData(), contourLines, borders, cValues);
double v;
ColorBreak cbb = ls.findLegendBreak(0);
@ -3692,22 +3692,22 @@ public class GraphicFactory {
maxData = maxmin[0];
minData = maxmin[1];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] xArray = gridData.xArray;
double[] yArray = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(xArray);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(yArray);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, xArray, yArray, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, xArray, yArray, gridData.getDoubleMissingValue(), S1);
List<PolyLine> contourLines = (List<PolyLine>) cbs[0];
List<wcontour.global.Border> borders = (List<wcontour.global.Border>) cbs[1];
if (isSmooth) {
contourLines = Contour.smoothLines(contourLines);
}
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues);
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(gridData.getData(), contourLines, borders, cValues);
double v;
ColorBreak cbb;
@ -3854,22 +3854,22 @@ public class GraphicFactory {
maxData = maxmin[0];
minData = maxmin[1];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] xArray = gridData.xArray;
double[] yArray = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(xArray);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(yArray);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, xArray, yArray, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, xArray, yArray, gridData.getDoubleMissingValue(), S1);
List<PolyLine> contourLines = (List<PolyLine>) cbs[0];
List<wcontour.global.Border> borders = (List<wcontour.global.Border>) cbs[1];
if (isSmooth) {
contourLines = Contour.smoothLines(contourLines);
}
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues);
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(gridData.getData(), contourLines, borders, cValues);
double v;
ColorBreak cbb;

View File

@ -15,6 +15,7 @@ package org.meteoinfo.data;
import java.io.BufferedReader;
import org.locationtech.proj4j.datum.Grid;
import org.meteoinfo.common.DataConvert;
import org.meteoinfo.common.Extent;
import org.meteoinfo.common.MIMath;
@ -31,14 +32,19 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.IntStream;
import org.meteoinfo.common.ResampleMethods;
import org.meteoinfo.common.util.GlobalUtil;
import org.meteoinfo.ndarray.Dimension;
import org.meteoinfo.ndarray.DimensionType;
//import org.meteoinfo.geoprocess.analysis.ResampleMethods;
import org.meteoinfo.ndarray.math.ArrayUtil;
import org.meteoinfo.projection.KnownCoordinateSystems;
import org.meteoinfo.projection.ProjectionInfo;
import org.meteoinfo.ndarray.Array;
@ -58,36 +64,29 @@ public class GridData {
/**
* Grid data
*/
public double[][] data;
protected double[][] data;
/// <summary>
/// x coordinate array
/// </summary>
public double[] xArray;
protected double[] xArray;
/// <summary>
/// y coordinate array
/// </summary>
public double[] yArray;
protected double[] yArray;
/// <summary>
/// Undef data
/// </summary>
public double missingValue;
protected double missingValue = -9999;
/**
* Projection information
*/
public ProjectionInfo projInfo = null;
public String fieldName = "Data";
protected ProjectionInfo projInfo = null;
protected String fieldName = "Data";
private boolean _xStag = false;
private boolean _yStag = false;
// </editor-fold>
// <editor-fold desc="Constructor">
/**
* Constructor
*/
public GridData() {
missingValue = -9999;
}
/**
* Constructor
*
@ -101,6 +100,96 @@ public class GridData {
data = new double[yArray.length][xArray.length];
}
/**
* Constructor
* @param data Data array
* @param xArray X array
* @param yArray Y array
* @param missingValue Missing value
* @param projInfo Projection info
*/
public GridData(double[][] data, double[] xArray, double[] yArray, double missingValue,
ProjectionInfo projInfo) {
this.data = data;
this.xArray = xArray;
this.yArray = yArray;
this.missingValue = missingValue;
this.projInfo = projInfo;
if (this.getYDelta() < 0) {
this.yArray = IntStream.range(0, this.yArray.length)
.mapToDouble(i -> this.yArray[this.yArray.length - 1 - i])
.toArray();
this.yReverse();
}
if (this.getXDelta() < 0) {
this.xArray = IntStream.range(0, this.xArray.length)
.mapToDouble(i -> this.xArray[this.xArray.length - 1 - i])
.toArray();
this.xReverse();
}
}
/**
* Constructor
* @param data Data array
* @param xArray X array
* @param yArray Y array
* @param missingValue Missing value
*/
public GridData(double[][] data, double[] xArray, double[] yArray, double missingValue) {
this(data, xArray, yArray, missingValue, null);
}
/**
* Constructor
* @param data Data array
* @param xArray X array
* @param yArray Y array
* @param missingValue Missing value
* @param projInfo Projection info
*/
public GridData(double[][] data, double[] xArray, double[] yArray, ProjectionInfo projInfo) {
this(data, xArray, yArray, -9999, projInfo);
}
/**
* Constructor
* @param data Data array
* @param xArray X array
* @param yArray Y array
*/
public GridData(double[][] data, double[] xArray, double[] yArray) {
this(data, xArray, yArray, -9999, null);
}
/**
* Constructor
* @param yNum Y number
* @param xNum X number
*/
public GridData(int yNum, int xNum) {
this(new double[yNum][xNum], new double[xNum], new double[yNum]);
this.xArray = new double[xNum];
for (int i = 0; i < xNum; i++) {
xArray[i] = i;
}
this.yArray = new double[yNum];
for (int i = 0; i < yNum; i++) {
yArray[i] = i;
}
}
/**
* Constructor
* @param xArray Y array
* @param yArray X array
*/
public GridData(double[] xArray, double[] yArray) {
this(new double[yArray.length][xArray.length], xArray, yArray);
}
/**
* Constructor
*
@ -262,6 +351,86 @@ public class GridData {
// </editor-fold>
// <editor-fold desc="Get Set Methods">
/**
* Get data array
* @return Data array
*/
public double[][] getData() {
return this.data;
}
/**
* Get x array
* @return X array
*/
public double[] getXArray() {
return this.xArray;
}
/**
* Set x array
* @param value X array
*/
public void setXArray(double[] value) {
this.xArray = value;
}
/**
* Get y array
* @return Y array
*/
public double[] getYArray() {
return this.yArray;
}
/**
* Set y array
* @param value Y array
*/
public void setYArray(double[] value) {
this.yArray = value;
}
/**
* Get missing value
* @return Missing value
*/
public double getDoubleMissingValue() {
return this.missingValue;
}
/**
* Get projection
* @return Projection
*/
public ProjectionInfo getProjInfo() {
return this.projInfo;
}
/**
* Set projection
* @param value Projection
*/
public void setProjInfo(ProjectionInfo value) {
this.projInfo = value;
}
/**
* Get field name
* @return Field name
*/
public String getFieldName() {
return this.fieldName;
}
/**
* Set field name
* @param value Field name
*/
public void setFieldName(String value) {
this.fieldName = value;
}
/**
* Get xArray number
*
@ -281,20 +450,20 @@ public class GridData {
}
/**
* Get xArray delt
* Get xArray delta
*
* @return xArray delt
* @return xArray delta
*/
public double getXDelt() {
public double getXDelta() {
return xArray[1] - xArray[0];
}
/**
* Get yArray delt
* Get yArray delta
*
* @return yArray delt
* @return yArray delta
*/
public double getYDelt() {
public double getYDelta() {
return yArray[1] - yArray[0];
}
@ -320,7 +489,7 @@ public class GridData {
*/
public boolean isGlobal() {
boolean isGlobal = false;
if (MIMath.doubleEquals(xArray[getXNum() - 1] + getXDelt() - xArray[0], 360.0)) {
if (MIMath.doubleEquals(xArray[getXNum() - 1] + getXDelta() - xArray[0], 360.0)) {
isGlobal = true;
}
@ -374,6 +543,26 @@ public class GridData {
return data[i][j];
}
/**
* Set value
* @param i I index
* @param j J index
* @param v Value
*/
public void setValue(int i, int j, Number v) {
this.data[i][j] = v.doubleValue();
}
/**
* Set value
* @param i I index
* @param j J index
* @param v Value
*/
public void setValue(int i, int j, double v) {
this.data[i][j] = v;
}
/**
* Get double value
*
@ -613,8 +802,8 @@ public class GridData {
}
//Get x/y index
double DX = this.getXDelt();
double DY = this.getYDelt();
double DX = this.getXDelta();
double DY = this.getYDelta();
int xIdx = 0, yIdx = 0;
xIdx = (int) ((x - xArray[0]) / DX);
yIdx = (int) ((y - yArray[0]) / DY);
@ -808,8 +997,8 @@ public class GridData {
int xNum = this.getXNum();
int yNum = this.getYNum();
double axdelt = this.getXDelt();
double aydelt = this.getYDelt();
double axdelt = this.getXDelta();
double aydelt = this.getYDelta();
int sXidx = 0;
int eXidx = xNum - 1;
int sYidx = 0;
@ -829,8 +1018,8 @@ public class GridData {
GridData cGrid = (GridData) this.clone();
int xidx, yidx;
double bxdelt = bGrid.getXDelt();
double bydelt = bGrid.getYDelt();
double bxdelt = bGrid.getXDelta();
double bydelt = bGrid.getYDelta();
for (int i = sYidx; i <= eYidx; i++) {
for (int j = sXidx; j <= eXidx; j++) {
xidx = (int) ((xArray[j] - bGrid.xArray[0]) / bxdelt);
@ -864,8 +1053,8 @@ public class GridData {
int xNum = this.getXNum();
int yNum = this.getYNum();
double axdelt = this.getXDelt();
double aydelt = this.getYDelt();
double axdelt = this.getXDelta();
double aydelt = this.getYDelta();
int sXidx = 0;
int eXidx = xNum - 1;
int sYidx = 0;
@ -885,8 +1074,8 @@ public class GridData {
GridData cGrid = (GridData) this.clone();
int xidx, yidx;
double bxdelt = bGrid.getXDelt();
double bydelt = bGrid.getYDelt();
double bxdelt = bGrid.getXDelta();
double bydelt = bGrid.getYDelta();
for (int i = sYidx; i <= eYidx; i++) {
for (int j = sXidx; j <= eXidx; j++) {
xidx = (int) ((xArray[j] - bGrid.xArray[0]) / bxdelt);
@ -1425,7 +1614,7 @@ public class GridData {
newX[i] = xArray[i];
}
newX[xNum] = newX[xNum - 1] + getXDelt();
newX[xNum] = newX[xNum - 1] + getXDelta();
for (i = 0; i < yNum; i++) {
for (j = 0; j < xNum; j++) {
newGriddata[i][j] = data[i][j];
@ -1505,9 +1694,6 @@ public class GridData {
return null;
}
GridData aGridData = new GridData();
aGridData.projInfo = projInfo;
aGridData.missingValue = missingValue;
int sXidx = 0, eXidx = xNum - 1, sYidx = 0, eYidx = yNum - 1;
//Get start x
@ -1577,18 +1763,16 @@ public class GridData {
newY[i - sYidx] = yArray[i];
}
aGridData.xArray = newX;
aGridData.yArray = newY;
double[][] newData = new double[newYNum][newXNum];
for (i = sYidx; i <= eYidx; i++) {
for (int j = sXidx; j <= eXidx; j++) {
newData[i - sYidx][j - sXidx] = data[i][j];
}
}
aGridData.data = newData;
return aGridData;
GridData gridData = new GridData(newData, newX, newY, this.missingValue, this.projInfo);
return gridData;
}
/**
@ -1601,9 +1785,6 @@ public class GridData {
* @return Extracted grid data
*/
public GridData extract(int sXIdx, int sYIdx, int xNum, int yNum) {
GridData aGridData = new GridData();
aGridData.projInfo = projInfo;
aGridData.missingValue = missingValue;
int eXIdx = sXIdx + xNum - 1, eYIdx = sYIdx + yNum - 1;
double[] newX = new double[xNum];
int i;
@ -1616,18 +1797,14 @@ public class GridData {
newY[i - sYIdx] = yArray[i];
}
aGridData.xArray = newX;
aGridData.yArray = newY;
double[][] newData = new double[yNum][xNum];
for (i = sYIdx; i <= eYIdx; i++) {
for (int j = sXIdx; j <= eXIdx; j++) {
newData[i - sYIdx][j - sXIdx] = data[i][j];
}
}
aGridData.data = newData;
return aGridData;
return new GridData(newData, newX, newY, this.missingValue, this.projInfo);
}
/**
@ -1642,9 +1819,6 @@ public class GridData {
* @return Extracted grid data
*/
public GridData extract(int sXIdx, int eXIdx, int xstep, int sYIdx, int eYIdx, int ystep) {
GridData aGridData = new GridData();
aGridData.projInfo = projInfo;
aGridData.missingValue = missingValue;
int xNum = (eXIdx - sXIdx) / xstep;
int yNum = (eYIdx - sYIdx) / ystep;
double[] newX = new double[xNum];
@ -1661,9 +1835,6 @@ public class GridData {
idx += 1;
}
aGridData.xArray = newX;
aGridData.yArray = newY;
double[][] newData = new double[yNum][xNum];
int yidx = 0;
for (i = sYIdx; i < eYIdx; i += ystep) {
@ -1674,9 +1845,8 @@ public class GridData {
}
yidx += 1;
}
aGridData.data = newData;
return aGridData;
return new GridData(newData, newX, newY, this.missingValue, this.projInfo);
}
/**
@ -1713,29 +1883,27 @@ public class GridData {
int xNum = (getXNum() + skipJ - 1) / skipJ;
int i, j, idxI, idxJ;
GridData gdata = new GridData();
gdata.missingValue = missingValue;
gdata.xArray = new double[xNum];
gdata.yArray = new double[yNum];
gdata.data = new double[yNum][xNum];
double[] xArray = new double[xNum];
double[] yArray = new double[yNum];
double[][] data = new double[yNum][xNum];
for (i = 0; i < yNum; i++) {
idxI = i * skipI;
gdata.yArray[i] = yArray[idxI];
yArray[i] = yArray[idxI];
}
for (j = 0; j < xNum; j++) {
idxJ = j * skipJ;
gdata.xArray[j] = xArray[idxJ];
xArray[j] = xArray[idxJ];
}
for (i = 0; i < yNum; i++) {
idxI = i * skipI;
for (j = 0; j < xNum; j++) {
idxJ = j * skipJ;
gdata.data[i][j] = data[idxI][idxJ];
data[i][j] = data[idxI][idxJ];
}
}
return gdata;
return new GridData(data, xArray, yArray, this.missingValue, this.projInfo);
}
/**
@ -1755,8 +1923,8 @@ public class GridData {
//Get x/y index
int xIdx = 0, yIdx = 0;
xIdx = (int) ((x - xArray[0]) / this.getXDelt());
yIdx = (int) ((y - yArray[0]) / this.getYDelt());
xIdx = (int) ((x - xArray[0]) / this.getXDelta());
yIdx = (int) ((y - yArray[0]) / this.getYDelta());
if (xIdx == xnum - 1) {
xIdx = xnum - 2;
}
@ -1810,7 +1978,7 @@ public class GridData {
}
//Get x/y index
double xdelta = this.getXDelt();
double xdelta = this.getXDelta();
int xIdx = (int) ((x - xmin) / xdelta);
int yIdx = 0;
int i;
@ -1958,7 +2126,7 @@ public class GridData {
* @return Minimum x of the grid border
*/
public double getBorderXMin() {
return this.getXMin() - this.getXDelt() / 2;
return this.getXMin() - this.getXDelta() / 2;
}
/**
@ -1967,7 +2135,7 @@ public class GridData {
* @return Maximum x of the grid border
*/
public double getBorderXMax() {
return this.getXMax() + this.getXDelt() / 2;
return this.getXMax() + this.getXDelta() / 2;
}
/**
@ -1976,7 +2144,7 @@ public class GridData {
* @return Minimum y of the grid border
*/
public double getBorderYMin() {
return this.getYMin() - this.getYDelt() / 2;
return this.getYMin() - this.getYDelta() / 2;
}
/**
@ -1985,7 +2153,7 @@ public class GridData {
* @return Maximum y of the grid border
*/
public double getBorderYMax() {
return this.getYMax() + this.getYDelt() / 2;
return this.getYMax() + this.getYDelta() / 2;
}
/**
@ -2000,8 +2168,8 @@ public class GridData {
int yidx = -1;
if (x >= this.getBorderXMin() && x <= this.getBorderXMax()) {
if (y >= this.getBorderYMin() && y <= this.getBorderYMax()) {
xidx = (int) ((x - this.getBorderXMin()) / this.getXDelt());
yidx = (int) ((y - this.getBorderYMin()) / this.getYDelt());
xidx = (int) ((x - this.getBorderXMin()) / this.getXDelta());
yidx = (int) ((y - this.getBorderYMin()) / this.getYDelta());
}
}
if (xidx >= this.getXNum() || yidx >= this.getYNum()) {
@ -2073,7 +2241,7 @@ public class GridData {
sw.newLine();
sw.write("YLLCENTER " + String.valueOf(yArray[0]));
sw.newLine();
sw.write("CELLSIZE " + String.valueOf(this.getXDelt()));
sw.write("CELLSIZE " + String.valueOf(this.getXDelta()));
sw.newLine();
sw.write("NODATA_VALUE " + String.valueOf(this.missingValue));
sw.newLine();
@ -2140,9 +2308,9 @@ public class GridData {
sw.newLine();
sw.write("ulymap " + String.valueOf(yArray[yArray.length - 1]));
sw.newLine();
sw.write("xdim " + String.valueOf(this.getXDelt()));
sw.write("xdim " + String.valueOf(this.getXDelta()));
sw.newLine();
sw.write("ydim " + String.valueOf(this.getYDelt()));
sw.write("ydim " + String.valueOf(this.getYDelta()));
sw.newLine();
sw.flush();
@ -2460,8 +2628,8 @@ public class GridData {
} else if (y < yArray[0] || y > yArray[yArray.length - 1]) {
newdata[i][j] = missingValue;
} else {
xIdx = (int) ((x - xArray[0]) / getXDelt());
yIdx = (int) ((y - yArray[0]) / getYDelt());
xIdx = (int) ((x - xArray[0]) / getXDelta());
yIdx = (int) ((y - yArray[0]) / getYDelta());
newdata[i][j] = data[yIdx][xIdx];
}
}
@ -2532,13 +2700,8 @@ public class GridData {
newY[i] = (this.yArray[(i - 1) / 2] + this.yArray[(i - 1) / 2 + 1]) / 2;
}
}
GridData gdata = new GridData();
gdata.data = newData;
gdata.xArray = newX;
gdata.yArray = newY;
gdata.missingValue = this.missingValue;
return gdata;
return new GridData(newData, newX, newY, this.missingValue, this.projInfo);
}
/**
@ -2835,8 +2998,8 @@ public class GridData {
} else if (y < yArray[0] || y > yArray[yArray.length - 1]) {
newdata[i][j] = missingValue;
} else {
xIdx = (int) ((x - xArray[0]) / getXDelt());
yIdx = (int) ((y - yArray[0]) / getYDelt());
xIdx = (int) ((x - xArray[0]) / getXDelta());
yIdx = (int) ((y - yArray[0]) / getYDelta());
newdata[i][j] = data[yIdx][xIdx];
}
} catch (Exception e) {
@ -3003,7 +3166,7 @@ public class GridData {
public GridData unStagger_X() {
int xn = this.getXNum();
int yn = this.getYNum();
double dx = this.getXDelt();
double dx = this.getXDelta();
int xn_us = xn - 1;
int i, j;
GridData usData = new GridData(this);
@ -3029,7 +3192,7 @@ public class GridData {
public GridData unStagger_Y() {
int xn = this.getXNum();
int yn = this.getYNum();
double dy = this.getYDelt();
double dy = this.getYDelta();
int yn_us = yn - 1;
int i, j;
GridData usData = new GridData(this);
@ -3106,10 +3269,22 @@ public class GridData {
* @param xNum X number
*/
public Byte(int yNum, int xNum) {
super(yNum, xNum);
data = new byte[yNum][xNum];
missingValue = -9999;
}
/**
* Constructor
* @param xArray Y array
* @param yArray X array
*/
public Byte(double[] xArray, double[] yArray) {
super(xArray, yArray);
data = new byte[yArray.length][xArray.length];
missingValue = -9999;
}
/**
* Get missing value
*
@ -3245,10 +3420,22 @@ public class GridData {
* @param xNum X number
*/
public Integer(int yNum, int xNum) {
super(yNum, xNum);
data = new int[yNum][xNum];
missingValue = -9999;
}
/**
* Constructor
* @param xArray Y array
* @param yArray X array
*/
public Integer(double[] xArray, double[] yArray) {
super(xArray, yArray);
data = new int[yArray.length][xArray.length];
missingValue = -9999;
}
/**
* Get missing value
*
@ -3357,10 +3544,22 @@ public class GridData {
* @param xNum X number
*/
public Double(int yNum, int xNum) {
super(yNum, xNum);
data = new double[yNum][xNum];
missingValue = -9999.0;
}
/**
* Constructor
* @param xArray Y array
* @param yArray X array
*/
public Double(double[] xArray, double[] yArray) {
super(xArray, yArray);
data = new double[yArray.length][xArray.length];
missingValue = -9999;
}
/**
* Get missing value
*
@ -3430,10 +3629,22 @@ public class GridData {
* @param xNum X number
*/
public Float(int yNum, int xNum) {
super(yNum, xNum);
data = new float[yNum][xNum];
missingValue = -9999;
}
/**
* Constructor
* @param xArray Y array
* @param yArray X array
*/
public Float(double[] xArray, double[] yArray) {
super(xArray, yArray);
data = new float[yArray.length][xArray.length];
missingValue = -9999;
}
/**
* Get missing value
*

View File

@ -710,15 +710,15 @@ public class GeoTiff {
}
//gData.data = values;
gData.xArray = X;
gData.yArray = Y;
gData.setXArray(X);
gData.setYArray(Y);
//Projection
String projStr = getProjection();
if (projStr != null) {
gData.projInfo = ProjectionInfo.factory(projStr);
gData.setProjInfo(ProjectionInfo.factory(projStr));
} else {
gData.projInfo = KnownCoordinateSystems.geographic.world.WGS1984;
gData.setProjInfo(KnownCoordinateSystems.geographic.world.WGS1984);
}
return gData;

View File

@ -1064,7 +1064,7 @@ public class MeteoDataInfo {
MathParser mathParser = new MathParser(this);
try {
GridData gridData = (GridData) mathParser.evaluate(varName);
gridData.projInfo = this.getProjectionInfo();
gridData.setProjInfo(this.getProjectionInfo());
return gridData;
} catch (ParseException | IOException ex) {
Logger.getLogger(MeteoDataInfo.class.getName()).log(Level.SEVERE, null, ex);
@ -1072,8 +1072,8 @@ public class MeteoDataInfo {
}
} else {
GridData gridData = this.getGridData();
gridData.projInfo = this.getProjectionInfo();
gridData.fieldName = varName;
gridData.setProjInfo(this.getProjectionInfo());
gridData.setFieldName(varName);
return gridData;
}
}
@ -1119,7 +1119,7 @@ public class MeteoDataInfo {
}
if (gdata != null) {
gdata.projInfo = this.getProjectionInfo();
gdata.setProjInfo(this.getProjectionInfo());
}
return gdata;
@ -1218,7 +1218,7 @@ public class MeteoDataInfo {
GridData gData = this.getGridData(varName);
GridData tData = new GridData(gData);
//tData.missingValue = -9999.0;
tData = tData.setValue(tData.missingValue);
tData = tData.setValue(tData.getDoubleMissingValue());
int xnum = gData.getXNum();
int ynum = gData.getYNum();
LocalDateTime date = this.getDataInfo().getTimes().get(0);
@ -1231,9 +1231,9 @@ public class MeteoDataInfo {
}
for (int i = 0; i < ynum; i++) {
for (int j = 0; j < xnum; j++) {
if (gData.data[i][j] >= threshold) {
if (MIMath.doubleEquals(tData.data[i][j], tData.missingValue)) {
tData.data[i][j] = hour;
if (gData.getData()[i][j] >= threshold) {
if (MIMath.doubleEquals(tData.getDoubleValue(i, j), tData.getDoubleMissingValue())) {
tData.setValue(i, j, hour);
}
}
}

View File

@ -894,13 +894,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
theData = unpackARLGridData(dataBytes, xNum, yNum, aDL);
GridData gridData = new GridData();
gridData.data = theData;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = Y;
return gridData;
return new GridData(theData, X, Y, missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -950,16 +944,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = newGridData;
gridData.missingValue = missingValue;
gridData.xArray = Y;
gridData.yArray = new double[tNum];
double[] yArray = new double[tNum];
for (int i = 0; i < tNum; i++) {
gridData.yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
return gridData;
return new GridData(newGridData, Y, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1009,16 +999,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = newGridData;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = new double[tNum];
double[] yArray = new double[tNum];
for (int i = 0; i < tNum; i++) {
gridData.yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
return gridData;
return new GridData(newGridData, X, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1067,16 +1053,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = newGridData;
gridData.missingValue = missingValue;
gridData.xArray = Y;
gridData.yArray = new double[lNum];
double[] yArray = new double[lNum];
for (int i = 0; i < lNum; i++) {
gridData.yArray[i] = var.getLevels().get(i);
yArray[i] = var.getLevels().get(i);
}
return gridData;
return new GridData(newGridData, Y, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1125,16 +1107,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = newGridData;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = new double[lNum];
double[] yArray = new double[lNum];
for (int i = 0; i < lNum; i++) {
gridData.yArray[i] = var.getLevels().get(i);
yArray[i] = var.getLevels().get(i);
}
return gridData;
return new GridData(newGridData, X, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1187,19 +1165,16 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = newGridData;
gridData.missingValue = missingValue;
gridData.xArray = new double[tNum];
double[] xArray = new double[tNum];
for (int i = 0; i < tNum; i++) {
gridData.xArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
xArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
gridData.yArray = new double[lNum];
double[] yArray = new double[lNum];
for (int i = 0; i < lNum; i++) {
gridData.yArray[i] = var.getLevels().get(i);
yArray[i] = var.getLevels().get(i);
}
return gridData;
return new GridData(newGridData, xArray, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1219,12 +1194,10 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
double[][] gridData;
double aValue;
GridData aGridData = new GridData();
aGridData.missingValue = missingValue;
aGridData.xArray = new double[this.getTimeNum()];
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][this.getTimeNum()];
double[] xArray = new double[this.getTimeNum()];
double[] yArray = new double[1];
yArray[0] = 0;
double[][] data = new double[1][this.getTimeNum()];
//Update level and variable index
Variable aVar = this.getVariable(varName);
@ -1251,13 +1224,13 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
gridData = unpackARLGridData(dataBytes, xNum, yNum, aDL);
aValue = gridData[latIdx][lonIdx];
aGridData.xArray[t] = JDateUtil.toOADate(this.getTimes().get(t));
aGridData.data[0][t] = aValue;
xArray[t] = JDateUtil.toOADate(this.getTimes().get(t));
data[0][t] = aValue;
}
br.close();
return aGridData;
return new GridData(data, xArray, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1278,12 +1251,10 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
double[][] gridData;
double aValue;
GridData aGridData = new GridData();
aGridData.missingValue = missingValue;
aGridData.xArray = new double[lNum];
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][lNum];
double[] xArray = new double[lNum];
double[] yArray = new double[1];
yArray[0] = 0;
double[][] data = new double[1][lNum];
br.seek(timeIdx * recsPerTime * recLen);
br.seek(br.getFilePointer() + indexLen);
@ -1306,13 +1277,13 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
br.read(dataBytes);
gridData = unpackARLGridData(dataBytes, xNum, yNum, aDL);
aValue = gridData[latIdx][lonIdx];
aGridData.xArray[i] = levels.get(levIdx);
aGridData.data[0][i] = aValue;
xArray[i] = levels.get(levIdx);
data[0][i] = aValue;
}
br.close();
return aGridData;
return new GridData(data, xArray, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1331,12 +1302,8 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
double[][] gridData;
double aValue;
GridData aGridData = new GridData();
aGridData.missingValue = missingValue;
aGridData.xArray = X;
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][X.length];
double[] yArray = new double[1];
double[][] data = new double[1][X.length];
//Update level and variable index
Variable aVar = this.getVariable(varName);
@ -1363,12 +1330,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
for (i = 0; i < xNum; i++) {
aValue = gridData[latIdx][i];
aGridData.data[0][i] = aValue;
data[0][i] = aValue;
}
br.close();
return aGridData;
return new GridData(data, X, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1387,12 +1354,8 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
double[][] gridData;
double aValue;
GridData aGridData = new GridData();
aGridData.missingValue = missingValue;
aGridData.xArray = Y;
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][Y.length];
double[] yArray = new double[1];
double[][] data = new double[1][Y.length];
//Update level and variable index
Variable aVar = this.getVariable(varName);
@ -1419,12 +1382,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
for (i = 0; i < yNum; i++) {
aValue = gridData[i][lonIdx];
aGridData.data[0][i] = aValue;
data[0][i] = aValue;
}
br.close();
return aGridData;
return new GridData(data, Y, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -1984,7 +1947,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
private byte[] packARLGridData(GridData gridData, DataLabel aDL) {
int nx = gridData.getXNum();
int ny = gridData.getYNum();
double var1 = gridData.data[0][0];
double var1 = gridData.getDoubleValue(0, 0);
double rold = var1;
double rmax = 0.0;
int i, j;
@ -1992,10 +1955,10 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
for (i = 0; i < ny; i++) {
for (j = 0; j < nx; j++) {
//Compute max difference between elements along row
rmax = Math.max(Math.abs(gridData.data[i][j] - rold), rmax);
rold = gridData.data[i][j];
rmax = Math.max(Math.abs(gridData.getDoubleValue(i, j) - rold), rmax);
rold = gridData.getDoubleValue(i, j);
}
rold = gridData.data[i][0];
rold = gridData.getDoubleValue(i, 0);
}
double sexp = 0.0;
@ -2021,7 +1984,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
for (j = 0; j < ny; j++) {
VOLD = rcol;
for (i = 0; i < nx; i++) {
ival = (int) ((gridData.data[j][i] - VOLD) * SCALE + 127.5);
ival = (int) ((gridData.getDoubleValue(j, i) - VOLD) * SCALE + 127.5);
dataBytes[INDX] = (byte) ival;
VOLD = (float) (ival - 127) / SCALE + VOLD;
if (i == 0) {

View File

@ -523,13 +523,8 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData aGridData = new GridData();
aGridData.data = newGridData;
aGridData.xArray = this.getXDimension().getValues();
aGridData.yArray = this.getYDimension().getValues();
aGridData.missingValue = this.getMissingValue();
return aGridData;
return new GridData(newGridData, this.getXDimension().getValues(),
this.getYDimension().getValues(), this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;

View File

@ -294,13 +294,8 @@ import org.meteoinfo.data.meteodata.Attribute;
sr.close();
GridData aGridData = new GridData();
aGridData.data = theData;
aGridData.xArray = this.getXDimension().getValues();
aGridData.yArray = this.getYDimension().getValues();
aGridData.missingValue = this.getMissingValue();
return aGridData;
return new GridData(theData, this.getXDimension().getValues(),
this.getYDimension().getValues(), this.missingValue);
} catch (IOException ex) {
Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;

View File

@ -808,7 +808,6 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
//Get grid data
int i, j;
GridData gridData = new GridData();
double[] x = new double[_numLonGrid];
double[] y = new double[_numLatGrid];
double xDelt = (_lrLongitude - _ulLongitude) / _numLonGrid;
@ -820,8 +819,6 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
for (i = 0; i < _numLatGrid; i++) {
y[i] = _lrLatitude + yDelt * i;
}
gridData.xArray = x;
gridData.yArray = y;
double[][] gData = new double[_numLatGrid][_numLonGrid];
int bi = 0;
@ -842,9 +839,8 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
bi += _byteGridData;
}
}
gridData.data = gData;
return gridData;
return new GridData(gData, x, y);
}
private GridData getGridData_1() throws IOException {
@ -852,7 +848,6 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
//Get grid data
int i, j;
GridData gridData = new GridData();
int xNum = (int) _width;
int yNum = (int) _height;
double[] x = new double[xNum];
@ -864,8 +859,6 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
for (i = 0; i < yNum; i++) {
y[i] = _yLB + _yDelt * i;
}
gridData.xArray = x;
gridData.yArray = y;
double[][] gData = new double[yNum][xNum];
for (i = 0; i < yNum; i++) {
@ -873,9 +866,8 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
gData[yNum - i - 1][j] = DataConvert.byte2Int(imageBytes[i * xNum + j]);
}
}
gridData.data = gData;
return gridData;
return new GridData(gData, x, y);
}
/**

View File

@ -25,6 +25,7 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.locationtech.proj4j.datum.Grid;
import org.meteoinfo.common.DataConvert;
import org.meteoinfo.data.GridArray;
import org.meteoinfo.data.GridData;
@ -471,11 +472,9 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BIL(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData gData = new GridData();
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
gData.missingValue = this.getMissingValue();
gData.data = new double[_nrows][_ncols];
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
double[][] data = new double[_nrows][_ncols];
br.seek(this._skipbytes);
int i, j;
@ -496,12 +495,12 @@ import org.meteoinfo.data.meteodata.Attribute;
System.arraycopy(byteData, start, bytes, 0, nbytes);
start += nbytes;
if (this._pixeltype.toLowerCase().equals("float")) {
gData.data[_nrows - 1 - i][j] = DataConvert.bytes2Float(bytes, _byteOrder);
data[_nrows - 1 - i][j] = DataConvert.bytes2Float(bytes, _byteOrder);
} else {
if (nbytes >= 2) {
gData.data[_nrows - 1 - i][j] = DataConvert.bytes2Int(bytes, _byteOrder);
data[_nrows - 1 - i][j] = DataConvert.bytes2Int(bytes, _byteOrder);
} else {
gData.data[_nrows - 1 - i][j] = DataConvert.byte2Int(bytes[0]);
data[_nrows - 1 - i][j] = DataConvert.byte2Int(bytes[0]);
}
}
}
@ -509,7 +508,7 @@ import org.meteoinfo.data.meteodata.Attribute;
}
br.close();
return gData;
return new GridData(data, xArray, yArray, this.missingValue, this.projInfo);
} catch (FileNotFoundException ex) {
Logger.getLogger(BILDataInfo.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
@ -522,11 +521,9 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BIL_Int(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData.Integer gData = new GridData.Integer(_nrows, _ncols);
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
//gData.missingValue = this.getMissingValue();
//gData.data = new double[_nrows][_ncols];
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
GridData.Integer gData = new GridData.Integer(xArray, yArray);
br.seek(this._skipbytes);
int i, j;
@ -569,11 +566,8 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BIL_Byte(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData.Byte gData = new GridData.Byte(_nrows, _ncols);
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
//gData.missingValue = this.getMissingValue();
//gData.data = new double[_nrows][_ncols];
GridData.Byte gData = new GridData.Byte(this.getXDimension().getValues(),
this.getYDimension().getValues());
br.seek(this._skipbytes);
int i, j;
@ -605,11 +599,9 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BIP(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData gData = new GridData();
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
gData.missingValue = this.getMissingValue();
gData.data = new double[_nrows][_ncols];
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
double[][] data = new double[_nrows][_ncols];
br.seek(this._skipbytes);
int i, j;
@ -625,12 +617,12 @@ import org.meteoinfo.data.meteodata.Attribute;
bytes = new byte[nbytes];
br.read(bytes);
if (this._pixeltype.toLowerCase().equals("float")) {
gData.data[_nrows - 1 - i][j] = DataConvert.bytes2Float(bytes, _byteOrder);
data[_nrows - 1 - i][j] = DataConvert.bytes2Float(bytes, _byteOrder);
} else {
if (nbytes >= 2) {
gData.data[_nrows - 1 - i][j] = DataConvert.bytes2Int(bytes, _byteOrder);
data[_nrows - 1 - i][j] = DataConvert.bytes2Int(bytes, _byteOrder);
} else {
gData.data[_nrows - 1 - i][j] = DataConvert.byte2Int(bytes[0]);
data[_nrows - 1 - i][j] = DataConvert.byte2Int(bytes[0]);
}
}
}
@ -640,7 +632,7 @@ import org.meteoinfo.data.meteodata.Attribute;
}
br.close();
return gData;
return new GridData(data, xArray, yArray, this.missingValue, this.projInfo);
} catch (FileNotFoundException ex) {
Logger.getLogger(BILDataInfo.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
@ -653,11 +645,9 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BSQ(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData gData = new GridData();
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
gData.missingValue = this.getMissingValue();
gData.data = new double[_nrows][_ncols];
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
double[][] data = new double[_nrows][_ncols];
br.seek(this._skipbytes);
int i, j;
@ -677,12 +667,12 @@ import org.meteoinfo.data.meteodata.Attribute;
System.arraycopy(byteData, start, bytes, 0, nbytes);
start += nbytes;
if (this._pixeltype.toLowerCase().equals("float")) {
gData.data[_nrows - 1 - i][j] = DataConvert.bytes2Float(bytes, _byteOrder);
data[_nrows - 1 - i][j] = DataConvert.bytes2Float(bytes, _byteOrder);
} else {
if (nbytes >= 2) {
gData.data[_nrows - 1 - i][j] = DataConvert.bytes2Int(bytes, _byteOrder);
data[_nrows - 1 - i][j] = DataConvert.bytes2Int(bytes, _byteOrder);
} else {
gData.data[_nrows - 1 - i][j] = DataConvert.byte2Int(bytes[0]);
data[_nrows - 1 - i][j] = DataConvert.byte2Int(bytes[0]);
}
}
}
@ -690,7 +680,7 @@ import org.meteoinfo.data.meteodata.Attribute;
}
br.close();
return gData;
return new GridData(data, xArray, yArray, this.missingValue, this.projInfo);
} catch (FileNotFoundException ex) {
Logger.getLogger(BILDataInfo.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
@ -703,11 +693,9 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BSQ_Int(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData.Integer gData = new GridData.Integer(_nrows, _ncols);
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
//gData.missingValue = this.getMissingValue();
//gData.data = new double[_nrows][_ncols];
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
GridData.Integer gData = new GridData.Integer(xArray, yArray);
br.seek(this._skipbytes);
int i, j;
@ -751,11 +739,9 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BSQ_Byte(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData.Byte gData = new GridData.Byte(_nrows, _ncols);
gData.xArray = this.getXDimension().getValues();
gData.yArray = this.getYDimension().getValues();
//gData.missingValue = this.getMissingValue();
//gData.data = new double[_nrows][_ncols];
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
GridData.Byte gData = new GridData.Byte(xArray, yArray);
br.seek(this._skipbytes);
int i, j;

View File

@ -183,9 +183,9 @@ import org.meteoinfo.data.meteodata.Attribute;
@Override
public GridData getGridData_LonLat(int timeIdx, String varName, int levelIdx) {
GridData gdata = this.geoTiff.getGridData_Value();
gdata.xArray = this.getXDimension().getValues();
gdata.yArray = this.getYDimension().getValues();
gdata.projInfo = this.getProjectionInfo();
gdata.setXArray(this.getXDimension().getValues());
gdata.setYArray(this.getYDimension().getValues());
gdata.setProjInfo(this.getProjectionInfo());
return gdata;
}

View File

@ -1511,24 +1511,23 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
*/
@Override
public GridData getGridData_LonLat(int timeIdx, String varName, int levelIdx) {
GridData gridData = new GridData();
try {
int varIdx = this.getVariableIndex(varName);
gridData.data = readGrADSData_Grid_LonLat(timeIdx, varIdx, levelIdx);
double[][] data = readGrADSData_Grid_LonLat(timeIdx, varIdx, levelIdx);
GridData gridData = new GridData(data, X, Y, this.missingValue);
if (OPTIONS.yrev) {
gridData.yReverse();
}
return gridData;
} catch (FileNotFoundException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
gridData.xArray = X;
gridData.yArray = Y;
gridData.missingValue = this.getMissingValue();
if (OPTIONS.yrev) {
gridData.yReverse();
}
return gridData;
return null;
}
/**
@ -1679,16 +1678,12 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.close();
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = Y;
aGridData.yArray = new double[this.getTimeNum()];
double[] yArray = new double[this.getTimeNum()];
for (i = 0; i < this.getTimeNum(); i++) {
aGridData.yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
return aGridData;
return new GridData(gridData, Y, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -1773,16 +1768,12 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.close();
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = X;
aGridData.yArray = new double[this.getTimeNum()];
double[] yArray = new double[this.getTimeNum()];
for (i = 0; i < this.getTimeNum(); i++) {
aGridData.yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
return aGridData;
return new GridData(gridData, X, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -1840,17 +1831,12 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
}
br.close();
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = Y;
double[] levels = new double[VARDEF.getVars().get(varIdx).getLevelNum()];
for (i = 0; i < levels.length; i++) {
levels[i] = ZDEF.ZLevels[i];
}
aGridData.yArray = levels;
return aGridData;
return new GridData(gridData, Y, levels, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -1908,17 +1894,12 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
}
br.close();
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = X;
double[] levels = new double[VARDEF.getVars().get(varIdx).getLevelNum()];
for (i = 0; i < levels.length; i++) {
levels[i] = ZDEF.ZLevels[i];
}
aGridData.yArray = levels;
return aGridData;
return new GridData(gridData, X, levels, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -2006,20 +1987,16 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.close();
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = new double[this.getTimeNum()];
double[] xArray = new double[this.getTimeNum()];
for (i = 0; i < this.getTimeNum(); i++) {
aGridData.xArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
xArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
double[] levels = new double[VARDEF.getVars().get(varIdx).getLevelNum()];
for (i = 0; i < levels.length; i++) {
levels[i] = ZDEF.ZLevels[i];
}
aGridData.yArray = levels;
return aGridData;
return new GridData(gridData, xArray, levels, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -2035,12 +2012,10 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
byte[] aBytes = new byte[4];
float aValue;
GridData aGridData = new GridData();
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = new double[TDEF.getTimeNum()];
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][TDEF.getTimeNum()];
double[] xArray = new double[TDEF.getTimeNum()];
double[] yArray = new double[1];
yArray[0] = 0;
double[][] data = new double[1][TDEF.getTimeNum()];
if (OPTIONS.template) {
for (t = 0; t < TDEF.getTimeNum(); t++) {
@ -2071,8 +2046,8 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.read(aBytes);
aValue = DataConvert.bytes2Float(aBytes, _byteOrder);
aGridData.xArray[t] = JDateUtil.toOADate(TDEF.times.get(t));
aGridData.data[0][t] = aValue;
xArray[t] = JDateUtil.toOADate(TDEF.times.get(t));
data[0][t] = aValue;
br.close();
}
@ -2101,14 +2076,14 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.read(aBytes);
aValue = DataConvert.bytes2Float(aBytes, _byteOrder);
aGridData.xArray[t] = JDateUtil.toOADate(TDEF.times.get(t));
aGridData.data[0][t] = aValue;
xArray[t] = JDateUtil.toOADate(TDEF.times.get(t));
data[0][t] = aValue;
}
br.close();
}
return aGridData;
return new GridData(data, xArray, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -2133,12 +2108,10 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
byte[] aBytes = new byte[4];
float aValue;
GridData aGridData = new GridData();
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = new double[ZDEF.ZNum];
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][ZDEF.ZNum];
double[] xArray = new double[ZDEF.ZNum];
double[] yArray = new double[1];
yArray[0] = 0;
double[][] data = new double[1][ZDEF.ZNum];
br.seek(FILEHEADER + tIdx * RecLenPerTime);
@ -2161,13 +2134,13 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.read(aBytes);
aValue = DataConvert.bytes2Float(aBytes, _byteOrder);
aGridData.xArray[i] = ZDEF.ZLevels[i];
aGridData.data[0][i] = aValue;
xArray[i] = ZDEF.ZLevels[i];
data[0][i] = aValue;
}
br.close();
return aGridData;
return new GridData(data, xArray, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -2191,12 +2164,9 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
byte[] aBytes = new byte[4];
float aValue;
GridData aGridData = new GridData();
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = X;
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][X.length];
double[] yArray = new double[1];
yArray[0] = 0;
double[][] data = new double[1][X.length];
br.seek(FILEHEADER + tIdx * RecLenPerTime);
for (i = 0; i < varIdx; i++) {
@ -2215,12 +2185,12 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
for (i = 0; i < XNum; i++) {
br.read(aBytes);
aValue = DataConvert.bytes2Float(aBytes, _byteOrder);
aGridData.data[0][i] = aValue;
data[0][i] = aValue;
}
br.close();
return aGridData;
return new GridData(data, X, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -2244,12 +2214,9 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
byte[] aBytes = new byte[4];
float aValue;
GridData aGridData = new GridData();
aGridData.missingValue = this.getMissingValue();
aGridData.xArray = Y;
aGridData.yArray = new double[1];
aGridData.yArray[0] = 0;
aGridData.data = new double[1][Y.length];
double[] yArray = new double[1];
yArray[0] = 0;
double[][] data = new double[1][Y.length];
br.seek(FILEHEADER + tIdx * RecLenPerTime);
for (i = 0; i < varIdx; i++) {
@ -2269,12 +2236,12 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.seek(aPosition + i * XNum * 4 + lonIdx * 4);
br.read(aBytes);
aValue = DataConvert.bytes2Float(aBytes, _byteOrder);
aGridData.data[0][i] = aValue;
data[0][i] = aValue;
}
br.close();
return aGridData;
return new GridData(data, Y, yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}
@ -2291,9 +2258,6 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
*/
public GridData getGridData_Station(int vIdx, String stID) {
try {
GridData gData = new GridData();
gData.missingValue = this.getMissingValue();
RandomAccessFile br = new RandomAccessFile(DSET, "r");
int i, stNum, tNum;
STDataHead aSTDH = new STDataHead();
@ -2307,17 +2271,17 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
}
byte[] aBytes;
gData.xArray = new double[this.getTimeNum()];
double[] xArray = new double[this.getTimeNum()];
for (i = 0; i < this.getTimeNum(); i++) {
gData.xArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
xArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
gData.yArray = new double[aVar.getLevelNum()];
double[] yArray = new double[aVar.getLevelNum()];
for (i = 0; i < aVar.getLevelNum(); i++) {
gData.yArray[i] = i + 1;
yArray[i] = i + 1;
}
gData.data = new double[aVar.getLevelNum()][this.getTimeNum()];
double[][] data = new double[aVar.getLevelNum()][this.getTimeNum()];
stNum = 0;
tNum = 0;
@ -2365,7 +2329,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
for (i = 0; i < aSTDH.NLev - aSTDH.Flag; i++) {
br.skipBytes(4 + vIdx * 4);
aBytes = getByteArray(br, 4);
gData.data[i][tNum] = DataConvert.bytes2Float(aBytes, _byteOrder);
data[i][tNum] = DataConvert.bytes2Float(aBytes, _byteOrder);
br.skipBytes((uVarNum - vIdx - 1) * 4);
}
} else {
@ -2387,7 +2351,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
br.close();
return gData;
return new GridData(data, xArray, yArray, this.missingValue);
} catch (FileNotFoundException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
@ -2760,7 +2724,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
*/
public void writeGridData(GridData gridData) {
try {
writeGrADSData_Grid(_bw, gridData.data);
writeGrADSData_Grid(_bw, gridData.getData());
} catch (IOException ex) {
Logger.getLogger(GrADSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
}

View File

@ -799,13 +799,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData gridData = new GridData();
gridData.data = newDataArray;
gridData.xArray = newX;
gridData.yArray = this.getYDimension().getValues();
gridData.missingValue = this.getMissingValue();
return gridData;
return new GridData(newDataArray, newX, this.getYDimension().getValues(), this.missingValue);
} catch (IOException ex) {
Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;

View File

@ -532,13 +532,8 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
}
}
GridData gridData = new GridData();
gridData.data = data;
gridData.xArray = this.getXDimension().getValues();
gridData.yArray = this.getYDimension().getValues();
gridData.missingValue = this.getMissingValue();
return gridData;
return new GridData(data, this.getXDimension().getValues(), this.getYDimension().getValues(),
this.missingValue);
}
@Override

View File

@ -502,13 +502,8 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData aGridData = new GridData();
aGridData.data = newGridData;
aGridData.xArray = this.getXDimension().getValues();
aGridData.yArray = this.getYDimension().getValues();
aGridData.missingValue = this.getMissingValue();
return aGridData;
return new GridData(newGridData, this.getXDimension().getValues(),
this.getYDimension().getValues(), this.missingValue);
} catch (IOException ex) {
Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;

View File

@ -383,7 +383,6 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
br.read(bytes);
br.close();
GridData gridData = new GridData();
double[][] gData = new double[yNum][xNum];
if (dataByteNum == 1) {
for (int i = 0; i < yNum; i++) {
@ -400,9 +399,7 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
}
}
}
gridData.data = gData;
gridData.xArray = this.getXDimension().getValues();
gridData.yArray = this.getYDimension().getValues();
GridData gridData = new GridData(gData, this.getXDimension().getValues(), this.getYDimension().getValues());
return gridData;
} catch (IOException e) {

View File

@ -377,18 +377,14 @@ public class MICAPS13DataInfo extends DataInfo implements IGridDataInfo {
@Override
public GridData getGridData_LonLat(int timeIdx, String varName, int levelIdx) {
GridData gridData = new GridData();
double[][] gData = new double[_yNum][_xNum];
for (int i = 0; i < _yNum; i++) {
for (int j = 0; j < _xNum; j++) {
gData[i][j] = DataConvert.byte2Int(_imageBytes[i * _xNum + j]);
}
}
gridData.data = gData;
gridData.xArray = this.getXDimension().getValues();
gridData.yArray = this.getYDimension().getValues();
return gridData;
return new GridData(gData, this.getXDimension().getValues(), this.getYDimension().getValues());
}
@Override

View File

@ -428,13 +428,8 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData aGridData = new GridData();
aGridData.data = newGridData;
aGridData.xArray = this.getXDimension().getValues();
aGridData.yArray = this.getYDimension().getValues();
aGridData.missingValue = this.getMissingValue();
return aGridData;
return new GridData(newGridData, this.getXDimension().getValues(),
this.getYDimension().getValues(), this.missingValue);
} catch (IOException ex) {
Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;

View File

@ -823,13 +823,7 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData gridData = new GridData();
gridData.data = theData;
gridData.missingValue = this.getMissingValue();
gridData.xArray = xdim.getValues();
gridData.yArray = ydim.getValues();
return gridData;
return new GridData(theData, xdim.getValues(), ydim.getValues(), this.missingValue);
} catch (FileNotFoundException ex) {
Logger.getLogger(MM5IMDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -867,13 +861,7 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData gridData = new GridData();
gridData.data = theData;
gridData.missingValue = this.getMissingValue();
gridData.xArray = xdim.getValues();
gridData.yArray = ydim.getValues();
return gridData;
return new GridData(theData, xdim.getValues(), ydim.getValues(), this.missingValue);
}
@Override
@ -912,16 +900,12 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = theData;
gridData.missingValue = this.getMissingValue();
gridData.xArray = ydim.getValues();
gridData.yArray = new double[tNum];
double[] yArray = new double[tNum];
for (i = 0; i < tNum; i++) {
gridData.yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
return gridData;
return new GridData(theData, ydim.getValues(), yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(MM5DataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -968,16 +952,12 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
br.close();
GridData gridData = new GridData();
gridData.data = theData;
gridData.missingValue = this.getMissingValue();
gridData.xArray = xdim.getValues();
gridData.yArray = new double[tNum];
double[] yArray = new double[tNum];
for (i = 0; i < tNum; i++) {
gridData.yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
yArray[i] = JDateUtil.toOADate(this.getTimes().get(i));
}
return gridData;
return new GridData(theData, xdim.getValues(), yArray, this.missingValue);
} catch (IOException ex) {
Logger.getLogger(MM5DataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;

View File

@ -298,9 +298,6 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
}
}
GridData gridData = new GridData();
gridData.data = theData;
gridData.missingValue = this.getMissingValue();
double[] X = new double[dh.idim];
for (i = 0; i < dh.idim; i++) {
X[i] = dh.startlon + dh.deltalon * i;
@ -309,10 +306,8 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
for (i = 0; i < dh.jdim; i++) {
Y[i] = dh.startlat + dh.deltalat * (dh.jdim - 1 - i);
}
gridData.xArray = X;
gridData.yArray = Y;
return gridData;
return new GridData(theData, X, Y, this.getMissingValue());
} catch (FileNotFoundException ex) {
Logger.getLogger(MM5IMDataInfo.class.getName()).log(Level.SEVERE, null, ex);
return null;
@ -445,7 +440,7 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
int i, j, k;
for (i = 0; i < yn; i++) {
for (j = 0; j < xn; j++) {
bytes = DataConvert.float2Bytes((float) gridData.data[yn - 1 -i][j], _byteOrder);
bytes = DataConvert.float2Bytes((float) gridData.getValue(yn - 1 -i, j), _byteOrder);
for (k = 0; k < 4; k++) {
dataBytes[start + k] = bytes[k];
}

View File

@ -2076,15 +2076,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getXDimension().getValues();
aGridData.yArray = nvar.getYDimension().getValues();
aGridData.setMissingValue(missingValue);
if (this.isYReverse()) {
aGridData.yReverse();
}
GridData aGridData = new GridData(gridData, nvar.getXDimension().getValues(),
nvar.getYDimension().getValues(), missingValue);
if (this._convention == Conventions.WRFOUT) {
if (nvar.getName().equals("U")) {
@ -2179,15 +2172,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getYDimension().getValues();
aGridData.yArray = nvar.getTDimension().getValues();
aGridData.missingValue = missingValue;
if (this.isYReverse()) {
aGridData.xReverse();
}
GridData aGridData = new GridData(gridData, nvar.getYDimension().getValues(),
nvar.getTDimension().getValues(), missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2271,11 +2257,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getYDimension().getValues();
aGridData.yArray = nvar.getTDimension().getValues();
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getXDimension().getValues(),
nvar.getTDimension().getValues(), missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2361,15 +2344,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getYDimension().getValues();
aGridData.yArray = nvar.getZDimension().getValues();
aGridData.missingValue = missingValue;
if (this.isYReverse()) {
aGridData.xReverse();
}
GridData aGridData = new GridData(gridData, nvar.getYDimension().getValues(),
nvar.getZDimension().getValues(), missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2454,11 +2430,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getXDimension().getValues();
aGridData.yArray = nvar.getZDimension().getValues();
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getXDimension().getValues(),
nvar.getZDimension().getValues(), missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2548,11 +2521,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getTDimension().getValues();
aGridData.yArray = nvar.getZDimension().getValues();
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getTDimension().getValues(),
nvar.getZDimension().getValues(), missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2633,11 +2603,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getTDimension().getValues();
aGridData.yArray = new double[1];
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getTDimension().getValues(),
new double[1], missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2718,11 +2685,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getZDimension().getValues();
aGridData.yArray = new double[1];
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getZDimension().getValues(),
new double[1], missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2803,11 +2767,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getXDimension().getValues();
aGridData.yArray = new double[1];
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getXDimension().getValues(),
new double[1], missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -2888,11 +2849,8 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = nvar.getYDimension().getValues();
aGridData.yArray = new double[1];
aGridData.missingValue = missingValue;
GridData aGridData = new GridData(gridData, nvar.getYDimension().getValues(),
new double[1], missingValue);
return aGridData;
} catch (IOException | ucar.ma2.InvalidRangeException ex) {
@ -3378,12 +3336,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
}
GridData aGridData = new GridData();
aGridData.data = gridData;
aGridData.xArray = xdim.getValues();
aGridData.yArray = ydim.getValues();
return aGridData;
return new GridData(gridData, xdim.getValues(), ydim.getValues());
}
/**
@ -3393,7 +3346,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
* @return NetCDF array 2D
*/
public static Array gridToArray2D(GridData gData) {
Array a = Array.factory(gData.data);
Array a = Array.factory(gData.getData());
int[] shape = new int[2];
shape[0] = gData.getYNum();
shape[1] = gData.getXNum();
@ -3409,7 +3362,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
* @return NetCDF array 3D
*/
public static Array gridToArray3D(GridData gData) {
Array a = Array.factory(gData.data);
Array a = Array.factory(gData.getData());
int[] shape = new int[3];
shape[0] = 1;
shape[1] = gData.getYNum();
@ -3426,7 +3379,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
* @return NetCDF array 4D
*/
public static Array gridToArray4D(GridData gData) {
Array a = Array.factory(gData.data);
Array a = Array.factory(gData.getData());
int[] shape = new int[4];
shape[0] = 1;
shape[1] = 1;

View File

@ -74,10 +74,10 @@ public class LegendManage {
//Generate lengendscheme
if (aLT == LegendType.UNIQUE_VALUE) {
aLS = createUniqValueLegendScheme(CValues, colors,
aST, MinData, MaxData, hasUndef, aGridData.missingValue);
aST, MinData, MaxData, hasUndef, aGridData.getDoubleMissingValue());
} else {
aLS = createGraduatedLegendScheme(CValues, colors,
aST, MinData, MaxData, hasUndef, aGridData.missingValue);
aST, MinData, MaxData, hasUndef, aGridData.getDoubleMissingValue());
}
return aLS;
@ -1311,7 +1311,7 @@ public class LegendManage {
boolean hasUndef = gdata.getMaxMinValue(maxmin);
double min = maxmin[1];
double max = maxmin[0];
return createLegendScheme(min, max, interval, legendType, shapeType, hasUndef, gdata.missingValue);
return createLegendScheme(min, max, interval, legendType, shapeType, hasUndef, gdata.getDoubleMissingValue());
}
/**
@ -1329,7 +1329,7 @@ public class LegendManage {
boolean hasUndef = gdata.getMaxMinValue(maxmin);
double min = maxmin[1];
double max = maxmin[0];
return createLegendScheme(min, max, n, legendType, shapeType, hasUndef, gdata.missingValue);
return createLegendScheme(min, max, n, legendType, shapeType, hasUndef, gdata.getDoubleMissingValue());
}
/**
@ -1348,7 +1348,7 @@ public class LegendManage {
boolean hasUndef = gdata.getMaxMinValue(maxmin);
double min = maxmin[1];
double max = maxmin[0];
return createLegendScheme(min, max, n, ct, legendType, shapeType, hasUndef, gdata.missingValue);
return createLegendScheme(min, max, n, ct, legendType, shapeType, hasUndef, gdata.getDoubleMissingValue());
}
/**

View File

@ -683,15 +683,15 @@ public class DrawMeteoData {
Object[] ccs = LegendManage.getContoursAndColors(ls);
double[] cValues = (double[]) ccs[0];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] xArray = gridData.xArray;
double[] yArray = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(xArray);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(yArray);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, xArray, yArray, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, xArray, yArray, gridData.getDoubleMissingValue(), S1);
List<PolyLine> ContourLines = (List<PolyLine>) cbs[0];
if (ContourLines.isEmpty()) {
@ -908,22 +908,22 @@ public class DrawMeteoData {
maxData = maxmin[0];
minData = maxmin[1];
int[][] S1 = new int[gridData.data.length][gridData.data[0].length];
double[] xArray = gridData.xArray;
double[] yArray = gridData.yArray;
if (gridData.getXDelt() < 0)
int[][] S1 = new int[gridData.getYNum()][gridData.getXNum()];
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
if (gridData.getXDelta() < 0)
ArrayUtils.reverse(xArray);
if (gridData.getYDelt() < 0)
if (gridData.getYDelta() < 0)
ArrayUtils.reverse(yArray);
Object[] cbs = ContourDraw.tracingContourLines(gridData.data,
cValues, xArray, yArray, gridData.missingValue, S1);
Object[] cbs = ContourDraw.tracingContourLines(gridData.getData(),
cValues, xArray, yArray, gridData.getDoubleMissingValue(), S1);
ContourLines = (List<PolyLine>) cbs[0];
List<wcontour.global.Border> borders = (List<wcontour.global.Border>) cbs[1];
if (isSmooth) {
ContourLines = wcontour.Contour.smoothLines(ContourLines);
}
ContourPolygons = ContourDraw.tracingPolygons(gridData.data, ContourLines, borders, cValues);
ContourPolygons = ContourDraw.tracingPolygons(gridData.getData(), ContourLines, borders, cValues);
//wContour.Global.Polygon aPolygon;
//Color aColor;
@ -1051,38 +1051,40 @@ public class DrawMeteoData {
Field aDC = new Field(fieldName, DataType.DOUBLE);
aLayer.editAddField(aDC);
double XDelt = gridData.xArray[1] - gridData.xArray[0];
double YDelt = gridData.yArray[1] - gridData.yArray[0];
double XDelt = gridData.getXDelta();
double YDelt = gridData.getYDelta();
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
for (i = 0; i < gridData.getYNum(); i++) {
for (j = 0; j < gridData.getXNum(); j++) {
PList = new ArrayList<>();
aPoint = new PointD();
aPoint.X = gridData.xArray[j] - XDelt / 2;
aPoint.Y = gridData.yArray[i] - YDelt / 2;
aPoint.X = xArray[j] - XDelt / 2;
aPoint.Y = yArray[i] - YDelt / 2;
PList.add(aPoint);
aPoint = new PointD();
aPoint.X = gridData.xArray[j] - XDelt / 2;
aPoint.Y = gridData.yArray[i] + YDelt / 2;
aPoint.X = xArray[j] - XDelt / 2;
aPoint.Y = yArray[i] + YDelt / 2;
PList.add(aPoint);
aPoint = new PointD();
aPoint.X = gridData.xArray[j] + XDelt / 2;
aPoint.Y = gridData.yArray[i] + YDelt / 2;
aPoint.X = xArray[j] + XDelt / 2;
aPoint.Y = yArray[i] + YDelt / 2;
PList.add(aPoint);
aPoint = new PointD();
aPoint.X = gridData.xArray[j] + XDelt / 2;
aPoint.Y = gridData.yArray[i] - YDelt / 2;
aPoint.X = xArray[j] + XDelt / 2;
aPoint.Y = yArray[i] - YDelt / 2;
PList.add(aPoint);
PList.add(PList.get(0));
PolygonShape aPGS = new PolygonShape();
aPGS.lowValue = gridData.data[i][j];
aPGS.lowValue = gridData.getDoubleValue(i, j);
aPGS.highValue = aPGS.lowValue;
aPGS.setPoints(PList);
int shapeNum = aLayer.getShapeNum();
try {
if (aLayer.editInsertShape(aPGS, shapeNum)) {
aLayer.editCellValue(fieldName, shapeNum, gridData.data[i][j]);
aLayer.editCellValue(fieldName, shapeNum, gridData.getDoubleValue(i, j));
}
} catch (Exception ex) {
Logger.getLogger(DrawMeteoData.class.getName()).log(Level.SEVERE, null, ex);
@ -1213,19 +1215,21 @@ public class DrawMeteoData {
Field aDC = new Field(fieldName, DataType.DOUBLE);
aLayer.editAddField(aDC);
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
for (i = 0; i < gridData.getYNum(); i++) {
for (j = 0; j < gridData.getXNum(); j++) {
aPoint = new PointD();
aPoint.X = gridData.xArray[j];
aPoint.Y = gridData.yArray[i];
aPoint.X = xArray[j];
aPoint.Y = yArray[i];
PointShape aPointShape = new PointShape();
aPointShape.setPoint(aPoint);
aPointShape.setValue(gridData.data[i][j]);
aPointShape.setValue(gridData.getDoubleValue(i, j));
int shapeNum = aLayer.getShapeNum();
try {
if (aLayer.editInsertShape(aPointShape, shapeNum)) {
aLayer.editCellValue(fieldName, shapeNum, gridData.data[i][j]);
aLayer.editCellValue(fieldName, shapeNum, gridData.getDoubleValue(i, j));
}
} catch (Exception ex) {
Logger.getLogger(DrawMeteoData.class.getName()).log(Level.SEVERE, null, ex);
@ -1343,8 +1347,8 @@ public class DrawMeteoData {
double windDir, windSpeed;
float size = 6;
PointD aPoint;
int XNum = uData.xArray.length;
int YNum = uData.yArray.length;
int XNum = uData.getXNum();
int YNum = uData.getYNum();
String columnName = lName.split("_")[0];
VectorLayer aLayer = new VectorLayer(ShapeTypes.POINT);
@ -1363,15 +1367,17 @@ public class DrawMeteoData {
aLayer.editAddField(columnName, DataType.FLOAT);
}
double[] xArray = uData.getXArray();
double[] yArray = uData.getYArray();
for (i = 0; i < YNum; i++) {
for (j = 0; j < XNum; j++) {
windDir = windDirData.data[i][j];
windSpeed = windSpeedData.data[i][j];
if (!MIMath.doubleEquals(windDir, windDirData.missingValue)) {
if (!MIMath.doubleEquals(windSpeed, windSpeedData.missingValue)) {
windDir = windDirData.getDoubleValue(i, j);
windSpeed = windSpeedData.getDoubleValue(i, j);
if (!MIMath.doubleEquals(windDir, windDirData.getDoubleMissingValue())) {
if (!MIMath.doubleEquals(windSpeed, windSpeedData.getDoubleMissingValue())) {
aPoint = new PointD();
aPoint.X = uData.xArray[j];
aPoint.Y = uData.yArray[i];
aPoint.X = xArray[j];
aPoint.Y = yArray[i];
WindArrow aArraw = new WindArrow();
aArraw.angle = windDir;
aArraw.length = (float) windSpeed;
@ -1379,20 +1385,20 @@ public class DrawMeteoData {
aArraw.setPoint(aPoint);
if (ifColor) {
aArraw.setValue(gridData.data[i][j]);
aArraw.setValue(gridData.getDoubleValue(i, j));
}
int shapeNum = aLayer.getShapeNum();
try {
if (aLayer.editInsertShape(aArraw, shapeNum)) {
if (isUV) {
aLayer.editCellValue("U", shapeNum, uData.data[i][j]);
aLayer.editCellValue("V", shapeNum, vData.data[i][j]);
aLayer.editCellValue("U", shapeNum, uData.getDoubleValue(i, j));
aLayer.editCellValue("V", shapeNum, vData.getDoubleValue(i, j));
}
aLayer.editCellValue("WindDirection", shapeNum, aArraw.angle);
aLayer.editCellValue("WindSpeed", shapeNum, aArraw.length);
if (ifColor && ifAdd) {
aLayer.editCellValue(columnName, shapeNum, gridData.data[i][j]);
aLayer.editCellValue(columnName, shapeNum, gridData.getDoubleValue(i, j));
}
}
} catch (Exception ex) {
@ -1525,8 +1531,8 @@ public class DrawMeteoData {
WindBarb aWB;
double windDir, windSpeed;
PointD aPoint;
int XNum = windDirData.xArray.length;
int YNum = windDirData.yArray.length;
int XNum = windDirData.getXNum();
int YNum = windDirData.getYNum();
String columnName = lName.split("_")[0];
VectorLayer aLayer = new VectorLayer(ShapeTypes.POINT);
@ -1545,31 +1551,33 @@ public class DrawMeteoData {
aLayer.editAddField(columnName, DataType.FLOAT);
}
double[] xArray = windDirData.getXArray();
double[] yArray = windDirData.getYArray();
for (i = 0; i < YNum; i++) {
for (j = 0; j < XNum; j++) {
windDir = windDirData.data[i][j];
windSpeed = windSpeedData.data[i][j];
if (!MIMath.doubleEquals(windDir, windDirData.missingValue)) {
if (!MIMath.doubleEquals(windSpeed, windSpeedData.missingValue)) {
windDir = windDirData.getDoubleValue(i, j);
windSpeed = windSpeedData.getDoubleValue(i, j);
if (!MIMath.doubleEquals(windDir, windDirData.getDoubleMissingValue())) {
if (!MIMath.doubleEquals(windSpeed, windSpeedData.getDoubleMissingValue())) {
aPoint = new PointD();
aPoint.X = windDirData.xArray[j];
aPoint.Y = windDirData.yArray[i];
aPoint.X = xArray[j];
aPoint.Y = yArray[i];
aWB = Draw.calWindBarb((float) windDir, (float) windSpeed, 0, 10, aPoint);
if (ifColor) {
aWB.setValue(gridData.data[i][j]);
aWB.setValue(gridData.getDoubleValue(i, j));
}
int shapeNum = aLayer.getShapeNum();
try {
if (aLayer.editInsertShape(aWB, shapeNum)) {
if (isUV) {
aLayer.editCellValue("U", shapeNum, uData.data[i][j]);
aLayer.editCellValue("V", shapeNum, vData.data[i][j]);
aLayer.editCellValue("U", shapeNum, uData.getDoubleValue(i, j));
aLayer.editCellValue("V", shapeNum, vData.getDoubleValue(i, j));
}
aLayer.editCellValue("WindDirection", shapeNum, aWB.angle);
aLayer.editCellValue("WindSpeed", shapeNum, aWB.windSpeed);
if (ifColor && ifAdd) {
aLayer.editCellValue(columnName, shapeNum, gridData.data[i][j]);
aLayer.editCellValue(columnName, shapeNum, gridData.getDoubleValue(i, j));
}
}
} catch (Exception ex) {
@ -1676,8 +1684,8 @@ public class DrawMeteoData {
vGridData = uvData[1];
}
List<PolyLine> streamlines = wcontour.Contour.tracingStreamline(uGridData.data, vGridData.data,
uGridData.xArray, vGridData.yArray, uGridData.missingValue, density);
List<PolyLine> streamlines = wcontour.Contour.tracingStreamline(uGridData.getData(), vGridData.getData(),
uGridData.getXArray(), vGridData.getYArray(), uGridData.getDoubleMissingValue(), density);
PolyLine aLine;
VectorLayer aLayer = new VectorLayer(ShapeTypes.POLYLINE);

View File

@ -29,22 +29,24 @@ public class GeoMathUtil {
int yNum = gridData.getYNum();
GridData cGrid = new GridData(gridData);
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
for (int i = 0; i < yNum; i++) {
if (gridData.yArray[i] >= aPGS.getExtent().minY && gridData.yArray[i] <= aPGS.getExtent().maxY) {
if (yArray[i] >= aPGS.getExtent().minY && yArray[i] <= aPGS.getExtent().maxY) {
for (int j = 0; j < xNum; j++) {
if (gridData.xArray[j] >= aPGS.getExtent().minX && gridData.xArray[j] <= aPGS.getExtent().maxX) {
if (GeoComputation.pointInPolygon(aPGS, new PointD(gridData.xArray[j], gridData.yArray[i]))) {
cGrid.data[i][j] = gridData.data[i][j];
if (xArray[j] >= aPGS.getExtent().minX && xArray[j] <= aPGS.getExtent().maxX) {
if (GeoComputation.pointInPolygon(aPGS, new PointD(xArray[j], yArray[i]))) {
cGrid.setValue(i, j, gridData.getDoubleValue(i, j));
} else {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
} else {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
}
} else {
for (int j = 0; j < xNum; j++) {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
}
}
@ -64,12 +66,14 @@ public class GeoMathUtil {
int yNum = gridData.getYNum();
GridData cGrid = new GridData(gridData);
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
for (int i = 0; i < yNum; i++) {
for (int j = 0; j < xNum; j++) {
if (GeoComputation.pointInPolygons(polygons, new PointD(gridData.xArray[j], gridData.yArray[i]))) {
cGrid.data[i][j] = gridData.data[i][j];
if (GeoComputation.pointInPolygons(polygons, new PointD(xArray[j], yArray[i]))) {
cGrid.setValue(i, j, gridData.getDoubleValue(i, j));
} else {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
}
}
@ -92,22 +96,24 @@ public class GeoMathUtil {
int xNum = gridData.getXNum();
int yNum = gridData.getYNum();
GridData cGrid = new GridData(gridData);
double[] xArray = gridData.getXArray();
double[] yArray = gridData.getYArray();
for (int i = 0; i < yNum; i++) {
if (gridData.yArray[i] >= maskLayer.getExtent().minY && gridData.yArray[i] <= maskLayer.getExtent().maxY) {
if (yArray[i] >= maskLayer.getExtent().minY && yArray[i] <= maskLayer.getExtent().maxY) {
for (int j = 0; j < xNum; j++) {
if (gridData.xArray[j] >= maskLayer.getExtent().minX && gridData.xArray[j] <= maskLayer.getExtent().maxX) {
if (GeoComputation.pointInPolygonLayer(maskLayer, new PointD(gridData.xArray[j], gridData.yArray[i]), false)) {
cGrid.data[i][j] = gridData.data[i][j];
if (xArray[j] >= maskLayer.getExtent().minX && xArray[j] <= maskLayer.getExtent().maxX) {
if (GeoComputation.pointInPolygonLayer(maskLayer, new PointD(xArray[j], yArray[i]), false)) {
cGrid.setValue(i, j, gridData.getDoubleValue(i, j));
} else {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
} else {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
}
} else {
for (int j = 0; j < xNum; j++) {
cGrid.data[i][j] = gridData.missingValue;
cGrid.setValue(i, j, gridData.getDoubleMissingValue());
}
}
}
@ -260,19 +266,13 @@ public class GeoMathUtil {
stationData.filterData_Radius(0, interSet.getGridDataSetting().dataExtent);
double[][] gData = InterpUtil.barnes(stationData.getX(), stationData.getY(), stationData.getStData(),
X, Y, interSet.getRadiusList(), 1., 1.);
aGridData = new GridData();
aGridData.xArray = X;
aGridData.yArray = Y;
aGridData.data = gData;
aGridData = new GridData(gData, X, Y);
break;
case KRIGING:
stationData.filterData_Radius(0, interSet.getGridDataSetting().dataExtent);
gData = InterpUtil.kriging(stationData.getX(), stationData.getY(), stationData.getStData(),
X, Y, interSet.getBeta());
aGridData = new GridData();
aGridData.xArray = X;
aGridData.yArray = Y;
aGridData.data = gData;
aGridData = new GridData(gData, X, Y);
break;
case ASSIGN_POINT_GRID:
stationData.filterData_Radius(0, interSet.getGridDataSetting().dataExtent);
@ -299,13 +299,7 @@ public class GeoMathUtil {
double[][] dataArray;
dataArray = wcontour.Interpolate.interpolation_IDW_Radius(S, X, Y, minPNum, radius, missingValue);
GridData gridData = new GridData();
gridData.data = dataArray;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = Y;
return gridData;
return new GridData(dataArray, X, Y, missingValue);
}
/**
@ -346,13 +340,7 @@ public class GeoMathUtil {
public static GridData interpolate_Neighbor(double[][] S, double[] X, double[] Y, int pNum, double missingValue) {
double[][] dataArray = wcontour.Interpolate.interpolation_IDW_Neighbor(S, X, Y, pNum, missingValue);
GridData gridData = new GridData();
gridData.data = dataArray;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = Y;
return gridData;
return new GridData(dataArray, X, Y, missingValue);
}
/**
@ -392,13 +380,7 @@ public class GeoMathUtil {
List<Double> radList, double missingValue) {
double[][] dataArray = wcontour.Interpolate.cressman(S, X, Y, missingValue, radList);
GridData gridData = new GridData();
gridData.data = dataArray;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = Y;
return gridData;
return new GridData(dataArray, X, Y, missingValue);
}
/**
@ -441,13 +423,7 @@ public class GeoMathUtil {
public static GridData interpolate_Assign(double[][] S, double[] X, double[] Y, double missingValue) {
double[][] dataArray = wcontour.Interpolate.assignPointToGrid(S, X, Y, missingValue);
GridData gridData = new GridData();
gridData.data = dataArray;
gridData.missingValue = missingValue;
gridData.xArray = X;
gridData.yArray = Y;
return gridData;
return new GridData(dataArray, X, Y, missingValue);
}
/**

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\common_math\spatial">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
<RecentFolder Folder="D:\Run\emips\run_meic"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\grib">
<RecentFolder Folder="D:\Run\emips"/>
<RecentFolder Folder="D:\Run\emips\run_cams"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
@ -12,21 +10,25 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\spatial"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\interpolate\griddata_kriging.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\kmeans_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\spatial\pdist_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\grib\grapes_3km_orig.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\interpolate\griddata_kriging.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\kmeans_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\spatial\pdist_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\io\grib\grapes_3km_orig.py"/>
</RecentFiles>
</File>
<Font>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="config.xml" Type="configurefile">
<Path OpenPath="D:\Temp"/>
<Path OpenPath="D:\Temp\grads"/>
<Font>
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
<LegendFont FontName="宋体" FontSize="12"/>

View File

@ -41,38 +41,13 @@
<VisibleScale EnableMaxVisScale="false" EnableMinVisScale="false" MaxVisScale="0.0" MinVisScale="0.0"/>
</Layer>
</GroupLayer>
<Graphics>
<Graphic>
<Shape Selected="false" ShapeType="POINT" Visible="true">
<Points>
<Point X="106.39914497430632" Y="55.56145018191728"/>
</Points>
</Shape>
<Legend Angle="0.0" Color="0xff0033cc" FontBold="false" FontName="Arial" FontSize="20" LegendType="LABEL_BREAK" Text="Text&#10;Line2&#10;Line3" YShift="33.5"/>
</Graphic>
<Graphic>
<Shape Selected="true" ShapeType="POINT" Visible="true">
<Points>
<Point X="77.38859672823503" Y="55.89738587600925"/>
</Points>
</Shape>
<Legend Angle="0.0" Color="0xffff0000" FontBold="false" FontName="Verdana" FontSize="20" LegendType="LABEL_BREAK" Text="Text" YShift="10.5"/>
</Graphic>
<Graphic>
<Shape Selected="false" ShapeType="POINT" Visible="true">
<Points>
<Point X="94.77296447753906" Y="49.94377517700195"/>
</Points>
</Shape>
<Legend Angle="0.0" CharIndex="0" Color="0xff000000" DrawFill="true" DrawOutline="true" FontName="Arial" ImagePath="" LegendType="POINT_BREAK" MarkerType="SIMPLE" OutlineColor="0xff000000" Size="10.0" Style="CIRCLE"/>
</Graphic>
</Graphics>
<Graphics/>
</MapFrame>
</MapFrames>
<Layout BackColor="0xffffffff" ForeColor="0xff000000" Landscape="true" PaperSizeHeight="900" PaperSizeName="Custom" PaperSizeWidth="500" SmoothingMode="false">
<LayoutElements>
<LayoutMap DrawBackColor="false" DrawDegreeSymbol="false" DrawGridLabel="true" DrawGridLine="false" DrawNeatLine="true" ElementType="LAYOUT_MAP" GridFontName="Arial" GridFontSize="12" GridLabelPosition="LEFT_BOTTOM" GridLineColor="0xff808080" GridLineSize="1.0" GridLineStyle="DASH" GridXDelt="10.0" GridXOrigin="-180.0" GridYDelt="10.0" GridYOrigin="-90.0" Height="364" Left="48" NeatLineColor="0xff000000" NeatLineSize="1.0" Top="30" Width="776"/>
<LayoutGraphic ElementType="LAYOUT_GRAPHIC" Height="67" IsTitle="false" Left="754" Top="136" Width="48">
<LayoutGraphic ElementType="LAYOUT_GRAPHIC" Height="67" IsTitle="false" Left="730" Top="135" Width="48">
<Graphic>
<Shape Selected="false" ShapeType="POINT" Visible="true">
<Points>

View File

@ -77,7 +77,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
private MeteoDataInfo _meteoDataInfo = new MeteoDataInfo();
private MeteoUVSet meteoUVSet = new MeteoUVSet();
DrawType2D _2DDrawType;
private GridData _gridData = new GridData();
private GridData _gridData;
private StationData _stationData = new StationData();
boolean _useSameLegendScheme = false;
boolean _useSameGridInterSet = false;
@ -1049,7 +1049,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
viewGridData();
} else if (_meteoDataInfo.isStationData()) {
viewStationData();
if (_gridData.xArray != null && _gridData.yArray != null) {
if (_gridData.getXArray() != null && _gridData.getYArray() != null) {
if (_gridData.getXNum() > 0 && _gridData.getYNum() > 0) {
viewGridData();
}
@ -1062,11 +1062,11 @@ public class FrmMeteoData extends javax.swing.JDialog {
return;
}
if (_gridData.data == null) {
if (_gridData.getData() == null) {
return;
}
if (_gridData.data.length == 0) {
if (_gridData.getYNum() == 0) {
return;
}

View File

@ -556,8 +556,8 @@ public class FrmOneDim extends javax.swing.JFrame {
double[] xvs = new double[itemCount];
double[] yvs = new double[itemCount];
for (int i = 0; i < itemCount; i++) {
xvs[i] = gData.xArray[i];
yvs[i] = gData.data[0][i];
xvs[i] = gData.getXArray()[i];
yvs[i] = gData.getData()[0][i];
}
if (this.isSamePlotDim && this._chartPanel.getChart() != null) {
XY1DPlot plot = (XY1DPlot) this._chartPanel.getChart().getPlot();
@ -596,7 +596,7 @@ public class FrmOneDim extends javax.swing.JFrame {
} else {
XYListDataset dataset = new XYListDataset();
dataset.addSeries(seriesKey, xvs, yvs);
dataset.setMissingValue(gData.missingValue);
dataset.setMissingValue(gData.getDoubleMissingValue());
String title = varName + "_" + this.jComboBox_PlotDim.getSelectedItem().toString() + " Graph";
PlotOrientation po = PlotOrientation.VERTICAL;
@ -679,12 +679,12 @@ public class FrmOneDim extends javax.swing.JFrame {
double[] xvs = new double[itemCount];
double[] yvs = new double[itemCount];
for (int i = 0; i < itemCount; i++) {
xvs[i] = gData.xArray[i];
yvs[i] = gData.data[0][i];
xvs[i] = gData.getXArray()[i];
yvs[i] = gData.getDoubleValue(0, i);
}
XYListDataset dataset = new XYListDataset();
dataset.addSeries(seriesKey, xvs, yvs);
dataset.setMissingValue(gData.missingValue);
dataset.setMissingValue(gData.getDoubleMissingValue());
String title = varName + "_" + this.jComboBox_PlotDim.getSelectedItem().toString() + " Graph";
PlotOrientation po = PlotOrientation.VERTICAL;

View File

@ -883,11 +883,11 @@ public class FrmSectionPlot extends javax.swing.JFrame {
return;
}
if (_gridData.data == null) {
if (_gridData.getData() == null) {
return;
}
if (_gridData.data.length == 0) {
if (_gridData.getData().length == 0) {
return;
}
@ -1966,12 +1966,12 @@ public class FrmSectionPlot extends javax.swing.JFrame {
setXYCoords(_gridData);
if (this.jCheckBox_YReverse.isVisible() && this.jCheckBox_YReverse.isSelected()) {
double[][] aGD = (double[][]) _gridData.data.clone();
double[][] aGD = (double[][]) _gridData.getData().clone();
int yn = _gridData.getYNum();
int xn = _gridData.getXNum();
for (int i = 0; i < yn; i++) {
for (int j = 0; j < xn; j++) {
_gridData.data[i][j] = aGD[yn - i - 1][j];
_gridData.setValue(i, j, aGD[yn - i - 1][j]);
}
}
}
@ -2033,50 +2033,41 @@ public class FrmSectionPlot extends javax.swing.JFrame {
}
private void setXYCoords(GridData aGridData) {
if (aGridData == null) {
aGridData = new GridData();
}
int i;
int xNum = 0, yNum = 0;
switch (_plotDimension) {
case Time_Lon:
xNum = this.jComboBox_Lon1.getItemCount();
yNum = this.jComboBox_Time1.getItemCount();
aGridData.xArray = new double[xNum];
aGridData.yArray = new double[yNum];
break;
case Time_Lat:
xNum = this.jComboBox_Lat1.getItemCount();
yNum = this.jComboBox_Time1.getItemCount();
aGridData.xArray = new double[xNum];
aGridData.yArray = new double[yNum];
break;
case Level_Lat:
xNum = this.jComboBox_Lat1.getItemCount();
yNum = this.jComboBox_Level1.getItemCount();
aGridData.xArray = new double[xNum];
aGridData.yArray = new double[yNum];
break;
case Level_Lon:
xNum = this.jComboBox_Lon1.getItemCount();
yNum = this.jComboBox_Level1.getItemCount();
aGridData.xArray = new double[xNum];
aGridData.yArray = new double[yNum];
break;
case Level_Time:
xNum = this.jComboBox_Time1.getItemCount();
yNum = this.jComboBox_Level1.getItemCount();
aGridData.xArray = new double[xNum];
aGridData.yArray = new double[yNum];
break;
}
double[] xArray = new double[xNum];
double[] yArray = new double[yNum];
for (i = 0; i < xNum; i++) {
aGridData.xArray[i] = i;
xArray[i] = i;
}
for (i = 0; i < yNum; i++) {
aGridData.yArray[i] = i;
yArray[i] = i;
}
aGridData.setXArray(xArray);
aGridData.setYArray(yArray);
}
private void zoomToExtent(Extent aExtent) {

View File

@ -63,7 +63,7 @@ public class FrmViewData extends javax.swing.JFrame {
for (int i = 0; i < yNum; i++) {
for (int j = 0; j < xNum; j++) {
tData[i][j] = String.format(dFormat, gData.data[i][j]);
tData[i][j] = String.format(dFormat, gData.getDoubleValue(i, j));
}
}
@ -305,7 +305,7 @@ public class FrmViewData extends javax.swing.JFrame {
fileName = fileName + "." + extent;
}
ProjectionInfo projInfo = ((GridData) _data).projInfo;
ProjectionInfo projInfo = ((GridData) _data).getProjInfo();
if (projInfo.isLonLat()) {
try {
((GridData) _data).toStation(inFile, fileName);