Issue #2508 Added DiscreteGridSlice.getKeys(), deprecated getKey()
Change-Id: I5d47498c2056de1c217927102770092bb57a372c Former-commit-id:42e924e021
[formerly38e33092a2
[formerly 19246ae601e292bd26ba8ba6b9446ef8d82ee663]] Former-commit-id:38e33092a2
Former-commit-id:b61ccc1609
This commit is contained in:
parent
7648e116ad
commit
f0529e0eee
17 changed files with 404 additions and 369 deletions
|
@ -51,6 +51,7 @@
|
|||
# (e.g. grid[mask] = value)
|
||||
# Oct 07, 2013 2424 randerso remove use of pytz
|
||||
# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys in _getGridResults
|
||||
# Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
#
|
||||
########################################################################
|
||||
import types, string, time, sys
|
||||
|
@ -484,7 +485,7 @@ class SmartScript(BaseTool.BaseTool):
|
|||
if result[0].dtype != numpy.int8:
|
||||
# scalar
|
||||
result = result[0]
|
||||
else:
|
||||
else:
|
||||
# discrete or weather
|
||||
keys = JUtil.javaObjToPyVal(slice.getKeyList())
|
||||
result.append(keys)
|
||||
|
@ -650,7 +651,7 @@ class SmartScript(BaseTool.BaseTool):
|
|||
slice = DiscreteGridSlice()
|
||||
bits = self.__dataMgr.getIscDataAccess().getCompositeGrid(gid, exactMatch, slice)
|
||||
keys = []
|
||||
for k in slice.getKey():
|
||||
for k in slice.getKeys():
|
||||
keys.append(str(k))
|
||||
args = (bits.__numpy__[0], slice.getDiscreteGrid().__numpy__[0], keys)
|
||||
return args
|
||||
|
|
|
@ -72,6 +72,7 @@ import com.vividsolutions.jts.geom.MultiPolygon;
|
|||
* 30Jan2013 #15719 jdynina Fixed allowed field size to accept more
|
||||
* than 128 characters
|
||||
* 02/19/2013 1637 randerso Added throws declarations to translateDataFrom
|
||||
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -102,8 +103,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
DiscreteGridSlice thisSlice = getDiscreteSlice();
|
||||
Grid2DByte grid = thisSlice.getDiscreteGrid();
|
||||
|
||||
if (grid.getXdim() != pointsToSmooth.getXdim()
|
||||
|| grid.getYdim() != pointsToSmooth.getYdim()) {
|
||||
if ((grid.getXdim() != pointsToSmooth.getXdim())
|
||||
|| (grid.getYdim() != pointsToSmooth.getYdim())) {
|
||||
statusHandler.handle(
|
||||
Priority.ERROR,
|
||||
"Dimension mismatch in doSmooth: " + getGrid().getXdim()
|
||||
|
@ -121,7 +122,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
getISCGrid(time, slice);
|
||||
}
|
||||
originalGrid = slice.getDiscreteGrid();
|
||||
originalKey = slice.getKey();
|
||||
originalKey = slice.getKeys();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
originalGrid = new Grid2DByte();
|
||||
originalKey = new DiscreteKey[0];
|
||||
|
@ -155,8 +156,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
// uses fewer than nine points if near grid edge,
|
||||
// but always has at least four values to average.
|
||||
Arrays.fill(histo, (short) 0);
|
||||
for (int newx = i - ss; newx <= i + ss; newx++) {
|
||||
for (int newy = j - ss; newy <= j + ss; newy++) {
|
||||
for (int newx = i - ss; newx <= (i + ss); newx++) {
|
||||
for (int newy = j - ss; newy <= (j + ss); newy++) {
|
||||
// if inside grid limits, make a smoothed value
|
||||
if (originalGrid.isValid(newx, newy)) {
|
||||
histo[0xFF & originalGrid.get(newx, newy)]++;
|
||||
|
@ -234,7 +235,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
// complex case - translation is necessary
|
||||
else {
|
||||
// copy the key from the source to the destination
|
||||
setKey(((DiscreteGridSlice) sourceGrid.getGridSlice()).getKey());
|
||||
setKey(((DiscreteGridSlice) sourceGrid.getGridSlice()).getKeys());
|
||||
|
||||
// find no discrete key, which is always the 1st one
|
||||
int nowx = 0;
|
||||
|
@ -340,8 +341,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
protected Grid2DBit doPencilStretch(Date time, WxValue value,
|
||||
Coordinate[] path, Grid2DBit editArea) {
|
||||
Grid2DByte grid = getGrid();
|
||||
if (grid.getXdim() != editArea.getXdim()
|
||||
|| grid.getYdim() != editArea.getYdim()) {
|
||||
if ((grid.getXdim() != editArea.getXdim())
|
||||
|| (grid.getYdim() != editArea.getYdim())) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Dimension mismatch in doPencilStretch: " + grid.getXdim()
|
||||
+ ',' + grid.getYdim() + ' ' + editArea.getXdim()
|
||||
|
@ -675,8 +676,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
protected Grid2DBit doCopy(Date time, Grid2DBit pointsToCopy, Point delta) {
|
||||
DiscreteGridSlice thisSlice = getDiscreteSlice();
|
||||
Grid2DByte sliceGrid = thisSlice.getDiscreteGrid();
|
||||
if (sliceGrid.getXdim() != pointsToCopy.getXdim()
|
||||
|| sliceGrid.getYdim() != pointsToCopy.getYdim()) {
|
||||
if ((sliceGrid.getXdim() != pointsToCopy.getXdim())
|
||||
|| (sliceGrid.getYdim() != pointsToCopy.getYdim())) {
|
||||
throw new IllegalArgumentException("Dimension mismatch in doCopy: "
|
||||
+ sliceGrid.getXdim() + ',' + sliceGrid.getYdim() + ' '
|
||||
+ pointsToCopy.getXdim() + ',' + pointsToCopy.getYdim());
|
||||
|
@ -695,7 +696,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
getISCGrid(time, slice);
|
||||
}
|
||||
originalGrid = slice.getDiscreteGrid();
|
||||
originalKey = slice.getKey();
|
||||
originalKey = slice.getKeys();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
originalGrid = new Grid2DByte();
|
||||
originalKey = new DiscreteKey[0];
|
||||
|
@ -751,8 +752,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
@Override
|
||||
protected Grid2DBit doFillIn(Date time, Grid2DBit pointsToFillIn) {
|
||||
Grid2DByte grid = getGrid();
|
||||
if (grid.getXdim() != pointsToFillIn.getXdim()
|
||||
|| grid.getYdim() != pointsToFillIn.getYdim()) {
|
||||
if ((grid.getXdim() != pointsToFillIn.getXdim())
|
||||
|| (grid.getYdim() != pointsToFillIn.getYdim())) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Dimension mismatch in doFillIn: " + grid.getXdim() + ','
|
||||
+ grid.getYdim() + ' ' + pointsToFillIn.getXdim()
|
||||
|
@ -814,8 +815,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
boolean done = false;
|
||||
while (!done) {
|
||||
// Check for bounds
|
||||
if (coord.x < 0 || coord.x >= gridCells.getXdim()
|
||||
|| coord.y < 0 || coord.y >= gridCells.getYdim()) {
|
||||
if ((coord.x < 0) || (coord.x >= gridCells.getXdim())
|
||||
|| (coord.y < 0) || (coord.y >= gridCells.getYdim())) {
|
||||
done = true;
|
||||
}
|
||||
// Check for bit set
|
||||
|
@ -882,8 +883,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
Grid2DBit points) {
|
||||
Grid2DByte grid = getGrid();
|
||||
Point dim = new Point(grid.getXdim(), grid.getYdim());
|
||||
if (values.getXdim() != dim.x || values.getYdim() != dim.y
|
||||
|| points.getXdim() != dim.x || points.getYdim() != dim.y) {
|
||||
if ((values.getXdim() != dim.x) || (values.getYdim() != dim.y)
|
||||
|| (points.getXdim() != dim.x) || (points.getYdim() != dim.y)) {
|
||||
throw new IllegalArgumentException(
|
||||
"bad values/points dimensions for grid for: "
|
||||
+ this.getParm().getParmID() + " gridDim="
|
||||
|
@ -903,7 +904,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
int numValues = values.getXdim() * values.getYdim();
|
||||
byte[] bp = values.getBuffer().array();
|
||||
for (int i = 0; i < numValues; i++) {
|
||||
if ((0xFF & bp[i]) > key.size() - 1) {
|
||||
if ((0xFF & bp[i]) > (key.size() - 1)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Illegal discrete grid (bad values) in gridSet()");
|
||||
}
|
||||
|
@ -915,7 +916,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
parmId.getCompositeName());
|
||||
|
||||
// REPLACE mode is easy
|
||||
if (parm.getParmState().getCombineMode() == ParmState.CombineMode.REPLACE
|
||||
if ((parm.getParmState().getCombineMode() == ParmState.CombineMode.REPLACE)
|
||||
|| !overlapping) {
|
||||
// create remap array
|
||||
byte[] remap = new byte[256];
|
||||
|
@ -1019,7 +1020,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
}
|
||||
|
||||
private DiscreteKey[] getKey() {
|
||||
return ((DiscreteGridSlice) getGridSlice()).getKey();
|
||||
return ((DiscreteGridSlice) getGridSlice()).getKeys();
|
||||
}
|
||||
|
||||
private void setKey(DiscreteKey[] key) {
|
||||
|
@ -1034,8 +1035,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
|
|||
protected boolean doValid() {
|
||||
String emsg = "Grid contains data which exceeds limits for this parm. ";
|
||||
|
||||
if (!getGridTime().isValid() || getParm() == null
|
||||
|| getGridSlice() == null) {
|
||||
if (!getGridTime().isValid() || (getParm() == null)
|
||||
|| (getGridSlice() == null)) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Invalid grid time, bad parm or data slice");
|
||||
return false; // time, parm, or data slice not valid
|
||||
|
|
|
@ -74,6 +74,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 07/14/09 1995 bphillip Initial release
|
||||
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -105,6 +106,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
}
|
||||
|
||||
// returns corresponding ISC gridid, parm, grid
|
||||
@Override
|
||||
public GridID getISCGridID(GridID id, boolean exactMatch) {
|
||||
|
||||
Parm p = this.getISCParm(id.getParm());
|
||||
|
@ -150,10 +152,12 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParmID getISCParmID(ParmID parmID) {
|
||||
return dataMgr.getParmManager().getISCParmID(parmID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parm getISCParm(Parm p) {
|
||||
|
||||
if (p == null) {
|
||||
|
@ -185,6 +189,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
return iscP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getISCSite(Point loc, GridID gid) {
|
||||
String empty = "";
|
||||
String officeType = gid.getParm().getOfficeType();
|
||||
|
@ -202,6 +207,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inOurSite(Point loc, GridID gid) {
|
||||
// must be our office type to be inOurSite
|
||||
if (!dataMgr.getOfficeType().equals(gid.getParm().getOfficeType())) {
|
||||
|
@ -216,12 +222,14 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxValue getDataPoint(GridID gridID, Coordinate worldLoc)
|
||||
throws GFEServerException {
|
||||
Coordinate gloc = new Coordinate();
|
||||
return getDataPoint(gridID, worldLoc, gloc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxValue getDataPoint(GridID gridID, Coordinate worldLoc,
|
||||
Coordinate gloc) throws GFEServerException {
|
||||
if (gridID.getParm() == null) {
|
||||
|
@ -233,8 +241,8 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
boolean inGrid = false;
|
||||
gloc = MapUtil.latLonToGridCoordinate(worldLoc,
|
||||
PixelOrientation.UPPER_RIGHT, location);
|
||||
inGrid = gloc.x >= 0 && gloc.x < location.getNx() && gloc.y >= 0
|
||||
&& gloc.y < location.getNy();
|
||||
inGrid = (gloc.x >= 0) && (gloc.x < location.getNx()) && (gloc.y >= 0)
|
||||
&& (gloc.y < location.getNy());
|
||||
if (!inGrid) {
|
||||
return WxValue.defaultValue(gridID.getParm());
|
||||
}
|
||||
|
@ -263,6 +271,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
|
||||
ScalarGridSlice slice) {
|
||||
|
||||
|
@ -333,6 +342,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
return getCompositeGrid(gid, exactMatch, slice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
|
||||
VectorGridSlice slice) {
|
||||
|
||||
|
@ -397,6 +407,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
|
||||
WeatherGridSlice slice) {
|
||||
|
||||
|
@ -484,6 +495,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
return siteMask.or(ourSiteMask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
|
||||
DiscreteGridSlice slice) {
|
||||
|
||||
|
@ -519,9 +531,9 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
slice.setDiscreteGrid(primary.getDiscreteSlice().getDiscreteGrid()
|
||||
.clone());
|
||||
DiscreteKey[] keys = new DiscreteKey[primary.getDiscreteSlice()
|
||||
.getKey().length];
|
||||
.getKeys().length];
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
keys[i] = new DiscreteKey(primary.getDiscreteSlice().getKey()[i]);
|
||||
keys[i] = new DiscreteKey(primary.getDiscreteSlice().getKeys()[i]);
|
||||
}
|
||||
|
||||
slice.setKey(keys);
|
||||
|
@ -544,9 +556,9 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
// blend the isc grid into the grid/key for those points set
|
||||
Grid2DByte iscGrid = iscGridData.getDiscreteSlice().getDiscreteGrid();
|
||||
|
||||
DiscreteKey[] iscKey = iscGridData.getDiscreteSlice().getKey();
|
||||
DiscreteKey[] iscKey = iscGridData.getDiscreteSlice().getKeys();
|
||||
|
||||
DiscreteKey[] keyList = slice.getKey();
|
||||
DiscreteKey[] keyList = slice.getKeys();
|
||||
Map<DiscreteKey, Integer> keyIndexMap = new HashMap<DiscreteKey, Integer>(
|
||||
keyList.length);
|
||||
for (int i = 0; i < keyList.length; i++) {
|
||||
|
@ -595,7 +607,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
for (int i = 0; i < available.size(); i++) {
|
||||
String name = available.get(i).getName();
|
||||
|
||||
if (name.length() >= 5 && name.startsWith("ISC_")
|
||||
if ((name.length() >= 5) && name.startsWith("ISC_")
|
||||
&& (name.indexOf('_', 4) == -1)) {
|
||||
String site = name.substring(4);
|
||||
if (knownSites.contains(site)) {
|
||||
|
|
|
@ -184,6 +184,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ant time weighted average.
|
||||
* Apr 02, 2013 #1774 randerso Fixed a possible deadlock issue.
|
||||
* Aug 27, 2013 #2302 randerso Fix simultaneous save issue
|
||||
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -593,7 +594,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
this.grids.acquireReadLock();
|
||||
try {
|
||||
if (this.grids.size() > 0 && !getGridInfo().isTimeIndependentParm()) {
|
||||
if ((this.grids.size() > 0)
|
||||
&& !getGridInfo().isTimeIndependentParm()) {
|
||||
return new TimeRange(
|
||||
this.grids.get(0).getGridTime().getStart(), this.grids
|
||||
.get(this.grids.size() - 1).getGridTime()
|
||||
|
@ -965,7 +967,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
Date[] dateArray = { absTime };
|
||||
IGridData[] gridData = startParmEdit(dateArray);
|
||||
|
||||
if (gridData != null && gridData.length == 1) {
|
||||
if ((gridData != null) && (gridData.length == 1)) {
|
||||
return gridData[0];
|
||||
}
|
||||
|
||||
|
@ -1029,7 +1031,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
IGridData grid = null;
|
||||
grid = overlappingGrid(absTime);
|
||||
|
||||
if (grid != null && isOkToEdit(grid.getGridTime())) {
|
||||
if ((grid != null) && isOkToEdit(grid.getGridTime())) {
|
||||
retGrids.add(grid);
|
||||
affectedTimes.add(grid.getGridTime());
|
||||
saveUndoTimes.add(grid.getGridTime());
|
||||
|
@ -1245,7 +1247,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
boolean invChanged = false;
|
||||
IGridData leftGrid = overlappingGrid(splitTimeRange.getStart());
|
||||
if (leftGrid != null
|
||||
if ((leftGrid != null)
|
||||
&& !leftGrid.getGridTime().getStart()
|
||||
.equals(splitTimeRange.getStart())) {
|
||||
IGridData newGrid = null;
|
||||
|
@ -1266,7 +1268,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
IGridData rightGrid = overlappingGrid(new Date(splitTimeRange.getEnd()
|
||||
.getTime() - 1000));
|
||||
if (rightGrid != null
|
||||
if ((rightGrid != null)
|
||||
&& !rightGrid.getGridTime().getEnd()
|
||||
.equals(splitTimeRange.getEnd())) {
|
||||
IGridData newGrid;
|
||||
|
@ -1355,10 +1357,10 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
// in some cases, you can end up with an invalid TR
|
||||
if (!expTR.isValid()
|
||||
|| orgTR.getStart().getTime() < replaceRange.getStart()
|
||||
.getTime()
|
||||
|| orgTR.getEnd().getTime() > replaceRange.getEnd()
|
||||
.getTime()) {
|
||||
|| (orgTR.getStart().getTime() < replaceRange.getStart()
|
||||
.getTime())
|
||||
|| (orgTR.getEnd().getTime() > replaceRange.getEnd()
|
||||
.getTime())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1461,8 +1463,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
// add proportional value to existing grid
|
||||
float timeRatio = (float) intersect.getDuration()
|
||||
/ (float) orgTR.getDuration();
|
||||
if (grids.get(j).getGridSlice() instanceof IContinuousSlice
|
||||
&& grid.getGridSlice() instanceof IContinuousSlice) {
|
||||
if ((grids.get(j).getGridSlice() instanceof IContinuousSlice)
|
||||
&& (grid.getGridSlice() instanceof IContinuousSlice)) {
|
||||
|
||||
IGridSlice copy;
|
||||
try {
|
||||
|
@ -1656,8 +1658,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
e);
|
||||
}
|
||||
|
||||
if (copy instanceof IContinuousSlice
|
||||
&& newgrid.getGridSlice() instanceof IContinuousSlice) {
|
||||
if ((copy instanceof IContinuousSlice)
|
||||
&& (newgrid.getGridSlice() instanceof IContinuousSlice)) {
|
||||
((IContinuousSlice) copy).operateEquals(Op.MULTIPLY, timeRatio,
|
||||
dataManager.getRefManager().fullRefSet().getGrid());
|
||||
((IContinuousSlice) newgrid.getGridSlice()).operateEquals(
|
||||
|
@ -2068,8 +2070,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
ParmID parmId = getParmID();
|
||||
String siteId = parmId.getDbId().getSiteId();
|
||||
|
||||
if (grids.length == 1
|
||||
&& getGridInfo().getGridType() != GridType.WEATHER) {
|
||||
if ((grids.length == 1)
|
||||
&& (getGridInfo().getGridType() != GridType.WEATHER)) {
|
||||
// nothing to average so we're done, except in the weather case
|
||||
try {
|
||||
gridSlice = grids[0].getGridSlice().clone();
|
||||
|
@ -2119,8 +2121,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
float dur = gridTR.get(k).getDuration();
|
||||
for (int i = 0; i < ge.getSpan(0); i++) {
|
||||
for (int j = 0; j < ge.getSpan(1); j++) {
|
||||
uSum.set(i, j, uSum.get(i, j) + uGrid.get(i, j) * dur);
|
||||
vSum.set(i, j, vSum.get(i, j) + vGrid.get(i, j) * dur);
|
||||
uSum.set(i, j, uSum.get(i, j) + (uGrid.get(i, j) * dur));
|
||||
vSum.set(i, j, vSum.get(i, j) + (vGrid.get(i, j) * dur));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2184,7 +2186,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
// values that exceed the configured percentage
|
||||
ArrayList<WeatherSubKey> weightedKeys = new ArrayList<WeatherSubKey>();
|
||||
for (int k = 0; k < subKeys.size(); k++) {
|
||||
if ((float) wcount.get(k) / totalDuration > significantPercent) {
|
||||
if (((float) wcount.get(k) / totalDuration) > significantPercent) {
|
||||
weightedKeys.add(subKeys.get(k));
|
||||
}
|
||||
}
|
||||
|
@ -2237,7 +2239,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
Map<DiscreteKey, MutableInteger> values = new HashMap<DiscreteKey, MutableInteger>();
|
||||
for (int k = 0; k < gridCount; k++) {
|
||||
DiscreteKey key1[] = ((DiscreteGridSlice) grids[k]
|
||||
.getGridSlice()).getKey();
|
||||
.getGridSlice()).getKeys();
|
||||
Grid2DByte grid1 = ((DiscreteGridSlice) grids[k]
|
||||
.getGridSlice()).getDiscreteGrid();
|
||||
// TextString kv = key1[grid1(i, j)].keyAsString();
|
||||
|
@ -2323,8 +2325,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
public void adjust(float deltaValue, final Date time,
|
||||
final ReferenceData refData) {
|
||||
// Can't adjust weather or discrete
|
||||
if (getGridInfo().getGridType() == GridType.WEATHER
|
||||
|| getGridInfo().getGridType() == GridType.DISCRETE) {
|
||||
if ((getGridInfo().getGridType() == GridType.WEATHER)
|
||||
|| (getGridInfo().getGridType() == GridType.DISCRETE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2348,7 +2350,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
Date[] dateArray = { absTime };
|
||||
IGridData[] gridData = extendParmEdit(dateArray);
|
||||
|
||||
if (gridData != null && gridData.length == 1) {
|
||||
if ((gridData != null) && (gridData.length == 1)) {
|
||||
return gridData[0];
|
||||
}
|
||||
|
||||
|
@ -2434,8 +2436,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
*/
|
||||
public boolean timeShiftTR(TimeRange tr, int secondsToShift,
|
||||
boolean copyOnly) {
|
||||
if (Math.abs(secondsToShift)
|
||||
% this.gridInfo.getTimeConstraints().getRepeatInterval() != 0) {
|
||||
if ((Math.abs(secondsToShift) % this.gridInfo.getTimeConstraints()
|
||||
.getRepeatInterval()) != 0) {
|
||||
throw new IllegalArgumentException("timeShiftSelectedTR of "
|
||||
+ secondsToShift + " not an interval of "
|
||||
+ this.gridInfo.getTimeConstraints().getRepeatInterval()
|
||||
|
@ -2443,15 +2445,15 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
}
|
||||
|
||||
// Make sure the given timeRange is valid and there is something to do
|
||||
if (!tr.isValid() || secondsToShift == 0) {
|
||||
if (!tr.isValid() || (secondsToShift == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate source and destination timeRanges
|
||||
TimeRange sourceTR = new TimeRange(tr.getStart(), tr.getEnd());
|
||||
TimeRange destinationTR = new TimeRange(tr.getStart().getTime()
|
||||
+ secondsToShift * 1000, tr.getEnd().getTime() + secondsToShift
|
||||
* 1000);
|
||||
+ (secondsToShift * 1000), tr.getEnd().getTime()
|
||||
+ (secondsToShift * 1000));
|
||||
|
||||
// Create a combinedTR that includes the all blocks it touches
|
||||
TimeRange combinedTR = destinationTR;
|
||||
|
@ -2502,27 +2504,28 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
for (int i = 0; i < destGrids.length; i++) {
|
||||
TimeRange tr2 = destGrids[i].getGridTime();
|
||||
tr2 = new TimeRange(tr2.getStart().getTime() + secondsToShift
|
||||
* 1000, tr2.getEnd().getTime() + secondsToShift * 1000);
|
||||
tr2 = new TimeRange(tr2.getStart().getTime()
|
||||
+ (secondsToShift * 1000), tr2.getEnd().getTime()
|
||||
+ (secondsToShift * 1000));
|
||||
destGrids[i].changeValidTime(tr2, true);
|
||||
destGrids[i].updateHistoryToModified(this.dataManager.getWsId());
|
||||
}
|
||||
|
||||
// Trim the start of the first copied grid, if necessary
|
||||
if (destGrids[0].getGridTime().getStart().getTime() < sourceTR
|
||||
.getStart().getTime() + secondsToShift * 1000) {
|
||||
if (destGrids[0].getGridTime().getStart().getTime() < (sourceTR
|
||||
.getStart().getTime() + (secondsToShift * 1000))) {
|
||||
TimeRange newTR = new TimeRange(sourceTR.getStart().getTime()
|
||||
+ secondsToShift * 1000, destGrids[0].getGridTime()
|
||||
+ (secondsToShift * 1000), destGrids[0].getGridTime()
|
||||
.getEnd().getTime());
|
||||
destGrids[0].changeValidTime(newTR, true);
|
||||
}
|
||||
|
||||
// Trim the end of the last copied grid, if necessary
|
||||
if (destGrids[destGrids.length - 1].getGridTime().getEnd().getTime() > sourceTR
|
||||
.getEnd().getTime() + secondsToShift * 1000) {
|
||||
if (destGrids[destGrids.length - 1].getGridTime().getEnd().getTime() > (sourceTR
|
||||
.getEnd().getTime() + (secondsToShift * 1000))) {
|
||||
TimeRange newTR = new TimeRange(destGrids[destGrids.length - 1]
|
||||
.getGridTime().getStart().getTime(), sourceTR.getEnd()
|
||||
.getTime() + secondsToShift * 1000);
|
||||
.getTime() + (secondsToShift * 1000));
|
||||
destGrids[destGrids.length - 1].changeValidTime(newTR, true);
|
||||
}
|
||||
|
||||
|
@ -2730,9 +2733,9 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
IGridData leftGrid = overlappingGrid(timeRange.getStart());
|
||||
IGridData rightGrid = overlappingGrid(new Date(timeRange.getEnd()
|
||||
.getTime() - 1000));
|
||||
if ((leftGrid == null || leftGrid.getGridTime().getStart()
|
||||
if (((leftGrid == null) || leftGrid.getGridTime().getStart()
|
||||
.equals(timeRange.getStart()))
|
||||
&& (rightGrid == null || rightGrid.getGridTime().getEnd()
|
||||
&& ((rightGrid == null) || rightGrid.getGridTime().getEnd()
|
||||
.equals(timeRange.getEnd()))) {
|
||||
return false; // nothing to split
|
||||
}
|
||||
|
@ -3180,8 +3183,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
ParmState.CombineMode cCombineMode = this.parmState.getCombineMode();
|
||||
if (this.gridInfo.getGridType() == GFERecord.GridType.VECTOR) {
|
||||
this.parmState.setVectorMode(ParmState.VectorMode.BOTH);
|
||||
} else if (this.gridInfo.getGridType() == GFERecord.GridType.WEATHER
|
||||
|| this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE) {
|
||||
} else if ((this.gridInfo.getGridType() == GFERecord.GridType.WEATHER)
|
||||
|| (this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE)) {
|
||||
this.parmState.setCombineMode(ParmState.CombineMode.REPLACE);
|
||||
}
|
||||
|
||||
|
@ -3198,8 +3201,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
// restore the edit modes
|
||||
if (this.gridInfo.getGridType() == GFERecord.GridType.VECTOR) {
|
||||
this.parmState.setVectorMode(cVectorMode);
|
||||
} else if (this.gridInfo.getGridType() == GFERecord.GridType.WEATHER
|
||||
|| this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE) {
|
||||
} else if ((this.gridInfo.getGridType() == GFERecord.GridType.WEATHER)
|
||||
|| (this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE)) {
|
||||
this.parmState.setCombineMode(cCombineMode);
|
||||
}
|
||||
|
||||
|
@ -3367,13 +3370,13 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
if (interval < tc.getRepeatInterval()) {
|
||||
interval = tc.getRepeatInterval();
|
||||
}
|
||||
if (interval % tc.getRepeatInterval() != 0) {
|
||||
interval = (interval / tc.getRepeatInterval() + 1)
|
||||
if ((interval % tc.getRepeatInterval()) != 0) {
|
||||
interval = ((interval / tc.getRepeatInterval()) + 1)
|
||||
* tc.getRepeatInterval();
|
||||
}
|
||||
}
|
||||
|
||||
if (interval == 0 || duration == 0) {
|
||||
if ((interval == 0) || (duration == 0)) {
|
||||
gridTimes.add(tr);
|
||||
}
|
||||
|
||||
|
@ -3415,8 +3418,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
*/
|
||||
public Parm min(TimeRange timeRange) {
|
||||
// Can't take the minimum of a weather or discrete type
|
||||
if (this.gridInfo.getGridType() == GridType.WEATHER
|
||||
|| this.gridInfo.getGridType() == GridType.DISCRETE) {
|
||||
if ((this.gridInfo.getGridType() == GridType.WEATHER)
|
||||
|| (this.gridInfo.getGridType() == GridType.DISCRETE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -3478,8 +3481,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
*/
|
||||
public Parm max(TimeRange timeRange) {
|
||||
// Can't take the minimum of a weather or discrete type
|
||||
if (this.gridInfo.getGridType() == GridType.WEATHER
|
||||
|| this.gridInfo.getGridType() == GridType.DISCRETE) {
|
||||
if ((this.gridInfo.getGridType() == GridType.WEATHER)
|
||||
|| (this.gridInfo.getGridType() == GridType.DISCRETE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -3541,8 +3544,8 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
*/
|
||||
public Parm sum(TimeRange timeRange) {
|
||||
// Can't take the minimum of a weather or discrete type
|
||||
if (this.gridInfo.getGridType() == GridType.WEATHER
|
||||
|| this.gridInfo.getGridType() == GridType.DISCRETE) {
|
||||
if ((this.gridInfo.getGridType() == GridType.WEATHER)
|
||||
|| (this.gridInfo.getGridType() == GridType.DISCRETE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -3769,7 +3772,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
for (k = 0; k < gridCount; k++) {
|
||||
DiscreteKey[] key1 = ((DiscreteGridSlice) grids[k]
|
||||
.getGridSlice()).getKey();
|
||||
.getGridSlice()).getKeys();
|
||||
Grid2DByte grid1 = ((DiscreteGridSlice) grids[k]
|
||||
.getGridSlice()).getDiscreteGrid();
|
||||
DiscreteKey dkv = key1[grid1.get(i, j)];
|
||||
|
@ -3919,16 +3922,16 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
// left
|
||||
{
|
||||
end = mid - 1;
|
||||
mid = (end - begin) / 2 + begin;
|
||||
mid = ((end - begin) / 2) + begin;
|
||||
} else // on the right
|
||||
{
|
||||
begin = mid + 1;
|
||||
mid = (end - begin) / 2 + begin;
|
||||
mid = ((end - begin) / 2) + begin;
|
||||
}
|
||||
}
|
||||
|
||||
// Did we find it? Last chance...
|
||||
if (mid >= 0 && mid < this.grids.size()
|
||||
if ((mid >= 0) && (mid < this.grids.size())
|
||||
&& this.grids.get(mid).getGridTime().contains(time)) {
|
||||
return this.grids.get(mid);
|
||||
}
|
||||
|
@ -4042,7 +4045,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
}
|
||||
|
||||
// set duration to interval if needed
|
||||
if (interval != 0 && duration == 0) {
|
||||
if ((interval != 0) && (duration == 0)) {
|
||||
duration = interval;
|
||||
}
|
||||
|
||||
|
@ -4120,7 +4123,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
|
||||
// eliminate all of the earlier and the later grids from
|
||||
// basegrids
|
||||
if (endIndex != -1 && endIndex < baseGrids.size() - 1) {
|
||||
if ((endIndex != -1) && (endIndex < (baseGrids.size() - 1))) {
|
||||
baseGrids.subList(endIndex + 1, baseGrids.size()).clear();
|
||||
}
|
||||
if (startIndex >= 1) {
|
||||
|
@ -4160,7 +4163,7 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
st.setTime(st.getTime() + interval * 1000);
|
||||
st.setTime(st.getTime() + (interval * 1000));
|
||||
}
|
||||
|
||||
// now split grids if necessary due to interference with base grids
|
||||
|
@ -4173,12 +4176,12 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
if (bgTime.contains(t)) {
|
||||
break; // can't salvage this one
|
||||
}
|
||||
if (bgTime.getStart().compareTo(t.getStart()) <= 0
|
||||
&& bgTime.getEnd().compareTo(t.getEnd()) < 0) {
|
||||
if ((bgTime.getStart().compareTo(t.getStart()) <= 0)
|
||||
&& (bgTime.getEnd().compareTo(t.getEnd()) < 0)) {
|
||||
newDSTR.add(new TimeRange(bgTime.getEnd(), t.getEnd()));
|
||||
overlaps = true;
|
||||
} else if (bgTime.getStart().compareTo(t.getStart()) > 0
|
||||
&& bgTime.getEnd().compareTo(t.getEnd()) >= 0) {
|
||||
} else if ((bgTime.getStart().compareTo(t.getStart()) > 0)
|
||||
&& (bgTime.getEnd().compareTo(t.getEnd()) >= 0)) {
|
||||
newDSTR.add(new TimeRange(t.getStart(), bgTime
|
||||
.getStart()));
|
||||
overlaps = true;
|
||||
|
@ -4227,13 +4230,13 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
interptimes.add(bs.getValidTime());
|
||||
|
||||
// if a gap's time range fits in here, append to arrays.
|
||||
if (i < baseGrids.size() - 1) {
|
||||
if (i < (baseGrids.size() - 1)) {
|
||||
IGridSlice nbs = baseGrids.get(i + 1).getGridSlice();
|
||||
for (j = 0; j < newDSTR.size(); j++) {
|
||||
TimeRange ntr = newDSTR.get(j);
|
||||
if (ntr.getStart().compareTo(bs.getValidTime().getEnd()) >= 0
|
||||
&& ntr.getEnd().compareTo(
|
||||
nbs.getValidTime().getStart()) <= 0) {
|
||||
if ((ntr.getStart().compareTo(bs.getValidTime().getEnd()) >= 0)
|
||||
&& (ntr.getEnd().compareTo(
|
||||
nbs.getValidTime().getStart()) <= 0)) {
|
||||
// make an empty NONE type GridSlice for the
|
||||
// ones to
|
||||
// be interpolated, and append the time for it.
|
||||
|
@ -4469,11 +4472,11 @@ public abstract class Parm implements Comparable<Parm> {
|
|||
int idx2 = strings.indexOf(parm2);
|
||||
|
||||
// parms in strings come before those that aren't
|
||||
if (idx1 != -1 && idx2 == -1) {
|
||||
if ((idx1 != -1) && (idx2 == -1)) {
|
||||
cmp = -1;
|
||||
} else if (idx1 == -1 && idx2 != -1) {
|
||||
} else if ((idx1 == -1) && (idx2 != -1)) {
|
||||
cmp = 1;
|
||||
} else if (idx1 != -1 && idx2 != -1 && idx1 != idx2) {
|
||||
} else if ((idx1 != -1) && (idx2 != -1) && (idx1 != idx2)) {
|
||||
// both are in strings at different indices.
|
||||
// compare their position in strings.
|
||||
if (idx1 > idx2) {
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.raytheon.viz.gfe.core.griddata.WeatherGridData;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 12, 2012 dgilling Initial creation
|
||||
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
|
||||
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -96,7 +97,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
|
|||
tempNames.addAll(encodeGridAndMask(gd, mask, i, sb, instance));
|
||||
sb.append(')');
|
||||
|
||||
if (i < argTuples.size() - 1) {
|
||||
if (i < (argTuples.size() - 1)) {
|
||||
sb.append(',');
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
|
|||
jepString.append('(');
|
||||
jepString.append(name);
|
||||
jepString.append(',');
|
||||
DiscreteKey[] keys = grid.getDiscreteSlice().getKey();
|
||||
DiscreteKey[] keys = grid.getDiscreteSlice().getKeys();
|
||||
ArrayList<String> stringKeys = new ArrayList<String>(keys.length);
|
||||
for (DiscreteKey k : keys) {
|
||||
stringKeys.add(k.toString());
|
||||
|
|
|
@ -124,6 +124,7 @@ import com.raytheon.viz.gfe.Activator;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 2, 2008 #1161 randerso Initial creation
|
||||
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -380,7 +381,7 @@ public class DiscreteInterp extends Interp {
|
|||
findWxTypeGroups(joint, single);
|
||||
|
||||
// do joint interpolation if needed.
|
||||
if (joint.size() > 0 && joint.get(0) != 0 && joint.get(1) != 0) {
|
||||
if ((joint.size() > 0) && (joint.get(0) != 0) && (joint.get(1) != 0)) {
|
||||
jointInterpControl(joint, workGrid1, workGrid2, groupGrid1,
|
||||
groupGrid2, newGrid, fraction, interpResult);
|
||||
}
|
||||
|
@ -441,8 +442,8 @@ public class DiscreteInterp extends Interp {
|
|||
Grid2DByte grid2 = baseData2.getDiscreteGrid();
|
||||
|
||||
// extract the lists of weatherKeys associated with each index grid
|
||||
DiscreteKey[] keys1 = baseData1.getKey();
|
||||
DiscreteKey[] keys2 = baseData2.getKey();
|
||||
DiscreteKey[] keys1 = baseData1.getKeys();
|
||||
DiscreteKey[] keys2 = baseData2.getKeys();
|
||||
|
||||
// Make a list of DiscreteKeys that spans both keys1 and keys2.
|
||||
|
||||
|
@ -711,18 +712,18 @@ public class DiscreteInterp extends Interp {
|
|||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
if (x > _xDim - 1) {
|
||||
if (x > (_xDim - 1)) {
|
||||
x = _xDim - 1;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
if (y > _yDim - 1) {
|
||||
if (y > (_yDim - 1)) {
|
||||
y = _yDim - 1;
|
||||
}
|
||||
|
||||
// if the point has a different and non-zero value
|
||||
if (grid.get(x, y) != 0 && grid.get(x, y) != wxValue) {
|
||||
if ((grid.get(x, y) != 0) && (grid.get(x, y) != wxValue)) {
|
||||
// have found a contiguous point of differing value
|
||||
|
||||
// set flag for contiguous point
|
||||
|
@ -848,8 +849,8 @@ public class DiscreteInterp extends Interp {
|
|||
for (j = 1; j < _wxTypeInfoMatrix.getYDim(); j++) {
|
||||
// if types match, and
|
||||
// if it contiguous to other types
|
||||
if (_wxTypeList1.get(i).wxType == _wxTypeInfoMatrix.get(0,
|
||||
j) && _wxTypeList1.get(i).isContig) {
|
||||
if ((_wxTypeList1.get(i).wxType == _wxTypeInfoMatrix.get(0,
|
||||
j)) && _wxTypeList1.get(i).isContig) {
|
||||
// now there is a list of the types this one
|
||||
// is contiguous to, but they may not be in
|
||||
// same order as first column in matrix.
|
||||
|
@ -858,10 +859,10 @@ public class DiscreteInterp extends Interp {
|
|||
// when find it, flag in matrix, but only in
|
||||
// upper left half: where j>m
|
||||
for (m = 1; m < _wxTypeInfoMatrix.getXDim(); m++) {
|
||||
if (j > m
|
||||
&& _wxTypeInfoMatrix.get(m, 0) == _wxTypeList1
|
||||
if ((j > m)
|
||||
&& (_wxTypeInfoMatrix.get(m, 0) == _wxTypeList1
|
||||
.get(i).contigWxType.get(k)
|
||||
.intValue()) {
|
||||
.intValue())) {
|
||||
_wxTypeInfoMatrix.set(m, j, 1); // done!
|
||||
}
|
||||
}
|
||||
|
@ -876,14 +877,14 @@ public class DiscreteInterp extends Interp {
|
|||
for (i = 0; i < _wxTypeList2.size(); i++) {
|
||||
if (_wxTypeList2.get(i).wxType != 0) {
|
||||
for (m = 1; m < _wxTypeInfoMatrix.getXDim(); m++) {
|
||||
if (_wxTypeList2.get(i).wxType == _wxTypeInfoMatrix.get(m,
|
||||
0) && _wxTypeList2.get(i).isContig) {
|
||||
if ((_wxTypeList2.get(i).wxType == _wxTypeInfoMatrix.get(m,
|
||||
0)) && _wxTypeList2.get(i).isContig) {
|
||||
for (k = 0; k < _wxTypeList2.get(i).contigWxType.size(); k++) {
|
||||
for (j = 1; j < _wxTypeInfoMatrix.getXDim(); j++) {
|
||||
if (m > j
|
||||
&& _wxTypeInfoMatrix.get(0, j) == _wxTypeList2
|
||||
if ((m > j)
|
||||
&& (_wxTypeInfoMatrix.get(0, j) == _wxTypeList2
|
||||
.get(i).contigWxType.get(k)
|
||||
.intValue()) {
|
||||
.intValue())) {
|
||||
_wxTypeInfoMatrix.set(m, j, 1); // done!
|
||||
}
|
||||
}
|
||||
|
@ -945,9 +946,10 @@ public class DiscreteInterp extends Interp {
|
|||
|
||||
// loop over left col
|
||||
for (n = 1; n < _wxTypeInfoMatrix.getYDim(); n++) {
|
||||
if (n != m // not on diagonal
|
||||
&& _wxTypeInfoMatrix.get(m, n) == 1
|
||||
&& _wxTypeInfoMatrix.get(n, m) == 1) {
|
||||
if ((n != m // not on diagonal
|
||||
)
|
||||
&& (_wxTypeInfoMatrix.get(m, n) == 1)
|
||||
&& (_wxTypeInfoMatrix.get(n, m) == 1)) {
|
||||
jointInterp = true;
|
||||
|
||||
// add _wxTypeInfoMatrix(m,0) to joint if not already
|
||||
|
@ -1080,7 +1082,7 @@ public class DiscreteInterp extends Interp {
|
|||
for (i = 0; i < joint.size(); i++) {
|
||||
if (size[i] != 0) {
|
||||
for (j = i + 1; j < joint.size(); j++) {
|
||||
if (size[j] > size[i] && size[j] > 0) {
|
||||
if ((size[j] > size[i]) && (size[j] > 0)) {
|
||||
tempwx = joint.get(i);
|
||||
tempsize = size[i];
|
||||
joint.set(i, joint.get(j));
|
||||
|
@ -1178,11 +1180,11 @@ public class DiscreteInterp extends Interp {
|
|||
// kind of weather wxValue were found in that grid. Reset the
|
||||
// 0,0 to the other center x,y so the area does not move to the
|
||||
// corner. It will grow or shrink in the same place.
|
||||
if (center1.x == 0 && center1.y == 0) {
|
||||
if ((center1.x == 0) && (center1.y == 0)) {
|
||||
center1.x = center2.x;
|
||||
center1.y = center2.y;
|
||||
}
|
||||
if (center2.x == 0 && center2.y == 0) {
|
||||
if ((center2.x == 0) && (center2.y == 0)) {
|
||||
center2.x = center1.x;
|
||||
center2.y = center1.y;
|
||||
}
|
||||
|
@ -1208,26 +1210,26 @@ public class DiscreteInterp extends Interp {
|
|||
y = j + _dy;
|
||||
|
||||
// if the translated point is still on visible grid
|
||||
if (x >= 0 && x < _xDim && y >= 0 && y < _yDim) {
|
||||
if ((x >= 0) && (x < _xDim) && (y >= 0) && (y < _yDim)) {
|
||||
// if this point is part of BOTH the original area,
|
||||
// and part of the final area when translated,
|
||||
// it is a point in the "core area."
|
||||
if (_featureStart.get(i, j) == wxValue
|
||||
&& _featureEnd.get(x, y) == wxValue) {
|
||||
if ((_featureStart.get(i, j) == wxValue)
|
||||
&& (_featureEnd.get(x, y) == wxValue)) {
|
||||
_coreArea.set(i, j, 1);
|
||||
}
|
||||
|
||||
// if it appears in original grid but not in final grid,
|
||||
// it will "fade away", so note in _fadeArea.
|
||||
if (_featureStart.get(i, j) == wxValue
|
||||
&& _featureEnd.get(x, y) != wxValue) {
|
||||
_fadeArea.set(i + _xDim / 2, j + _yDim / 2, 1);
|
||||
if ((_featureStart.get(i, j) == wxValue)
|
||||
&& (_featureEnd.get(x, y) != wxValue)) {
|
||||
_fadeArea.set(i + (_xDim / 2), j + (_yDim / 2), 1);
|
||||
|
||||
// compute distance "dist" from center of
|
||||
// weather area to this _fadeArea point
|
||||
dist = (float) Math.sqrt((i - center1.x)
|
||||
* (i - center1.x) + (j - center1.y)
|
||||
* (j - center1.y));
|
||||
dist = (float) Math
|
||||
.sqrt(((i - center1.x) * (i - center1.x))
|
||||
+ ((j - center1.y) * (j - center1.y)));
|
||||
|
||||
// compute which angle sector this point lies in
|
||||
deltax = i - center1.x;
|
||||
|
@ -1240,8 +1242,8 @@ public class DiscreteInterp extends Interp {
|
|||
_faControl.set(sector, 1, dist);
|
||||
}
|
||||
// set min distance to edge of _fadeArea in this sector
|
||||
if (dist < _faControl.get(sector, 0)
|
||||
|| _faControl.get(sector, 0) == 0.0f) {
|
||||
if ((dist < _faControl.get(sector, 0))
|
||||
|| (_faControl.get(sector, 0) == 0.0f)) {
|
||||
_faControl.set(sector, 0, dist);
|
||||
}
|
||||
}
|
||||
|
@ -1250,11 +1252,12 @@ public class DiscreteInterp extends Interp {
|
|||
// for original grid points which land
|
||||
// outside data grid when projected:
|
||||
// keep 'em as _fadeArea points.
|
||||
if (_featureStart.get(i, j) == wxValue
|
||||
&& (x < 0 || x >= _xDim || y < 0 || y >= _yDim)) {
|
||||
_fadeArea.set(i + _xDim / 2, j + _yDim / 2, 1);
|
||||
dist = (float) Math.sqrt((i - center1.x) * (i - center1.x)
|
||||
+ (j - center1.y) * (j - center1.y));
|
||||
if ((_featureStart.get(i, j) == wxValue)
|
||||
&& ((x < 0) || (x >= _xDim) || (y < 0) || (y >= _yDim))) {
|
||||
_fadeArea.set(i + (_xDim / 2), j + (_yDim / 2), 1);
|
||||
dist = (float) Math
|
||||
.sqrt(((i - center1.x) * (i - center1.x))
|
||||
+ ((j - center1.y) * (j - center1.y)));
|
||||
|
||||
// compute which angle sector this point lies in
|
||||
deltax = i - center1.x;
|
||||
|
@ -1267,8 +1270,8 @@ public class DiscreteInterp extends Interp {
|
|||
_faControl.set(sector, 1, dist);
|
||||
}
|
||||
// set min distance to edge of _fadeArea in this sector
|
||||
if (dist < _faControl.get(sector, 0)
|
||||
|| _faControl.get(sector, 0) == 0.0f) {
|
||||
if ((dist < _faControl.get(sector, 0))
|
||||
|| (_faControl.get(sector, 0) == 0.0f)) {
|
||||
_faControl.set(sector, 0, dist);
|
||||
}
|
||||
}
|
||||
|
@ -1306,16 +1309,17 @@ public class DiscreteInterp extends Interp {
|
|||
mainy = y - _dy;
|
||||
|
||||
// indices in the _growArea grid:
|
||||
m = mainx + _xDim / 2;
|
||||
n = mainy + _yDim / 2;
|
||||
m = mainx + (_xDim / 2);
|
||||
n = mainy + (_yDim / 2);
|
||||
// (make sure (n,m) inside the _growArea grid)
|
||||
if (m >= 0 && m < 2 * _xDim && n >= 0 && n < 2 * _yDim) {
|
||||
if ((m >= 0) && (m < (2 * _xDim)) && (n >= 0)
|
||||
&& (n < (2 * _yDim))) {
|
||||
_growArea.set(m, n, 1);
|
||||
|
||||
// compute distance "dist" from center of
|
||||
// weather area to this _growArea point
|
||||
arg = (mainx - center1.x) * (mainx - center1.x)
|
||||
+ (mainy - center1.y) * (mainy - center1.y);
|
||||
arg = ((mainx - center1.x) * (mainx - center1.x))
|
||||
+ ((mainy - center1.y) * (mainy - center1.y));
|
||||
dist = (float) Math.sqrt(arg);
|
||||
|
||||
// compute which angle sector this point lies in
|
||||
|
@ -1330,8 +1334,8 @@ public class DiscreteInterp extends Interp {
|
|||
}
|
||||
|
||||
// set min distance to edge of _growArea in this sector
|
||||
if (dist < _gaControl.get(sector, 0)
|
||||
|| _gaControl.get(sector, 0) == 0.0f) {
|
||||
if ((dist < _gaControl.get(sector, 0))
|
||||
|| (_gaControl.get(sector, 0) == 0.0f)) {
|
||||
_gaControl.set(sector, 0, dist);
|
||||
}
|
||||
}
|
||||
|
@ -1373,14 +1377,14 @@ public class DiscreteInterp extends Interp {
|
|||
|
||||
// (A) number of radians per sector = 2 * pi /(how many sectors in
|
||||
// circle)
|
||||
double step = 2.0 * Math.PI / _numSectors;
|
||||
double step = (2.0 * Math.PI) / _numSectors;
|
||||
|
||||
// compartimentalize into sectors:
|
||||
sector = (int) (0.5 + (angle + Math.PI) / step) - 1;
|
||||
sector = (int) (0.5 + ((angle + Math.PI) / step)) - 1;
|
||||
|
||||
// (A)
|
||||
// bad value clamp (should not occur)
|
||||
if (sector < 0 || sector >= _numSectors) {
|
||||
if ((sector < 0) || (sector >= _numSectors)) {
|
||||
sector = 0;
|
||||
}
|
||||
|
||||
|
@ -1418,8 +1422,8 @@ public class DiscreteInterp extends Interp {
|
|||
|
||||
Point center = new Point();
|
||||
if (num != 0) {
|
||||
center.x = (int) (0.5 + sumX / num);
|
||||
center.y = (int) (0.5 + sumY / num);
|
||||
center.x = (int) (0.5 + (sumX / num));
|
||||
center.y = (int) (0.5 + (sumY / num));
|
||||
} else {
|
||||
center.x = 0;
|
||||
center.y = 0;
|
||||
|
@ -1505,18 +1509,18 @@ public class DiscreteInterp extends Interp {
|
|||
|
||||
// Add in points from grow and fade Areas where appropriate.
|
||||
// loop over coordinates for _growArea and _fadeArea grids
|
||||
for (int i = 0; i < 2 * _xDim; i++) {
|
||||
for (int j = 0; j < 2 * _yDim; j++) {
|
||||
for (int i = 0; i < (2 * _xDim); i++) {
|
||||
for (int j = 0; j < (2 * _yDim); j++) {
|
||||
// "i,j" positions for grow or fade area
|
||||
// as if on on main grid coordinates (there may not actually
|
||||
// be any main grid points with these indexes).
|
||||
mainx = i - _xDim / 2;
|
||||
mainy = j - _yDim / 2;
|
||||
mainx = i - (_xDim / 2);
|
||||
mainy = j - (_yDim / 2);
|
||||
|
||||
// distance from center of initial area to this g or f area
|
||||
// point.
|
||||
dist = Math.sqrt((mainx - center1.x) * (mainx - center1.x)
|
||||
+ (mainy - center1.y) * (mainy - center1.y));
|
||||
dist = Math.sqrt(((mainx - center1.x) * (mainx - center1.x))
|
||||
+ ((mainy - center1.y) * (mainy - center1.y)));
|
||||
|
||||
// translated position for this step:
|
||||
// (coordinates in _growArea and _fadeArea grid system)
|
||||
|
@ -1524,8 +1528,8 @@ public class DiscreteInterp extends Interp {
|
|||
int jj = j + (int) ((_dy * zeta) + 0.5);
|
||||
|
||||
// translated position on main grid
|
||||
tmainy = jj - _yDim / 2;
|
||||
tmainx = ii - _xDim / 2;
|
||||
tmainy = jj - (_yDim / 2);
|
||||
tmainx = ii - (_xDim / 2);
|
||||
|
||||
// get angle sector for this point
|
||||
sector = findAngleSector(mainx - center1.x, mainy - center1.y);
|
||||
|
@ -1568,8 +1572,9 @@ public class DiscreteInterp extends Interp {
|
|||
// from center of moving area, addthis point to the weather
|
||||
// area.
|
||||
// (also make sure it's on the main grid!)
|
||||
if (dist < testGAdist && tmainy >= 0 && tmainx < _xDim
|
||||
&& tmainx >= 0 && tmainy < _yDim) {
|
||||
if ((dist < testGAdist) && (tmainy >= 0)
|
||||
&& (tmainx < _xDim) && (tmainx >= 0)
|
||||
&& (tmainy < _yDim)) {
|
||||
newGrid.set(tmainx, tmainy, wxValue);
|
||||
}
|
||||
|
||||
|
@ -1609,8 +1614,9 @@ public class DiscreteInterp extends Interp {
|
|||
// only keep a _fadeArea point inside the
|
||||
// limiting distance
|
||||
// (also make sure it's on the main grid!)
|
||||
if (dist < testFAdist && tmainy >= 0 && tmainy < _yDim
|
||||
&& tmainx >= 0 && tmainx < _xDim) {
|
||||
if ((dist < testFAdist) && (tmainy >= 0)
|
||||
&& (tmainy < _yDim) && (tmainx >= 0)
|
||||
&& (tmainx < _xDim)) {
|
||||
newGrid.set(tmainx, tmainy, wxValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,6 +164,7 @@ import com.vividsolutions.jts.geom.Envelope;
|
|||
* Mar 04, 2013 1637 randerso Fix time matching for ISC grids
|
||||
* Aug 27, 2013 2287 randerso Fixed scaling and direction of wind arrows
|
||||
* Sep 23, 2013 2363 bsteffen Add more vector configuration options.
|
||||
* Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -340,7 +341,7 @@ public class GFEResource extends
|
|||
* changed, data appeared/disappeared)
|
||||
*/
|
||||
private void resetFrame(TimeRange timeRange) {
|
||||
if (curTime != null && timeRange.overlaps(curTime.getValidPeriod())) {
|
||||
if ((curTime != null) && timeRange.overlaps(curTime.getValidPeriod())) {
|
||||
lastDisplayedTime = null;
|
||||
issueRefresh();
|
||||
}
|
||||
|
@ -492,7 +493,7 @@ public class GFEResource extends
|
|||
|
||||
// hack to get around target.getDefaultFont()-centeredness in
|
||||
// contourDisplay.
|
||||
double contourMagnification = magnification * gfeFont.getFontSize()
|
||||
double contourMagnification = (magnification * gfeFont.getFontSize())
|
||||
/ target.getDefaultFont().getFontSize();
|
||||
|
||||
double density = parm.getDisplayAttributes().getDensity();
|
||||
|
@ -509,7 +510,7 @@ public class GFEResource extends
|
|||
.getValidPeriod());
|
||||
|
||||
boolean iscParm = this.parm.isIscParm();
|
||||
if (gd.length == 0 && !dataManager.getParmManager().iscMode()) {
|
||||
if ((gd.length == 0) && !dataManager.getParmManager().iscMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -519,7 +520,7 @@ public class GFEResource extends
|
|||
|
||||
if (!this.curTime.equals(this.lastDisplayedTime)
|
||||
|| !visMode.equals(this.lastVisMode)
|
||||
|| this.lastIscMode != dataManager.getParmManager().iscMode()) {
|
||||
|| (this.lastIscMode != dataManager.getParmManager().iscMode())) {
|
||||
|
||||
this.lastDisplayedTime = this.curTime;
|
||||
this.lastVisMode = visMode;
|
||||
|
@ -537,7 +538,7 @@ public class GFEResource extends
|
|||
|
||||
if (gd != null) {
|
||||
IGridSlice gs = null;
|
||||
if (dataManager.getParmManager().iscMode() && gd.length == 0) {
|
||||
if (dataManager.getParmManager().iscMode() && (gd.length == 0)) {
|
||||
GridParmInfo gpi = this.parm.getGridInfo();
|
||||
GridType gridType = gpi.getGridType();
|
||||
|
||||
|
@ -583,8 +584,8 @@ public class GFEResource extends
|
|||
gs = gd[0].getGridSlice();
|
||||
}
|
||||
|
||||
if (gs instanceof VectorGridSlice
|
||||
|| gs instanceof ScalarGridSlice) {
|
||||
if ((gs instanceof VectorGridSlice)
|
||||
|| (gs instanceof ScalarGridSlice)) {
|
||||
|
||||
if (this.gridDisplay != null) {
|
||||
this.gridDisplay.dispose();
|
||||
|
@ -660,9 +661,8 @@ public class GFEResource extends
|
|||
mag, dir, descriptor, MapUtil
|
||||
.getGridGeometry(gs.getGridInfo()
|
||||
.getGridLoc()),
|
||||
VECTOR_DENSITY_FACTOR,
|
||||
false, visTypeToDisplayType(type),
|
||||
vectorConfig));
|
||||
VECTOR_DENSITY_FACTOR, false,
|
||||
visTypeToDisplayType(type), vectorConfig));
|
||||
break;
|
||||
|
||||
case WIND_BARB:
|
||||
|
@ -753,7 +753,7 @@ public class GFEResource extends
|
|||
gid, true, slice);
|
||||
}
|
||||
|
||||
for (DiscreteKey discreteKey : slice.getKey()) {
|
||||
for (DiscreteKey discreteKey : slice.getKeys()) {
|
||||
|
||||
if (discreteKey.isValid()) {
|
||||
outlineShapes.put(discreteKey, target
|
||||
|
@ -1330,9 +1330,9 @@ public class GFEResource extends
|
|||
Coordinate gridCoord = MapUtil.latLonToGridCoordinate(coord,
|
||||
PixelOrientation.CENTER, gridLocation);
|
||||
|
||||
if (gridCoord.x < 0 || gridCoord.y < 0
|
||||
|| gridCoord.x >= gridLocation.getNx()
|
||||
|| gridCoord.y >= gridLocation.getNy()) {
|
||||
if ((gridCoord.x < 0) || (gridCoord.y < 0)
|
||||
|| (gridCoord.x >= gridLocation.getNx())
|
||||
|| (gridCoord.y >= gridLocation.getNy())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1471,21 +1471,21 @@ public class GFEResource extends
|
|||
|
||||
// now see if adjacent grid cells exist containing the
|
||||
// same data.
|
||||
if ((xGrid + xLabelGrid > gridDim.x) || (xGrid - 1 < 0)) {
|
||||
if (((xGrid + xLabelGrid) > gridDim.x) || ((xGrid - 1) < 0)) {
|
||||
continue;
|
||||
}
|
||||
if ((yGrid + yLabelGrid > gridDim.y) || (yGrid - 1 < 0)) {
|
||||
if (((yGrid + yLabelGrid) > gridDim.y) || ((yGrid - 1) < 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
byte weatherByteVal = byteData.get(xGrid, yGrid);
|
||||
|
||||
boolean printLabel = true;
|
||||
for (int ii = xGrid - 1; ii < xGrid + xLabelGrid; ii++) {
|
||||
for (int j = yGrid - 1; j < yGrid + yLabelGrid; j++) {
|
||||
for (int ii = xGrid - 1; ii < (xGrid + xLabelGrid); ii++) {
|
||||
for (int j = yGrid - 1; j < (yGrid + yLabelGrid); j++) {
|
||||
if (!parm.getDisplayAttributes().getDisplayMask()
|
||||
.getAsBoolean(ii, j)
|
||||
|| byteData.get(ii, j) != weatherByteVal) {
|
||||
|| (byteData.get(ii, j) != weatherByteVal)) {
|
||||
printLabel = false;
|
||||
break;
|
||||
}
|
||||
|
@ -1550,9 +1550,9 @@ public class GFEResource extends
|
|||
for (xpos = gridOffset; xpos < gridDim.x; xpos += gridInterval) {
|
||||
yCounter++;
|
||||
int xCounter = 0;
|
||||
for (ypos = yCounter % 4 + 1; ypos < gridDim.y - gridOffset; ypos += gridInterval) {
|
||||
for (ypos = (yCounter % 4) + 1; ypos < (gridDim.y - gridOffset); ypos += gridInterval) {
|
||||
xCounter++;
|
||||
int xGrid = xpos + (xCounter % 4 * gridOffset);
|
||||
int xGrid = xpos + ((xCounter % 4) * gridOffset);
|
||||
if (xGrid > gridDim.x) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Jan 23, 2013 #1524 randerso Fix missing discrete color bar and error when clicking
|
||||
* on discrete color bar when no grid exists
|
||||
* Feb 12, 2013 15719 jdynina Fixed out of bounds error in calcGridColorTable
|
||||
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -213,7 +214,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
|
|||
public void paint(IGraphicsTarget target, PaintProperties paintProps)
|
||||
throws VizException {
|
||||
DataTime currentTime = paintProps.getFramesInfo().getCurrentFrame();
|
||||
if (parm == null || currentTime == null) {
|
||||
if ((parm == null) || (currentTime == null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -241,7 +242,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
|
|||
DiscreteGridSlice slice = new DiscreteGridSlice();
|
||||
parm.getDataManager().getIscDataAccess()
|
||||
.getCompositeGrid(gid, true, slice);
|
||||
if (slice.getKey().length == 0) {
|
||||
if (slice.getKeys().length == 0) {
|
||||
return;
|
||||
}
|
||||
iscGridData = new DiscreteGridData(this.parm, slice);
|
||||
|
@ -365,7 +366,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
|
|||
}
|
||||
// for DISCRETE
|
||||
else {
|
||||
DiscreteKey[] dKeys = ((DiscreteGridSlice) gs).getKey();
|
||||
DiscreteKey[] dKeys = ((DiscreteGridSlice) gs).getKeys();
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (cArray[i]) {
|
||||
gridWValues.add(new DiscreteWxValue(dKeys[i], parm));
|
||||
|
@ -485,7 +486,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
|
|||
|
||||
double pickupLabelSize = target.getStringsBounds(dstring)
|
||||
.getWidth();
|
||||
double pickupLabelDrawPoint = (minX + (pickupIndex * keywidth) + keywidth / 2)
|
||||
double pickupLabelDrawPoint = (minX + (pickupIndex * keywidth) + (keywidth / 2))
|
||||
* xScaleFactor;
|
||||
pickupLabelMinX = pickupLabelDrawPoint - (pickupLabelSize / 2);
|
||||
pickupLabelMaxX = pickupLabelDrawPoint + (pickupLabelSize / 2);
|
||||
|
@ -535,7 +536,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
|
|||
maxY, 0.0, seColorBarTickColor, 1.0f);
|
||||
|
||||
String keyName = colorEntry.getValue().toString();
|
||||
labelLoc = (float) (minX + ikeywidth) + (float) keywidth / 2;
|
||||
labelLoc = (float) (minX + ikeywidth) + ((float) keywidth / 2);
|
||||
|
||||
double boxMinXCoord = (minX + ikeywidth) * xScaleFactor;
|
||||
double boxMaxXCoord = boxMinXCoord + (keywidth * xScaleFactor);
|
||||
|
@ -591,15 +592,15 @@ public class DiscreteColorbar implements IColorBarDisplay,
|
|||
int x = 0;
|
||||
for (ColorEntry colorEntry : colorTable) {
|
||||
// calculate the bounding box from x
|
||||
PixelExtent pe = new PixelExtent(x1 + x * keywidth, x1 + (x + 1)
|
||||
* keywidth, y1, y2);
|
||||
PixelExtent pe = new PixelExtent(x1 + (x * keywidth), x1
|
||||
+ ((x + 1) * keywidth), y1, y2);
|
||||
|
||||
Coordinate[] coordinates = new Coordinate[5];
|
||||
coordinates[0] = new Coordinate(x1 + x * keywidth, y1);
|
||||
coordinates[1] = new Coordinate(x1 + (x + 1) * keywidth, y1);
|
||||
coordinates[2] = new Coordinate(x1 + (x + 1) * keywidth, y2);
|
||||
coordinates[3] = new Coordinate(x1 + x * keywidth, y2);
|
||||
coordinates[4] = new Coordinate(x1 + x * keywidth, y1);
|
||||
coordinates[0] = new Coordinate(x1 + (x * keywidth), y1);
|
||||
coordinates[1] = new Coordinate(x1 + ((x + 1) * keywidth), y1);
|
||||
coordinates[2] = new Coordinate(x1 + ((x + 1) * keywidth), y2);
|
||||
coordinates[3] = new Coordinate(x1 + (x * keywidth), y2);
|
||||
coordinates[4] = new Coordinate(x1 + (x * keywidth), y1);
|
||||
|
||||
// draw the shaded rectangle with the correct color(s) and
|
||||
// pattern(s)
|
||||
|
|
|
@ -52,7 +52,7 @@ import com.raytheon.viz.gfe.types.MutableInteger;
|
|||
|
||||
/**
|
||||
* Contains a complete histogram for a single grid and parameter
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
|
@ -63,9 +63,10 @@ import com.raytheon.viz.gfe.types.MutableInteger;
|
|||
* May 29, 2009 2159 rjpeter Optimized sample methods.
|
||||
* May 24, 2012 673 randerso Added defaulted method calls
|
||||
* Jun 17, 2013 15951 ryu Fix index to wx/discrete key array
|
||||
*
|
||||
* Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -176,7 +177,7 @@ public class HistSample {
|
|||
* Description : Constructor far HistSample taking a histogram in the form
|
||||
* of a time range and a sequence of HistPairs, stores the information in
|
||||
* private data. Counts up the samples and stores that in _numSamplePoints.
|
||||
*
|
||||
*
|
||||
* @param timeRange
|
||||
* @param histPairs
|
||||
*/
|
||||
|
@ -211,7 +212,7 @@ public class HistSample {
|
|||
* cached. Sets number of sample points to zero. Calls sampleGrid() to
|
||||
* sample the grid. If successful, stores the time range and counts up the
|
||||
* number of sample points.
|
||||
*
|
||||
*
|
||||
* @param gridSlice
|
||||
* @param sampleArea
|
||||
* @param cachePoints
|
||||
|
@ -251,13 +252,13 @@ public class HistSample {
|
|||
* for WEATHER. The most common value for DISCRETE. For vector, if
|
||||
* separateMagDir is true, the magnitude is averaged separately from the
|
||||
* direction.
|
||||
*
|
||||
*
|
||||
* @param separateMagDir
|
||||
* @return
|
||||
*/
|
||||
public final HistValue average(boolean separateMagDir) {
|
||||
|
||||
if (separateMagDir == _averageMagDir && _average != null) {
|
||||
if ((separateMagDir == _averageMagDir) && (_average != null)) {
|
||||
return _average;
|
||||
}
|
||||
|
||||
|
@ -326,7 +327,7 @@ public class HistSample {
|
|||
* _histPairs.get(i).value().magnitude();
|
||||
float v = uSum / count;
|
||||
float u = vSum / count;
|
||||
float mag = binit((float) Math.sqrt(u * u + v * v),
|
||||
float mag = binit((float) Math.sqrt((u * u) + (v * v)),
|
||||
_resolution);
|
||||
float dir = binit((float) (Math.atan2(u, v) * RAD_TO_DEG),
|
||||
10.0f);
|
||||
|
@ -361,7 +362,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* Description : the square root function
|
||||
*
|
||||
*
|
||||
* @param val
|
||||
* @return
|
||||
*/
|
||||
|
@ -378,7 +379,7 @@ public class HistSample {
|
|||
* Returns the standard deviation of each component separately for VECTOR.
|
||||
* Should not be called for WEATHER. For vector, if separate MagDir is true,
|
||||
* the magnitude is averaged separately from the direction.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final HistValue stdDev() {
|
||||
|
@ -408,7 +409,7 @@ public class HistSample {
|
|||
|
||||
float dev = 0.0f;
|
||||
if (count != 0) {
|
||||
dev = (float) squareRoot((sum2 - (sum * sum) / count) / count);
|
||||
dev = (float) squareRoot((sum2 - ((sum * sum) / count)) / count);
|
||||
}
|
||||
hs._stdDev = new HistValue(dev);
|
||||
return _stdDev;
|
||||
|
@ -444,10 +445,10 @@ public class HistSample {
|
|||
float vdev = 0.0f;
|
||||
|
||||
if (count != 0) {
|
||||
dev = (float) squareRoot((sum2 - (sum * sum) / count) / count);
|
||||
udev = (float) squareRoot((uSum2 - (uSum * uSum) / count)
|
||||
dev = (float) squareRoot((sum2 - ((sum * sum) / count)) / count);
|
||||
udev = (float) squareRoot((uSum2 - ((uSum * uSum) / count))
|
||||
/ count);
|
||||
vdev = (float) squareRoot((vSum2 - (vSum * vSum) / count)
|
||||
vdev = (float) squareRoot((vSum2 - ((vSum * vSum) / count))
|
||||
/ count);
|
||||
}
|
||||
hs._stdDev = new HistValue(dev, udev + udev);
|
||||
|
@ -470,7 +471,7 @@ public class HistSample {
|
|||
* the HistPair's for the maximum count value and returns it. In the case
|
||||
* where more than one entry shares the maximum count value, then only the
|
||||
* highest value (sort order) value will be returned.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final HistValue mostCommonValue() {
|
||||
|
@ -504,7 +505,7 @@ public class HistSample {
|
|||
* case where more than one entyr shares the maximum count value, then only
|
||||
* the highest value (sort order) value will be returned. Works only on
|
||||
* SCALAR and VECTOR.
|
||||
*
|
||||
*
|
||||
* @param resolution
|
||||
* @return
|
||||
*/
|
||||
|
@ -515,7 +516,7 @@ public class HistSample {
|
|||
|
||||
// cached?
|
||||
if ((_binnedMostCommonValue != null)
|
||||
&& resolution == _binnedMostCommonValueFactor) {
|
||||
&& (resolution == _binnedMostCommonValueFactor)) {
|
||||
return _binnedMostCommonValue;
|
||||
}
|
||||
|
||||
|
@ -543,11 +544,11 @@ public class HistSample {
|
|||
* Finds and returns the middle value associated with the sample. The middle
|
||||
* value is that value that is halfway between the lowest and highest in
|
||||
* terms of count, and not value. This is a no-op for WEATHER/DISCRETE.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final HistValue middleValue() {
|
||||
if (_histPairs.size() == 0
|
||||
if ((_histPairs.size() == 0)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.WEATHER)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
|
@ -564,7 +565,7 @@ public class HistSample {
|
|||
int runningCount = 0;
|
||||
for (int i = 0; i < _histPairs.get(i).count(); i++) {
|
||||
runningCount += _histPairs.get(i).count();
|
||||
if ((float) runningCount / (float) _numSamplePoints > 0.50) {
|
||||
if (((float) runningCount / (float) _numSamplePoints) > 0.50) {
|
||||
hs._middleValue = _histPairs.get(i).value();
|
||||
return _middleValue;
|
||||
}
|
||||
|
@ -577,11 +578,11 @@ public class HistSample {
|
|||
* Description : Returns the absolute minimum value for the sample points.
|
||||
* This is a no-op for WEATHER/DISCRETE. Only the magnitude component for
|
||||
* VECTOR is used for comparison.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final HistValue absoluteMin() {
|
||||
if (_histPairs.size() == 0
|
||||
if ((_histPairs.size() == 0)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.WEATHER)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
|
@ -603,11 +604,11 @@ public class HistSample {
|
|||
* Description : REturns the absolute maximum value for the sample points.
|
||||
* This is a no-op for WEATHER/DISCRETE. Only the magnitude component for
|
||||
* VECTOR is used for comparison.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final HistValue absoluteMax() {
|
||||
if (_histPairs.size() == 0
|
||||
if ((_histPairs.size() == 0)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.WEATHER)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
|
@ -643,7 +644,7 @@ public class HistSample {
|
|||
* most common value is provide for WEATERH. Outliers are eliminated.
|
||||
* Percent ranges from 0 to 50. For vector, if separateMagDir is true, the
|
||||
* magnitude is averaged separately from the direction.
|
||||
*
|
||||
*
|
||||
* @param minpercent
|
||||
* @param maxpercent
|
||||
* @param separateMagDir
|
||||
|
@ -653,17 +654,17 @@ public class HistSample {
|
|||
boolean separateMagDir) {
|
||||
HistValue bogus = new HistValue();
|
||||
HistSample hs = this;
|
||||
if (_histPairs.size() == 0 || minpercent < 0 || minpercent > 50
|
||||
|| maxpercent < 0 || maxpercent > 50) {
|
||||
if ((_histPairs.size() == 0) || (minpercent < 0) || (minpercent > 50)
|
||||
|| (maxpercent < 0) || (maxpercent > 50)) {
|
||||
hs._moderatedAverage = new HistValue();
|
||||
hs._moderatedAverageMinPercent = hs._moderatedAverageMaxPercent = 0;
|
||||
return _moderatedAverage;
|
||||
}
|
||||
|
||||
// cached value
|
||||
if (minpercent == _moderatedAverageMinPercent
|
||||
&& maxpercent == _moderatedAverageMaxPercent
|
||||
&& _moderatedAverage != null) {
|
||||
if ((minpercent == _moderatedAverageMinPercent)
|
||||
&& (maxpercent == _moderatedAverageMaxPercent)
|
||||
&& (_moderatedAverage != null)) {
|
||||
return _moderatedAverage;
|
||||
}
|
||||
|
||||
|
@ -672,8 +673,8 @@ public class HistSample {
|
|||
hs._moderatedAverageMaxPercent = maxpercent;
|
||||
|
||||
float runningCount = 0;
|
||||
int minlimitCount = (int) (minpercent * _numSamplePoints / 100.0);
|
||||
int maxlimitCount = (int) ((100 - maxpercent) * _numSamplePoints / 100.0);
|
||||
int minlimitCount = (int) ((minpercent * _numSamplePoints) / 100.0);
|
||||
int maxlimitCount = (int) (((100 - maxpercent) * _numSamplePoints) / 100.0);
|
||||
|
||||
switch (_histPairs.get(0).value().dataType()) {
|
||||
case SCALAR: {
|
||||
|
@ -684,11 +685,11 @@ public class HistSample {
|
|||
int maxVCount = (int) runningCount + _histPairs.get(i).count();
|
||||
|
||||
int numInclude = 0;
|
||||
if (minlimitCount > maxVCount || maxlimitCount < minVCount) {
|
||||
if ((minlimitCount > maxVCount) || (maxlimitCount < minVCount)) {
|
||||
numInclude = 0;
|
||||
} else {
|
||||
numInclude = Math.max(minlimitCount, minVCount)
|
||||
- Math.min(maxlimitCount, maxVCount) + 1;
|
||||
numInclude = (Math.max(minlimitCount, minVCount) - Math
|
||||
.min(maxlimitCount, maxVCount)) + 1;
|
||||
}
|
||||
|
||||
if (numInclude != 0) {
|
||||
|
@ -714,11 +715,12 @@ public class HistSample {
|
|||
+ _histPairs.get(i).count();
|
||||
|
||||
int numInclude = 0;
|
||||
if (minlimitCount > maxVCount || maxlimitCount < minVCount) {
|
||||
if ((minlimitCount > maxVCount)
|
||||
|| (maxlimitCount < minVCount)) {
|
||||
numInclude = 0;
|
||||
} else {
|
||||
numInclude = Math.max(minlimitCount, minVCount)
|
||||
- Math.min(maxlimitCount, maxVCount) + 1;
|
||||
numInclude = (Math.max(minlimitCount, minVCount) - Math
|
||||
.min(maxlimitCount, maxVCount)) + 1;
|
||||
}
|
||||
if (numInclude != 0) {
|
||||
int tCount = numInclude;
|
||||
|
@ -757,11 +759,12 @@ public class HistSample {
|
|||
+ _histPairs.get(i).count();
|
||||
|
||||
int numInclude = 0;
|
||||
if (minlimitCount > maxVCount || maxlimitCount < minVCount) {
|
||||
if ((minlimitCount > maxVCount)
|
||||
|| (maxlimitCount < minVCount)) {
|
||||
numInclude = 0;
|
||||
} else {
|
||||
numInclude = Math.max(minlimitCount, minVCount)
|
||||
- Math.min(maxlimitCount, maxVCount) + 1;
|
||||
numInclude = (Math.max(minlimitCount, minVCount) - Math
|
||||
.min(maxlimitCount, maxVCount)) + 1;
|
||||
}
|
||||
|
||||
if (numInclude != 0) {
|
||||
|
@ -782,7 +785,8 @@ public class HistSample {
|
|||
}
|
||||
float u = uSum / count;
|
||||
float v = vSum / count;
|
||||
float mag = binit((float) Math.sqrt(u * u + v * v), _resolution);
|
||||
float mag = binit((float) Math.sqrt((u * u) + (v * v)),
|
||||
_resolution);
|
||||
float dir = binit((float) (Math.atan2(u, v) * RAD_TO_DEG),
|
||||
10.0f);
|
||||
while (dir < 0.0) {
|
||||
|
@ -821,29 +825,29 @@ public class HistSample {
|
|||
* points. this is a no-op for WEATHER/DISCRETE. Percent should be between 0
|
||||
* and 50. This routine eliminates the bottom xx% of sample values and
|
||||
* returns that value.
|
||||
*
|
||||
*
|
||||
* @param percent
|
||||
* @return
|
||||
*/
|
||||
public final HistValue moderatedMin(int percent) {
|
||||
HistSample hs = this;
|
||||
if (_histPairs.size() == 0 || percent < 0 || percent > 50
|
||||
|| _histPairs.get(0).value().dataType() == GridType.WEATHER
|
||||
|| _histPairs.get(0).value().dataType() == GridType.DISCRETE) {
|
||||
if ((_histPairs.size() == 0) || (percent < 0) || (percent > 50)
|
||||
|| (_histPairs.get(0).value().dataType() == GridType.WEATHER)
|
||||
|| (_histPairs.get(0).value().dataType() == GridType.DISCRETE)) {
|
||||
hs._moderatedMin = new HistValue();
|
||||
hs._moderatedMinPercent = 0;
|
||||
return _moderatedMin; // default histValue()
|
||||
}
|
||||
|
||||
// cached?
|
||||
if (_moderatedMinPercent == percent && _moderatedMin != null) {
|
||||
if ((_moderatedMinPercent == percent) && (_moderatedMin != null)) {
|
||||
return _moderatedMin;
|
||||
}
|
||||
|
||||
hs._moderatedMinPercent = percent;
|
||||
|
||||
float runningCount = 0;
|
||||
float limitCount = (float) (percent * _numSamplePoints / 100.0);
|
||||
float limitCount = (float) ((percent * _numSamplePoints) / 100.0);
|
||||
|
||||
for (int i = 0; i < _histPairs.size(); i++) {
|
||||
runningCount += _histPairs.get(i).count();
|
||||
|
@ -865,15 +869,15 @@ public class HistSample {
|
|||
* points. This is a no-op for WEATHER/DISCRETE. Percent should be between 0
|
||||
* and 50. This routine eliminates the top 15% of sample values and returns
|
||||
* that value.
|
||||
*
|
||||
*
|
||||
* @param percent
|
||||
* @return
|
||||
*/
|
||||
public final HistValue moderatedMax(int percent) {
|
||||
HistSample hs = this;
|
||||
if (_histPairs.size() == 0
|
||||
|| percent < 0
|
||||
|| percent > 50
|
||||
if ((_histPairs.size() == 0)
|
||||
|| (percent < 0)
|
||||
|| (percent > 50)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.WEATHER)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
|
@ -884,14 +888,14 @@ public class HistSample {
|
|||
}
|
||||
|
||||
// cached?
|
||||
if (_moderatedMax != null && _moderatedMaxPercent == percent) {
|
||||
if ((_moderatedMax != null) && (_moderatedMaxPercent == percent)) {
|
||||
return _moderatedMax;
|
||||
}
|
||||
|
||||
hs._moderatedMaxPercent = percent;
|
||||
|
||||
float runningCount = 0;
|
||||
float limitCount = (float) (percent * _numSamplePoints / 100.0);
|
||||
float limitCount = (float) ((percent * _numSamplePoints) / 100.0);
|
||||
|
||||
for (int i = _histPairs.size() - 1; i >= 0; i--) {
|
||||
runningCount += _histPairs.get(i).count();
|
||||
|
@ -922,7 +926,7 @@ public class HistSample {
|
|||
* most common value is provided for WEATHER/DISCRETE. Outliers are
|
||||
* eliminated based on standard deviation. For vector, if separateMagDir is
|
||||
* true, the magnitude is averaged separately from the direction.
|
||||
*
|
||||
*
|
||||
* @param minStdD
|
||||
* @param maxStdD
|
||||
* @param separateMagDir
|
||||
|
@ -933,7 +937,7 @@ public class HistSample {
|
|||
HistValue bogus = new HistValue();
|
||||
HistSample hs = this;
|
||||
|
||||
if (_histPairs.size() == 0 || minStdD < 0 || maxStdD < 0) {
|
||||
if ((_histPairs.size() == 0) || (minStdD < 0) || (maxStdD < 0)) {
|
||||
hs._stdDevAvgMinStdD = hs._stdDevAvgMaxStdD = 0;
|
||||
hs._stdDevMagDir = false;
|
||||
hs._stdDevAvg = new HistValue();
|
||||
|
@ -941,9 +945,9 @@ public class HistSample {
|
|||
}
|
||||
|
||||
// use cached value if possible
|
||||
if (_stdDevAvg != null && _stdDevAvgMinStdD == minStdD
|
||||
&& _stdDevAvgMaxStdD == maxStdD
|
||||
&& separateMagDir == _stdDevMagDir) {
|
||||
if ((_stdDevAvg != null) && (_stdDevAvgMinStdD == minStdD)
|
||||
&& (_stdDevAvgMaxStdD == maxStdD)
|
||||
&& (separateMagDir == _stdDevMagDir)) {
|
||||
return _stdDevAvg;
|
||||
}
|
||||
|
||||
|
@ -955,13 +959,13 @@ public class HistSample {
|
|||
case SCALAR: {
|
||||
float sDev = stdDev().scalar();
|
||||
float avg = average(true).scalar();
|
||||
float minValue = avg - minStdD * sDev;
|
||||
float maxValue = avg + maxStdD * sDev;
|
||||
float minValue = avg - (minStdD * sDev);
|
||||
float maxValue = avg + (maxStdD * sDev);
|
||||
float sum = 0.0f;
|
||||
int count = 0;
|
||||
for (int i = 0; i < _histPairs.size(); i++) {
|
||||
float v = _histPairs.get(i).value().scalar();
|
||||
if (v >= minValue && v <= maxValue) {
|
||||
if ((v >= minValue) && (v <= maxValue)) {
|
||||
sum += _histPairs.get(i).count() * v;
|
||||
count += _histPairs.get(i).count();
|
||||
}
|
||||
|
@ -975,8 +979,8 @@ public class HistSample {
|
|||
case VECTOR: {
|
||||
float sDev = stdDev().scalar();
|
||||
float avg = average(true).scalar();
|
||||
float minValue = avg - minStdD * sDev;
|
||||
float maxValue = avg + maxStdD * sDev;
|
||||
float minValue = avg - (minStdD * sDev);
|
||||
float maxValue = avg + (maxStdD * sDev);
|
||||
float sum = 0.0f;
|
||||
int count = 0;
|
||||
float uSum = 0.0f;
|
||||
|
@ -984,7 +988,7 @@ public class HistSample {
|
|||
if (separateMagDir) {
|
||||
for (int i = 0; i < _histPairs.size(); i++) {
|
||||
float v = _histPairs.get(i).value().magnitude();
|
||||
if (v >= minValue && v <= maxValue) {
|
||||
if ((v >= minValue) && (v <= maxValue)) {
|
||||
int tCount = _histPairs.get(i).count();
|
||||
sum += tCount * _histPairs.get(i).value().magnitude();
|
||||
count += tCount;
|
||||
|
@ -1018,7 +1022,7 @@ public class HistSample {
|
|||
} else {
|
||||
for (int i = 0; i < _histPairs.size(); i++) {
|
||||
float v = _histPairs.get(i).value().magnitude();
|
||||
if (v >= minValue && v <= maxValue) {
|
||||
if ((v >= minValue) && (v <= maxValue)) {
|
||||
int tCount = _histPairs.get(i).count();
|
||||
count += tCount;
|
||||
uSum += tCount
|
||||
|
@ -1038,7 +1042,7 @@ public class HistSample {
|
|||
}
|
||||
float u = uSum / count;
|
||||
float v = vSum / count;
|
||||
float mag = binit((float) (Math.sqrt(u * u + v * v)),
|
||||
float mag = binit((float) (Math.sqrt((u * u) + (v * v))),
|
||||
_resolution);
|
||||
float dir = binit((float) (Math.atan2(u, v) * RAD_TO_DEG),
|
||||
10.0f);
|
||||
|
@ -1075,15 +1079,15 @@ public class HistSample {
|
|||
* Description : Returns the representative minimum value for the sample
|
||||
* points. This is a no-op for WEATHER/DISCRETE. Based on standard
|
||||
* deviations.
|
||||
*
|
||||
*
|
||||
* @param stdD
|
||||
* @return
|
||||
*/
|
||||
public final HistValue stdDevMin(float stdD) {
|
||||
HistSample hs = this;
|
||||
|
||||
if (_histPairs.size() == 0
|
||||
|| stdD < 0
|
||||
if ((_histPairs.size() == 0)
|
||||
|| (stdD < 0)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.WEATHER)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
|
@ -1094,7 +1098,7 @@ public class HistSample {
|
|||
}
|
||||
|
||||
// use cached value if possible
|
||||
if (_stdDevMin != null && _stdDevMinD == stdD) {
|
||||
if ((_stdDevMin != null) && (_stdDevMinD == stdD)) {
|
||||
return _stdDevMin;
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1106,7 @@ public class HistSample {
|
|||
|
||||
float sDev = stdDev().scalar();
|
||||
float avg = average(true).scalar();
|
||||
float minValue = avg - stdD * sDev;
|
||||
float minValue = avg - (stdD * sDev);
|
||||
if (_histPairs.get(0).value().scalar() > minValue) {
|
||||
minValue = _histPairs.get(0).value().scalar();
|
||||
}
|
||||
|
@ -1118,15 +1122,15 @@ public class HistSample {
|
|||
* Description : Returns the representative maximum value for the sample
|
||||
* points. This is a no-op for WEATHER/DISCRETE. Based on standard
|
||||
* deviations.
|
||||
*
|
||||
*
|
||||
* @param stdD
|
||||
* @return
|
||||
*/
|
||||
public final HistValue stdDevMax(float stdD) {
|
||||
HistSample hs = this;
|
||||
|
||||
if (_histPairs.size() == 0
|
||||
|| stdD < 0
|
||||
if ((_histPairs.size() == 0)
|
||||
|| (stdD < 0)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.DISCRETE)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
|
@ -1137,14 +1141,14 @@ public class HistSample {
|
|||
}
|
||||
|
||||
// use cached value if possible
|
||||
if (_stdDevMax != null && _stdDevMaxD == stdD) {
|
||||
if ((_stdDevMax != null) && (_stdDevMaxD == stdD)) {
|
||||
return _stdDevMax;
|
||||
}
|
||||
hs._stdDevMaxD = stdD;
|
||||
|
||||
float sDev = stdDev().scalar();
|
||||
float avg = average(true).scalar();
|
||||
float maxValue = avg + stdD * sDev;
|
||||
float maxValue = avg + (stdD * sDev);
|
||||
if (_histPairs.get(_histPairs.size() - 1).value().scalar() < maxValue) {
|
||||
maxValue = _histPairs.get(_histPairs.size() - 1).value().scalar();
|
||||
}
|
||||
|
@ -1156,14 +1160,14 @@ public class HistSample {
|
|||
/**
|
||||
* OUtputs the histogram for this grid, but binned by the specified float
|
||||
* value. This only applies to SCALAR and VECTOR data.
|
||||
*
|
||||
*
|
||||
* @param resolution
|
||||
* @return
|
||||
*/
|
||||
public List<HistPair> binnedHistogram(float resolution) {
|
||||
HistSample hs = this;
|
||||
if (_histPairs.size() == 0
|
||||
|| resolution <= 0.0
|
||||
if ((_histPairs.size() == 0)
|
||||
|| (resolution <= 0.0)
|
||||
|| _histPairs.get(0).value().dataType().equals(GridType.NONE)
|
||||
|| _histPairs.get(0).value().dataType()
|
||||
.equals(GridType.WEATHER)
|
||||
|
@ -1230,7 +1234,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* Description : Bins the data sample based on the resolution
|
||||
*
|
||||
*
|
||||
* @param v
|
||||
* @param resolution
|
||||
* @return
|
||||
|
@ -1255,7 +1259,7 @@ public class HistSample {
|
|||
* that the grid is valid and grid and Grid2DBit sizes match. Ensures there
|
||||
* are points in the sample area. Switch cases on data type and then
|
||||
* extracts out the data for each sample point.
|
||||
*
|
||||
*
|
||||
* @param grid
|
||||
* @param area
|
||||
* @param cachePoints
|
||||
|
@ -1310,7 +1314,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* If the sample was of scalars this function is called
|
||||
*
|
||||
*
|
||||
* @param grid
|
||||
* @param area
|
||||
* @param cachePoints
|
||||
|
@ -1469,7 +1473,7 @@ public class HistSample {
|
|||
ParmID parmId = grid.getGridInfo().getParmID();
|
||||
Grid2DByte gs = ((DiscreteGridSlice) grid).getDiscreteGrid();
|
||||
String siteId = parmId.getDbId().getSiteId();
|
||||
DiscreteKey[] key = ((DiscreteGridSlice) grid).getKey();
|
||||
DiscreteKey[] key = ((DiscreteGridSlice) grid).getKeys();
|
||||
for (int x = ll.x; x <= ur.x; x++) {
|
||||
for (int y = ll.y; y <= ur.y; y++) {
|
||||
if (area.get(x, y) != 0) {
|
||||
|
@ -1525,7 +1529,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* Description : counts the number of sample points and returns the number
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int countSamplePoints() {
|
||||
|
@ -1553,7 +1557,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* Description : Returns the sample's valid time
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final TimeRange validTime() {
|
||||
|
@ -1562,7 +1566,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* Description : Returns the histogram associated with this sample
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final HistPair[] histogram() {
|
||||
|
@ -1571,7 +1575,7 @@ public class HistSample {
|
|||
|
||||
/**
|
||||
* Description : Returns the number of points associated with this sample
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int numOfPoints() {
|
||||
|
|
|
@ -70,6 +70,7 @@ import com.raytheon.viz.gfe.core.wxvalue.WxValue;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 20, 2008 njensen Initial creation
|
||||
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
|
||||
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -201,7 +202,7 @@ public class SmartToolController extends BaseGfePyController {
|
|||
Set<String> set = null;
|
||||
String[] tools = new String[0];
|
||||
try {
|
||||
if (parmName == null && parmTypeName == null) {
|
||||
if ((parmName == null) && (parmTypeName == null)) {
|
||||
set = (Set<String>) execute("getScripts", INTERFACE, null);
|
||||
} else {
|
||||
HashMap<String, Object> argMap = new HashMap<String, Object>(2);
|
||||
|
@ -325,7 +326,7 @@ public class SmartToolController extends BaseGfePyController {
|
|||
jep.set("discreteGridData", grid);
|
||||
jep.eval("discreteGridNumpy = discreteGridData.__numpy__");
|
||||
jep.eval("discreteGridNumpy = discreteGridNumpy[0]");
|
||||
DiscreteKey[] keys = grid.getDiscreteSlice().getKey();
|
||||
DiscreteKey[] keys = grid.getDiscreteSlice().getKeys();
|
||||
ArrayList<String> stringKeys = new ArrayList<String>();
|
||||
for (DiscreteKey k : keys) {
|
||||
stringKeys.add(k.toString());
|
||||
|
|
|
@ -71,6 +71,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 13, 2011 #8393 dgilling Initial creation
|
||||
* 02/19/13 #1637 randerso Added exception handling for Discrete and Weather
|
||||
* 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -139,7 +140,7 @@ public class ASCIIGrid {
|
|||
* @return
|
||||
*/
|
||||
public boolean translateGrid(int index, GridParmInfo destGPI) {
|
||||
if ((index < 0) || (index > gridSlices.size() - 1)) {
|
||||
if ((index < 0) || (index > (gridSlices.size() - 1))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -337,7 +338,7 @@ public class ASCIIGrid {
|
|||
for (int i = discrete.getDiscreteGrid().getYdim() - 1; i >= 0; i--) {
|
||||
for (int j = 0; j < discrete.getDiscreteGrid()
|
||||
.getXdim(); j++) {
|
||||
String key = discrete.getKey()[discrete
|
||||
String key = discrete.getKeys()[discrete
|
||||
.getDiscreteGrid().get(j, i)].toString();
|
||||
outputStream.println(key);
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
* 06/13/13 #2044 randerso Pass in GridDbConfig as construction parameter
|
||||
* 07/30/13 #2057 randerso Added a static deleteDatabase method
|
||||
* 08/05/13 #1571 randerso Refactored to store GridParmInfo and ParmStorageinfo in postgres database
|
||||
* 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1664,7 +1665,7 @@ public class IFPGridDatabase extends GridDatabase {
|
|||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
boolean first = true;
|
||||
for (DiscreteKey key : slice.getKey()) {
|
||||
for (DiscreteKey key : slice.getKeys()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
|
|
@ -68,7 +68,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Aug 11, 2009 njensen Initial creation
|
||||
* Mar 06, 2013 1735 rferrel Change to retrieve multiple points
|
||||
* in a single grid request.
|
||||
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
|
||||
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
|
||||
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -213,7 +214,7 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements
|
|||
} else if (slice instanceof DiscreteGridSlice) {
|
||||
DiscreteGridSlice gs = (DiscreteGridSlice) slice;
|
||||
byte value = gs.getDiscreteGrid().get(x, y);
|
||||
String key = gs.getKey()[value].toString();
|
||||
String key = gs.getKeys()[value].toString();
|
||||
Type type = Type.STRING;
|
||||
view.setData(param, type, unit, key);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ from com.raytheon.uf.common.localization import LocalizationContext_Localization
|
|||
# 08/09/2013 1571 randerso Changed projections to use the Java
|
||||
# ProjectionType enumeration
|
||||
# 09/20/13 2405 dgilling Clip grids before inserting into cache.
|
||||
# 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
#
|
||||
|
||||
# Original A1 BATCH WRITE COUNT was 10, we found doubling that
|
||||
|
@ -140,18 +141,12 @@ class WECache(object):
|
|||
elif gridType == "VECTOR":
|
||||
vecGrids = grid.__numpy__
|
||||
return (clipToExtrema(vecGrids[0], clipArea), clipToExtrema(vecGrids[1], clipArea))
|
||||
elif gridType == "WEATHER":
|
||||
elif gridType == "WEATHER" or gridType =="DISCRETE":
|
||||
keys = grid.getKeys()
|
||||
keyList = []
|
||||
for theKey in keys:
|
||||
keyList.append(theKey.toString())
|
||||
return (clipToExtrema(grid.__numpy__[0], clipArea), keyList)
|
||||
elif gridType =="DISCRETE":
|
||||
keys = grid.getKey()
|
||||
keyList = []
|
||||
for theKey in keys:
|
||||
keyList.append(theKey.toString())
|
||||
return (clipToExtrema(grid.__numpy__[0], clipArea), keyList)
|
||||
|
||||
def __encodeGridHistory(self, histories):
|
||||
retVal = []
|
||||
|
|
|
@ -82,6 +82,7 @@ from com.raytheon.uf.edex.database.cluster import ClusterTask
|
|||
# 06/05/13 2063 dgilling Change __siteInDbGrid() to
|
||||
# call IFPWE.history() like A1.
|
||||
# 09/05/13 2307 dgilling Fix breakage caused by #2044.
|
||||
# 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -204,18 +205,12 @@ class WECache(object):
|
|||
elif gridType == "VECTOR":
|
||||
vecGrids = grid.__numpy__
|
||||
return (vecGrids[0], vecGrids[1])
|
||||
elif gridType == "WEATHER":
|
||||
elif gridType == "WEATHER" or gridType =="DISCRETE":
|
||||
keys = grid.getKeys()
|
||||
keyList = []
|
||||
for theKey in keys:
|
||||
keyList.append(theKey.toString())
|
||||
return (grid.__numpy__[0], keyList)
|
||||
elif gridType =="DISCRETE":
|
||||
keys = grid.getKey()
|
||||
keyList = []
|
||||
for theKey in keys:
|
||||
keyList.append(theKey.toString())
|
||||
return (grid.__numpy__[0], keyList)
|
||||
|
||||
def __encodeGridHistory(self, histories):
|
||||
retVal = []
|
||||
|
|
|
@ -36,7 +36,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.IGrid2D;
|
||||
|
@ -73,6 +72,7 @@ import com.raytheon.uf.common.util.StringUtil;
|
|||
* May 02, 2013 1949 bsteffen Update GFE data access in Product
|
||||
* Browser, Volume Browser, and Data Access
|
||||
* Framework.
|
||||
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -221,7 +221,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
} else if (slice instanceof DiscreteGridSlice) {
|
||||
DiscreteGridSlice castedSlice = (DiscreteGridSlice) slice;
|
||||
data = castedSlice.getDiscreteGrid();
|
||||
DiscreteKey[] dKeys = castedSlice.getKey();
|
||||
Object[] dKeys = castedSlice.getKeys();
|
||||
String[] keys = new String[dKeys.length];
|
||||
for (int i = 0; i < dKeys.length; i++) {
|
||||
keys[i] = dKeys[i].toString();
|
||||
|
@ -285,7 +285,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
|
||||
private GFERecord asGFERecord(Object obj) {
|
||||
if (obj instanceof GFERecord == false) {
|
||||
if ((obj instanceof GFERecord) == false) {
|
||||
throw new DataRetrievalException(this.getClass().getSimpleName()
|
||||
+ " cannot handle " + obj.getClass().getSimpleName());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Grid slice for Discrete weather elements
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
|
@ -58,6 +58,7 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
|
||||
* debugger when trying to display the grid
|
||||
* 10/29/2013 2476 njensen Updated getNumpy() and added getKeyList()
|
||||
* 10/31/2013 2508 randerso Added getKeys(), deprecated getKey()
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -75,7 +76,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
private String cacheId;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private DiscreteKey[] key;
|
||||
private DiscreteKey[] keys;
|
||||
|
||||
/**
|
||||
* Constructor for serialization only.
|
||||
|
@ -97,7 +98,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
Grid2DByte aGrid, DiscreteKey[] aKey) {
|
||||
super(validTime, gfeRecord);
|
||||
setDiscreteGrid(aGrid);
|
||||
key = aKey;
|
||||
keys = aKey;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +114,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
GridDataHistory[] history, Grid2DByte aGrid, DiscreteKey[] aKey) {
|
||||
super(validTime, gpi, history);
|
||||
setDiscreteGrid(aGrid);
|
||||
key = aKey;
|
||||
keys = aKey;
|
||||
}
|
||||
|
||||
public DiscreteGridSlice(TimeRange validTime, GridParmInfo gpi,
|
||||
|
@ -151,8 +152,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
Grid2DByte grid = rhs.getDiscreteGrid().clone();
|
||||
setDiscreteGrid(grid);
|
||||
|
||||
this.key = new DiscreteKey[rhs.key.length];
|
||||
System.arraycopy(rhs.key, 0, this.key, 0, rhs.key.length);
|
||||
this.keys = new DiscreteKey[rhs.keys.length];
|
||||
System.arraycopy(rhs.keys, 0, this.keys, 0, rhs.keys.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,11 +179,11 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
discreteGrid.assign(gsDiscreteGrid);
|
||||
setDiscreteGrid(discreteGrid);
|
||||
|
||||
this.key = new DiscreteKey[slice.key.length];
|
||||
System.arraycopy(slice.key, 0, this.key, 0, slice.key.length);
|
||||
this.keys = new DiscreteKey[slice.keys.length];
|
||||
System.arraycopy(slice.keys, 0, this.keys, 0, slice.keys.length);
|
||||
} else {
|
||||
setDiscreteGrid(null);
|
||||
this.key = new DiscreteKey[0];
|
||||
this.keys = new DiscreteKey[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,8 +238,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
byte[] thisData = grid.getBuffer().array();
|
||||
byte[] rhsData = rhsGrid.getBuffer().array();
|
||||
for (int i = 0; i < thisData.length; i++) {
|
||||
if (!this.key[0xFF & thisData[i]]
|
||||
.equals(rhsDiscreteGridSlice.key[0xFF & rhsData[i]])) {
|
||||
if (!this.keys[0xFF & thisData[i]]
|
||||
.equals(rhsDiscreteGridSlice.keys[0xFF & rhsData[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +255,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
* @return null if everything was ok, otherwise the reason why not
|
||||
*/
|
||||
public String checkKeyAndData() {
|
||||
int keyLength = key.length;
|
||||
int keyLength = keys.length;
|
||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
byte[] b = discreteGrid.getBuffer().array();
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
|
@ -278,10 +279,10 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
* @return null if the key is ok, otherwise the reason why not
|
||||
*/
|
||||
public String checkKey() {
|
||||
for (int i = 0; i < key.length; i++) {
|
||||
if (!this.key[i].isValid()) {
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
if (!this.keys[i].isValid()) {
|
||||
return "Invalid Key found in Grid. Key Position is " + i
|
||||
+ " Key is: " + key[i].getOrigStr();
|
||||
+ " Key is: " + keys[i].getOrigStr();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -316,19 +317,19 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
// find a key match
|
||||
byte dByte = 0;
|
||||
boolean found = false;
|
||||
for (int k = 0; k < key.length; k++) {
|
||||
if (key[k].equals(aValue)) {
|
||||
for (int k = 0; k < keys.length; k++) {
|
||||
if (keys[k].equals(aValue)) {
|
||||
dByte = (byte) k;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
DiscreteKey newKey[] = new DiscreteKey[key.length + 1];
|
||||
System.arraycopy(key, 0, newKey, 0, key.length);
|
||||
DiscreteKey newKey[] = new DiscreteKey[keys.length + 1];
|
||||
System.arraycopy(keys, 0, newKey, 0, keys.length);
|
||||
newKey[newKey.length - 1] = aValue;
|
||||
key = newKey;
|
||||
dByte = (byte) (key.length - 1);
|
||||
keys = newKey;
|
||||
dByte = (byte) (keys.length - 1);
|
||||
}
|
||||
|
||||
for (int i = ll.x; i <= ur.x; i++) {
|
||||
|
@ -370,23 +371,23 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
if (editArea.get(i, j) != 0) {
|
||||
// Get the DiscreteKey from the source grid
|
||||
byte dByte = gsDiscreteGrid.get(i, j);
|
||||
DiscreteKey dKey = gs.key[0xFF & dByte];
|
||||
DiscreteKey dKey = gs.keys[0xFF & dByte];
|
||||
// See if this key already exists in target grid
|
||||
boolean found = false;
|
||||
byte keyIndex = 0;
|
||||
for (int k = 0; k < key.length; k++) {
|
||||
if (key[k] == dKey) {
|
||||
for (int k = 0; k < keys.length; k++) {
|
||||
if (keys[k] == dKey) {
|
||||
found = true;
|
||||
keyIndex = (byte) k;
|
||||
}
|
||||
}
|
||||
if (!found) // not found, so add the key
|
||||
{
|
||||
DiscreteKey newKey[] = new DiscreteKey[key.length + 1];
|
||||
System.arraycopy(key, 0, newKey, 0, key.length);
|
||||
DiscreteKey newKey[] = new DiscreteKey[keys.length + 1];
|
||||
System.arraycopy(keys, 0, newKey, 0, keys.length);
|
||||
newKey[newKey.length - 1] = dKey;
|
||||
key = newKey;
|
||||
keyIndex = (byte) (key.length - 1);
|
||||
keys = newKey;
|
||||
keyIndex = (byte) (keys.length - 1);
|
||||
}
|
||||
|
||||
discreteGrid.set(i, j, keyIndex);
|
||||
|
@ -414,19 +415,19 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
// find a key match
|
||||
byte dByte = 0;
|
||||
boolean found = false;
|
||||
for (int k = 0; k < key.length; k++) {
|
||||
if (key[k].equals(aValue)) {
|
||||
for (int k = 0; k < keys.length; k++) {
|
||||
if (keys[k].equals(aValue)) {
|
||||
dByte = (byte) k;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
DiscreteKey newKey[] = new DiscreteKey[key.length + 1];
|
||||
System.arraycopy(key, 0, newKey, 0, key.length);
|
||||
DiscreteKey newKey[] = new DiscreteKey[keys.length + 1];
|
||||
System.arraycopy(keys, 0, newKey, 0, keys.length);
|
||||
newKey[newKey.length - 1] = aValue;
|
||||
key = newKey;
|
||||
dByte = (byte) (key.length - 1);
|
||||
keys = newKey;
|
||||
dByte = (byte) (keys.length - 1);
|
||||
}
|
||||
|
||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
|
@ -448,22 +449,22 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
Grid2DByte discreteGrid = gs.discreteGrid.clone();
|
||||
|
||||
List<DiscreteKey> currentKeys = new ArrayList<DiscreteKey>(
|
||||
Arrays.asList(this.key));
|
||||
Arrays.asList(this.keys));
|
||||
byte[] data = discreteGrid.getBuffer().array();
|
||||
int thisB;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
thisB = 0xFF & data[i];
|
||||
byte keyIndex;
|
||||
if ((keyIndex = (byte) currentKeys.indexOf(gs.key[thisB])) != -1) {
|
||||
if ((keyIndex = (byte) currentKeys.indexOf(gs.keys[thisB])) != -1) {
|
||||
data[i] = keyIndex;
|
||||
} else {
|
||||
data[i] = (byte) currentKeys.size();
|
||||
currentKeys.add(new DiscreteKey(gs.key[thisB]));
|
||||
currentKeys.add(new DiscreteKey(gs.keys[thisB]));
|
||||
}
|
||||
}
|
||||
|
||||
setDiscreteGrid(discreteGrid);
|
||||
this.key = currentKeys.toArray(new DiscreteKey[currentKeys.size()]);
|
||||
this.keys = currentKeys.toArray(new DiscreteKey[currentKeys.size()]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -478,7 +479,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
*/
|
||||
public Grid2DBit eq(DiscreteKey value) {
|
||||
if (!value.isValid()) {
|
||||
throw new IllegalArgumentException("Supplied key is invalid");
|
||||
throw new IllegalArgumentException("Supplied keys is invalid");
|
||||
}
|
||||
|
||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
|
@ -489,8 +490,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
// Get or make a Discrete
|
||||
byte dByte = 0;
|
||||
boolean found = false;
|
||||
for (int k = 0; k < key.length; k++) {
|
||||
if (key[k].equals(value)) {
|
||||
for (int k = 0; k < keys.length; k++) {
|
||||
if (keys[k].equals(value)) {
|
||||
dByte = (byte) k;
|
||||
found = true;
|
||||
}
|
||||
|
@ -545,17 +546,17 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
|
||||
// Check for each value
|
||||
// Get the list of subkey permutations from the value given
|
||||
List<String> searchKeys = key[0].descriptionSubKeys(value);
|
||||
List<String> searchKeys = keys[0].descriptionSubKeys(value);
|
||||
|
||||
// Get the byte values that correspond to the specified textStrings
|
||||
List<Byte> byteValues = new ArrayList<Byte>();
|
||||
|
||||
// Check each discrete key for a match of a subkey
|
||||
for (int i = 0; i < key.length; i++) {
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
// Check each subkey
|
||||
for (int j = 0; j < key[i].getSubKeys().size(); j++) {
|
||||
for (int j = 0; j < keys[i].getSubKeys().size(); j++) {
|
||||
for (int k = 0; k < searchKeys.size(); k++) {
|
||||
if (key[i].getSubKeys().get(j).equals(searchKeys.get(k))) {
|
||||
if (keys[i].getSubKeys().get(j).equals(searchKeys.get(k))) {
|
||||
byteValues.add((byte) i);
|
||||
break;
|
||||
}
|
||||
|
@ -604,7 +605,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
byte[] rhsB = gs.getDiscreteGrid().getBuffer().array();
|
||||
byte[] b = bits.getBuffer().array();
|
||||
for (int i = 0; i < thisB.length; i++) {
|
||||
if (key[0xFF & thisB[i]].equals(gs.key[0xFF & rhsB[i]])) {
|
||||
if (keys[0xFF & thisB[i]].equals(gs.keys[0xFF & rhsB[i]])) {
|
||||
b[i] = (byte) 1;
|
||||
}
|
||||
}
|
||||
|
@ -639,9 +640,9 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
* for duplicate keys, set all locations in grid that match that key to
|
||||
* the "first" of the duplicate keys
|
||||
*/
|
||||
for (int i = 0; i < (key.length - 1); i++) {
|
||||
for (int j = i; j < key.length; j++) {
|
||||
if (key[i].equals(key[j])) {
|
||||
for (int i = 0; i < (keys.length - 1); i++) {
|
||||
for (int j = i; j < keys.length; j++) {
|
||||
if (keys[i].equals(keys[j])) {
|
||||
discreteGrid.setAllOfValue((byte) j, (byte) i);
|
||||
}
|
||||
}
|
||||
|
@ -666,11 +667,11 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
.hasNext(); keyIndex++) {
|
||||
byte thisByte = usedKeysI.next();
|
||||
discreteGrid.setAllOfValue(thisByte, (byte) keyIndex);
|
||||
newKey[keyIndex] = key[0xFF & thisByte];
|
||||
newKey[keyIndex] = keys[0xFF & thisByte];
|
||||
}
|
||||
|
||||
setDiscreteGrid(discreteGrid);
|
||||
key = newKey;
|
||||
keys = newKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -688,9 +689,9 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
aGrid = aGrid.clone();
|
||||
}
|
||||
|
||||
DiscreteKey[] aKey = new DiscreteKey[this.key.length];
|
||||
DiscreteKey[] aKey = new DiscreteKey[this.keys.length];
|
||||
for (int i = 0; i < aKey.length; i++) {
|
||||
aKey[i] = new DiscreteKey(this.key[i]);
|
||||
aKey[i] = new DiscreteKey(this.keys[i]);
|
||||
}
|
||||
return new DiscreteGridSlice(aValidTime, aGpi, aHistory, aGrid, aKey);
|
||||
}
|
||||
|
@ -742,12 +743,23 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the discrete key
|
||||
* Return the discrete keys
|
||||
*
|
||||
* @return the discrete key
|
||||
* @return the discrete keys
|
||||
* @deprecated use getKeys() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public DiscreteKey[] getKey() {
|
||||
return this.key;
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the discrete keys
|
||||
*
|
||||
* @return the discrete keys
|
||||
*/
|
||||
public DiscreteKey[] getKeys() {
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
public void setDiscreteGrid(Grid2DByte grid) {
|
||||
|
@ -781,7 +793,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
}
|
||||
|
||||
public void setKey(DiscreteKey[] key) {
|
||||
this.key = key;
|
||||
this.keys = key;
|
||||
}
|
||||
|
||||
public void setKey(List<DiscreteKey[]> key) {
|
||||
|
@ -854,8 +866,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
}
|
||||
|
||||
public List<String> getKeyList() {
|
||||
List<String> list = new ArrayList<String>(key.length);
|
||||
for (DiscreteKey k : key) {
|
||||
List<String> list = new ArrayList<String>(keys.length);
|
||||
for (DiscreteKey k : keys) {
|
||||
list.add(k.toString());
|
||||
}
|
||||
return list;
|
||||
|
|
Loading…
Add table
Reference in a new issue