Issue #3572 Fixed getNumpy errors for Grid2DFloat
Change-Id: I6caf979c1d531a842f77d23dbd7f8e0865afecce Former-commit-id: e2ecb91569c2f622d45f7301c1eb4e058a2ab641
This commit is contained in:
parent
e7705c328e
commit
434d412882
8 changed files with 48 additions and 516 deletions
|
@ -17,6 +17,14 @@
|
|||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# Sep 01, 2014 3572 randerso Fix getTopo
|
||||
#
|
||||
########################################################################
|
||||
import DatabaseID, AbsTime, JUtil
|
||||
|
||||
from com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID as JavaDatabaseID
|
||||
|
@ -116,4 +124,4 @@ class DBSSClient:
|
|||
return self._dataMgr.getOpMode().name()
|
||||
|
||||
def getTopo(self):
|
||||
return self._tmgr.getCompositeTopo().getScalarGrid().__numpy__[0]
|
||||
return self._tmgr.getCompositeTopo().__numpy__[0]
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 07/14/09 1995 bphillip Initial release
|
||||
* 09/01/2014 3572 randerso Removed unused inOurSite method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -98,20 +99,6 @@ public interface IISCDataAccess {
|
|||
*/
|
||||
public String getISCSite(Point coord, GridID gid);
|
||||
|
||||
/**
|
||||
* Returns true if the coordinate (and grid id) is in our own domain. The
|
||||
* officeType for the parm and our officeType must be the same to be
|
||||
* considered "inOurSite".
|
||||
*
|
||||
* @param loc
|
||||
* The coordinate to check
|
||||
* @param gid
|
||||
* The gridID associated with the coordinate
|
||||
* @return true if coordinate is in our domain and the parm and office type
|
||||
* match
|
||||
*/
|
||||
public boolean inOurSite(Point loc, GridID gid);
|
||||
|
||||
/**
|
||||
* Returns the data point for the gridid. Will return either the data point
|
||||
* from the specified grid, or its corresponding isc grid, depending upon
|
||||
|
|
|
@ -36,7 +36,6 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2D;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBit;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBoolean;
|
||||
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.reference.ReferenceData;
|
||||
|
@ -75,6 +74,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 07/14/09 1995 bphillip Initial release
|
||||
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
* 09/01/2014 3572 randerso Removed ourSiteMap as it was unused and the only
|
||||
* thing that used Grid2DBoolean
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -90,10 +91,6 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
|
||||
private Map<String, Grid2D<String>> siteGridMap;
|
||||
|
||||
// private Map<String, List<String>> siteIdentifiers;
|
||||
|
||||
private Grid2DBoolean ourSiteMap;
|
||||
|
||||
/**
|
||||
* Constructs a new ISCDataAccess object
|
||||
*
|
||||
|
@ -207,21 +204,6 @@ 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())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.ourSiteMap.isValid(loc.x, loc.y)) {
|
||||
return this.ourSiteMap.get(loc.x, loc.y);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxValue getDataPoint(GridID gridID, Coordinate worldLoc)
|
||||
throws GFEServerException {
|
||||
|
@ -511,7 +493,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
"getCompositeGrid called on non-discrete parm");
|
||||
|
||||
slice.setDiscreteGrid(new Grid2DByte());
|
||||
slice.setKey(new DiscreteKey[0]);
|
||||
slice.setKeys(new DiscreteKey[0]);
|
||||
return new Grid2DBit();
|
||||
}
|
||||
|
||||
|
@ -519,7 +501,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
Grid2DBit ourSiteMask = null;
|
||||
if (primary == null) {
|
||||
slice.setDiscreteGrid(new Grid2DByte(nx, ny));
|
||||
slice.setKey(new DiscreteKey[0]);
|
||||
slice.setKeys(new DiscreteKey[0]);
|
||||
primary = new DiscreteGridData(gid.getParm(), slice);
|
||||
ourSiteMask = new Grid2DBit(nx, ny);
|
||||
} else {
|
||||
|
@ -536,7 +518,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
keys[i] = new DiscreteKey(primary.getDiscreteSlice().getKeys()[i]);
|
||||
}
|
||||
|
||||
slice.setKey(keys);
|
||||
slice.setKeys(keys);
|
||||
keys = null; // don't use this copy any more
|
||||
|
||||
// isc grid
|
||||
|
@ -580,7 +562,7 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
newKeyList[key.getValue().intValue()] = key.getKey();
|
||||
}
|
||||
|
||||
slice.setKey(newKeyList);
|
||||
slice.setKeys(newKeyList);
|
||||
return siteMask.or(ourSiteMask);
|
||||
}
|
||||
|
||||
|
@ -590,10 +572,6 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
protected void createSiteMask() {
|
||||
GridLocation gloc = dataMgr.getParmManager().compositeGridLocation();
|
||||
|
||||
// reinitialize data to empty
|
||||
ourSiteMap = new Grid2DBoolean(gloc.gridSize().x, gloc.gridSize().y);
|
||||
// siteIdentifiers = new HashMap<String, List<String>>();
|
||||
|
||||
siteGridMap = new HashMap<String, Grid2D<String>>();
|
||||
|
||||
// get list of known sites from server -- ignore any errors
|
||||
|
@ -624,7 +602,6 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
// point.
|
||||
Grid2D<String> sites = new Grid2D<String>(gloc.gridSize().x,
|
||||
gloc.gridSize().y);
|
||||
// List<String> siteIdentifiers = new ArrayList<String>();
|
||||
|
||||
for (String iscea : iscEAs) {
|
||||
|
||||
|
@ -642,7 +619,6 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
Grid2DBit bits = refDat.getGrid();
|
||||
|
||||
if (bits.isAnyBitsSet()) {
|
||||
// siteIdentifiers.add(iscea);
|
||||
|
||||
for (int y = 0; y < bits.getYdim(); y++) {
|
||||
for (int x = 0; x < bits.getXdim(); x++) {
|
||||
|
@ -652,22 +628,9 @@ public class ISCDataAccess implements IISCDataAccess {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// special mapping for our site map
|
||||
if (iscea.equals(dataMgr.getSiteID())) {
|
||||
for (int y = 0; y < bits.getYdim(); y++) {
|
||||
for (int x = 0; x < bits.getXdim(); x++) {
|
||||
if (bits.get(x, y) > 0) {
|
||||
ourSiteMap.set(x, y, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// store result in maps
|
||||
// this.siteIdentifiers.put(officeType, siteIdentifiers);
|
||||
this.siteGridMap.put(officeType, sites);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import java.nio.Buffer;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 5/7/08 875 bphillip Initial Creation.
|
||||
* Sep 01, 2014 3572 randerso Removed unnecessary @SuppressWarnings
|
||||
* to eliminate Java Warning
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,7 +62,6 @@ public class Grid2D<E> implements IGrid2D, Cloneable {
|
|||
* @param yDim
|
||||
* The height of the grid
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Grid2D(int xDim, int yDim) {
|
||||
this.xDim = xDim;
|
||||
this.yDim = yDim;
|
||||
|
|
|
@ -76,6 +76,7 @@ import java.nio.ByteBuffer;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 29, 2008 879 rbell Initial Creation.
|
||||
* Oct 22, 2008 1624 wdougherty Speed up translate method
|
||||
* Sep 01, 2014 3572 randerso Added clear(x,y) method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -217,6 +218,23 @@ public class Grid2DBit extends Grid2DByte implements Cloneable {
|
|||
buffer.put(yDim * this.xdim + xDim, (byte) 1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets a bit to 0.
|
||||
*
|
||||
* @param xDim
|
||||
* xDim x coordinate of bit to set
|
||||
* @param yDim
|
||||
* yDim y coordinate of bit to set
|
||||
*/
|
||||
@Override
|
||||
public void clear(int xDim, int yDim) {
|
||||
if (!isValid(xDim, yDim)) {
|
||||
throw new IllegalArgumentException("Dimensions are invalid");
|
||||
}
|
||||
buffer.put(yDim * this.xdim + xDim, (byte) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets all bits to the given value.
|
||||
|
|
|
@ -1,449 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.uf.common.dataplugin.gfe.grid;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import jep.INumpyable;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Grid2D implementation for the boolean type
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 07/14/09 1995 bphillip Initial release
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class Grid2DBoolean implements IGrid2D, Cloneable, INumpyable,
|
||||
ISerializableObject {
|
||||
|
||||
/**
|
||||
* The data buffer, holding the grid's contents
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
protected IntBuffer buffer;
|
||||
|
||||
/**
|
||||
* Width of the grid.
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
protected int xdim;
|
||||
|
||||
/**
|
||||
* Height of the grid.
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
protected int ydim;
|
||||
|
||||
/**
|
||||
* Constructor for serialization only.
|
||||
*/
|
||||
public Grid2DBoolean() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for creating a two-dimensional grid containing ints. xDim and
|
||||
* yDim specify the size of the grid.
|
||||
*
|
||||
* @param xDim
|
||||
* @param yDim
|
||||
*/
|
||||
public Grid2DBoolean(int xDim, int yDim) {
|
||||
this(xDim, yDim, IntBuffer.allocate(xDim * yDim));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for creating an initialized two-dimensional grid containing
|
||||
* ints.
|
||||
*
|
||||
* xDim and yDim specify the size of the grid.
|
||||
*
|
||||
* aValue is the initial value
|
||||
*
|
||||
* @param xDim
|
||||
* @param yDim
|
||||
* @param aValue
|
||||
*/
|
||||
public Grid2DBoolean(int xDim, int yDim, boolean aValue) {
|
||||
this(xDim, yDim);
|
||||
setAllValues(aValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for creating a two-dimensional grid containing ints. xDim and
|
||||
* yDim specify the size of the grid. data is an array of initialization
|
||||
* data.
|
||||
*
|
||||
* @param xDim
|
||||
* @param yDim
|
||||
* @param data
|
||||
* array of initialization data
|
||||
*/
|
||||
public Grid2DBoolean(int xDim, int yDim, boolean[] data) {
|
||||
this(xDim, yDim);
|
||||
if (xDim * yDim != data.length) {
|
||||
throw new IllegalArgumentException(
|
||||
"Dimensions do not match data length (" + xDim + "," + yDim
|
||||
+ ") " + data.length);
|
||||
}
|
||||
int[] intData = new int[data.length];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
if (data[i]) {
|
||||
intData[i] = 1;
|
||||
} else {
|
||||
intData[i] = 0;
|
||||
}
|
||||
}
|
||||
this.buffer.put(intData, 0, data.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for creating a two-dimensional grid containing ints. xDim and
|
||||
* yDim specify the size of the grid. data is a IntBuffer containing
|
||||
* initialization data.
|
||||
*
|
||||
* @param xDim
|
||||
* @param yDim
|
||||
* @param data
|
||||
* IntBuffer of initialization data
|
||||
*/
|
||||
public Grid2DBoolean(int xDim, int yDim, IntBuffer data) {
|
||||
if (xDim * yDim != data.limit()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Dimensions do not match data length (" + xDim + "," + yDim
|
||||
+ ") " + data.limit());
|
||||
}
|
||||
this.xdim = xDim;
|
||||
this.ydim = yDim;
|
||||
this.buffer = data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Copy constructor
|
||||
*
|
||||
* @param rhs
|
||||
* Grid2DBoolean to copy
|
||||
*/
|
||||
public Grid2DBoolean(Grid2DBoolean rhs) {
|
||||
this(rhs.xdim, rhs.ydim);
|
||||
this.buffer.put(rhs.buffer.array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xDim
|
||||
* x coordinate of boolean to retrieve
|
||||
* @param yDim
|
||||
* y coordinate of boolean to retrieve
|
||||
* @return the retrieved boolean
|
||||
*/
|
||||
public boolean get(int xDim, int yDim) {
|
||||
if (!isValid(xDim, yDim)) {
|
||||
throw new IllegalArgumentException("Dimensions not valid");
|
||||
}
|
||||
return buffer.get(yDim * this.xdim + xDim) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xDim
|
||||
* x coordinate of boolean to set
|
||||
* @param yDim
|
||||
* y coordinate of boolean to set
|
||||
* @param aValue
|
||||
* value of boolean to set
|
||||
*/
|
||||
public void set(int xDim, int yDim, boolean aValue) {
|
||||
if (!isValid(xDim, yDim)) {
|
||||
throw new IllegalArgumentException("Dimensions not valid");
|
||||
}
|
||||
if (aValue) {
|
||||
buffer.put(yDim * this.xdim + xDim, 1);
|
||||
} else {
|
||||
buffer.put(yDim * this.xdim + xDim, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets all booleans to the given value.
|
||||
*
|
||||
* @param aValue
|
||||
* value to set all booleans to.
|
||||
*/
|
||||
public void setAllValues(boolean aValue) {
|
||||
for (int i = 0; i < buffer.limit(); i++) {
|
||||
if (aValue) {
|
||||
buffer.put(i, 1);
|
||||
} else {
|
||||
buffer.put(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.xdim > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(int x, int y) {
|
||||
return (x < xdim && y < ydim && x >= 0 && y >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The data buffer is cleared.
|
||||
*/
|
||||
public void clear() {
|
||||
for (int i = 0; i < buffer.limit(); i++) {
|
||||
buffer.put(i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a particular coordinate to 0
|
||||
*
|
||||
* @param x
|
||||
* x coordinate to clear
|
||||
* @param y
|
||||
* y coordinate to clear
|
||||
*/
|
||||
public void clear(int x, int y) {
|
||||
buffer.put(y * xdim + x, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Translates the set booleans in this object by the amount specified in
|
||||
* deltaCoord and returns a new Grid2DBoolean.
|
||||
*
|
||||
* @param deltaCoord
|
||||
* coordinate representing the translation from each boolean's
|
||||
* origin
|
||||
* @return the resulting translation
|
||||
*/
|
||||
public Grid2DBoolean translate(Point deltaCoord) {
|
||||
// make another Grid2DBoolean
|
||||
Grid2DBoolean rVal = new Grid2DBoolean(this.xdim, this.ydim);
|
||||
|
||||
for (int x = 0; x < this.xdim; x++) {
|
||||
for (int y = 0; y < this.ydim; y++) {
|
||||
if (rVal.isValid(x + deltaCoord.x, y + deltaCoord.y)) {
|
||||
rVal.set(x + deltaCoord.x, y + deltaCoord.y, this.get(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Translates this Grid2DBoolean by the amount specified. Returns a
|
||||
* reference to this object.
|
||||
*
|
||||
* Uses translate() to translate the booleans, and then assigns the result
|
||||
* to this object using the assignment operator.
|
||||
*
|
||||
* @param deltaCoord
|
||||
* coordinate representing the translation from each boolean's
|
||||
* origin
|
||||
* @return this Grid2DBoolean after the translation
|
||||
*/
|
||||
public Grid2DBoolean translateMe(Point deltaCoord) {
|
||||
Grid2DBoolean t = translate(deltaCoord);
|
||||
this.buffer = t.buffer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntBuffer getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXdim() {
|
||||
return xdim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYdim() {
|
||||
return ydim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getGridSize() {
|
||||
return new Point(xdim, ydim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid2DBoolean subGrid(int minX, int minY, int maxX, int maxY) {
|
||||
Grid2DBoolean rVal = new Grid2DBoolean(maxX + 1 - minX, maxY + 1 - minY);
|
||||
for (int y = minY; y < maxY + 1; y++) {
|
||||
for (int x = minX; x < maxX + 1; x++) {
|
||||
boolean val = this.get(x, y);
|
||||
if (val) {
|
||||
rVal.buffer.put(1);
|
||||
} else {
|
||||
rVal.buffer.put(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Grid2DBoolean)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Grid2DBoolean rhs = (Grid2DBoolean) obj;
|
||||
|
||||
if (rhs == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean rVal = true;
|
||||
|
||||
if (this.xdim == rhs.xdim && this.ydim == rhs.ydim) {
|
||||
for (int i = 0; i < this.buffer.limit(); i++) {
|
||||
if (this.buffer.get(i) != rhs.buffer.get(i)) {
|
||||
rVal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rVal = false;
|
||||
}
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid2DBoolean clone() throws CloneNotSupportedException {
|
||||
Grid2DBoolean rVal = new Grid2DBoolean(this);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyWithMask(IGrid2D sourceGrid, Grid2DBit maskGrid) {
|
||||
if (!(sourceGrid instanceof Grid2DBoolean)) {
|
||||
throw new IllegalArgumentException(
|
||||
"The input source grid must be of type Grid2DBoolean");
|
||||
}
|
||||
|
||||
Grid2DBoolean sourceGrid2DBoolean = (Grid2DBoolean) sourceGrid;
|
||||
|
||||
if (this.xdim != sourceGrid2DBoolean.xdim || this.xdim != maskGrid.xdim
|
||||
|| this.ydim != sourceGrid2DBoolean.ydim
|
||||
|| this.ydim != maskGrid.ydim) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid, the input grid, and the input mask grid must have equal dimensions");
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.buffer.limit(); i++) {
|
||||
if (maskGrid.buffer.get(i) != 0) {
|
||||
this.buffer.put(i, sourceGrid2DBoolean.buffer.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllOfValue(boolean oldValue, boolean newValue) {
|
||||
for (int i = 0; i < buffer.limit(); i++) {
|
||||
if ((this.buffer.get(i) > 0 && oldValue)
|
||||
|| (this.buffer.get(i) == 0 && !oldValue)) {
|
||||
if (newValue) {
|
||||
this.buffer.put(i, 1);
|
||||
} else {
|
||||
this.buffer.put(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String rVal = "";
|
||||
|
||||
rVal += xdim + "X" + ydim + "\n[\n";
|
||||
for (int y = 0; y < ydim; y++) {
|
||||
for (int x = 0; x < xdim; x++) {
|
||||
rVal += this.get(x, y) + (x + 1 == xdim ? "" : ",");
|
||||
}
|
||||
rVal += "\n";
|
||||
}
|
||||
rVal += "]";
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getNumpy() {
|
||||
return new Object[] { buffer.array() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumpyX() {
|
||||
return xdim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumpyY() {
|
||||
return ydim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dim
|
||||
* the xDim to set
|
||||
*/
|
||||
public void setXdim(int dim) {
|
||||
xdim = dim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dim
|
||||
* the yDim to set
|
||||
*/
|
||||
public void setYdim(int dim) {
|
||||
ydim = dim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param buffer
|
||||
* the buffer to set
|
||||
*/
|
||||
public void setBuffer(IntBuffer buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,6 @@ import java.util.Arrays;
|
|||
|
||||
import jep.INumpyable;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
@ -41,6 +40,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2008 879 rbell Initial Creation.
|
||||
* Oct 22, 2008 1624 wdougherty Speed up translate method
|
||||
* Sep 01, 2014 3572 randerso Changed getNumpy to use getBytes()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,8 +48,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class Grid2DByte implements IGrid2D, Cloneable, INumpyable,
|
||||
ISerializableObject {
|
||||
public class Grid2DByte implements IGrid2D, Cloneable, INumpyable {
|
||||
|
||||
/**
|
||||
* The data buffer, holding the grid's contents
|
||||
|
@ -311,14 +310,17 @@ public class Grid2DByte implements IGrid2D, Cloneable, INumpyable,
|
|||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXdim() {
|
||||
return xdim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYdim() {
|
||||
return ydim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getGridSize() {
|
||||
return new Point(xdim, ydim);
|
||||
}
|
||||
|
@ -415,7 +417,7 @@ public class Grid2DByte implements IGrid2D, Cloneable, INumpyable,
|
|||
|
||||
@Override
|
||||
public Object[] getNumpy() {
|
||||
return new Object[] { buffer.array() };
|
||||
return new Object[] { getBytes() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.nio.FloatBuffer;
|
|||
|
||||
import jep.INumpyable;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -38,6 +37,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2008 879 rbell Initial Creation.
|
||||
* Sep 01, 2014 3572 randerso Changed getNumpy to use getFloats()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -45,8 +45,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class Grid2DFloat implements IGrid2D, Cloneable, INumpyable,
|
||||
ISerializableObject {
|
||||
public class Grid2DFloat implements IGrid2D, Cloneable, INumpyable {
|
||||
|
||||
/**
|
||||
* The data buffer, holding the grid's contents
|
||||
|
@ -321,14 +320,17 @@ public class Grid2DFloat implements IGrid2D, Cloneable, INumpyable,
|
|||
this.buffer.put(other.getBuffer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXdim() {
|
||||
return xdim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYdim() {
|
||||
return ydim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getGridSize() {
|
||||
return new Point(xdim, ydim);
|
||||
}
|
||||
|
@ -426,7 +428,7 @@ public class Grid2DFloat implements IGrid2D, Cloneable, INumpyable,
|
|||
|
||||
@Override
|
||||
public Object[] getNumpy() {
|
||||
return new Object[] { buffer.array() };
|
||||
return new Object[] { getFloats() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue