Merge "Issue #1571 Refactored GFE to store GridParmInfo and ParmStorageInfo in PostGres" into development
Former-commit-id:b6ed64f7bc
[formerly 2d79cbb93508d5c7f3a16fc4774c34deaa07923b] Former-commit-id:02442e8fba
This commit is contained in:
commit
918413d154
37 changed files with 2168 additions and 2469 deletions
|
@ -46,6 +46,9 @@
|
|||
# Cleaned up some constants
|
||||
# Jun 21, 2013 14983 ryu Fixed encodeEditArea() to evaluate query
|
||||
# when necessary
|
||||
# Aug 14, 2013 1571 randerso Fixed encodeEditArea() to return astype(numpy.bool8)
|
||||
# so mask can be used with advanced indexing
|
||||
# (e.g. grid[mask] = value)
|
||||
#
|
||||
########################################################################
|
||||
import types, string, time, sys
|
||||
|
@ -2080,7 +2083,7 @@ class SmartScript(BaseTool.BaseTool):
|
|||
if editArea.isQuery():
|
||||
editArea = self.__refSetMgr.evaluateQuery(editArea.getQuery())
|
||||
|
||||
return editArea.getGrid().__numpy__[0]
|
||||
return editArea.getGrid().__numpy__[0].astype(numpy.bool8)
|
||||
|
||||
def decodeEditArea(self, mask):
|
||||
# Returns a refData object for the given mask
|
||||
|
|
|
@ -84,6 +84,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 02/04/2008 chammack Initial Creation
|
||||
* 03/20/2013 #1774 randerso Use TimeUtil constants
|
||||
* 08/06/2013 #1571 randerso Changed ProjectionData constructor call
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -98,10 +99,9 @@ public class MockParmManager extends AbstractParmManager {
|
|||
private static final int TIME_OFFSET = -6;
|
||||
|
||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
||||
|
@ -208,7 +208,7 @@ public class MockParmManager extends AbstractParmManager {
|
|||
|
||||
// Hack for simulated data
|
||||
float[][] data = null;
|
||||
if (Activator.getDefault() != null
|
||||
if ((Activator.getDefault() != null)
|
||||
&& (gpi.getDescriptiveName().equals("Surface Temperature") || gpi
|
||||
.getDescriptiveName().equals("Dewpoint"))) {
|
||||
UnitConverter conv = SI.KELVIN.getConverterTo(NonSI.FAHRENHEIT);
|
||||
|
@ -281,8 +281,11 @@ public class MockParmManager extends AbstractParmManager {
|
|||
/ (g2dFloat.getXdim() + g2dFloat.getYdim());
|
||||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||
g2dFloat.set(m, n,
|
||||
((float) m + n) * step + gpi.getMinValue());
|
||||
g2dFloat.set(
|
||||
m,
|
||||
n,
|
||||
(((float) m + n) * step)
|
||||
+ gpi.getMinValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +309,7 @@ public class MockParmManager extends AbstractParmManager {
|
|||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||
g2dFloat.set(m, n,
|
||||
((float) m + n) * step + gpi.getMinValue());
|
||||
(((float) m + n) * step) + gpi.getMinValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,10 +333,10 @@ public class MockParmManager extends AbstractParmManager {
|
|||
// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dByte.getYdim(); n++) {
|
||||
if (m > 80 && m < 110 && n > 80 && n < 110) {
|
||||
if ((m > 80) && (m < 110) && (n > 80) && (n < 110)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
if (m > 90 && m < 100 && n > 110 && n < 140) {
|
||||
if ((m > 90) && (m < 100) && (n > 110) && (n < 140)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
}
|
||||
|
@ -362,10 +365,10 @@ public class MockParmManager extends AbstractParmManager {
|
|||
// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
||||
for (int n = 0; n < g2dByte.getYdim(); n++) {
|
||||
if (m > 80 && m < 110 && n > 80 && n < 110) {
|
||||
if ((m > 80) && (m < 110) && (n > 80) && (n < 110)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
if (m > 90 && m < 100 && n > 110 && n < 140) {
|
||||
if ((m > 90) && (m < 100) && (n > 110) && (n < 140)) {
|
||||
g2dByte.set(m, n, (byte) 1);
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +424,7 @@ public class MockParmManager extends AbstractParmManager {
|
|||
this.dataManager);
|
||||
|
||||
IGridData grid = null;
|
||||
if (data == null || data.length == 0) {
|
||||
if ((data == null) || (data.length == 0)) {
|
||||
grid = null;
|
||||
} else if (gpi.getGridType() == GridType.SCALAR) {
|
||||
grid = new ScalarGridData(parm, data[0]);
|
||||
|
@ -715,13 +718,13 @@ public class MockParmManager extends AbstractParmManager {
|
|||
parms.acquireWriteLock();
|
||||
try {
|
||||
for (Parm addParm : addParms) {
|
||||
if (addParm != null && !this.parms.contains(addParm)) {
|
||||
if ((addParm != null) && !this.parms.contains(addParm)) {
|
||||
this.parms.add(addParm); // add the additions
|
||||
}
|
||||
}
|
||||
|
||||
for (Parm removeParm : removeParms) {
|
||||
if (removeParm != null && this.parms.contains(removeParm)) {
|
||||
if ((removeParm != null) && this.parms.contains(removeParm)) {
|
||||
this.parms.remove(removeParm);
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +741,7 @@ public class MockParmManager extends AbstractParmManager {
|
|||
}
|
||||
|
||||
// send ParmListChanged notification
|
||||
if (addParms.size() > 0 || removeParms.size() > 0) {
|
||||
if ((addParms.size() > 0) || (removeParms.size() > 0)) {
|
||||
parms.acquireReadLock();
|
||||
try {
|
||||
fireParmListChanged(
|
||||
|
@ -765,7 +768,7 @@ public class MockParmManager extends AbstractParmManager {
|
|||
}
|
||||
|
||||
// send DisplayedParmListChanged notification
|
||||
if (removedDisplayed.size() > 0 || addedDisplayed.size() > 0) {
|
||||
if ((removedDisplayed.size() > 0) || (addedDisplayed.size() > 0)) {
|
||||
parms.acquireReadLock();
|
||||
try {
|
||||
fireDisplayedParmListChanged(this.parms
|
||||
|
|
59
deltaScripts/13.6.1/CleanupGfeHDF5Storage.py
Normal file
59
deltaScripts/13.6.1/CleanupGfeHDF5Storage.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python
|
||||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
#
|
||||
# Update GFE HDF5 Group format to include minutes
|
||||
#
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 11/18/10 njensen Initial Creation.
|
||||
# 06/13/13 #2044 randerso Fixed to use correct python
|
||||
#
|
||||
#
|
||||
#
|
||||
import os
|
||||
|
||||
hdf5loc = "/awips2/edex/data/hdf5/gfe"
|
||||
|
||||
def processDir(dir):
|
||||
# walk the directory tree removing *_GridParm.h5 files
|
||||
for file in os.listdir(dir):
|
||||
filePath = os.path.join(dir, file)
|
||||
if os.path.isfile(filePath) and str(filePath).endswith("_GridParm.h5"):
|
||||
print "Removing ", filePath
|
||||
os.remove(filePath)
|
||||
elif os.path.isdir(filePath):
|
||||
processDir(filePath)
|
||||
|
||||
# if directory is empty remove it
|
||||
if len(os.listdir(dir)) == 0:
|
||||
print "Removing ", dir
|
||||
os.removedirs(dir)
|
||||
|
||||
def main():
|
||||
processDir(hdf5loc)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
11
deltaScripts/13.6.1/CreateNewGfeTables.sh
Normal file
11
deltaScripts/13.6.1/CreateNewGfeTables.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
# run the update
|
||||
/awips2/psql/bin/psql -U awips -d metadata -f CreateNewGfeTables.sql
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FATAL: the update has failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: the update has completed successfully!"
|
||||
|
||||
exit 0
|
106
deltaScripts/13.6.1/CreateNewGfeTables.sql
Normal file
106
deltaScripts/13.6.1/CreateNewGfeTables.sql
Normal file
|
@ -0,0 +1,106 @@
|
|||
DROP TABLE IF EXISTS gfe_spatial;
|
||||
|
||||
-- Sequence: gfe_gridlocation_seq
|
||||
|
||||
-- DROP SEQUENCE gfe_gridlocation_seq;
|
||||
|
||||
CREATE SEQUENCE gfe_gridlocation_seq
|
||||
INCREMENT 1
|
||||
MINVALUE 1
|
||||
MAXVALUE 9223372036854775807
|
||||
START 1
|
||||
CACHE 1;
|
||||
ALTER TABLE gfe_gridlocation_seq
|
||||
OWNER TO awips;
|
||||
|
||||
-- Table: gfe_gridlocation
|
||||
|
||||
-- DROP TABLE gfe_gridlocation;
|
||||
|
||||
CREATE TABLE gfe_gridlocation
|
||||
(
|
||||
id integer NOT NULL,
|
||||
extent bytea NOT NULL,
|
||||
nx integer NOT NULL,
|
||||
ny integer NOT NULL,
|
||||
origin bytea NOT NULL,
|
||||
gridpointll bytea NOT NULL,
|
||||
gridpointur bytea NOT NULL,
|
||||
latintersect double precision NOT NULL,
|
||||
latlonll bytea NOT NULL,
|
||||
latlonorigin bytea NOT NULL,
|
||||
latlonur bytea NOT NULL,
|
||||
loncenter double precision NOT NULL,
|
||||
lonorigin double precision NOT NULL,
|
||||
projectionid character varying(32) NOT NULL,
|
||||
projectiontype character varying(20) NOT NULL,
|
||||
stdparallelone double precision NOT NULL,
|
||||
stdparalleltwo double precision NOT NULL,
|
||||
siteid character varying(8) NOT NULL,
|
||||
timezone character varying(32) NOT NULL,
|
||||
dbid_id integer NOT NULL,
|
||||
CONSTRAINT gfe_gridlocation_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT fk22b8153412156549 FOREIGN KEY (dbid_id)
|
||||
REFERENCES gfe_dbid (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT gfe_gridlocation_dbid_id_key UNIQUE (dbid_id)
|
||||
)
|
||||
WITH (
|
||||
OIDS=FALSE
|
||||
);
|
||||
ALTER TABLE gfe_gridlocation
|
||||
OWNER TO awips;
|
||||
|
||||
-- Sequence: gfe_parminfo_seq
|
||||
|
||||
-- DROP SEQUENCE gfe_parminfo_seq;
|
||||
|
||||
CREATE SEQUENCE gfe_parminfo_seq
|
||||
INCREMENT 1
|
||||
MINVALUE 1
|
||||
MAXVALUE 9223372036854775807
|
||||
START 1
|
||||
CACHE 1;
|
||||
ALTER TABLE gfe_parminfo_seq
|
||||
OWNER TO awips;
|
||||
|
||||
-- Table: gfe_parminfo
|
||||
|
||||
-- DROP TABLE gfe_parminfo;
|
||||
|
||||
CREATE TABLE gfe_parminfo
|
||||
(
|
||||
id integer NOT NULL,
|
||||
datamultiplier real NOT NULL,
|
||||
dataoffset real NOT NULL,
|
||||
datatype character varying(8) NOT NULL,
|
||||
descriptivename character varying(64) NOT NULL,
|
||||
gridtype character varying(8) NOT NULL,
|
||||
maxvalue real NOT NULL,
|
||||
minvalue real NOT NULL,
|
||||
"precision" integer NOT NULL,
|
||||
rateparm boolean NOT NULL,
|
||||
duration integer NOT NULL,
|
||||
repeatinterval integer NOT NULL,
|
||||
starttime integer NOT NULL,
|
||||
valid boolean NOT NULL,
|
||||
timeindependentparm boolean NOT NULL,
|
||||
unitstring character varying(64) NOT NULL,
|
||||
storagetype character varying(8) NOT NULL,
|
||||
gridloc_id integer NOT NULL,
|
||||
parmid_id integer NOT NULL,
|
||||
CONSTRAINT gfe_parminfo_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT fk1871875338803a4d FOREIGN KEY (gridloc_id)
|
||||
REFERENCES gfe_gridlocation (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT fk187187537bab05cc FOREIGN KEY (parmid_id)
|
||||
REFERENCES gfe_parmid (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT gfe_parminfo_parmid_id_key UNIQUE (parmid_id)
|
||||
)
|
||||
WITH (
|
||||
OIDS=FALSE
|
||||
);
|
||||
ALTER TABLE gfe_parminfo
|
||||
OWNER TO awips;
|
||||
|
|
@ -33,6 +33,7 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType;
|
|||
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.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmStorageInfo;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
||||
|
@ -46,6 +47,7 @@ import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/14/08 #1030 randerso Initial port
|
||||
* 04/8/08 #875 bphillip Added getter for Grid Parm Info dictionary
|
||||
* 08/05/2013 #1571 randerso Made GridParmInfo a field in ParmStorageInfo
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -56,8 +58,6 @@ import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
|||
public class GridDbConfig {
|
||||
private final Log theLogger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private HashMap<String, GridParmInfo> _gridInfoDict;
|
||||
|
||||
private HashMap<String, ParmStorageInfo> _parmInfoDict;
|
||||
|
||||
private WxDefinition _wxDefinition;
|
||||
|
@ -108,33 +108,33 @@ public class GridDbConfig {
|
|||
int nentries = (int) (((maxV - minV) * dprecision));
|
||||
|
||||
// check for byte possibilities
|
||||
if (nentries <= Math.pow(2.0, 8.0) - 1) {
|
||||
if (nentries <= (Math.pow(2.0, 8.0) - 1)) {
|
||||
format.dataMultiplier = dprecision;
|
||||
format.dataOffset = 0;
|
||||
int minVarValue = 0;
|
||||
int maxVarValue = 255;
|
||||
if (minV * format.dataMultiplier < minVarValue) {
|
||||
format.dataOffset = minV - minVarValue / format.dataMultiplier;
|
||||
if ((minV * format.dataMultiplier) < minVarValue) {
|
||||
format.dataOffset = minV
|
||||
- (minVarValue / format.dataMultiplier);
|
||||
}
|
||||
if (maxV * format.dataMultiplier > maxVarValue) {
|
||||
format.dataOffset = maxV - maxVarValue / format.dataMultiplier;
|
||||
if ((maxV * format.dataMultiplier) > maxVarValue) {
|
||||
format.dataOffset = maxV
|
||||
- (maxVarValue / format.dataMultiplier);
|
||||
}
|
||||
format.storageFormat = "byte";
|
||||
}
|
||||
|
||||
// check for short possibilities
|
||||
else if (nentries <= Math.pow(2.0, 16.0) - 2) {
|
||||
else if (nentries <= (Math.pow(2.0, 16.0) - 2)) {
|
||||
format.dataMultiplier = dprecision;
|
||||
format.dataOffset = 0;
|
||||
double maxVarValue = Math.pow(2.0, 15.0) - 1;
|
||||
double minVarValue = -(Math.pow(2.0, 15.0) - 2);
|
||||
if (minV * format.dataMultiplier < minVarValue) {
|
||||
format.dataOffset = (float) (minV - minVarValue
|
||||
/ format.dataMultiplier);
|
||||
if ((minV * format.dataMultiplier) < minVarValue) {
|
||||
format.dataOffset = (float) (minV - (minVarValue / format.dataMultiplier));
|
||||
}
|
||||
if (maxV * format.dataMultiplier > maxVarValue) {
|
||||
format.dataOffset = (float) (maxV - maxVarValue
|
||||
/ format.dataMultiplier);
|
||||
if ((maxV * format.dataMultiplier) > maxVarValue) {
|
||||
format.dataOffset = (float) (maxV - (maxVarValue / format.dataMultiplier));
|
||||
}
|
||||
format.storageFormat = "short";
|
||||
}
|
||||
|
@ -156,11 +156,9 @@ public class GridDbConfig {
|
|||
* @param parmStorageInfo
|
||||
* @return
|
||||
*/
|
||||
private boolean addParmInfo(final GridParmInfo gridParmInfo,
|
||||
final ParmStorageInfo parmStorageInfo) {
|
||||
String key = gridParmInfo.getParmID().getParmName() + "_"
|
||||
+ gridParmInfo.getParmID().getParmLevel();
|
||||
_gridInfoDict.put(key, gridParmInfo);
|
||||
private boolean addParmInfo(final ParmStorageInfo parmStorageInfo) {
|
||||
String key = parmStorageInfo.getParmName() + "_"
|
||||
+ parmStorageInfo.getParmLevel();
|
||||
_parmInfoDict.put(key, parmStorageInfo);
|
||||
|
||||
return true;
|
||||
|
@ -258,10 +256,9 @@ public class GridDbConfig {
|
|||
calcKrunchValues(dataFormat, config.maxAllowedValue,
|
||||
config.minAllowedValue, precision, format);
|
||||
|
||||
ParmStorageInfo psi = new ParmStorageInfo(dataFormat, config.gridSize,
|
||||
parmID.getParmName(), parmID.getParmLevel(), format.dataOffset,
|
||||
format.dataMultiplier, format.storageFormat);
|
||||
return addParmInfo(gpi, psi);
|
||||
ParmStorageInfo psi = new ParmStorageInfo(dataFormat, gpi,
|
||||
format.dataOffset, format.dataMultiplier, format.storageFormat);
|
||||
return addParmInfo(psi);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,7 +277,6 @@ public class GridDbConfig {
|
|||
this._wxDefinition = wxDef;
|
||||
this._discreteDefinition = dDef;
|
||||
this._projectionData = projectionData;
|
||||
this._gridInfoDict = new HashMap<String, GridParmInfo>();
|
||||
this._parmInfoDict = new HashMap<String, ParmStorageInfo>();
|
||||
|
||||
for (int i = 0; i < smc.grids.size(); i++) {
|
||||
|
@ -302,8 +298,6 @@ public class GridDbConfig {
|
|||
this._wxDefinition = orig._wxDefinition;
|
||||
this._discreteDefinition = orig._discreteDefinition;
|
||||
this._projectionData = orig._projectionData;
|
||||
this._gridInfoDict = (HashMap<String, GridParmInfo>) orig._gridInfoDict
|
||||
.clone();
|
||||
this._parmInfoDict = (HashMap<String, ParmStorageInfo>) orig._parmInfoDict
|
||||
.clone();
|
||||
}
|
||||
|
@ -320,7 +314,7 @@ public class GridDbConfig {
|
|||
public List<String> parmAndLevelList() {
|
||||
List<String> parmAndLevels = new ArrayList<String>();
|
||||
|
||||
for (String key : _gridInfoDict.keySet()) {
|
||||
for (String key : _parmInfoDict.keySet()) {
|
||||
parmAndLevels.add(key);
|
||||
}
|
||||
|
||||
|
@ -340,7 +334,7 @@ public class GridDbConfig {
|
|||
public GridParmInfo getGridParmInfo(final String parmName,
|
||||
final String level) {
|
||||
String composite = parmName + "_" + level;
|
||||
return _gridInfoDict.get(composite);
|
||||
return _parmInfoDict.get(composite).getGridParmInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,8 +358,10 @@ public class GridDbConfig {
|
|||
StringBuffer s = new StringBuffer();
|
||||
|
||||
s.append("GRID INFO DICT\n");
|
||||
for (Map.Entry<String, GridParmInfo> entry : _gridInfoDict.entrySet()) {
|
||||
s.append(entry.getKey() + ' ' + entry.getValue() + '\n');
|
||||
for (Map.Entry<String, ParmStorageInfo> entry : _parmInfoDict
|
||||
.entrySet()) {
|
||||
s.append(entry.getKey() + ' ' + entry.getValue().getGridParmInfo()
|
||||
+ '\n');
|
||||
}
|
||||
|
||||
s.append("PARM INFO DICT\n");
|
||||
|
@ -402,8 +398,4 @@ public class GridDbConfig {
|
|||
public ProjectionData projectionData() {
|
||||
return this._projectionData;
|
||||
}
|
||||
|
||||
public HashMap<String, GridParmInfo> get_gridInfoDict() {
|
||||
return _gridInfoDict;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
|||
* 06/24/08 #1160 randerso Added a method to get the Topo dbId
|
||||
* 07/09/09 #2590 njensen No longer singleton
|
||||
* 06/24/13 #2044 randerso Renamed satdirs to satdata to match serverConfig.py
|
||||
* 08/14/2013 #1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -453,7 +454,7 @@ public class IFPServerConfig {
|
|||
|
||||
// common database grid location
|
||||
ProjectionData dProj = new ProjectionData(config.domain.projectionID,
|
||||
config.domain.projectionType.ordinal(), config.domain.latLonLL,
|
||||
config.domain.projectionType, config.domain.latLonLL,
|
||||
config.domain.latLonUR, config.domain.latLonOrigin,
|
||||
config.domain.stdParallelOne, config.domain.stdParallelTwo,
|
||||
config.domain.gridPointLL, config.domain.gridPointUR,
|
||||
|
|
|
@ -1,107 +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.edex.plugin.gfe.config;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
/**
|
||||
* Derived class that consolidates storage info for a Parm.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/14/08 #1030 randerso Initial port
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ParmStorageInfo extends StorageInfo {
|
||||
private String _parmName;
|
||||
|
||||
private String _level;
|
||||
|
||||
private float _dataOffset;
|
||||
|
||||
private float _dataMultiplier;
|
||||
|
||||
private String _dataType;
|
||||
|
||||
public ParmStorageInfo(final String dataType, final Point gridSize,
|
||||
final String parmName, final String level, float dataOffset,
|
||||
float dataMultiplier, final String storageType) {
|
||||
super(storageType, gridSize);
|
||||
_parmName = parmName;
|
||||
_level = level;
|
||||
_dataOffset = dataOffset;
|
||||
_dataMultiplier = dataMultiplier;
|
||||
_dataType = dataType;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ParmStorageInfo)) {
|
||||
return false;
|
||||
}
|
||||
ParmStorageInfo rhs = (ParmStorageInfo) obj;
|
||||
|
||||
if (!_parmName.equals(rhs.parmName()) || !_level.equals(rhs.level())
|
||||
|| _dataOffset != rhs.dataOffset()
|
||||
|| _dataMultiplier != rhs.dataMultiplier()
|
||||
|| !_dataType.equals(rhs.dataType())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String parmName() {
|
||||
return _parmName;
|
||||
}
|
||||
|
||||
public String level() {
|
||||
return _level;
|
||||
}
|
||||
|
||||
public float dataOffset() {
|
||||
return _dataOffset;
|
||||
}
|
||||
|
||||
public float dataMultiplier() {
|
||||
return _dataMultiplier;
|
||||
}
|
||||
|
||||
public String dataType() {
|
||||
return _dataType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ParmStorageInfo for parm: " + parmName() + " Level: " + level()
|
||||
+ " DataType: " + dataType() + " GridSize: " + gridSize()
|
||||
+ " DataOffset: " + dataOffset() + " DataMultiplier: "
|
||||
+ dataMultiplier() + " StorageAreaName: " + storageAreaName()
|
||||
+ " StorageType: " + storageType();
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/13/08 #1030 randerso Initial port
|
||||
* 08/09/2013 #1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,9 +53,8 @@ public class SimpleGridLocation {
|
|||
// ProjectionData
|
||||
public String projectionID;
|
||||
|
||||
public ProjectionData.ProjectionType projectionType; // NONE,
|
||||
public ProjectionData.ProjectionType projectionType;
|
||||
|
||||
// // LAMBERT_CONFORMAL, MERCATOR, POLAR_STEOGRAPHIC, LATLON
|
||||
public Coordinate latLonLL;
|
||||
|
||||
public Coordinate latLonUR;
|
||||
|
@ -82,14 +82,14 @@ public class SimpleGridLocation {
|
|||
}
|
||||
|
||||
public SimpleGridLocation(Point gridSize, Coordinate origin,
|
||||
Coordinate extent, String projID, int projType, Coordinate llll,
|
||||
Coordinate llur, Coordinate llo, float sp1, float sp2, Point gpll,
|
||||
Point gpur, float li, float lc, float lo) {
|
||||
Coordinate extent, String projID, ProjectionType projType,
|
||||
Coordinate llll, Coordinate llur, Coordinate llo, float sp1,
|
||||
float sp2, Point gpll, Point gpur, float li, float lc, float lo) {
|
||||
this.gridSize = gridSize;
|
||||
this.domainOrigin = origin;
|
||||
this.domainExtent = extent;
|
||||
this.projectionID = projID;
|
||||
this.projectionType = ProjectionType.values()[projType];
|
||||
this.projectionType = projType;
|
||||
this.latLonLL = llll;
|
||||
this.latLonUR = llur;
|
||||
this.latLonOrigin = llo;
|
||||
|
|
|
@ -1,96 +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.edex.plugin.gfe.config;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
/**
|
||||
* StorageInfo is a base class for AreaStorageInfo and ParmStorageInfo. This
|
||||
* contains the storage type and grid size. Storage type may be byte, short, or
|
||||
* float.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/18/08 #1030 randerso Initial port
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class StorageInfo {
|
||||
// TODO: if we don't end up porting AreaStorageInfo we should combine this
|
||||
// with ParmStorageInfo
|
||||
private String _storageType;
|
||||
|
||||
private Point _gridSize;
|
||||
|
||||
private String _storageAreaName;
|
||||
|
||||
protected StorageInfo(final String storageType, final Point gridSize) {
|
||||
this._storageType = storageType;
|
||||
this._gridSize = gridSize;
|
||||
this._storageAreaName = makeStorageAreaName(storageType, gridSize);
|
||||
}
|
||||
|
||||
public final String storageType() {
|
||||
return _storageType;
|
||||
}
|
||||
|
||||
public final Point gridSize() {
|
||||
return _gridSize;
|
||||
}
|
||||
|
||||
public final String storageAreaName() {
|
||||
return _storageAreaName;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
|
||||
}
|
||||
if (!(obj instanceof StorageInfo)) {
|
||||
return false;
|
||||
}
|
||||
StorageInfo rhs = (StorageInfo) obj;
|
||||
if (!_storageType.equals(rhs.storageType())
|
||||
|| !_gridSize.equals(rhs.gridSize())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and returns a TextString that uniquely identifies the storage
|
||||
* info. This string is a concatenation of the storageType and gridSize.
|
||||
*
|
||||
* @param storageType
|
||||
* @param gridSize
|
||||
* @return
|
||||
*/
|
||||
static String makeStorageAreaName(final String storageType,
|
||||
final Point gridSize) {
|
||||
return storageType + gridSize.x + 'x' + gridSize.y;
|
||||
}
|
||||
}
|
|
@ -50,7 +50,9 @@ import com.raytheon.uf.common.dataplugin.PluginException;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
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.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmStorageInfo;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
||||
|
@ -98,6 +100,8 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
* 07/30/13 #2057 randerso Added support marking and eventually purging obsolete databases
|
||||
* 08/08/13 DR16485 ryu Remove call to getDatabaseId() from getMaxInsertTimeByDbId()
|
||||
* so new GFE databases aren't accidentally created.
|
||||
* 08/05/13 #1571 randerso Added support for storing GridLocation and ParmStorageInfo in database
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -219,13 +223,13 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves all known parm ids for the given database id.
|
||||
* Retrieves ParmStorageInfo for all known ParmIDs for the given DatabaseID.
|
||||
*
|
||||
* @param dbId
|
||||
* @return the list of ParmIDs for the database
|
||||
* @return the list of ParmStorageInfo for the database
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public List<ParmID> getParmIds(final DatabaseID dbId)
|
||||
public List<ParmStorageInfo> getParmStorageInfo(final DatabaseID dbId)
|
||||
throws DataAccessLayerException {
|
||||
Session sess = null;
|
||||
Transaction tx = null;
|
||||
|
@ -240,11 +244,17 @@ public class GFEDao extends DefaultPluginDao {
|
|||
// relations
|
||||
sess.buildLockRequest(LockOptions.NONE).lock(dbId);
|
||||
|
||||
Query query = sess.createQuery("FROM ParmID WHERE dbId = ?");
|
||||
Query query = sess
|
||||
.createQuery("FROM ParmStorageInfo WHERE gridParmInfo.parmID.dbId = ?");
|
||||
query.setParameter(0, dbId);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ParmID> list = query.list();
|
||||
List<ParmStorageInfo> list = query.list();
|
||||
tx.commit();
|
||||
|
||||
// initialize the grid location objects
|
||||
for (ParmStorageInfo psi : list) {
|
||||
psi.getGridParmInfo().getGridLoc().init();
|
||||
}
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
if (tx != null) {
|
||||
|
@ -256,7 +266,7 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
|
||||
throw new DataAccessLayerException(
|
||||
"Unable to look up parm id inventory for database id "
|
||||
"Unable to retrieve ParmStorageInfos for DatabaseID: "
|
||||
+ dbId, e);
|
||||
} finally {
|
||||
if (sess != null) {
|
||||
|
@ -270,6 +280,100 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a list of ParmStorageInfo
|
||||
*
|
||||
* @param psiList
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public void saveParmStorageInfo(List<ParmStorageInfo> psiList)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
if (psiList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StatelessSession sess = null;
|
||||
Transaction tx = null;
|
||||
|
||||
try {
|
||||
sess = getHibernateTemplate().getSessionFactory()
|
||||
.openStatelessSession();
|
||||
tx = sess.beginTransaction();
|
||||
|
||||
for (ParmStorageInfo psi : psiList) {
|
||||
sess.insert(psi);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
if (tx != null) {
|
||||
try {
|
||||
tx.rollback();
|
||||
} catch (Exception e1) {
|
||||
logger.error("Error occurred rolling back transaction", e1);
|
||||
}
|
||||
}
|
||||
|
||||
throw new DataAccessLayerException(
|
||||
"Unable to save ParmStorageInfos for "
|
||||
+ psiList.get(0).getParmID().getDbId(), e);
|
||||
} finally {
|
||||
if (sess != null) {
|
||||
try {
|
||||
sess.close();
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(
|
||||
"Error occurred closing database session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a ParmStorageInfo
|
||||
*
|
||||
* @param psi
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public void updateParmStorageInfo(ParmStorageInfo psi)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
StatelessSession sess = null;
|
||||
Transaction tx = null;
|
||||
|
||||
try {
|
||||
sess = getHibernateTemplate().getSessionFactory()
|
||||
.openStatelessSession();
|
||||
tx = sess.beginTransaction();
|
||||
sess.update(psi);
|
||||
tx.commit();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
if (tx != null) {
|
||||
try {
|
||||
tx.rollback();
|
||||
} catch (Exception e1) {
|
||||
logger.error("Error occurred rolling back transaction", e1);
|
||||
}
|
||||
}
|
||||
|
||||
throw new DataAccessLayerException(
|
||||
"Unable to update ParmStorageInfos for " + psi.getParmID(),
|
||||
e);
|
||||
} finally {
|
||||
if (sess != null) {
|
||||
try {
|
||||
sess.close();
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(
|
||||
"Error occurred closing database session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database row for the passed parmId. If the row does not
|
||||
* exist, the row will be created.
|
||||
|
@ -353,7 +457,7 @@ public class GFEDao extends DefaultPluginDao {
|
|||
* transaction.
|
||||
*
|
||||
* @param sess
|
||||
* @param dbId
|
||||
* @param parmId
|
||||
* @return
|
||||
*/
|
||||
private ParmID getParmId(Session sess, ParmID parmId) {
|
||||
|
@ -960,8 +1064,7 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes GridParmInfo from the HDF5 file and any data associated with that
|
||||
* info
|
||||
* Removes all grids associated with a parm
|
||||
*
|
||||
* @param parmId
|
||||
* The parm to delete data for
|
||||
|
@ -969,20 +1072,8 @@ public class GFEDao extends DefaultPluginDao {
|
|||
* If errors occur
|
||||
*/
|
||||
public void removeParmData(ParmID parmId) throws DataAccessLayerException {
|
||||
|
||||
try {
|
||||
IDataStore ds = DataStoreFactory.getDataStore(GfeUtil
|
||||
.getGridParmHdf5File(GridDatabase.gfeBaseDataDir,
|
||||
parmId.getDbId()));
|
||||
ds.deleteDatasets("/GridParmInfo/" + parmId.getCompositeName(),
|
||||
"/GridParmStorageInfo/" + parmId.getCompositeName());
|
||||
} catch (Exception e1) {
|
||||
throw new DataAccessLayerException("Error deleting data from HDF5",
|
||||
e1);
|
||||
}
|
||||
List<TimeRange> trs = this.getTimes(parmId);
|
||||
this.deleteRecords(parmId, trs);
|
||||
// TODO: Remove all Locks??
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1317,4 +1408,45 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or update a GridLocation object
|
||||
*
|
||||
* @param gloc
|
||||
* the GridLocation object
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public void saveOrUpdateGridLocation(GridLocation gloc)
|
||||
throws DataAccessLayerException {
|
||||
Session sess = null;
|
||||
Transaction tx = null;
|
||||
|
||||
try {
|
||||
sess = getHibernateTemplate().getSessionFactory().openSession();
|
||||
tx = sess.beginTransaction();
|
||||
sess.saveOrUpdate(gloc);
|
||||
tx.commit();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
if (tx != null) {
|
||||
try {
|
||||
tx.rollback();
|
||||
} catch (Exception e1) {
|
||||
logger.error("Error occurred rolling back transaction", e1);
|
||||
}
|
||||
}
|
||||
|
||||
throw new DataAccessLayerException(
|
||||
"Unable to save GridLocation for " + gloc.getSiteId(), e);
|
||||
} finally {
|
||||
if (sess != null) {
|
||||
try {
|
||||
sess.close();
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(
|
||||
"Error occurred closing database session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package com.raytheon.edex.plugin.gfe.server.database;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -39,10 +38,6 @@ import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.message.WsId;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.util.Pair;
|
||||
|
@ -76,6 +71,8 @@ import com.raytheon.uf.common.util.Pair;
|
|||
* and cachedParmId
|
||||
* 05/02/13 #1969 randerso Removed unnecessary updateDbs method
|
||||
* 06/13/13 #2044 randerso Code cleanup
|
||||
* 08/13/13 #1571 randerso Moved retrieveFromHDF5 methods into IFPGridDatabase
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -110,245 +107,19 @@ public abstract class GridDatabase {
|
|||
*
|
||||
* @param dbId
|
||||
* The database ID for this database
|
||||
* @param gridConfig
|
||||
* The configuration information for this database
|
||||
*/
|
||||
protected GridDatabase(DatabaseID dbId) {
|
||||
this.dbId = dbId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the FloatDataRecord for a grid from HDF5
|
||||
*
|
||||
* @param parmId
|
||||
* @param time
|
||||
* @return the FloatDataRecord
|
||||
* @throws GfeException
|
||||
*/
|
||||
public FloatDataRecord retrieveFromHDF5(ParmID parmId, TimeRange time)
|
||||
throws GfeException {
|
||||
return retrieveFromHDF5(parmId, Arrays.asList(new TimeRange[] { time }))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve FloatDataRecords for a multiple time ranges from HDF5
|
||||
* Returns the mapping of ParmIds and TimeRanges to DataStores and groups
|
||||
* where the data should be stored.
|
||||
*
|
||||
* @param parmId
|
||||
* @param times
|
||||
* @return the FloatDataRecords
|
||||
* @throws GfeException
|
||||
* @return mapping
|
||||
*/
|
||||
public FloatDataRecord[] retrieveFromHDF5(ParmID parmId,
|
||||
List<TimeRange> times) throws GfeException {
|
||||
FloatDataRecord[] scalarData = null;
|
||||
Map<IDataStore, Pair<List<TimeRange>, String[]>> dsAndGroups = getDataStoreAndGroups(
|
||||
parmId, times);
|
||||
|
||||
try {
|
||||
Map<TimeRange, FloatDataRecord> records = new HashMap<TimeRange, FloatDataRecord>(
|
||||
(int) (1.25 * times.size()) + 1);
|
||||
|
||||
// loop over the dataStores and their respective groups to pull all
|
||||
// data, stored into records to reorder requests by times
|
||||
for (Map.Entry<IDataStore, Pair<List<TimeRange>, String[]>> entry : dsAndGroups
|
||||
.entrySet()) {
|
||||
Pair<List<TimeRange>, String[]> pair = entry.getValue();
|
||||
String[] groups = pair.getSecond();
|
||||
|
||||
IDataRecord[] rawData = entry.getKey().retrieveGroups(groups,
|
||||
Request.ALL);
|
||||
|
||||
if (rawData.length != groups.length) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid number of dataSets returned expected 1 per group, received: "
|
||||
+ ((double) rawData.length / groups.length));
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (TimeRange timeRange : pair.getFirst()) {
|
||||
records.put(timeRange, (FloatDataRecord) rawData[count++]);
|
||||
}
|
||||
}
|
||||
|
||||
scalarData = new FloatDataRecord[times.size()];
|
||||
int count = 0;
|
||||
for (TimeRange timeRange : times) {
|
||||
scalarData[count++] = records.get(timeRange);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GfeException("Unable to get data from HDF5 for ParmID: "
|
||||
+ parmId + " TimeRange: " + times, e);
|
||||
}
|
||||
|
||||
return scalarData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the magnitude and direction grids for a vector parm from HDF5
|
||||
*
|
||||
* @param parmId
|
||||
* @param time
|
||||
* @return the the magnitude and direction grids
|
||||
* @throws GfeException
|
||||
*/
|
||||
public FloatDataRecord[] retrieveVectorFromHDF5(ParmID parmId,
|
||||
TimeRange time) throws GfeException {
|
||||
return retrieveVectorFromHDF5(parmId,
|
||||
Arrays.asList(new TimeRange[] { time }))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the magnitude and direction grids for multiple time ranges for a
|
||||
* vector parm from HDF5
|
||||
*
|
||||
* @param parmId
|
||||
* @param times
|
||||
* @return array of magnitude and direction grids
|
||||
* @throws GfeException
|
||||
*/
|
||||
public FloatDataRecord[][] retrieveVectorFromHDF5(ParmID parmId,
|
||||
List<TimeRange> times) throws GfeException {
|
||||
FloatDataRecord[][] vectorData = null;
|
||||
Map<IDataStore, Pair<List<TimeRange>, String[]>> dsAndGroups = getDataStoreAndGroups(
|
||||
parmId, times);
|
||||
|
||||
try {
|
||||
Map<TimeRange, FloatDataRecord[]> records = new HashMap<TimeRange, FloatDataRecord[]>(
|
||||
(int) (1.25 * times.size()) + 1);
|
||||
|
||||
// loop over the dataStores and their respective groups to pull all
|
||||
// data, stored into records to reorder requests by times
|
||||
for (Map.Entry<IDataStore, Pair<List<TimeRange>, String[]>> entry : dsAndGroups
|
||||
.entrySet()) {
|
||||
Pair<List<TimeRange>, String[]> pair = entry.getValue();
|
||||
String[] groups = pair.getSecond();
|
||||
|
||||
IDataRecord[] rawData = entry.getKey().retrieveGroups(groups,
|
||||
Request.ALL);
|
||||
|
||||
if (rawData.length != (groups.length * 2)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid number of dataSets returned expected per group, received: "
|
||||
+ ((double) rawData.length / groups.length));
|
||||
}
|
||||
|
||||
// iterate over the data from this dataStore adding it records
|
||||
int count = 0;
|
||||
for (TimeRange timeRange : pair.getFirst()) {
|
||||
FloatDataRecord[] recs = new FloatDataRecord[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
IDataRecord rec = rawData[(count * 2) + i];
|
||||
if ("Mag".equals(rec.getName())) {
|
||||
recs[0] = (FloatDataRecord) rec;
|
||||
} else if ("Dir".equals(rec.getName())) {
|
||||
recs[1] = (FloatDataRecord) rec;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Unknown dataset retrieved for vector data. Valid values: Mag, Dir Received: "
|
||||
+ rec.getName());
|
||||
}
|
||||
}
|
||||
records.put(timeRange, recs);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
vectorData = new FloatDataRecord[times.size()][2];
|
||||
int count = 0;
|
||||
for (TimeRange timeRange : times) {
|
||||
vectorData[count++] = records.get(timeRange);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GfeException("Unable to get data from HDF5 for ParmID: "
|
||||
+ parmId + " TimeRange: " + times, e);
|
||||
}
|
||||
|
||||
return vectorData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the data and keys for a Discrete grid from HDF5
|
||||
*
|
||||
* @param parmId
|
||||
* @param time
|
||||
* @return ByteDataRecords[] array containing the data and keys
|
||||
* @throws GfeException
|
||||
*/
|
||||
public ByteDataRecord[] retrieveDiscreteFromHDF5(ParmID parmId,
|
||||
TimeRange time) throws GfeException {
|
||||
return retrieveDiscreteFromHDF5(parmId,
|
||||
Arrays.asList(new TimeRange[] { time }))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the ByteDataRecord for a Discrete grid for multiple time ranges
|
||||
* from HDF5
|
||||
*
|
||||
* @param parmId
|
||||
* @param times
|
||||
* @return array containing the data and keys for the specified times
|
||||
* @throws GfeException
|
||||
*/
|
||||
public ByteDataRecord[][] retrieveDiscreteFromHDF5(ParmID parmId,
|
||||
List<TimeRange> times) throws GfeException {
|
||||
ByteDataRecord[][] byteRecords = null;
|
||||
Map<IDataStore, Pair<List<TimeRange>, String[]>> dsAndGroups = getDataStoreAndGroups(
|
||||
parmId, times);
|
||||
|
||||
try {
|
||||
// loop over the dataStores and their respective groups to pull all
|
||||
// data
|
||||
Map<TimeRange, ByteDataRecord[]> records = new HashMap<TimeRange, ByteDataRecord[]>(
|
||||
(int) (1.25 * times.size()) + 1);
|
||||
|
||||
for (Map.Entry<IDataStore, Pair<List<TimeRange>, String[]>> entry : dsAndGroups
|
||||
.entrySet()) {
|
||||
Pair<List<TimeRange>, String[]> pair = entry.getValue();
|
||||
String[] groups = pair.getSecond();
|
||||
|
||||
IDataRecord[] rawData = entry.getKey().retrieveGroups(groups,
|
||||
Request.ALL);
|
||||
|
||||
if (rawData.length != (groups.length * 2)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid number of dataSets returned expected 2 per group, received: "
|
||||
+ ((double) rawData.length / groups.length));
|
||||
}
|
||||
|
||||
// iterate over the data from this dataStore adding it records
|
||||
int count = 0;
|
||||
for (TimeRange timeRange : pair.getFirst()) {
|
||||
ByteDataRecord[] recs = new ByteDataRecord[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
IDataRecord rec = rawData[(count * 2) + i];
|
||||
|
||||
if ("Data".equals(rec.getName())) {
|
||||
recs[0] = (ByteDataRecord) rec;
|
||||
} else if ("Keys".equals(rec.getName())) {
|
||||
recs[1] = (ByteDataRecord) rec;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Unknown dataset retrieved for vector data. Valid values: Data, Keys Received: "
|
||||
+ rec.getName());
|
||||
}
|
||||
}
|
||||
records.put(timeRange, recs);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
byteRecords = new ByteDataRecord[times.size()][2];
|
||||
int count = 0;
|
||||
for (TimeRange timeRange : times) {
|
||||
byteRecords[count++] = records.get(timeRange);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GfeException("Unable to get data from HDF5 for ParmID: "
|
||||
+ parmId + " TimeRange: " + times, e);
|
||||
}
|
||||
return byteRecords;
|
||||
}
|
||||
|
||||
protected Map<IDataStore, Pair<List<TimeRange>, String[]>> getDataStoreAndGroups(
|
||||
ParmID parmId, List<TimeRange> times) {
|
||||
Map<File, Pair<List<TimeRange>, String[]>> fileMap = GfeUtil
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,549 +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.edex.plugin.gfe.util;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StreamTokenizer;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.GeneralEnvelope;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.metadata.spatial.PixelOrientation;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData.ProjectionType;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
public class CreateGFEGridsSQL {
|
||||
static final CreateGFEGridsSQL x = new CreateGFEGridsSQL();
|
||||
|
||||
// public class ProjectionData {
|
||||
// String projectionType;
|
||||
//
|
||||
// Coordinate latLonLL;
|
||||
//
|
||||
// Coordinate latLonUR;
|
||||
//
|
||||
// Coordinate latLonOrigin;
|
||||
//
|
||||
// double stdParallelOne;
|
||||
//
|
||||
// double stdParallelTwo;
|
||||
//
|
||||
// Coordinate gridPointLL;
|
||||
//
|
||||
// Coordinate gridPointUR;
|
||||
//
|
||||
// double latIntersect;
|
||||
//
|
||||
// double lonCenter;
|
||||
//
|
||||
// double lonOrigin;
|
||||
//
|
||||
// public ProjectionData() {
|
||||
// latLonLL = new Coordinate();
|
||||
// latLonUR = new Coordinate();
|
||||
// latLonOrigin = new Coordinate();
|
||||
// gridPointLL = new Coordinate();
|
||||
// gridPointUR = new Coordinate();
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * (non-Javadoc)
|
||||
// *
|
||||
// * @see java.lang.Object#toString()
|
||||
// */
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// String result = "{";
|
||||
//
|
||||
// result += projectionType + ", ";
|
||||
// result += latLonLL + ", ";
|
||||
// result += latLonUR + ", ";
|
||||
// result += latLonOrigin + ", ";
|
||||
// result += stdParallelOne + ", ";
|
||||
// result += stdParallelTwo + ", ";
|
||||
// result += gridPointLL + ", ";
|
||||
// result += gridPointUR + ", ";
|
||||
// result += latIntersect + ", ";
|
||||
// result += lonCenter + ", ";
|
||||
// result += lonOrigin;
|
||||
//
|
||||
// result += "}";
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
public class GridData {
|
||||
Coordinate gridSize;
|
||||
|
||||
Coordinate origin;
|
||||
|
||||
Coordinate extent;
|
||||
|
||||
String timeZone;
|
||||
|
||||
String projName;
|
||||
|
||||
public GridData() {
|
||||
gridSize = new Coordinate();
|
||||
origin = new Coordinate();
|
||||
extent = new Coordinate();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String result = "{";
|
||||
|
||||
result += gridSize + ", ";
|
||||
result += origin + ", ";
|
||||
result += extent + ", ";
|
||||
result += timeZone + ", ";
|
||||
result += projName;
|
||||
|
||||
result += "}";
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new FileReader(
|
||||
"/home/randerso/gfe/GFEProjs.txt"));
|
||||
StreamTokenizer st = new StreamTokenizer(in);
|
||||
st.eolIsSignificant(false);
|
||||
st.parseNumbers();
|
||||
st.quoteChar('\'');
|
||||
st.commentChar('#');
|
||||
st.wordChars('_', '_');
|
||||
|
||||
LinkedHashMap<String, ProjectionData> projMap = new LinkedHashMap<String, ProjectionData>();
|
||||
while (st.ttype != StreamTokenizer.TT_EOF) {
|
||||
if (getToken(st) != StreamTokenizer.TT_WORD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ProjectionData proj = readProj(st);
|
||||
if (proj != null) {
|
||||
projMap.put(proj.getProjectionID(), proj);
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
|
||||
in = new BufferedReader(new FileReader(
|
||||
"/home/randerso/gfe/GFEGrids.txt"));
|
||||
|
||||
st = new StreamTokenizer(in);
|
||||
st.eolIsSignificant(false);
|
||||
st.parseNumbers();
|
||||
st.ordinaryChar('\'');
|
||||
st.commentChar('#');
|
||||
st.wordChars('_', '_');
|
||||
st.wordChars('/', '/');
|
||||
|
||||
LinkedHashMap<String, GridData> gridMap = new LinkedHashMap<String, GridData>();
|
||||
while (st.ttype != StreamTokenizer.TT_EOF) {
|
||||
if (getToken(st) != StreamTokenizer.TT_WORD) {
|
||||
continue;
|
||||
}
|
||||
String id = st.sval;
|
||||
|
||||
GridData grid = readGrid(st);
|
||||
if (grid != null) {
|
||||
if (projMap.containsKey(grid.projName)) {
|
||||
gridMap.put(id, grid);
|
||||
} else {
|
||||
System.out.println("Grid: " + id
|
||||
+ " refers to unknown projection "
|
||||
+ grid.projName);
|
||||
}
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(
|
||||
"/home/randerso/gfe/spatial_gfe.sql"));
|
||||
out.write("DROP TABLE IF EXISTS awips.spatial_gfe;\n");
|
||||
out.write("CREATE TABLE awips.spatial_gfe\n");
|
||||
out.write("(\n");
|
||||
out.write(" siteId character varying(4),\n");
|
||||
out.write(" nx integer,\n");
|
||||
out.write(" ny integer,\n");
|
||||
out.write(" timeZone character varying(32),\n");
|
||||
out.write(" crs character varying(2047),\n");
|
||||
out.write(" coverage geometry,\n");
|
||||
out.write(" CONSTRAINT spatial_gfe_pkey PRIMARY KEY (siteId)\n");
|
||||
out.write(")\n");
|
||||
out.write("WITHOUT OIDS;\n");
|
||||
out.write("ALTER TABLE awips.spatial_gfe OWNER TO awips;\n");
|
||||
out.write("\n\n");
|
||||
|
||||
for (String gridId : gridMap.keySet()) {
|
||||
GridData grid = gridMap.get(gridId);
|
||||
String sql = createInsert(gridId, grid, projMap
|
||||
.get(grid.projName));
|
||||
out.write(sql);
|
||||
out.write("\n\n");
|
||||
}
|
||||
out.close();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getToken(StreamTokenizer st) throws IOException {
|
||||
loop: while (st.nextToken() != StreamTokenizer.TT_EOF) {
|
||||
switch (st.ttype) {
|
||||
case StreamTokenizer.TT_NUMBER:
|
||||
case StreamTokenizer.TT_WORD:
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
return st.ttype;
|
||||
}
|
||||
|
||||
public static GridData readGrid(StreamTokenizer st) throws IOException {
|
||||
GridData grid = x.new GridData();
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
grid.gridSize.x = st.nval;
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
grid.gridSize.y = st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
grid.origin.x = st.nval;
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
grid.origin.y = st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
grid.extent.x = st.nval;
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
grid.extent.y = st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_WORD) {
|
||||
return null;
|
||||
}
|
||||
grid.timeZone = st.sval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_WORD) {
|
||||
return null;
|
||||
}
|
||||
grid.projName = st.sval;
|
||||
|
||||
TimeZone tz = TimeZone.getTimeZone(grid.timeZone);
|
||||
|
||||
if (!grid.timeZone.equals(tz.getID())) {
|
||||
System.out
|
||||
.println("ERROR: unrecognized time zone " + grid.timeZone);
|
||||
}
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
public static ProjectionData readProj(StreamTokenizer st)
|
||||
throws IOException {
|
||||
|
||||
String id = st.sval;
|
||||
if (getToken(st) != StreamTokenizer.TT_WORD) {
|
||||
return null;
|
||||
}
|
||||
String s = st.sval;
|
||||
ProjectionType projectionType = ProjectionType.valueOf(s);
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
Coordinate latLonLL = new Coordinate();
|
||||
latLonLL.x = MapUtil.correctLon(st.nval);
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
latLonLL.y = st.nval;
|
||||
|
||||
Coordinate latLonUR = new Coordinate();
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
latLonUR.x = MapUtil.correctLon(st.nval);
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
latLonUR.y = st.nval;
|
||||
|
||||
Coordinate latLonOrigin = new Coordinate();
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
latLonOrigin.x = MapUtil.correctLon(st.nval);
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
latLonOrigin.y = st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
float stdParallelOne = (float) st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
float stdParallelTwo = (float) st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
Point gridPointLL = new Point();
|
||||
gridPointLL.x = (int) st.nval;
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
gridPointLL.y = (int) st.nval;
|
||||
|
||||
Point gridPointUR = new Point();
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
gridPointUR.x = (int) st.nval;
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
gridPointUR.y = (int) st.nval;
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
float latIntersect = (float) MapUtil.correctLat(st.nval);
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
float lonCenter = (float) MapUtil.correctLon(st.nval);
|
||||
|
||||
if (getToken(st) != StreamTokenizer.TT_NUMBER) {
|
||||
return null;
|
||||
}
|
||||
float lonOrigin = (float) MapUtil.correctLon(st.nval);
|
||||
|
||||
ProjectionData proj = new ProjectionData(id, projectionType.ordinal(),
|
||||
latLonLL, latLonUR, latLonOrigin, stdParallelOne,
|
||||
stdParallelTwo, gridPointLL, gridPointUR, latIntersect,
|
||||
lonCenter, lonOrigin);
|
||||
return proj;
|
||||
}
|
||||
|
||||
public static String createInsert(String gridId, GridData grid,
|
||||
ProjectionData proj) {
|
||||
try {
|
||||
// construct the appropriate CRS based on the projection type
|
||||
CoordinateReferenceSystem crs;
|
||||
switch (proj.getProjectionType()) {
|
||||
case LAMBERT_CONFORMAL:
|
||||
crs = MapUtil.constructLambertConformal(
|
||||
MapUtil.AWIPS_EARTH_RADIUS, MapUtil.AWIPS_EARTH_RADIUS,
|
||||
proj.getStdParallelOne(), proj.getStdParallelTwo(),
|
||||
proj.getLatLonOrigin().x);
|
||||
break;
|
||||
|
||||
case MERCATOR:
|
||||
crs = MapUtil.constructMercator(MapUtil.AWIPS_EARTH_RADIUS,
|
||||
MapUtil.AWIPS_EARTH_RADIUS, proj.getStdParallelOne(),
|
||||
proj.getLonCenter());
|
||||
break;
|
||||
|
||||
case POLAR_STEREOGRAPHIC:
|
||||
crs = MapUtil.constructNorthPolarStereo(
|
||||
MapUtil.AWIPS_EARTH_RADIUS, MapUtil.AWIPS_EARTH_RADIUS,
|
||||
60.0, proj.getLonOrigin());
|
||||
break;
|
||||
|
||||
case LATLON:
|
||||
crs = MapUtil.LATLON_PROJECTION;
|
||||
break;
|
||||
|
||||
case NONE:
|
||||
default:
|
||||
System.out.println("ERROR: unknown projection type: "
|
||||
+ proj.getProjectionType());
|
||||
return "";
|
||||
}
|
||||
|
||||
// transform the projection corner points to CRS units
|
||||
MathTransform mt = MapUtil.getTransformFromLatLon(crs);
|
||||
double[] output = new double[4];
|
||||
mt.transform(new double[] { proj.getLatLonLL().x,
|
||||
proj.getLatLonLL().y, proj.getLatLonUR().x,
|
||||
proj.getLatLonUR().y }, 0, output, 0, 2);
|
||||
|
||||
// create a grid geometry for the projection
|
||||
GeneralEnvelope ge = new GeneralEnvelope(2);
|
||||
ge.setCoordinateReferenceSystem(crs);
|
||||
ge.setRange(0, Math.min(output[0], output[2]), Math.max(output[0],
|
||||
output[2]));
|
||||
ge.setRange(1, Math.min(output[1], output[3]), Math.max(output[1],
|
||||
output[3]));
|
||||
|
||||
GeneralGridEnvelope gr = new GeneralGridEnvelope(new int[] {
|
||||
proj.getGridPointLL().x, proj.getGridPointLL().y },
|
||||
new int[] { proj.getGridPointUR().x,
|
||||
proj.getGridPointUR().y }, false);
|
||||
|
||||
GridGeometry2D projGeom = new GridGeometry2D(gr, ge);
|
||||
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
double[] latLon = new double[8];
|
||||
|
||||
// check to see if the projection looks right
|
||||
// mt = dmtf.createConcatenatedTransform(projGeom
|
||||
// .getGridToCRS(PixelOrientation.UPPER_LEFT), MapUtil
|
||||
// .getTransformToLatLon(crs));
|
||||
// mt.transform(new double[] { proj.getGridPointLL().x,
|
||||
// proj.getGridPointUR().y, proj.getGridPointLL().x,
|
||||
// proj.getGridPointLL().y, proj.getGridPointUR().x,
|
||||
// proj.getGridPointLL().y, proj.getGridPointUR().x,
|
||||
// proj.getGridPointUR().y }, 0, latLon, 0, 4);
|
||||
//
|
||||
// System.out.println();
|
||||
// System.out.println(grid.projName);
|
||||
// for (int i = 0; i < latLon.length; i += 2) {
|
||||
// System.out
|
||||
// .println("(" + latLon[i + 1] + ", " + latLon[i] + ")");
|
||||
// }
|
||||
|
||||
// transform the grid corners from grid coordinates to CRS units
|
||||
// need to adjust for the fact that AWIPS considers 1,1 to be in
|
||||
// lower left
|
||||
// and GeoTools considers 1,1 to be in upper left
|
||||
Coordinate ll = new Coordinate(grid.origin.x,
|
||||
proj.getGridPointUR().y - grid.origin.y
|
||||
+ proj.getGridPointLL().y);
|
||||
Coordinate ur = new Coordinate(grid.origin.x + grid.extent.x, ll.y
|
||||
- grid.extent.y);
|
||||
|
||||
mt.transform(new double[] { ll.x, ll.y, ur.x, ur.y }, 0, output, 0,
|
||||
2);
|
||||
|
||||
// System.out.println();
|
||||
// for (int i = 0; i < output.length; i += 2) {
|
||||
// System.out
|
||||
// .println("(" + output[i + 1] + ", " + output[i] + ")");
|
||||
// }
|
||||
|
||||
mt = projGeom.getGridToCRS(PixelOrientation.UPPER_LEFT);
|
||||
output = new double[4];
|
||||
mt.transform(new double[] { ll.x, ll.y, ur.x, ur.y }, 0, output, 0,
|
||||
2);
|
||||
|
||||
// construct the grid geometry that covers the GFE grid
|
||||
ge.setRange(0, Math.min(output[0], output[2]), Math.max(output[0],
|
||||
output[2]));
|
||||
ge.setRange(1, Math.min(output[1], output[3]), Math.max(output[1],
|
||||
output[3]));
|
||||
GridGeometry2D gridGeom = new GridGeometry2D(
|
||||
new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] {
|
||||
(int) grid.gridSize.x - 1,
|
||||
(int) grid.gridSize.y - 1 }, false), ge);
|
||||
|
||||
// set up the transform from grid coordinates to lon/lat
|
||||
mt = dmtf.createConcatenatedTransform(gridGeom
|
||||
.getGridToCRS(PixelOrientation.CENTER), MapUtil
|
||||
.getTransformToLatLon(crs));
|
||||
|
||||
// transform grid corner points to Lat/Lon
|
||||
mt.transform(new double[] { -1.0, grid.gridSize.y - 1, -1.0, -1.0,
|
||||
grid.gridSize.x - 1, -1.0, grid.gridSize.x - 1,
|
||||
grid.gridSize.y - 1 }, 0, latLon, 0, 4);
|
||||
|
||||
// System.out.println();
|
||||
// System.out.println(gridId);
|
||||
// for (int i = 0; i < latLon.length; i += 2) {
|
||||
// System.out
|
||||
// .println("(" + latLon[i + 1] + ", " + latLon[i] + ")");
|
||||
// }
|
||||
|
||||
StringBuffer sql = new StringBuffer();
|
||||
sql
|
||||
.append("INSERT INTO awips.spatial_gfe (siteId,nx,ny,timeZone,crs,coverage) VALUES (");
|
||||
|
||||
sql.append("'" + gridId + "',");
|
||||
sql.append((int) grid.gridSize.x + ",");
|
||||
sql.append((int) grid.gridSize.y + ",");
|
||||
sql.append("'" + grid.timeZone + "',");
|
||||
sql.append("'" + crs.toWKT() + "',\n");
|
||||
sql.append("GeomFromText('POLYGON ((" + latLon[0] + " " + latLon[1]
|
||||
+ ",\n" + latLon[2] + " " + latLon[3] + ",\n" + latLon[4]
|
||||
+ " " + latLon[5] + ",\n" + latLon[6] + " " + latLon[7]
|
||||
+ ",\n" + latLon[0] + " " + latLon[1] + "))',-1)");
|
||||
|
||||
sql.append(");");
|
||||
return sql.toString();
|
||||
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (FactoryException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -17,8 +17,21 @@
|
|||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
# doConfig - validate and convert serverConfig into simple Java objects
|
||||
#
|
||||
# this file was originally config.py
|
||||
# it was renamed to avoid a conflict with jep's built-in config module
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 08/09/2013 #1571 randerso Changed projections to use the Java
|
||||
# ProjectionType enumeration
|
||||
#
|
||||
########################################################################
|
||||
import types
|
||||
|
||||
from java.util import ArrayList,LinkedHashMap
|
||||
|
@ -51,9 +64,15 @@ def check(data, fmt, message, allData = None):
|
|||
m = m + ' All: ' + `allData`
|
||||
raise AssertionError, m
|
||||
for i in xrange(len(data)):
|
||||
if type(data[i]) != fmt[i]:
|
||||
obj = data[i]
|
||||
if hasattr(obj, "jclassname"):
|
||||
t = obj.jclassname
|
||||
else:
|
||||
t = type(obj)
|
||||
|
||||
if t != fmt[i]:
|
||||
m = message + ": Wrong data type found, " + \
|
||||
"Expected " + `fmt[i]` + ", got " + `type(data[i])` + \
|
||||
"Expected " + `fmt[i]` + ", got " + `t` + \
|
||||
" for position #" + `i+1` + " Input: " + `data`
|
||||
if allData is not None:
|
||||
m = m + ' All: ' + `allData`
|
||||
|
@ -235,8 +254,9 @@ def parseDBItm(site, domain, item):
|
|||
def updateProjections(projection):
|
||||
from com.raytheon.uf.common.dataplugin.gfe.config import ProjectionData
|
||||
# extract projection data
|
||||
projFmt = (str, int, tuple, tuple, tuple, float, float, tuple, tuple,
|
||||
float, float, float)
|
||||
projFmt = (str,
|
||||
"com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData$ProjectionType",
|
||||
tuple, tuple, tuple, float, float, tuple, tuple, float, float, float)
|
||||
projID, ptype, pllll, pllur, pllo, pspo, pspt, pgpll, pgpur, pli, \
|
||||
plc, plo = check(projection, projFmt, "Format error in Projection")
|
||||
check(pllll, (float, float),
|
||||
|
@ -276,8 +296,9 @@ def parseGridLocation(domain):
|
|||
check(origin, (float, float), "Origin format error from SITES", domain)
|
||||
check(extent, (float, float), "Extent format error from SITES", domain)
|
||||
|
||||
projFmt = (str, int, tuple, tuple, tuple, float, float, tuple, tuple,
|
||||
float, float, float)
|
||||
projFmt = (str,
|
||||
"com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData$ProjectionType",
|
||||
tuple, tuple, tuple, float, float, tuple, tuple, float, float, float)
|
||||
projID, projType, llll, llur, llo, sp1, sp2, gpll, gpur, li, lc, lo = \
|
||||
check(proj, projFmt, "Format error in Projection")
|
||||
check(llll, (float, float),
|
||||
|
|
|
@ -17,8 +17,21 @@
|
|||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
# serverConfig -- base GFE server configuration file
|
||||
#
|
||||
# NOTE: THIS FILE SHOULD NOT BE USER-MODIFIED. INSTEAD REFER TO THE
|
||||
# LOCAL CONFIG DOCUMENTATION ON HOW TO OVERRIDE SETTINGS IN THIS FILE.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 08/09/2013 #1571 randerso Changed projections to use the Java
|
||||
# ProjectionType enumeration
|
||||
#
|
||||
########################################################################
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# USEFUL DEFINES
|
||||
|
@ -458,11 +471,12 @@ if not BASELINE and siteImport('localWxConfig'):
|
|||
# Projection Configuration section.
|
||||
#
|
||||
#---------------------------------------------------------------------------
|
||||
NONE = 0
|
||||
LAMBERT_CONFORMAL = 1
|
||||
MERCATOR = 2
|
||||
POLAR_STEREOGRAPHIC = 3
|
||||
LATLON = 4
|
||||
from com.raytheon.uf.common.dataplugin.gfe.config import ProjectionData_ProjectionType as ProjectionType
|
||||
NONE = ProjectionType.NONE
|
||||
LAMBERT_CONFORMAL = ProjectionType.LAMBERT_CONFORMAL
|
||||
MERCATOR = ProjectionType.MERCATOR
|
||||
POLAR_STEREOGRAPHIC = ProjectionType.POLAR_STEREOGRAPHIC
|
||||
LATLON = ProjectionType.LATLON
|
||||
|
||||
# projectionID / projectionType / latLonLL / latLonUR /
|
||||
# latLonOrigin / stdParallelOne / stdParallelTwo / gridPointLL / gridPointUR
|
||||
|
|
|
@ -67,6 +67,8 @@ from com.raytheon.uf.common.localization import LocalizationContext_Localization
|
|||
# 05/23/13 1759 dgilling Remove unnecessary imports.
|
||||
# 06/13/13 2044 randerso Updated for changes to TopoDatabaseManager
|
||||
# 07/25/13 2233 randerso Improved memory utilization and performance
|
||||
# 08/09/2013 1571 randerso Changed projections to use the Java
|
||||
# ProjectionType enumeration
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -650,15 +652,15 @@ def storeProjectionAttributes(var, projectionData):
|
|||
setattr(var, "projectionType", projectionType.toString())
|
||||
|
||||
# Now store the projection specific attributes
|
||||
if projectionType.toString() == "LAMBERT_CONFORMAL":
|
||||
if ProjectionType.LAMBERT_CONFORMAL.equals(projectionType):
|
||||
setattr(var, "latLonOrigin", (projectionData.getLatLonOrigin().x, projectionData.getLatLonOrigin().y))
|
||||
setattr(var, "stdParallelOne", projectionData.getStdParallelOne())
|
||||
setattr(var, "stdParallelTwo", projectionData.getStdParallelTwo())
|
||||
|
||||
if projectionType.toString() == "POLAR_STEREOGRAPHIC":
|
||||
if ProjectionType.POLAR_STEREOGRAPHIC.equals(projectionType):
|
||||
setattr(var, "lonOrigin", projectionData.getLonOrigin())
|
||||
|
||||
if projectionType.toString() == "MERCATOR":
|
||||
if ProjectionType.MERCATOR.equals(projectionType):
|
||||
setattr(var, "lonCenter", projectionData.getLonCenter())
|
||||
|
||||
return
|
||||
|
|
|
@ -2,7 +2,9 @@ com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData
|
|||
com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID
|
||||
com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord
|
||||
com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation
|
||||
com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo
|
||||
com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID
|
||||
com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmStorageInfo
|
||||
com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData
|
||||
com.raytheon.uf.common.dataplugin.gfe.sample.SampleData
|
||||
com.raytheon.uf.common.dataplugin.gfe.server.lock.Lock
|
||||
|
|
|
@ -49,7 +49,6 @@ import com.raytheon.uf.common.geospatial.interpolation.GridReprojection;
|
|||
import com.raytheon.uf.common.geospatial.interpolation.NearestNeighborInterpolation;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.PrecomputedGridReprojection;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.ByteBufferWrapper;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
|
@ -68,6 +67,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* 07/09/13 #2044 randerso Made SoftReferences to interp and rotation since
|
||||
* they can be quite large and may not be needed frequently
|
||||
* 07/17/13 #2185 bsteffen Cache computed grid reprojections.
|
||||
* 08/13/13 #1571 randerso Passed fill values into interpolator.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -154,7 +154,7 @@ public class RemapGrid {
|
|||
float max, float min, float outputFill) throws FactoryException,
|
||||
TransformException {
|
||||
|
||||
Grid2DFloat retVal = resample(input);
|
||||
Grid2DFloat retVal = resample(input, inputFill, outputFill);
|
||||
limitGrid(retVal, inputFill, max, min, outputFill);
|
||||
return retVal;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class RemapGrid {
|
|||
return input;
|
||||
}
|
||||
|
||||
retVal = resample(input);
|
||||
retVal = resample(input, inputFill, outputFill);
|
||||
|
||||
ByteBuffer buffer = retVal.getBuffer();
|
||||
buffer.rewind();
|
||||
|
@ -259,7 +259,7 @@ public class RemapGrid {
|
|||
* The max value for data values
|
||||
* @param minLimit
|
||||
* The min value for data values
|
||||
* @param outputFillValue
|
||||
* @param outputFill
|
||||
* The output fill value
|
||||
* @param rotate
|
||||
* The rotation flag
|
||||
|
@ -273,9 +273,9 @@ public class RemapGrid {
|
|||
* If grid dimensions do not match or resampling fails
|
||||
*/
|
||||
public void remapUV(final Grid2DFloat uinput, final Grid2DFloat vinput,
|
||||
float inputFill, float maxLimit, float minLimit,
|
||||
float outputFillValue, boolean rotate, boolean flip,
|
||||
Grid2DFloat magGrid, Grid2DFloat dirGrid) throws Exception {
|
||||
float inputFill, float maxLimit, float minLimit, float outputFill,
|
||||
boolean rotate, boolean flip, Grid2DFloat magGrid,
|
||||
Grid2DFloat dirGrid) throws Exception {
|
||||
|
||||
if ((uinput.getXdim() != sourceGloc.getNx())
|
||||
|| (uinput.getYdim() != sourceGloc.getNy())
|
||||
|
@ -303,13 +303,13 @@ public class RemapGrid {
|
|||
}
|
||||
}
|
||||
|
||||
Grid2DFloat resampledUinput = resample(uinput);
|
||||
Grid2DFloat resampledVinput = resample(vinput);
|
||||
Grid2DFloat resampledUinput = resample(uinput, Float.NaN, Float.NaN);
|
||||
Grid2DFloat resampledVinput = resample(vinput, Float.NaN, Float.NaN);
|
||||
|
||||
calculateWindGrid(resampledUinput, resampledVinput, rotate, flip,
|
||||
magGrid, dirGrid);
|
||||
|
||||
limitGrid(magGrid, inputFill, maxLimit, minLimit, outputFillValue);
|
||||
limitGrid(magGrid, inputFill, maxLimit, minLimit, outputFill);
|
||||
limitGrid(dirGrid, 0.0f, 360.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
|
@ -476,12 +476,16 @@ public class RemapGrid {
|
|||
*
|
||||
* @param input
|
||||
* The input data
|
||||
* @param inputFill
|
||||
* the input fill value
|
||||
* @param outputFill
|
||||
* the output fill value
|
||||
* @return The resampled data
|
||||
* @throws TransformException
|
||||
* @throws FactoryException
|
||||
*/
|
||||
private Grid2DByte resample(final Grid2DByte input)
|
||||
throws FactoryException, TransformException {
|
||||
private Grid2DByte resample(final Grid2DByte input, float inputFill,
|
||||
float outputFill) throws FactoryException, TransformException {
|
||||
|
||||
GridGeometry2D sourceGeometry = MapUtil.getGridGeometry(sourceGloc);
|
||||
|
||||
|
@ -491,10 +495,15 @@ public class RemapGrid {
|
|||
GridGeometry2D destGeometry = MapUtil.getGridGeometry(destinationGloc);
|
||||
GridReprojection interp = PrecomputedGridReprojection.getReprojection(
|
||||
sourceGeometry, destGeometry);
|
||||
DataSource source = new ByteBufferWrapper(data, sourceGeometry);
|
||||
|
||||
ByteBufferWrapper source = new ByteBufferWrapper(data, sourceGeometry);
|
||||
source.setFillValue(inputFill);
|
||||
|
||||
ByteBufferWrapper dest = new ByteBufferWrapper(destGeometry);
|
||||
dest.setFillValue(outputFill);
|
||||
|
||||
resampledData = interp.reprojectedGrid(
|
||||
new NearestNeighborInterpolation(), source,
|
||||
new ByteBufferWrapper(destGeometry)).getBuffer();
|
||||
new NearestNeighborInterpolation(), source, dest).getBuffer();
|
||||
|
||||
// Remap the the output data into a Grid2DFloat object
|
||||
|
||||
|
@ -510,12 +519,16 @@ public class RemapGrid {
|
|||
*
|
||||
* @param input
|
||||
* The input data
|
||||
* @param inputFill
|
||||
* the input fill value
|
||||
* @param outputFill
|
||||
* the output fill value
|
||||
* @return The resampled data
|
||||
* @throws TransformException
|
||||
* @throws FactoryException
|
||||
*/
|
||||
private Grid2DFloat resample(final Grid2DFloat input)
|
||||
throws FactoryException, TransformException {
|
||||
private Grid2DFloat resample(final Grid2DFloat input, float inputFill,
|
||||
float outputFill) throws FactoryException, TransformException {
|
||||
|
||||
GridGeometry2D sourceGeometry = MapUtil.getGridGeometry(sourceGloc);
|
||||
|
||||
|
@ -566,9 +579,16 @@ public class RemapGrid {
|
|||
|
||||
GridReprojection interp = PrecomputedGridReprojection
|
||||
.getReprojection(sourceGeometry, destGeometry);
|
||||
DataSource source = new FloatArrayWrapper(data, sourceGeometry);
|
||||
|
||||
FloatArrayWrapper source = new FloatArrayWrapper(data,
|
||||
sourceGeometry);
|
||||
source.setFillValue(inputFill);
|
||||
|
||||
FloatArrayWrapper dest = new FloatArrayWrapper(destGeometry);
|
||||
dest.setFillValue(outputFill);
|
||||
|
||||
f1 = interp.reprojectedGrid(new BilinearInterpolation(), source,
|
||||
new FloatArrayWrapper(destGeometry)).getArray();
|
||||
dest).getArray();
|
||||
}
|
||||
|
||||
// Remap the the output data into a Grid2DFloat object
|
||||
|
|
|
@ -22,6 +22,11 @@ package com.raytheon.uf.common.dataplugin.gfe.config;
|
|||
import java.awt.Point;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Transient;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -44,6 +49,8 @@ import com.raytheon.uf.common.serialization.adapters.CoordAdapter;
|
|||
import com.raytheon.uf.common.serialization.adapters.PointAdapter;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
|
@ -56,91 +63,136 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* 03/13/08 #1030 randerso Initial port
|
||||
* 04/24/08 #1047 randerso Made all fields private and created getters
|
||||
* 04/24/13 #1935 randerso Fixed date line spanning issue
|
||||
* 08/06/13 #1571 randerso Added hibernate annotations
|
||||
* Removed constructor with int for ProjectionType
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
@Embeddable
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class ProjectionData implements ISerializableObject {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ProjectionData.class);
|
||||
|
||||
private static float COMPARISON_THRESHOLD = 0.005f;
|
||||
|
||||
/**
|
||||
* Enumeration of supported map projections
|
||||
*/
|
||||
public static enum ProjectionType {
|
||||
NONE, LAMBERT_CONFORMAL, MERCATOR, POLAR_STEREOGRAPHIC, LATLON
|
||||
/** Undefined map projection */
|
||||
NONE,
|
||||
|
||||
/** Lambert Conformal map projection */
|
||||
LAMBERT_CONFORMAL,
|
||||
|
||||
/** MERCATOR map projection */
|
||||
MERCATOR,
|
||||
|
||||
/** North polar stereographic map projection */
|
||||
POLAR_STEREOGRAPHIC,
|
||||
|
||||
/** Lat/Lon (implemented as Equidistant Cylindrical) map projection */
|
||||
LATLON
|
||||
};
|
||||
|
||||
@Column(length = 32, nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String projectionID;
|
||||
|
||||
@Column(length = 20, nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private ProjectionType projectionType;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Coordinate latLonLL;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Coordinate latLonUR;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Coordinate latLonOrigin;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private double stdParallelOne;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private double stdParallelTwo;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = PointAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Point gridPointLL;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = PointAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Point gridPointUR;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private double latIntersect;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private double lonCenter;
|
||||
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private double lonOrigin;
|
||||
|
||||
@Transient
|
||||
private CoordinateReferenceSystem crs;
|
||||
|
||||
@Transient
|
||||
private GridGeometry2D gridGeometry;
|
||||
|
||||
@Transient
|
||||
private MathTransform crsToLatLon;
|
||||
|
||||
@Transient
|
||||
private MathTransform latLonToCrs;
|
||||
|
||||
@Transient
|
||||
private HashMap<PixelOrientation, MathTransform> gridToLatLon;
|
||||
|
||||
@Transient
|
||||
private HashMap<PixelOrientation, MathTransform> latLonToGrid;
|
||||
|
||||
@Transient
|
||||
private HashMap<PixelOrientation, MathTransform> gridToCrs;
|
||||
|
||||
@Transient
|
||||
private boolean initialized;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public ProjectionData() {
|
||||
latLonLL = new Coordinate();
|
||||
latLonUR = new Coordinate();
|
||||
|
@ -155,17 +207,34 @@ public class ProjectionData implements ISerializableObject {
|
|||
initialized = false;
|
||||
}
|
||||
|
||||
public ProjectionData(String projID, int projType, Coordinate latLonLL,
|
||||
Coordinate latLonUR, Coordinate latLonOrig, float stdPar1,
|
||||
float stdPar2, Point gridLL, Point gridUR, float latInt,
|
||||
float lonCenter, float lonOrig) {
|
||||
this(projID, ProjectionType.values()[projType], latLonLL, latLonUR,
|
||||
latLonOrig, stdPar1, stdPar2, gridLL, gridUR, latInt,
|
||||
lonCenter, lonOrig);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param projID
|
||||
* name associated with this projection
|
||||
* @param projType
|
||||
* projection type
|
||||
* @param latLonLL
|
||||
* lat/lon of lower left corner
|
||||
* @param latLonUR
|
||||
* lat/lon of upper right corner
|
||||
* @param latLonOrig
|
||||
* lat/lon of origin (Lambert)
|
||||
* @param stdPar1
|
||||
* standard parallel one (Lambert, Mercator)
|
||||
* @param stdPar2
|
||||
* standard parallel two (Lambert)
|
||||
* @param gridLL
|
||||
* coordinates of lower left grid cell, typically (1,1)
|
||||
* @param gridUR
|
||||
* coordinates of upper right grid cell, typically (nX,nY)
|
||||
* @param latInt
|
||||
* lat intersect (unused, preserved for A1 compatibility)
|
||||
* @param lonCenter
|
||||
* lon center (Mercator, LatLon)
|
||||
* @param lonOrig
|
||||
* lon origin (Lambert, Polar Stereographic)
|
||||
*/
|
||||
public ProjectionData(String projID, ProjectionType projType,
|
||||
Coordinate latLonLL, Coordinate latLonUR, Coordinate latLonOrig,
|
||||
float stdPar1, float stdPar2, Point gridLL, Point gridUR,
|
||||
|
@ -188,7 +257,10 @@ public class ProjectionData implements ISerializableObject {
|
|||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
/**
|
||||
* Initialize the object. Must be called after database retrieval
|
||||
*/
|
||||
public void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
@ -259,6 +331,11 @@ public class ProjectionData implements ISerializableObject {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Coordinate Reference System (CRS) of this projection
|
||||
*
|
||||
* @return the CRS
|
||||
*/
|
||||
public synchronized CoordinateReferenceSystem getCrs() {
|
||||
if (crs == null) {
|
||||
|
||||
|
@ -310,20 +387,20 @@ public class ProjectionData implements ISerializableObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Math.abs(this.latLonLL.y - rhs.latLonLL.y) > COMPARISON_THRESHOLD
|
||||
|| Math.abs(this.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD
|
||||
|| Math.abs(this.latLonUR.y - rhs.latLonUR.y) > COMPARISON_THRESHOLD
|
||||
|| Math.abs(this.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD) {
|
||||
if ((Math.abs(this.latLonLL.y - rhs.latLonLL.y) > COMPARISON_THRESHOLD)
|
||||
|| (Math.abs(this.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD)
|
||||
|| (Math.abs(this.latLonUR.y - rhs.latLonUR.y) > COMPARISON_THRESHOLD)
|
||||
|| (Math.abs(this.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// specific projection comparisons
|
||||
switch (this.projectionType) {
|
||||
case LAMBERT_CONFORMAL:
|
||||
return (Math.abs(this.latLonOrigin.y - rhs.latLonOrigin.y) < COMPARISON_THRESHOLD
|
||||
|| Math.abs(this.latLonOrigin.x - rhs.latLonOrigin.x) < COMPARISON_THRESHOLD
|
||||
|| Math.abs(this.stdParallelOne - rhs.stdParallelOne) < COMPARISON_THRESHOLD || Math
|
||||
.abs(this.stdParallelTwo - rhs.stdParallelTwo) < COMPARISON_THRESHOLD);
|
||||
return ((Math.abs(this.latLonOrigin.y - rhs.latLonOrigin.y) < COMPARISON_THRESHOLD)
|
||||
|| (Math.abs(this.latLonOrigin.x - rhs.latLonOrigin.x) < COMPARISON_THRESHOLD)
|
||||
|| (Math.abs(this.stdParallelOne - rhs.stdParallelOne) < COMPARISON_THRESHOLD) || (Math
|
||||
.abs(this.stdParallelTwo - rhs.stdParallelTwo) < COMPARISON_THRESHOLD));
|
||||
case POLAR_STEREOGRAPHIC:
|
||||
return (Math.abs(this.lonOrigin - rhs.lonOrigin) < COMPARISON_THRESHOLD);
|
||||
case MERCATOR:
|
||||
|
@ -335,6 +412,15 @@ public class ProjectionData implements ISerializableObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the lat/lon of the specified corner or center of a grid cell
|
||||
*
|
||||
* @param gridCoord
|
||||
* coordinates of the grid cell
|
||||
* @param orientation
|
||||
* desired corner or center
|
||||
* @return the lat/lon
|
||||
*/
|
||||
public Coordinate gridCoordinateToLatLon(Coordinate gridCoord,
|
||||
PixelOrientation orientation) {
|
||||
Coordinate latLon = new Coordinate();
|
||||
|
@ -354,51 +440,40 @@ public class ProjectionData implements ISerializableObject {
|
|||
latLon.x = output[0];
|
||||
latLon.y = output[1];
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.error(
|
||||
"Error computing grid coordinate to lat/lon transform", e);
|
||||
}
|
||||
return latLon;
|
||||
}
|
||||
|
||||
public Coordinate latLonToGridCoordinate(Coordinate latLon,
|
||||
PixelOrientation orientation) {
|
||||
Coordinate gridCoord = new Coordinate();
|
||||
MathTransform mt = latLonToGrid.get(orientation);
|
||||
try {
|
||||
if (mt == null) {
|
||||
init();
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
mt = dmtf.createConcatenatedTransform(latLonToCrs, gridGeometry
|
||||
.getGridToCRS(orientation).inverse());
|
||||
latLonToGrid.put(orientation, mt);
|
||||
}
|
||||
|
||||
double[] output = new double[2];
|
||||
mt.transform(new double[] { latLon.x, latLon.y }, 0, output, 0, 1);
|
||||
gridCoord.x = output[0];
|
||||
gridCoord.y = output[1];
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return gridCoord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the math transform from grid coordinate to the specified corner or
|
||||
* center lat/lon
|
||||
*
|
||||
* @param orientation
|
||||
* desired corner or center
|
||||
* @return the transform
|
||||
*/
|
||||
public MathTransform getGridToCrs(PixelOrientation orientation) {
|
||||
MathTransform mt = gridToCrs.get(orientation);
|
||||
try {
|
||||
if (mt == null) {
|
||||
init();
|
||||
mt = gridGeometry.getGridToCRS(orientation);
|
||||
gridToCrs.put(orientation, mt);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
if (mt == null) {
|
||||
init();
|
||||
mt = gridGeometry.getGridToCRS(orientation);
|
||||
gridToCrs.put(orientation, mt);
|
||||
}
|
||||
return mt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a grid cell coordinate to the native CRS coordinate of this
|
||||
* projection
|
||||
*
|
||||
* @param gridCoord
|
||||
* grid cell coordinate
|
||||
* @param orientation
|
||||
* desired corner or center of the grid cell
|
||||
* @return native CRS coordinate
|
||||
*/
|
||||
public Coordinate gridCoordinateToCrs(Coordinate gridCoord,
|
||||
PixelOrientation orientation) {
|
||||
Coordinate crsCoordinate = new Coordinate();
|
||||
|
@ -410,114 +485,204 @@ public class ProjectionData implements ISerializableObject {
|
|||
crsCoordinate.x = output[0];
|
||||
crsCoordinate.y = output[1];
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.error(
|
||||
"Error computing grid coordinate to CRS transform", e);
|
||||
}
|
||||
return crsCoordinate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the projectionID
|
||||
*/
|
||||
public String getProjectionID() {
|
||||
return projectionID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the projectionType
|
||||
*/
|
||||
public ProjectionType getProjectionType() {
|
||||
return projectionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the latLonLL
|
||||
*/
|
||||
public Coordinate getLatLonLL() {
|
||||
return latLonLL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the latLonUR
|
||||
*/
|
||||
public Coordinate getLatLonUR() {
|
||||
return latLonUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the latLonOrigin
|
||||
*/
|
||||
public Coordinate getLatLonOrigin() {
|
||||
return latLonOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stdParallelOne
|
||||
*/
|
||||
public double getStdParallelOne() {
|
||||
return stdParallelOne;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stdParallelTwo
|
||||
*/
|
||||
public double getStdParallelTwo() {
|
||||
return stdParallelTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gridPointLL
|
||||
*/
|
||||
public Point getGridPointLL() {
|
||||
return gridPointLL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gridPointUR
|
||||
*/
|
||||
public Point getGridPointUR() {
|
||||
return gridPointUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the latIntersect
|
||||
*/
|
||||
public double getLatIntersect() {
|
||||
return latIntersect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lonCenter
|
||||
*/
|
||||
public double getLonCenter() {
|
||||
return lonCenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lonOrigin
|
||||
*/
|
||||
public double getLonOrigin() {
|
||||
return lonOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param projectionID
|
||||
* the projectionID to set
|
||||
*/
|
||||
public void setProjectionID(String projectionID) {
|
||||
this.projectionID = projectionID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param projectionType
|
||||
* the projectionType to set
|
||||
*/
|
||||
public void setProjectionType(ProjectionType projectionType) {
|
||||
this.projectionType = projectionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latLonLL
|
||||
* the latLonLL to set
|
||||
*/
|
||||
public void setLatLonLL(Coordinate latLonLL) {
|
||||
this.latLonLL = latLonLL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latLonUR
|
||||
* the latLonUR to set
|
||||
*/
|
||||
public void setLatLonUR(Coordinate latLonUR) {
|
||||
this.latLonUR = latLonUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latLonOrigin
|
||||
* the latLonOrigin to set
|
||||
*/
|
||||
public void setLatLonOrigin(Coordinate latLonOrigin) {
|
||||
this.latLonOrigin = latLonOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdParallelOne
|
||||
* the stdParallelOne to set
|
||||
*/
|
||||
public void setStdParallelOne(double stdParallelOne) {
|
||||
this.stdParallelOne = stdParallelOne;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdParallelTwo
|
||||
* the stdParallelTwo to set
|
||||
*/
|
||||
public void setStdParallelTwo(double stdParallelTwo) {
|
||||
this.stdParallelTwo = stdParallelTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridPointLL
|
||||
* the gridPointLL to set
|
||||
*/
|
||||
public void setGridPointLL(Point gridPointLL) {
|
||||
this.gridPointLL = gridPointLL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridPointUR
|
||||
* the gridPointUR to set
|
||||
*/
|
||||
public void setGridPointUR(Point gridPointUR) {
|
||||
this.gridPointUR = gridPointUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latIntersect
|
||||
* the latIntersect to set
|
||||
*/
|
||||
public void setLatIntersect(double latIntersect) {
|
||||
this.latIntersect = latIntersect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lonCenter
|
||||
* the lonCenter to set
|
||||
*/
|
||||
public void setLonCenter(double lonCenter) {
|
||||
this.lonCenter = lonCenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lonOrigin
|
||||
* the lonOrigin to set
|
||||
*/
|
||||
public void setLonOrigin(double lonOrigin) {
|
||||
this.lonOrigin = lonOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the width of the projection in grid cells
|
||||
*/
|
||||
public Integer getNx() {
|
||||
return this.gridPointUR.x - this.gridPointLL.x + 1;
|
||||
return (this.gridPointUR.x - this.gridPointLL.x) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the height of the projection in grid cells
|
||||
*/
|
||||
public Integer getNy() {
|
||||
return this.gridPointUR.y - this.gridPointLL.y + 1;
|
||||
return (this.gridPointUR.y - this.gridPointLL.y) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,10 +24,18 @@ import java.awt.Rectangle;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -42,7 +50,8 @@ import org.geotools.geometry.GeneralEnvelope;
|
|||
import org.geotools.referencing.GeodeticCalculator;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.geotools.referencing.operation.builder.GridToEnvelopeMapper;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.opengis.metadata.spatial.PixelOrientation;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
@ -91,6 +100,8 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
|||
* 07/10/13 #2044 randerso Changed constructor to take ISpatialObject instead of GridCoverage
|
||||
* 07/16/13 #2181 bsteffen Convert geometry types to use hibernate-
|
||||
* spatial
|
||||
* 08/06/13 #1571 randerso Added hibernate annotations, javadoc cleanup,
|
||||
* made init method public for use in GFEDao
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -99,24 +110,27 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
|||
* @version 1.0
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "gfe_spatial")
|
||||
@Table(name = "gfe_gridlocation", uniqueConstraints = { @UniqueConstraint(columnNames = { "dbId_id" }) })
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class GridLocation extends PersistableDataObject implements
|
||||
public class GridLocation extends PersistableDataObject<String> implements
|
||||
ISpatialObject, ISerializableObject {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(GridLocation.class);
|
||||
|
||||
private static class PythonNumpyFloatGrid implements INumpyable {
|
||||
private int nx;
|
||||
|
||||
private int ny;
|
||||
|
||||
/**
|
||||
* Container for lat/lon grids to be returned to python where they are
|
||||
* reshaped using numpy for performance
|
||||
*
|
||||
*/
|
||||
private static class PythonNumpyLatLonGrid implements INumpyable {
|
||||
private float[] data;
|
||||
|
||||
public PythonNumpyFloatGrid(int nx, int ny, float[] data) {
|
||||
this.nx = nx;
|
||||
this.ny = ny;
|
||||
public PythonNumpyLatLonGrid(int nx, int ny, float[] data) {
|
||||
if ((nx * ny * 2) != data.length) {
|
||||
throw new IllegalArgumentException(
|
||||
"data must be of length nx*ny*2");
|
||||
}
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
@ -144,24 +158,38 @@ public class GridLocation extends PersistableDataObject implements
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Auto-generated surrogate key
|
||||
*/
|
||||
@Id
|
||||
@SequenceGenerator(name = "GFE_GRIDLOCATION_GENERATOR", sequenceName = "gfe_gridlocation_seq")
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GFE_GRIDLOCATION_GENERATOR")
|
||||
private int id;
|
||||
|
||||
/** The database id associated with this grid location */
|
||||
@OneToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
@JoinColumn(referencedColumnName = "id", name = "dbId_id")
|
||||
private DatabaseID dbId;
|
||||
|
||||
@Column(length = 8, nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String siteId;
|
||||
|
||||
/** Number of points along the x-axis */
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected Integer nx;
|
||||
|
||||
/** Number of points along the y-axis */
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected Integer ny;
|
||||
|
||||
@Column
|
||||
@Column(length = 32, nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String timeZone;
|
||||
|
@ -169,31 +197,30 @@ public class GridLocation extends PersistableDataObject implements
|
|||
@Transient
|
||||
private Coordinate gridCellSize;
|
||||
|
||||
@Transient
|
||||
@Embedded
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private ProjectionData projection;
|
||||
|
||||
@Transient
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Coordinate origin;
|
||||
|
||||
@Transient
|
||||
@Column(nullable = false)
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Coordinate extent;
|
||||
|
||||
@Column(name = "coverage")
|
||||
@Type(type = "org.hibernatespatial.GeometryUserType")
|
||||
@Transient
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
private Polygon geometry;
|
||||
|
||||
@Column(name = "crs", length = 2047)
|
||||
@Transient
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String crsWKT;
|
||||
|
@ -201,32 +228,50 @@ public class GridLocation extends PersistableDataObject implements
|
|||
@Transient
|
||||
private CoordinateReferenceSystem crsObject;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization
|
||||
*/
|
||||
public GridLocation() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data
|
||||
* Constructor
|
||||
*
|
||||
* @param id
|
||||
* @param proj
|
||||
* @param gridSize
|
||||
* @param domainOrigin
|
||||
* @param domainExtent
|
||||
* @param timeZone
|
||||
*/
|
||||
public GridLocation(String id, ProjectionData proj,
|
||||
java.awt.Point gridSize, Coordinate domainOrigin,
|
||||
Coordinate domainExtent, String timeZone) {
|
||||
if ((id == null) || id.isEmpty()) {
|
||||
throw new IllegalArgumentException("id may not be null or empty");
|
||||
}
|
||||
this.siteId = id;
|
||||
this.nx = gridSize.x;
|
||||
this.ny = gridSize.y;
|
||||
this.projection = proj;
|
||||
this.origin = domainOrigin;
|
||||
this.extent = domainExtent;
|
||||
this.timeZone = timeZone;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the object. Must be called after database retrieval
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void init() {
|
||||
try {
|
||||
if ((id == null) || id.isEmpty()) {
|
||||
throw new IllegalArgumentException(
|
||||
"id may not be null or empty");
|
||||
}
|
||||
this.siteId = id;
|
||||
this.nx = gridSize.x;
|
||||
this.ny = gridSize.y;
|
||||
this.projection = proj;
|
||||
this.origin = domainOrigin;
|
||||
this.extent = domainExtent;
|
||||
this.timeZone = timeZone;
|
||||
this.crsObject = proj.getCrs();
|
||||
this.projection.init();
|
||||
this.crsObject = this.projection.getCrs();
|
||||
this.crsWKT = this.crsObject.toWKT();
|
||||
|
||||
// This is here to help find issues where the WKT won't parse.
|
||||
|
@ -241,13 +286,13 @@ public class GridLocation extends PersistableDataObject implements
|
|||
}
|
||||
|
||||
// transform the grid corners from grid coordinates to CRS units
|
||||
Coordinate ll = domainOrigin;
|
||||
Coordinate ur = new Coordinate(domainOrigin.x + domainExtent.x,
|
||||
domainOrigin.y + domainExtent.y);
|
||||
Coordinate ll = this.origin;
|
||||
Coordinate ur = new Coordinate(this.origin.x + this.extent.x,
|
||||
this.origin.y + this.extent.y);
|
||||
|
||||
Coordinate llCrs = proj.gridCoordinateToCrs(ll,
|
||||
Coordinate llCrs = this.projection.gridCoordinateToCrs(ll,
|
||||
PixelOrientation.CENTER);
|
||||
Coordinate urCrs = proj.gridCoordinateToCrs(ur,
|
||||
Coordinate urCrs = this.projection.gridCoordinateToCrs(ur,
|
||||
PixelOrientation.CENTER);
|
||||
|
||||
// construct the grid geometry that covers the GFE grid
|
||||
|
@ -296,6 +341,9 @@ public class GridLocation extends PersistableDataObject implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param proj
|
||||
*/
|
||||
public GridLocation(ProjectionData proj) {
|
||||
this(
|
||||
proj.getProjectionID(), //
|
||||
|
@ -311,6 +359,10 @@ public class GridLocation extends PersistableDataObject implements
|
|||
"GMT");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param coverage
|
||||
*/
|
||||
public GridLocation(String id, ISpatialObject coverage) {
|
||||
this.siteId = id;
|
||||
this.crsObject = coverage.getCrs();
|
||||
|
@ -320,6 +372,11 @@ public class GridLocation extends PersistableDataObject implements
|
|||
this.ny = coverage.getNy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param gloc
|
||||
* @param subGrid
|
||||
*/
|
||||
public GridLocation(String id, GridLocation gloc, Rectangle subGrid) {
|
||||
try {
|
||||
this.siteId = id;
|
||||
|
@ -359,6 +416,29 @@ public class GridLocation extends PersistableDataObject implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbId
|
||||
* the dbId to set
|
||||
*/
|
||||
public void setDbId(DatabaseID dbId) {
|
||||
this.dbId = dbId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the timeZone
|
||||
*/
|
||||
|
@ -375,7 +455,7 @@ public class GridLocation extends PersistableDataObject implements
|
|||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return the grid size
|
||||
*/
|
||||
public java.awt.Point gridSize() {
|
||||
return new java.awt.Point(nx, ny);
|
||||
|
@ -431,7 +511,7 @@ public class GridLocation extends PersistableDataObject implements
|
|||
* make sure each point is exactly one point away and save it.
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
* @return the connected grid points array
|
||||
*/
|
||||
public java.awt.Point[] connectGridPoints(java.awt.Point points[]) {
|
||||
if (points.length == 0) {
|
||||
|
@ -454,7 +534,7 @@ public class GridLocation extends PersistableDataObject implements
|
|||
/**
|
||||
* Returns the size in kilometers for each grid cell.
|
||||
*
|
||||
* @return
|
||||
* @return grid cell size in kilometers
|
||||
*/
|
||||
public Coordinate gridCellSize() {
|
||||
|
||||
|
@ -577,10 +657,23 @@ public class GridLocation extends PersistableDataObject implements
|
|||
return ref.getGrid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute grid cell coordinate containing a lat/lon
|
||||
*
|
||||
* @param lat
|
||||
* @param lon
|
||||
* @return the grid cell coordinate
|
||||
*/
|
||||
public Point gridCell(float lat, float lon) {
|
||||
return gridCoordinate(new Coordinate(lon, lat));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute grid cell coordinate containing a lat/lon
|
||||
*
|
||||
* @param lonLat
|
||||
* @return the grid cell coordinate
|
||||
*/
|
||||
public Point gridCoordinate(Coordinate lonLat) {
|
||||
Coordinate gcf = MapUtil.latLonToGridCoordinate(lonLat,
|
||||
PixelOrientation.CENTER, this);
|
||||
|
@ -589,6 +682,12 @@ public class GridLocation extends PersistableDataObject implements
|
|||
return new Point(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the lat/lon coordinate at the center of a grid cell
|
||||
*
|
||||
* @param gridCell
|
||||
* @return the lat/lon
|
||||
*/
|
||||
public Coordinate latLonCenter(Coordinate gridCell) {
|
||||
return MapUtil.gridCoordinateToLatLon(gridCell,
|
||||
PixelOrientation.CENTER, this);
|
||||
|
@ -605,30 +704,54 @@ public class GridLocation extends PersistableDataObject implements
|
|||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the projection
|
||||
*/
|
||||
public ProjectionData getProjection() {
|
||||
return projection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the origin
|
||||
*/
|
||||
public Coordinate getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the extent
|
||||
*/
|
||||
public Coordinate getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the serialVersionUID
|
||||
*/
|
||||
public static long getSerialVersionUID() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param projection
|
||||
* the projection
|
||||
*/
|
||||
public void setProjection(ProjectionData projection) {
|
||||
this.projection = projection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param origin
|
||||
* the origin
|
||||
*/
|
||||
public void setOrigin(Coordinate origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extent
|
||||
* the extent
|
||||
*/
|
||||
public void setExtent(Coordinate extent) {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
@ -701,11 +824,11 @@ public class GridLocation extends PersistableDataObject implements
|
|||
return false;
|
||||
}
|
||||
|
||||
if (projection == null) {
|
||||
if (other.projection != null) {
|
||||
if (crsWKT == null) {
|
||||
if (other.crsWKT != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!projection.equals(other.projection)) {
|
||||
} else if (!crsWKT.equals(other.crsWKT)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -761,47 +884,91 @@ public class GridLocation extends PersistableDataObject implements
|
|||
return ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the siteId
|
||||
*/
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param siteId
|
||||
* the siteId
|
||||
*/
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crsWKT
|
||||
*/
|
||||
public String getCrsWKT() {
|
||||
return crsWKT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param crsWKT
|
||||
* the crsWKT
|
||||
*/
|
||||
public void setCrsWKT(String crsWKT) {
|
||||
this.crsWKT = crsWKT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crs
|
||||
*/
|
||||
public CoordinateReferenceSystem getCrsObject() {
|
||||
return getCrs();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param crsObject
|
||||
* the crs
|
||||
*/
|
||||
public void setCrsObject(CoordinateReferenceSystem crsObject) {
|
||||
this.crsObject = crsObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nx
|
||||
* the nx
|
||||
*/
|
||||
public void setNx(Integer nx) {
|
||||
this.nx = nx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ny
|
||||
* the ny
|
||||
*/
|
||||
public void setNy(Integer ny) {
|
||||
this.ny = ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param geometry
|
||||
*/
|
||||
public void setGeometry(Geometry geometry) {
|
||||
this.geometry = (Polygon) geometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param geometry
|
||||
*/
|
||||
public void setGeometry(Polygon geometry) {
|
||||
this.geometry = geometry;
|
||||
}
|
||||
|
||||
public PythonNumpyFloatGrid getLatLonGrid() {
|
||||
/**
|
||||
* Returns a 1-dimensional lat/lon grid to be reshaped by numpy for
|
||||
* performance. End users should use the getLatLonGrids function in
|
||||
* SmartScript.py or MetLib.py
|
||||
*
|
||||
* This function is not intended for use by Java code.
|
||||
*
|
||||
* @return the lat/lon grid
|
||||
*/
|
||||
public PythonNumpyLatLonGrid getLatLonGrid() {
|
||||
float[] gridCells = new float[2 * nx * ny];
|
||||
int i = 0;
|
||||
for (float x = 0; x < nx; x++) {
|
||||
|
@ -820,13 +987,16 @@ public class GridLocation extends PersistableDataObject implements
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new PythonNumpyFloatGrid(nx, ny, latLon);
|
||||
return new PythonNumpyLatLonGrid(nx, ny, latLon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459,
|
||||
12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
@ -863,7 +1033,7 @@ public class GridLocation extends PersistableDataObject implements
|
|||
latLon = MapUtil.gridCoordinateToLatLon(gridCoord, orientation, gloc);
|
||||
System.out.println(gridCoord.x + "," + gridCoord.y + " " + latLon);
|
||||
|
||||
PythonNumpyFloatGrid latLonGrid = gloc.getLatLonGrid();
|
||||
PythonNumpyLatLonGrid latLonGrid = gloc.getLatLonGrid();
|
||||
float[] data = (float[]) latLonGrid.getNumPy()[0];
|
||||
for (int x = 0; x < gloc.getNx(); x++) {
|
||||
for (int y = 0; y < gloc.getNy(); y++) {
|
||||
|
|
|
@ -28,6 +28,20 @@ import javax.measure.unit.NonSI;
|
|||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.measure.unit.UnitFormat;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
|
||||
|
@ -52,6 +66,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* 03/20/2013 #1774 randerso Removed unnecessary XML annotations,
|
||||
* added isValid method to match A1
|
||||
* 04/02/2013 #1774 randerso Improved error message in validCheck
|
||||
* 08/06/13 #1571 randerso Added hibernate annotations, javadoc cleanup
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,6 +74,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Embeddable
|
||||
@DynamicSerialize
|
||||
public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
|
@ -89,52 +105,73 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
}
|
||||
|
||||
/** The parm id associated with this grid parm info */
|
||||
@OneToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
@JoinColumn(referencedColumnName = "id", name = "parmId_id")
|
||||
@DynamicSerializeElement
|
||||
private ParmID parmID;
|
||||
|
||||
/** The grid location associated with this grid parm info */
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
@PrimaryKeyJoinColumn
|
||||
@DynamicSerializeElement
|
||||
private GridLocation gridLoc;
|
||||
|
||||
/** The grid type */
|
||||
@Column(length = 8, nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
@DynamicSerializeElement
|
||||
private GridType gridType;
|
||||
|
||||
/** The parameter descriptive name */
|
||||
@Column(length = 64, nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private String descriptiveName;
|
||||
|
||||
/** The units associated with the parameter */
|
||||
@Column(length = 64, nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private String unitString;
|
||||
|
||||
@Transient
|
||||
private Unit<?> unitObject;
|
||||
|
||||
/** The minimum allowed value */
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private float minValue;
|
||||
|
||||
/** The maximum allowed value */
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private float maxValue;
|
||||
|
||||
/** The precision of the value */
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private int precision;
|
||||
|
||||
/** Is value a rate parameter */
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private boolean rateParm;
|
||||
|
||||
/** Time Constraints */
|
||||
@Embedded
|
||||
@DynamicSerializeElement
|
||||
private TimeConstraints timeConstraints;
|
||||
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private boolean timeIndependentParm;
|
||||
|
||||
@Transient
|
||||
private String errorMessage;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization
|
||||
*/
|
||||
public GridParmInfo() {
|
||||
gridType = GridType.NONE;
|
||||
timeIndependentParm = false;
|
||||
|
@ -150,6 +187,11 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
timeConstraints = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*
|
||||
* @param orig
|
||||
*/
|
||||
public GridParmInfo(GridParmInfo orig) {
|
||||
this.parmID = orig.parmID;
|
||||
this.gridLoc = orig.gridLoc;
|
||||
|
@ -202,6 +244,20 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with rateParm defaulted to false
|
||||
*
|
||||
* @param id
|
||||
* @param gridLoc
|
||||
* @param gridType
|
||||
* @param unit
|
||||
* @param descriptiveName
|
||||
* @param minValue
|
||||
* @param maxValue
|
||||
* @param precision
|
||||
* @param timeIndependentParm
|
||||
* @param timeConstraints
|
||||
*/
|
||||
public GridParmInfo(ParmID id, GridLocation gridLoc, GridType gridType,
|
||||
String unit, String descriptiveName, float minValue,
|
||||
float maxValue, int precision, boolean timeIndependentParm,
|
||||
|
@ -255,7 +311,7 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
}
|
||||
|
||||
// units defined
|
||||
if (unitString == null || unitString.isEmpty()) {
|
||||
if ((unitString == null) || unitString.isEmpty()) {
|
||||
sb.append("GridParmInfo.Units are not defined.\n");
|
||||
}
|
||||
|
||||
|
@ -269,7 +325,7 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
}
|
||||
|
||||
// precision check
|
||||
if (precision < -2 || precision > 5) {
|
||||
if ((precision < -2) || (precision > 5)) {
|
||||
sb.append("GridParmInfo is invalid. Precision out of limits. ");
|
||||
sb.append(" Precision is: ");
|
||||
sb.append(precision);
|
||||
|
@ -317,6 +373,9 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
return unitString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unitObject
|
||||
*/
|
||||
public synchronized Unit<?> getUnitObject() {
|
||||
if (unitObject == null) {
|
||||
try {
|
||||
|
@ -378,6 +437,9 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
return new GridParmInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parmID
|
||||
*/
|
||||
public ParmID getParmID() {
|
||||
return parmID;
|
||||
}
|
||||
|
@ -391,20 +453,21 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
result = (prime * result)
|
||||
+ ((descriptiveName == null) ? 0 : descriptiveName.hashCode());
|
||||
result = prime * result + ((gridLoc == null) ? 0 : gridLoc.hashCode());
|
||||
result = prime * result
|
||||
result = (prime * result)
|
||||
+ ((gridLoc == null) ? 0 : gridLoc.hashCode());
|
||||
result = (prime * result)
|
||||
+ ((gridType == null) ? 0 : gridType.hashCode());
|
||||
result = prime * result + Float.floatToIntBits(maxValue);
|
||||
result = prime * result + Float.floatToIntBits(minValue);
|
||||
result = prime * result + ((parmID == null) ? 0 : parmID.hashCode());
|
||||
result = prime * result + precision;
|
||||
result = prime * result + (rateParm ? 1231 : 1237);
|
||||
result = prime * result
|
||||
result = (prime * result) + Float.floatToIntBits(maxValue);
|
||||
result = (prime * result) + Float.floatToIntBits(minValue);
|
||||
result = (prime * result) + ((parmID == null) ? 0 : parmID.hashCode());
|
||||
result = (prime * result) + precision;
|
||||
result = (prime * result) + (rateParm ? 1231 : 1237);
|
||||
result = (prime * result)
|
||||
+ ((timeConstraints == null) ? 0 : timeConstraints.hashCode());
|
||||
result = prime * result + (timeIndependentParm ? 1231 : 1237);
|
||||
result = prime * result
|
||||
result = (prime * result) + (timeIndependentParm ? 1231 : 1237);
|
||||
result = (prime * result)
|
||||
+ ((unitString == null) ? 0 : unitString.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
@ -502,6 +565,11 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
return timeIndependentParm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the parmId
|
||||
*
|
||||
* @param parmId
|
||||
*/
|
||||
public void resetParmID(ParmID parmId) {
|
||||
this.parmID = parmId;
|
||||
}
|
||||
|
@ -516,50 +584,98 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
|||
+ " GridType: " + gridType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parmID
|
||||
* the parmID to set
|
||||
*/
|
||||
public void setParmID(ParmID parmID) {
|
||||
this.parmID = parmID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridLoc
|
||||
* the gridLoc to set
|
||||
*/
|
||||
public void setGridLoc(GridLocation gridLoc) {
|
||||
this.gridLoc = gridLoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridType
|
||||
* the gridType to set
|
||||
*/
|
||||
public void setGridType(GridType gridType) {
|
||||
this.gridType = gridType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param descriptiveName
|
||||
* the descriptiveName to set
|
||||
*/
|
||||
public void setDescriptiveName(String descriptiveName) {
|
||||
this.descriptiveName = descriptiveName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unitString
|
||||
* the unitString to set
|
||||
*/
|
||||
public void setUnitString(String unitString) {
|
||||
this.unitString = unitString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unitObject
|
||||
* the unitObject to set
|
||||
*/
|
||||
public void setUnitObject(Unit<?> unitObject) {
|
||||
this.unitObject = unitObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minValue
|
||||
* the minValue to set
|
||||
*/
|
||||
public void setMinValue(float minValue) {
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxValue
|
||||
* the maxValue to set
|
||||
*/
|
||||
public void setMaxValue(float maxValue) {
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param precision
|
||||
* the precision to set
|
||||
*/
|
||||
public void setPrecision(int precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rateParm
|
||||
* the rateParm to set
|
||||
*/
|
||||
public void setRateParm(boolean rateParm) {
|
||||
this.rateParm = rateParm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeConstraints
|
||||
* the timeConstraints to set
|
||||
*/
|
||||
public void setTimeConstraints(TimeConstraints timeConstraints) {
|
||||
this.timeConstraints = timeConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeIndependentParm
|
||||
* the timeIndependentParm to set
|
||||
*/
|
||||
public void setTimeIndependentParm(boolean timeIndependentParm) {
|
||||
this.timeIndependentParm = timeIndependentParm;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,275 @@
|
|||
/**
|
||||
* 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.db.objects;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
* Derived class that consolidates storage info for a Parm.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/14/08 #1030 randerso Initial port
|
||||
* 08/05/2013 #1571 randerso Moved to com.raytheon.uf.common.dataplugin
|
||||
* Added GridParmInfo as a field.
|
||||
* Added hibernate annotations
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "gfe_parminfo", uniqueConstraints = { @UniqueConstraint(columnNames = { "parmId_id" }) })
|
||||
public class ParmStorageInfo implements ISerializableObject {
|
||||
|
||||
/**
|
||||
* Auto-generated surrogate key
|
||||
*/
|
||||
@Id
|
||||
@SequenceGenerator(name = "GFE_PARMINFO_GENERATOR", sequenceName = "gfe_parminfo_seq")
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GFE_PARMINFO_GENERATOR")
|
||||
private int id;
|
||||
|
||||
@Embedded
|
||||
private GridParmInfo gridParmInfo;
|
||||
|
||||
@Column(length = 8, nullable = false)
|
||||
private String storageType;
|
||||
|
||||
@Column(nullable = false)
|
||||
private float dataOffset;
|
||||
|
||||
@Column(nullable = false)
|
||||
private float dataMultiplier;
|
||||
|
||||
@Column(length = 8, nullable = false)
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public ParmStorageInfo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param dataType
|
||||
* @param gridParmInfo
|
||||
* @param dataOffset
|
||||
* @param dataMultiplier
|
||||
* @param storageType
|
||||
*/
|
||||
public ParmStorageInfo(final String dataType,
|
||||
final GridParmInfo gridParmInfo, float dataOffset,
|
||||
float dataMultiplier, final String storageType) {
|
||||
this.storageType = storageType;
|
||||
this.dataOffset = dataOffset;
|
||||
this.dataMultiplier = dataMultiplier;
|
||||
this.dataType = dataType;
|
||||
this.gridParmInfo = gridParmInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storageType
|
||||
*/
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gridSize
|
||||
*/
|
||||
public Point getGridSize() {
|
||||
return this.gridParmInfo.getGridLoc().gridSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parmID
|
||||
*/
|
||||
public ParmID getParmID() {
|
||||
return gridParmInfo.getParmID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parmName
|
||||
*/
|
||||
public String getParmName() {
|
||||
return gridParmInfo.getParmID().getParmName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parmLevel
|
||||
*/
|
||||
public String getParmLevel() {
|
||||
return gridParmInfo.getParmID().getParmLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level
|
||||
*/
|
||||
public String getLevel() {
|
||||
return gridParmInfo.getParmID().getParmLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataOffset
|
||||
*/
|
||||
public float getDataOffset() {
|
||||
return dataOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataMultiplier
|
||||
*/
|
||||
public float getDataMultiplier() {
|
||||
return dataMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataType
|
||||
*/
|
||||
public String getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gridParmInfo
|
||||
*/
|
||||
public GridParmInfo getGridParmInfo() {
|
||||
return gridParmInfo;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + Float.floatToIntBits(dataMultiplier);
|
||||
result = (prime * result) + Float.floatToIntBits(dataOffset);
|
||||
result = (prime * result)
|
||||
+ ((dataType == null) ? 0 : dataType.hashCode());
|
||||
result = (prime * result)
|
||||
+ ((gridParmInfo == null) ? 0 : gridParmInfo.hashCode());
|
||||
result = (prime * result)
|
||||
+ ((storageType == null) ? 0 : storageType.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ParmStorageInfo)) {
|
||||
return false;
|
||||
}
|
||||
ParmStorageInfo other = (ParmStorageInfo) obj;
|
||||
if (Float.floatToIntBits(dataMultiplier) != Float
|
||||
.floatToIntBits(other.dataMultiplier)) {
|
||||
return false;
|
||||
}
|
||||
if (Float.floatToIntBits(dataOffset) != Float
|
||||
.floatToIntBits(other.dataOffset)) {
|
||||
return false;
|
||||
}
|
||||
if (dataType == null) {
|
||||
if (other.dataType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!dataType.equals(other.dataType)) {
|
||||
return false;
|
||||
}
|
||||
if (gridParmInfo == null) {
|
||||
if (other.gridParmInfo != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!gridParmInfo.equals(other.gridParmInfo)) {
|
||||
return false;
|
||||
}
|
||||
if (storageType == null) {
|
||||
if (other.storageType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!storageType.equals(other.storageType)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("ParmStorageInfo for parm: ").append(getParmName());
|
||||
sb.append(" Level: ").append(getLevel());
|
||||
sb.append(" DataType: ").append(getDataType());
|
||||
sb.append(" GridSize: ").append(getGridSize());
|
||||
sb.append(" DataOffset: ").append(getDataOffset());
|
||||
sb.append(" DataMultiplier: ").append(getDataMultiplier());
|
||||
sb.append(" StorageType: ").append(getStorageType());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -23,6 +23,9 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.serialize.TimeConstraintsAdapter;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
|
@ -43,6 +46,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
* 2/19/2008 chammack Ported from AWIPS I
|
||||
* 03/20/2013 #1774 randerso Added isValid method, use TimeUtil constants,
|
||||
* added serialization adapter, removed setters.
|
||||
* 08/06/13 #1571 randerso Added hibernate annotations, javadoc cleanup
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,21 +54,26 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Embeddable
|
||||
@DynamicSerialize
|
||||
@DynamicSerializeTypeAdapter(factory = TimeConstraintsAdapter.class)
|
||||
public class TimeConstraints implements ISerializableObject {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TimeConstraints.class);
|
||||
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private int duration;
|
||||
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private int repeatInterval;
|
||||
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private int startTime;
|
||||
|
||||
@Column(nullable = false)
|
||||
boolean valid;
|
||||
|
||||
/**
|
||||
|
@ -77,21 +86,28 @@ public class TimeConstraints implements ISerializableObject {
|
|||
valid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param duration
|
||||
* @param repeatInterval
|
||||
* @param startTime
|
||||
*/
|
||||
public TimeConstraints(int duration, int repeatInterval, int startTime) {
|
||||
this.duration = duration;
|
||||
this.repeatInterval = repeatInterval;
|
||||
this.startTime = startTime;
|
||||
|
||||
if (this.duration == 0 && this.repeatInterval == 0
|
||||
&& this.startTime == 0) {
|
||||
if ((this.duration == 0) && (this.repeatInterval == 0)
|
||||
&& (this.startTime == 0)) {
|
||||
valid = true;
|
||||
} else {
|
||||
if (repeatInterval <= 0
|
||||
|| repeatInterval > TimeUtil.SECONDS_PER_DAY
|
||||
|| TimeUtil.SECONDS_PER_DAY % repeatInterval != 0
|
||||
|| repeatInterval < duration || startTime < 0
|
||||
|| startTime > TimeUtil.SECONDS_PER_DAY || duration < 0
|
||||
|| duration > TimeUtil.SECONDS_PER_DAY) {
|
||||
if ((repeatInterval <= 0)
|
||||
|| (repeatInterval > TimeUtil.SECONDS_PER_DAY)
|
||||
|| ((TimeUtil.SECONDS_PER_DAY % repeatInterval) != 0)
|
||||
|| (repeatInterval < duration) || (startTime < 0)
|
||||
|| (startTime > TimeUtil.SECONDS_PER_DAY) || (duration < 0)
|
||||
|| (duration > TimeUtil.SECONDS_PER_DAY)) {
|
||||
statusHandler.warn("Bad init values for TimeConstraints: "
|
||||
+ this);
|
||||
valid = false;
|
||||
|
@ -112,6 +128,7 @@ public class TimeConstraints implements ISerializableObject {
|
|||
*
|
||||
* @param absTime
|
||||
* the time that the range should contain
|
||||
* @return the time range
|
||||
*/
|
||||
public TimeRange constraintTime(Date absTime) {
|
||||
if (!valid) {
|
||||
|
@ -127,17 +144,18 @@ public class TimeConstraints implements ISerializableObject {
|
|||
|
||||
int tStart = startTime - repeatInterval;
|
||||
|
||||
while (tStart + duration >= 0) {
|
||||
while ((tStart + duration) >= 0) {
|
||||
// tstart+duration is ending time
|
||||
tStart -= repeatInterval; // keep going until below 0
|
||||
}
|
||||
|
||||
while (tStart < TimeUtil.SECONDS_PER_DAY) {
|
||||
int tEnd = tStart + duration;
|
||||
if ((tStart * TimeUtil.MILLIS_PER_SECOND) <= secSinceMidnight
|
||||
&& secSinceMidnight < (tEnd * TimeUtil.MILLIS_PER_SECOND)) {
|
||||
return new TimeRange(midnight + TimeUtil.MILLIS_PER_SECOND
|
||||
* tStart, midnight + TimeUtil.MILLIS_PER_SECOND * tEnd);
|
||||
if (((tStart * TimeUtil.MILLIS_PER_SECOND) <= secSinceMidnight)
|
||||
&& (secSinceMidnight < (tEnd * TimeUtil.MILLIS_PER_SECOND))) {
|
||||
return new TimeRange(midnight
|
||||
+ (TimeUtil.MILLIS_PER_SECOND * tStart), midnight
|
||||
+ (TimeUtil.MILLIS_PER_SECOND * tEnd));
|
||||
}
|
||||
tStart += repeatInterval;
|
||||
}
|
||||
|
@ -197,8 +215,8 @@ public class TimeConstraints implements ISerializableObject {
|
|||
|
||||
TimeConstraints rhs = (TimeConstraints) obj;
|
||||
|
||||
return (valid == rhs.valid && duration == rhs.duration
|
||||
&& repeatInterval == rhs.repeatInterval && startTime == rhs.startTime);
|
||||
return ((valid == rhs.valid) && (duration == rhs.duration)
|
||||
&& (repeatInterval == rhs.repeatInterval) && (startTime == rhs.startTime));
|
||||
|
||||
}
|
||||
|
||||
|
@ -207,7 +225,7 @@ public class TimeConstraints implements ISerializableObject {
|
|||
*
|
||||
* @param tr
|
||||
* the time range
|
||||
* @return
|
||||
* @return true if the input time range matches the time constraints
|
||||
*/
|
||||
public boolean validTR(final TimeRange tr) {
|
||||
if (!anyConstraints()) {
|
||||
|
@ -251,9 +269,8 @@ public class TimeConstraints implements ISerializableObject {
|
|||
// is beyond the time range given
|
||||
List<TimeRange> sbs = new ArrayList<TimeRange>(); // returned value
|
||||
TimeRange tr = firstSB(timeRange.getStart());
|
||||
while (timeRange.getEnd().getTime()
|
||||
+ (duration * TimeUtil.MILLIS_PER_SECOND) > tr.getEnd()
|
||||
.getTime()) {
|
||||
while ((timeRange.getEnd().getTime() + (duration * TimeUtil.MILLIS_PER_SECOND)) > tr
|
||||
.getEnd().getTime()) {
|
||||
if (tr.overlaps(timeRange)) {
|
||||
sbs.add(tr);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* 06/10/2009 2159 rjpeter Updated checkDims to check grid for null
|
||||
* 01/30/2013 15719 jdynina Allowed more than 128 char width wx
|
||||
* string
|
||||
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
|
||||
* debugger when trying to display the grid
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -167,8 +169,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
|
||||
if (gsDiscreteGrid != null) {
|
||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
if (discreteGrid.getXdim() != gsDiscreteGrid.getXdim()
|
||||
|| discreteGrid.getYdim() != gsDiscreteGrid.getYdim()) {
|
||||
if ((discreteGrid.getXdim() != gsDiscreteGrid.getXdim())
|
||||
|| (discreteGrid.getYdim() != gsDiscreteGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Supplied grid is not of same dimension");
|
||||
}
|
||||
|
@ -302,8 +304,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
Point gridSize = new Point(discreteGrid.getXdim(),
|
||||
discreteGrid.getYdim());
|
||||
if (editArea.getXdim() != gridSize.x
|
||||
|| editArea.getYdim() != gridSize.y) {
|
||||
if ((editArea.getXdim() != gridSize.x)
|
||||
|| (editArea.getYdim() != gridSize.y)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -353,8 +355,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
*/
|
||||
public boolean assign(DiscreteGridSlice gs, Grid2DBit editArea) {
|
||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
if (editArea.getXdim() != discreteGrid.getXdim()
|
||||
|| editArea.getYdim() != discreteGrid.getYdim()) {
|
||||
if ((editArea.getXdim() != discreteGrid.getXdim())
|
||||
|| (editArea.getYdim() != discreteGrid.getYdim())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -637,7 +639,7 @@ 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 i = 0; i < (key.length - 1); i++) {
|
||||
for (int j = i; j < key.length; j++) {
|
||||
if (key[i].equals(key[j])) {
|
||||
discreteGrid.setAllOfValue((byte) j, (byte) i);
|
||||
|
@ -693,16 +695,6 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
return new DiscreteGridSlice(aValidTime, aGpi, aHistory, aGrid, aKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder rVal = new StringBuilder(super.toString());
|
||||
|
||||
rVal.append("Discrete grid: ").append(getDiscreteGrid()).append("\n");
|
||||
rVal.append("Discrete keys: ").append(getKey()).append("\n");
|
||||
|
||||
return rVal.toString();
|
||||
}
|
||||
|
||||
private String checkDims() {
|
||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||
if (discreteGrid == null) {
|
||||
|
@ -712,8 +704,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
int x = discreteGrid.getXdim();
|
||||
int y = discreteGrid.getYdim();
|
||||
|
||||
if (x != gridParmInfo.getGridLoc().getNx()
|
||||
|| y != gridParmInfo.getGridLoc().getNy()) {
|
||||
if ((x != gridParmInfo.getGridLoc().getNx())
|
||||
|| (y != gridParmInfo.getGridLoc().getNy())) {
|
||||
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
||||
+ x
|
||||
+ ","
|
||||
|
@ -733,7 +725,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
|||
* @return the discrete grid
|
||||
*/
|
||||
public Grid2DByte getDiscreteGrid() {
|
||||
if (useCache && cacheId != null) {
|
||||
if (useCache && (cacheId != null)) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
||||
|
|
|
@ -55,6 +55,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* 01/30/2008 chammack Stubbed-out class based on AWIPS I
|
||||
* 02/20/2008 879 rbell Legacy conversion
|
||||
* 06/10/2009 2159 rjpeter Updated checkDims to check scalarGrid for null
|
||||
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
|
||||
* debugger when trying to display the grid
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -172,8 +174,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
|
||||
if (rhsScalarGrid != null) {
|
||||
Grid2DFloat scalarGrid = getScalarGrid();
|
||||
if (scalarGrid.getXdim() != rhsScalarGrid.getXdim()
|
||||
|| scalarGrid.getYdim() != rhsScalarGrid.getYdim()) {
|
||||
if ((scalarGrid.getXdim() != rhsScalarGrid.getXdim())
|
||||
|| (scalarGrid.getYdim() != rhsScalarGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Supplied grid is not of same dimension");
|
||||
}
|
||||
|
@ -191,7 +193,7 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
* @return the scalar grid
|
||||
*/
|
||||
public Grid2DFloat getScalarGrid() {
|
||||
if (useCache && cacheId != null) {
|
||||
if (useCache && (cacheId != null)) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
||||
|
@ -304,8 +306,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
Grid2DFloat thisGrid = getScalarGrid();
|
||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||
|
||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
||||
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid and supplied grid have different dimensions");
|
||||
}
|
||||
|
@ -370,8 +372,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
@Override
|
||||
public void limitValue(float minValue, float maxValue, Grid2DBit editArea) {
|
||||
Grid2DFloat grid = getScalarGrid();
|
||||
if (editArea.getXdim() != grid.getXdim()
|
||||
|| editArea.getYdim() != grid.getYdim()) {
|
||||
if ((editArea.getXdim() != grid.getXdim())
|
||||
|| (editArea.getYdim() != grid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid and edit area have different dimensions");
|
||||
}
|
||||
|
@ -425,8 +427,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
Grid2DFloat thisGrid = getScalarGrid();
|
||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||
|
||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
||||
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This and supplied GridSlice are different dimensions");
|
||||
}
|
||||
|
@ -458,8 +460,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
|
||||
Grid2DFloat thisGrid = getScalarGrid();
|
||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
||||
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This and supplied GridSlice are different dimensions");
|
||||
}
|
||||
|
@ -485,8 +487,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
public void operateEquals(Op op, float value, Grid2DBit editArea) {
|
||||
Grid2DFloat grid = getScalarGrid();
|
||||
|
||||
if (grid.getXdim() != editArea.getXdim()
|
||||
|| grid.getYdim() != editArea.getYdim()) {
|
||||
if ((grid.getXdim() != editArea.getXdim())
|
||||
|| (grid.getYdim() != editArea.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid and edit area have different dimensions");
|
||||
}
|
||||
|
@ -577,13 +579,13 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
Grid2DFloat thisGrid = getScalarGrid();
|
||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||
|
||||
if (thisGrid.getXdim() != editArea.getXdim()
|
||||
|| thisGrid.getYdim() != editArea.getYdim()) {
|
||||
if ((thisGrid.getXdim() != editArea.getXdim())
|
||||
|| (thisGrid.getYdim() != editArea.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid and edit area have different dimensions");
|
||||
}
|
||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
||||
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid and supplied grid have different dimensions");
|
||||
}
|
||||
|
@ -649,8 +651,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
Grid2DFloat thisGrid = getScalarGrid();
|
||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||
|
||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
||||
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"This grid and supplied grid have different dimensions");
|
||||
}
|
||||
|
@ -742,15 +744,6 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder rVal = new StringBuilder(super.toString());
|
||||
|
||||
rVal.append(" Scalar grid: ").append(getScalarGrid()).append("\n");
|
||||
|
||||
return rVal.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!super.equals(obj)) {
|
||||
|
@ -810,8 +803,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
x = grid.getXdim();
|
||||
y = grid.getYdim();
|
||||
|
||||
if (x != gridParmInfo.getGridLoc().getNx()
|
||||
|| y != gridParmInfo.getGridLoc().getNy()) {
|
||||
if ((x != gridParmInfo.getGridLoc().getNx())
|
||||
|| (y != gridParmInfo.getGridLoc().getNy())) {
|
||||
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
||||
+ x
|
||||
+ ","
|
||||
|
@ -844,7 +837,7 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
|||
float f;
|
||||
for (int i = 0; i < b.capacity(); i++) {
|
||||
f = b.get(i);
|
||||
if (f < minV || f > maxV) {
|
||||
if ((f < minV) || (f > maxV)) {
|
||||
return "Data Values Exceeded in Grid at coordinate: "
|
||||
+ (i % grid.getXdim()) + ',' + (i / grid.getXdim())
|
||||
+ " Value=" + f + " MinAllowed=" + minV
|
||||
|
|
|
@ -55,6 +55,9 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* 02/22/2008 879 rbell Legacy conversion, extended ScalarSlice
|
||||
* 06/10/2009 2159 rjpeter Updated checkDims to check dirGrid for null
|
||||
* 04/23/2013 1949 rjpeter Updated wind checks to keep float precision.
|
||||
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
|
||||
* debugger when trying to display the grid
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -315,23 +318,6 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
|||
return thisDirGrid.equals(rhsDirGrid);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder rVal = new StringBuilder(super.toString());
|
||||
|
||||
rVal.append("Vector Magnitude grid: ").append(getMagGrid())
|
||||
.append("\n");
|
||||
rVal.append("Vector Direction grid: ").append(getDirGrid())
|
||||
.append("\n");
|
||||
|
||||
return rVal.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a vector grid slice from u and v components.
|
||||
*
|
||||
|
@ -356,8 +342,8 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
|||
magGrid.set(
|
||||
i,
|
||||
j,
|
||||
(float) Math.sqrt(u.get(i, j) * u.get(i, j)
|
||||
+ v.get(i, j) * v.get(i, j)));
|
||||
(float) Math.sqrt((u.get(i, j) * u.get(i, j))
|
||||
+ (v.get(i, j) * v.get(i, j))));
|
||||
float dir = (float) Math.toDegrees(Math.atan2(u.get(i, j),
|
||||
v.get(i, j)));
|
||||
while (dir < 0.0f) {
|
||||
|
@ -401,8 +387,8 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
|||
magGrid.set(
|
||||
i,
|
||||
j,
|
||||
(float) Math.sqrt(u.get(i, j) * u.get(i, j)
|
||||
+ v.get(i, j) * v.get(i, j)));
|
||||
(float) Math.sqrt((u.get(i, j) * u.get(i, j))
|
||||
+ (v.get(i, j) * v.get(i, j))));
|
||||
float dir = (float) Math.toDegrees(Math.atan2(u.get(i, j),
|
||||
v.get(i, j)));
|
||||
while (dir < 0.0f) {
|
||||
|
@ -613,8 +599,8 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
|||
|
||||
// u and v components
|
||||
// (convert from knots to meters per second 1.94384 knots / m/s )
|
||||
float uw = (float) (Math.sin(rads) * mGrid.get(xc, yc) / 1.94384);
|
||||
float vw = (float) (Math.cos(rads) * mGrid.get(xc, yc) / 1.94384);
|
||||
float uw = (float) ((Math.sin(rads) * mGrid.get(xc, yc)) / 1.94384);
|
||||
float vw = (float) ((Math.cos(rads) * mGrid.get(xc, yc)) / 1.94384);
|
||||
|
||||
// (you might already have uw and vw to work with;
|
||||
// make sure they are in meters per second.)
|
||||
|
@ -631,7 +617,7 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
|||
|
||||
// multiply (dot product) wind vector by slope vector
|
||||
// to get the value of the vertical air motion.
|
||||
vertAirSpeed = uw * svx + vw * svy;
|
||||
vertAirSpeed = (uw * svx) + (vw * svy);
|
||||
|
||||
return vertAirSpeed; // meters per second, positive upward.
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Weather Grid Slize
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -54,6 +54,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 15, 2011 randerso Initial creation
|
||||
* Jan 30, 2013 15719 jdynina Allowed more than 128 char wx string
|
||||
* Aug 13, 2013 1571 randerso Removed toString to stop it from hanging the
|
||||
* debugger when trying to display the grid
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -168,8 +170,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
|
||||
if (gsWeatherGrid != null) {
|
||||
Grid2DByte weatherGrid = getWeatherGrid();
|
||||
if (weatherGrid.getXdim() != gsWeatherGrid.getXdim()
|
||||
|| weatherGrid.getYdim() != gsWeatherGrid.getYdim()) {
|
||||
if ((weatherGrid.getXdim() != gsWeatherGrid.getXdim())
|
||||
|| (weatherGrid.getYdim() != gsWeatherGrid.getYdim())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Supplied grid is not of same dimension");
|
||||
}
|
||||
|
@ -228,8 +230,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (grid.getXdim() != rhsGrid.getXdim()
|
||||
|| grid.getYdim() != rhsGrid.getYdim()) {
|
||||
if ((grid.getXdim() != rhsGrid.getXdim())
|
||||
|| (grid.getYdim() != rhsGrid.getYdim())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -303,8 +305,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
|
||||
Grid2DByte weatherGrid = getWeatherGrid();
|
||||
Point gridSize = new Point(weatherGrid.getXdim(), weatherGrid.getYdim());
|
||||
if (editArea.getXdim() != gridSize.x
|
||||
|| editArea.getYdim() != gridSize.y) {
|
||||
if ((editArea.getXdim() != gridSize.x)
|
||||
|| (editArea.getYdim() != gridSize.y)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -354,8 +356,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
*/
|
||||
public boolean assign(WeatherGridSlice gs, Grid2DBit editArea) {
|
||||
Grid2DByte weatherGrid = getWeatherGrid();
|
||||
if (editArea.getXdim() != weatherGrid.getXdim()
|
||||
|| editArea.getYdim() != weatherGrid.getYdim()) {
|
||||
if ((editArea.getXdim() != weatherGrid.getXdim())
|
||||
|| (editArea.getYdim() != weatherGrid.getYdim())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -718,14 +720,6 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
return new WeatherGridSlice(aValidTime, aGpi, aHistory, aGrid, aKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder rVal = new StringBuilder(super.toString());
|
||||
rVal.append("Weather grid: ").append(getWeatherGrid()).append("\n");
|
||||
rVal.append("Weather keys: ").append(getKeys()).append("\n");
|
||||
return rVal.toString();
|
||||
}
|
||||
|
||||
private String checkDims() {
|
||||
Grid2DByte weatherGrid = getWeatherGrid();
|
||||
if (weatherGrid == null) {
|
||||
|
@ -735,8 +729,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
int x = weatherGrid.getXdim();
|
||||
int y = weatherGrid.getYdim();
|
||||
|
||||
if (x != gridParmInfo.getGridLoc().getNx()
|
||||
|| y != gridParmInfo.getGridLoc().getNy()) {
|
||||
if ((x != gridParmInfo.getGridLoc().getNx())
|
||||
|| (y != gridParmInfo.getGridLoc().getNy())) {
|
||||
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
||||
+ x
|
||||
+ ","
|
||||
|
@ -756,7 +750,7 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
|||
* @return the discrete grid
|
||||
*/
|
||||
public Grid2DByte getWeatherGrid() {
|
||||
if (useCache && cacheId != null) {
|
||||
if (useCache && (cacheId != null)) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
||||
|
|
|
@ -1,83 +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.db.objects;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import org.opengis.metadata.spatial.PixelOrientation;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData.ProjectionType;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 6, 2011 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GridLocationTest {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0, 0, 0);
|
||||
GridLocation tbw = new GridLocation("TBW", grid211,
|
||||
new Point(145, 145), new Coordinate(64.00, 11.00),
|
||||
new Coordinate(9.0, 9.0), "EST5EDT");
|
||||
|
||||
GridLocation gloc = tbw;
|
||||
PixelOrientation orient = PixelOrientation.UPPER_LEFT;
|
||||
Coordinate c = new Coordinate();
|
||||
Coordinate ll;
|
||||
|
||||
ll = MapUtil.gridCoordinateToLatLon(c, orient, gloc);
|
||||
System.out.println("grid cell: " + c + " lonlat: " + ll);
|
||||
|
||||
c.x = gloc.getNx();
|
||||
ll = MapUtil.gridCoordinateToLatLon(c, orient, gloc);
|
||||
System.out.println("grid cell: " + c + " lonlat: " + ll);
|
||||
|
||||
c.y = gloc.getNy();
|
||||
ll = MapUtil.gridCoordinateToLatLon(c, orient, gloc);
|
||||
System.out.println("grid cell: " + c + " lonlat: " + ll);
|
||||
|
||||
c.x = 0;
|
||||
ll = MapUtil.gridCoordinateToLatLon(c, orient, gloc);
|
||||
System.out.println("grid cell: " + c + " lonlat: " + ll);
|
||||
}
|
||||
}
|
|
@ -30,6 +30,23 @@ import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData.ProjectionType;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* Unit test for ProjectionData
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 9, 2013 randerso Initial creation
|
||||
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ProjectionDataTest {
|
||||
private static final double TOLERANCE = 1e-3;
|
||||
|
||||
|
@ -53,11 +70,11 @@ public class ProjectionDataTest {
|
|||
new TestCase(
|
||||
//
|
||||
new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(),
|
||||
new Coordinate(-133.459, 12.190), new Coordinate(
|
||||
-49.385, 57.290), new Coordinate(-95.0,
|
||||
25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f),
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385,
|
||||
57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65),
|
||||
0.0f, 0.0f, 0.0f),
|
||||
|
||||
new Coordinate[][] {
|
||||
{ new Coordinate(1, 1),
|
||||
|
@ -72,11 +89,11 @@ public class ProjectionDataTest {
|
|||
new TestCase(
|
||||
//
|
||||
new ProjectionData("Grid203",
|
||||
ProjectionType.POLAR_STEREOGRAPHIC.ordinal(),
|
||||
new Coordinate(-185.837, 19.132), new Coordinate(
|
||||
-53.660, 57.634), new Coordinate(0.0, 0.0),
|
||||
0.0f, 0.0f, new Point(1, 1), new Point(45, 39),
|
||||
0.0f, 0.0f, -150.0f),
|
||||
ProjectionType.POLAR_STEREOGRAPHIC, new Coordinate(
|
||||
-185.837, 19.132), new Coordinate(-53.660,
|
||||
57.634), new Coordinate(0.0, 0.0), 0.0f,
|
||||
0.0f, new Point(1, 1), new Point(45, 39), 0.0f,
|
||||
0.0f, -150.0f),
|
||||
|
||||
new Coordinate[][] {
|
||||
{ new Coordinate(1, 1),
|
||||
|
@ -90,11 +107,12 @@ public class ProjectionDataTest {
|
|||
), //
|
||||
new TestCase(
|
||||
//
|
||||
new ProjectionData("Grid204", ProjectionType.MERCATOR
|
||||
.ordinal(), new Coordinate(-250.0, -25.0),
|
||||
new Coordinate(-109.129, 60.644), new Coordinate(
|
||||
0.0, 0.0), 0.0f, 0.0f, new Point(1, 1),
|
||||
new Point(93, 68), 0.0f, -179.564f, 0.0f),
|
||||
new ProjectionData("Grid204", ProjectionType.MERCATOR,
|
||||
new Coordinate(-250.0, -25.0), new Coordinate(
|
||||
-109.129, 60.644),
|
||||
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1,
|
||||
1), new Point(93, 68), 0.0f, -179.564f,
|
||||
0.0f),
|
||||
|
||||
new Coordinate[][] {
|
||||
{ new Coordinate(1, 1),
|
||||
|
@ -109,11 +127,12 @@ public class ProjectionDataTest {
|
|||
|
||||
new TestCase(
|
||||
//
|
||||
new ProjectionData("Grid208", ProjectionType.MERCATOR
|
||||
.ordinal(), new Coordinate(-167.315, 9.343),
|
||||
new Coordinate(-145.878, 28.092), new Coordinate(
|
||||
0.0, 0.0), 0.0f, 0.0f, new Point(1, 1),
|
||||
new Point(29, 27), 0.0f, -157.082f, 0.0f),
|
||||
new ProjectionData("Grid208", ProjectionType.MERCATOR,
|
||||
new Coordinate(-167.315, 9.343), new Coordinate(
|
||||
-145.878, 28.092),
|
||||
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1,
|
||||
1), new Point(29, 27), 0.0f, -157.082f,
|
||||
0.0f),
|
||||
|
||||
new Coordinate[][] {
|
||||
{ new Coordinate(1, 1),
|
||||
|
@ -128,11 +147,11 @@ public class ProjectionDataTest {
|
|||
|
||||
new TestCase(
|
||||
//
|
||||
new ProjectionData("Grid210", ProjectionType.MERCATOR
|
||||
.ordinal(), new Coordinate(-77.000, 9.000),
|
||||
new Coordinate(-58.625, 26.422), new Coordinate(
|
||||
0.0, 0.0), 0.0f, 0.0f, new Point(1, 1),
|
||||
new Point(25, 25), 0.0f, -67.812f, 0.0f),
|
||||
new ProjectionData("Grid210", ProjectionType.MERCATOR,
|
||||
new Coordinate(-77.000, 9.000), new Coordinate(
|
||||
-58.625, 26.422), new Coordinate(0.0, 0.0),
|
||||
0.0f, 0.0f, new Point(1, 1), new Point(25, 25),
|
||||
0.0f, -67.812f, 0.0f),
|
||||
|
||||
new Coordinate[][] {
|
||||
{ new Coordinate(1, 1),
|
||||
|
@ -148,11 +167,11 @@ public class ProjectionDataTest {
|
|||
new TestCase(
|
||||
//
|
||||
new ProjectionData("Grid214AK",
|
||||
ProjectionType.POLAR_STEREOGRAPHIC.ordinal(),
|
||||
new Coordinate(-178.571, 40.5301), new Coordinate(
|
||||
-93.689, 63.975), new Coordinate(0.0, 0.0),
|
||||
0.0f, 0.0f, new Point(1, 1), new Point(104, 70),
|
||||
0.0f, 0.0f, -150.0f),
|
||||
ProjectionType.POLAR_STEREOGRAPHIC, new Coordinate(
|
||||
-178.571, 40.5301), new Coordinate(-93.689,
|
||||
63.975), new Coordinate(0.0, 0.0), 0.0f,
|
||||
0.0f, new Point(1, 1), new Point(104, 70), 0.0f,
|
||||
0.0f, -150.0f),
|
||||
|
||||
new Coordinate[][] {
|
||||
{ new Coordinate(1, 1),
|
||||
|
@ -167,6 +186,9 @@ public class ProjectionDataTest {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* test grid coordinate to lat/lon conversion
|
||||
*/
|
||||
@Test
|
||||
public void testGridCoordinateToLatLon() {
|
||||
PixelOrientation orientation = PixelOrientation.CENTER;
|
||||
|
@ -181,34 +203,11 @@ public class ProjectionDataTest {
|
|||
gridCoord, orientation);
|
||||
System.out.println(gridCoord + " " + latLon);
|
||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
||||
+ latLon.x, withinTolerance(latLon.x, expected.x,
|
||||
TOLERANCE));
|
||||
+ latLon.x,
|
||||
withinTolerance(latLon.x, expected.x, TOLERANCE));
|
||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
||||
+ latLon.y, withinTolerance(latLon.y, expected.y,
|
||||
TOLERANCE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLatLonToGridCoordinate() {
|
||||
PixelOrientation orientation = PixelOrientation.CENTER;
|
||||
|
||||
for (TestCase testCase : testCases) {
|
||||
System.out
|
||||
.println("Projection: " + testCase.proj.getProjectionID());
|
||||
for (Coordinate[] coords : testCase.testInOut) {
|
||||
Coordinate expected = coords[0];
|
||||
Coordinate latLon = coords[1];
|
||||
Coordinate gridCoord = testCase.proj.latLonToGridCoordinate(
|
||||
latLon, orientation);
|
||||
System.out.println(gridCoord + " " + latLon);
|
||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
||||
+ gridCoord.x, withinTolerance(gridCoord.x, expected.x,
|
||||
TOLERANCE));
|
||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
||||
+ gridCoord.y, withinTolerance(gridCoord.y, expected.y,
|
||||
TOLERANCE));
|
||||
+ latLon.y,
|
||||
withinTolerance(latLon.y, expected.y, TOLERANCE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,22 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
|||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* GridLocation Unit Test
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
public class GridLocationTest {
|
||||
private static final double LATLON_TOLERANCE = 1e-3;
|
||||
|
||||
|
@ -43,30 +59,28 @@ public class GridLocationTest {
|
|||
}
|
||||
|
||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private static final ProjectionData grid204 = new ProjectionData("Grid204",
|
||||
ProjectionType.MERCATOR.ordinal(), new Coordinate(-250.0, -25.0),
|
||||
ProjectionType.MERCATOR, new Coordinate(-250.0, -25.0),
|
||||
new Coordinate(-109.129, 60.644), new Coordinate(0.0, 0.0), 0.0f,
|
||||
0.0f, new Point(1, 1), new Point(93, 68), 0.0f, -179.564f, 0.0f);
|
||||
|
||||
private static final ProjectionData grid208 = new ProjectionData("Grid208",
|
||||
ProjectionType.MERCATOR.ordinal(),
|
||||
new Coordinate(-166.219, 10.656), new Coordinate(-147.844, 27.917),
|
||||
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1, 1), new Point(
|
||||
25, 25), 0.0f, -157.082f, 0.0f);
|
||||
ProjectionType.MERCATOR, new Coordinate(-166.219, 10.656),
|
||||
new Coordinate(-147.844, 27.917), new Coordinate(0.0, 0.0), 0.0f,
|
||||
0.0f, new Point(1, 1), new Point(25, 25), 0.0f, -157.082f, 0.0f);
|
||||
|
||||
private static final ProjectionData grid210 = new ProjectionData("Grid210",
|
||||
ProjectionType.MERCATOR.ordinal(), new Coordinate(-77.000, 9.000),
|
||||
ProjectionType.MERCATOR, new Coordinate(-77.000, 9.000),
|
||||
new Coordinate(-58.625, 26.422), new Coordinate(0.0, 0.0), 0.0f,
|
||||
0.0f, new Point(1, 1), new Point(25, 25), 0.0f, -67.812f, 0.0f);
|
||||
|
||||
private static final ProjectionData grid214AK = new ProjectionData(
|
||||
"Grid214AK", ProjectionType.POLAR_STEREOGRAPHIC.ordinal(),
|
||||
new Coordinate(-178.571, 40.5301), new Coordinate(-93.689, 63.975),
|
||||
"Grid214AK", ProjectionType.POLAR_STEREOGRAPHIC, new Coordinate(
|
||||
-178.571, 40.5301), new Coordinate(-93.689, 63.975),
|
||||
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1, 1), new Point(
|
||||
104, 70), 0.0f, 0.0f, -150.0f);
|
||||
|
||||
|
@ -116,7 +130,7 @@ public class GridLocationTest {
|
|||
),
|
||||
|
||||
new TestCase(
|
||||
//
|
||||
//
|
||||
new GridLocation("HFO", grid208, new Point(321, 225),
|
||||
new Coordinate(7.00, 11.00), new Coordinate(10.0,
|
||||
7.0), "Pacific/Honolulu"),
|
||||
|
@ -133,7 +147,7 @@ public class GridLocationTest {
|
|||
),
|
||||
|
||||
new TestCase(
|
||||
//
|
||||
//
|
||||
new GridLocation("SJU", grid210, new Point(32, 28),
|
||||
new Coordinate(10.0, 10.0),
|
||||
new Coordinate(8.0, 7.0), "America/Puerto_Rico"),
|
||||
|
@ -150,7 +164,7 @@ public class GridLocationTest {
|
|||
),
|
||||
|
||||
new TestCase(
|
||||
//
|
||||
//
|
||||
new GridLocation("AJK", grid214AK, new Point(337, 241),
|
||||
new Coordinate(62.0, 23.0), new Coordinate(21.0,
|
||||
15.0), "America/Juneau"),
|
||||
|
@ -179,11 +193,11 @@ public class GridLocationTest {
|
|||
orientation, testCase.gloc);
|
||||
System.out.println(gridCoord + " " + latLon);
|
||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
||||
+ latLon.x, withinTolerance(latLon.x, expected.x,
|
||||
LATLON_TOLERANCE));
|
||||
+ latLon.x,
|
||||
withinTolerance(latLon.x, expected.x, LATLON_TOLERANCE));
|
||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
||||
+ latLon.y, withinTolerance(latLon.y, expected.y,
|
||||
LATLON_TOLERANCE));
|
||||
+ latLon.y,
|
||||
withinTolerance(latLon.y, expected.y, LATLON_TOLERANCE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,12 +215,14 @@ public class GridLocationTest {
|
|||
orientation, testCase.gloc);
|
||||
System.out.println(String.format("(%.3f,%.3f) (%.4f,%.4f)",
|
||||
gridCoord.x, gridCoord.y, latLon.x, latLon.y));
|
||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
||||
+ gridCoord.x, withinTolerance(gridCoord.x, expected.x,
|
||||
GRIDCELL_TOLERANCE));
|
||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
||||
+ gridCoord.y, withinTolerance(gridCoord.y, expected.y,
|
||||
GRIDCELL_TOLERANCE));
|
||||
Assert.assertTrue(
|
||||
"expected: " + expected.x + ", got: " + gridCoord.x,
|
||||
withinTolerance(gridCoord.x, expected.x,
|
||||
GRIDCELL_TOLERANCE));
|
||||
Assert.assertTrue(
|
||||
"expected: " + expected.y + ", got: " + gridCoord.y,
|
||||
withinTolerance(gridCoord.y, expected.y,
|
||||
GRIDCELL_TOLERANCE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 02/27/2008 879 rbell Initial Creation.
|
||||
* 01/30/2013 15719 jdynina Allowed more than 128 chars in wx string
|
||||
* 08/14/2013 1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -244,10 +245,9 @@ public class DiscreteGridSliceTest {
|
|||
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
||||
|
||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
||||
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/03/2008 879 rbell Initial Creation.
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -73,10 +74,9 @@ public class ScalarGridSliceTest {
|
|||
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
||||
|
||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
||||
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
||||
|
|
|
@ -43,6 +43,22 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Op;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* VectorGridSlice Unit Test
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class VectorGridSliceTest {
|
||||
|
@ -61,10 +77,9 @@ public class VectorGridSliceTest {
|
|||
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
||||
|
||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
||||
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
||||
|
|
|
@ -56,8 +56,9 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 26, 2008 rbell Initial creation
|
||||
* Mar 26, 2008 rbell Initial creation
|
||||
* Mar 20, 2013 #1774 randerso Use TimeUtil constants
|
||||
* Aug 14, 2013 #1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -102,8 +103,8 @@ public class ScalarGridDataTest {
|
|||
ParmID.defaultLevel());
|
||||
|
||||
ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459,
|
||||
12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 26, 2008 rbell Initial creation
|
||||
* Mar 20, 2013 #1774 randerso Use TimeUtil constants
|
||||
* Aug 14, 2013 #1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,7 +71,7 @@ public class VectorGridDataTest {
|
|||
|
||||
private final float testFA1[] = new float[145 * 145];
|
||||
{
|
||||
for (int i = 0; i < 145 * 145; i++) {
|
||||
for (int i = 0; i < (145 * 145); i++) {
|
||||
this.testFA1[i] = (float) (i + (i / (Math.pow(10.0,
|
||||
(i + "").length()))));
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ public class VectorGridDataTest {
|
|||
|
||||
private final float testFA1b[] = new float[145 * 145];
|
||||
{
|
||||
for (int i = 0; i < 145 * 145; i++) {
|
||||
for (int i = 0; i < (145 * 145); i++) {
|
||||
this.testFA1b[i] = i % 365;
|
||||
}
|
||||
}
|
||||
|
@ -99,10 +100,9 @@ public class VectorGridDataTest {
|
|||
"OAX_GRID__Practice_00000000_0000", ParmID.defaultLevel());
|
||||
|
||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private final GridLocation testGL1 = new GridLocation("OAX", this.grid211,
|
||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
||||
|
@ -126,7 +126,7 @@ public class VectorGridDataTest {
|
|||
|
||||
private final byte testBA2[] = new byte[145 * 145];
|
||||
{
|
||||
for (int i = 0; i < 145 * 145; i++) {
|
||||
for (int i = 0; i < (145 * 145); i++) {
|
||||
this.testFA1[i] = 0;
|
||||
}
|
||||
this.testFA1[0] = 1;
|
||||
|
@ -136,7 +136,7 @@ public class VectorGridDataTest {
|
|||
|
||||
private final float testFA2[] = new float[145 * 145];
|
||||
{
|
||||
for (int i = 0; i < 145 * 145; i++) {
|
||||
for (int i = 0; i < (145 * 145); i++) {
|
||||
this.testFA1[i] = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,13 +54,14 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* ReferenceSetManager Unit Test
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 8, 2008 randerso Initial creation
|
||||
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -133,10 +134,9 @@ public class ReferenceSetManagerTest {
|
|||
private static final RefIDChangedListener refIDChangedListener = new RefIDChangedListener();
|
||||
|
||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
||||
|
@ -184,7 +184,7 @@ public class ReferenceSetManagerTest {
|
|||
static {
|
||||
Grid2DBit grid = new Grid2DBit(gloc1.getNx(), gloc1.getNy(), true);
|
||||
for (int i = 0; i < grid.getXdim(); i++) {
|
||||
if (i == 0 || i == grid.getXdim() - 1) {
|
||||
if ((i == 0) || (i == (grid.getXdim() - 1))) {
|
||||
for (int j = 0; j < grid.getYdim(); j++) {
|
||||
grid.clear(i, j);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue