Issue #1571 Refactored GFE to store GridParmInfo and ParmStorageInfo in PostGres
Change-Id: Iae7cf49fc18abf03ef3b0ee498fb8e658f37d1cf Former-commit-id:3de94947e0
[formerly3fd2f523d9
] [formerly04d2fdc214
] [formerly5aee6f35ff
[formerly04d2fdc214
[formerly 3094dc247a6de94ff00321d093b431e3f401b0c5]]] Former-commit-id:5aee6f35ff
Former-commit-id: 288c866bff4b051e23f64443aa754d46ba800e69 [formerlyf0fb2391af
] Former-commit-id:06cbd815be
This commit is contained in:
parent
6fb558b74b
commit
c17e493249
37 changed files with 2168 additions and 2469 deletions
|
@ -46,6 +46,9 @@
|
||||||
# Cleaned up some constants
|
# Cleaned up some constants
|
||||||
# Jun 21, 2013 14983 ryu Fixed encodeEditArea() to evaluate query
|
# Jun 21, 2013 14983 ryu Fixed encodeEditArea() to evaluate query
|
||||||
# when necessary
|
# 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
|
import types, string, time, sys
|
||||||
|
@ -2080,7 +2083,7 @@ class SmartScript(BaseTool.BaseTool):
|
||||||
if editArea.isQuery():
|
if editArea.isQuery():
|
||||||
editArea = self.__refSetMgr.evaluateQuery(editArea.getQuery())
|
editArea = self.__refSetMgr.evaluateQuery(editArea.getQuery())
|
||||||
|
|
||||||
return editArea.getGrid().__numpy__[0]
|
return editArea.getGrid().__numpy__[0].astype(numpy.bool8)
|
||||||
|
|
||||||
def decodeEditArea(self, mask):
|
def decodeEditArea(self, mask):
|
||||||
# Returns a refData object for the given 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
|
* 02/04/2008 chammack Initial Creation
|
||||||
* 03/20/2013 #1774 randerso Use TimeUtil constants
|
* 03/20/2013 #1774 randerso Use TimeUtil constants
|
||||||
|
* 08/06/2013 #1571 randerso Changed ProjectionData constructor call
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -98,10 +99,9 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
private static final int TIME_OFFSET = -6;
|
private static final int TIME_OFFSET = -6;
|
||||||
|
|
||||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
||||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
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
|
// Hack for simulated data
|
||||||
float[][] data = null;
|
float[][] data = null;
|
||||||
if (Activator.getDefault() != null
|
if ((Activator.getDefault() != null)
|
||||||
&& (gpi.getDescriptiveName().equals("Surface Temperature") || gpi
|
&& (gpi.getDescriptiveName().equals("Surface Temperature") || gpi
|
||||||
.getDescriptiveName().equals("Dewpoint"))) {
|
.getDescriptiveName().equals("Dewpoint"))) {
|
||||||
UnitConverter conv = SI.KELVIN.getConverterTo(NonSI.FAHRENHEIT);
|
UnitConverter conv = SI.KELVIN.getConverterTo(NonSI.FAHRENHEIT);
|
||||||
|
@ -281,8 +281,11 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
/ (g2dFloat.getXdim() + g2dFloat.getYdim());
|
/ (g2dFloat.getXdim() + g2dFloat.getYdim());
|
||||||
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
for (int m = 0; m < g2dFloat.getXdim(); m++) {
|
||||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||||
g2dFloat.set(m, n,
|
g2dFloat.set(
|
||||||
((float) m + n) * step + gpi.getMinValue());
|
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 m = 0; m < g2dFloat.getXdim(); m++) {
|
||||||
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
for (int n = 0; n < g2dFloat.getYdim(); n++) {
|
||||||
g2dFloat.set(m, 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
|
// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||||
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
||||||
for (int n = 0; n < g2dByte.getYdim(); n++) {
|
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);
|
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);
|
g2dByte.set(m, n, (byte) 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,10 +365,10 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
// ADDED TO DISPLAY SOME DISCRETE DATA
|
// ADDED TO DISPLAY SOME DISCRETE DATA
|
||||||
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
for (int m = 0; m < g2dByte.getXdim(); m++) {
|
||||||
for (int n = 0; n < g2dByte.getYdim(); n++) {
|
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);
|
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);
|
g2dByte.set(m, n, (byte) 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +424,7 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
this.dataManager);
|
this.dataManager);
|
||||||
|
|
||||||
IGridData grid = null;
|
IGridData grid = null;
|
||||||
if (data == null || data.length == 0) {
|
if ((data == null) || (data.length == 0)) {
|
||||||
grid = null;
|
grid = null;
|
||||||
} else if (gpi.getGridType() == GridType.SCALAR) {
|
} else if (gpi.getGridType() == GridType.SCALAR) {
|
||||||
grid = new ScalarGridData(parm, data[0]);
|
grid = new ScalarGridData(parm, data[0]);
|
||||||
|
@ -715,13 +718,13 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
parms.acquireWriteLock();
|
parms.acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
for (Parm addParm : addParms) {
|
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
|
this.parms.add(addParm); // add the additions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Parm removeParm : removeParms) {
|
for (Parm removeParm : removeParms) {
|
||||||
if (removeParm != null && this.parms.contains(removeParm)) {
|
if ((removeParm != null) && this.parms.contains(removeParm)) {
|
||||||
this.parms.remove(removeParm);
|
this.parms.remove(removeParm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -738,7 +741,7 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send ParmListChanged notification
|
// send ParmListChanged notification
|
||||||
if (addParms.size() > 0 || removeParms.size() > 0) {
|
if ((addParms.size() > 0) || (removeParms.size() > 0)) {
|
||||||
parms.acquireReadLock();
|
parms.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
fireParmListChanged(
|
fireParmListChanged(
|
||||||
|
@ -765,7 +768,7 @@ public class MockParmManager extends AbstractParmManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send DisplayedParmListChanged notification
|
// send DisplayedParmListChanged notification
|
||||||
if (removedDisplayed.size() > 0 || addedDisplayed.size() > 0) {
|
if ((removedDisplayed.size() > 0) || (addedDisplayed.size() > 0)) {
|
||||||
parms.acquireReadLock();
|
parms.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
fireDisplayedParmListChanged(this.parms
|
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.GridLocation;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
|
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.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.db.objects.TimeConstraints;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition;
|
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteDefinition;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
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
|
* 03/14/08 #1030 randerso Initial port
|
||||||
* 04/8/08 #875 bphillip Added getter for Grid Parm Info dictionary
|
* 04/8/08 #875 bphillip Added getter for Grid Parm Info dictionary
|
||||||
|
* 08/05/2013 #1571 randerso Made GridParmInfo a field in ParmStorageInfo
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -56,8 +58,6 @@ import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
||||||
public class GridDbConfig {
|
public class GridDbConfig {
|
||||||
private final Log theLogger = LogFactory.getLog(this.getClass());
|
private final Log theLogger = LogFactory.getLog(this.getClass());
|
||||||
|
|
||||||
private HashMap<String, GridParmInfo> _gridInfoDict;
|
|
||||||
|
|
||||||
private HashMap<String, ParmStorageInfo> _parmInfoDict;
|
private HashMap<String, ParmStorageInfo> _parmInfoDict;
|
||||||
|
|
||||||
private WxDefinition _wxDefinition;
|
private WxDefinition _wxDefinition;
|
||||||
|
@ -108,33 +108,33 @@ public class GridDbConfig {
|
||||||
int nentries = (int) (((maxV - minV) * dprecision));
|
int nentries = (int) (((maxV - minV) * dprecision));
|
||||||
|
|
||||||
// check for byte possibilities
|
// 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.dataMultiplier = dprecision;
|
||||||
format.dataOffset = 0;
|
format.dataOffset = 0;
|
||||||
int minVarValue = 0;
|
int minVarValue = 0;
|
||||||
int maxVarValue = 255;
|
int maxVarValue = 255;
|
||||||
if (minV * format.dataMultiplier < minVarValue) {
|
if ((minV * format.dataMultiplier) < minVarValue) {
|
||||||
format.dataOffset = minV - minVarValue / format.dataMultiplier;
|
format.dataOffset = minV
|
||||||
|
- (minVarValue / format.dataMultiplier);
|
||||||
}
|
}
|
||||||
if (maxV * format.dataMultiplier > maxVarValue) {
|
if ((maxV * format.dataMultiplier) > maxVarValue) {
|
||||||
format.dataOffset = maxV - maxVarValue / format.dataMultiplier;
|
format.dataOffset = maxV
|
||||||
|
- (maxVarValue / format.dataMultiplier);
|
||||||
}
|
}
|
||||||
format.storageFormat = "byte";
|
format.storageFormat = "byte";
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for short possibilities
|
// 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.dataMultiplier = dprecision;
|
||||||
format.dataOffset = 0;
|
format.dataOffset = 0;
|
||||||
double maxVarValue = Math.pow(2.0, 15.0) - 1;
|
double maxVarValue = Math.pow(2.0, 15.0) - 1;
|
||||||
double minVarValue = -(Math.pow(2.0, 15.0) - 2);
|
double minVarValue = -(Math.pow(2.0, 15.0) - 2);
|
||||||
if (minV * format.dataMultiplier < minVarValue) {
|
if ((minV * format.dataMultiplier) < minVarValue) {
|
||||||
format.dataOffset = (float) (minV - minVarValue
|
format.dataOffset = (float) (minV - (minVarValue / format.dataMultiplier));
|
||||||
/ format.dataMultiplier);
|
|
||||||
}
|
}
|
||||||
if (maxV * format.dataMultiplier > maxVarValue) {
|
if ((maxV * format.dataMultiplier) > maxVarValue) {
|
||||||
format.dataOffset = (float) (maxV - maxVarValue
|
format.dataOffset = (float) (maxV - (maxVarValue / format.dataMultiplier));
|
||||||
/ format.dataMultiplier);
|
|
||||||
}
|
}
|
||||||
format.storageFormat = "short";
|
format.storageFormat = "short";
|
||||||
}
|
}
|
||||||
|
@ -156,11 +156,9 @@ public class GridDbConfig {
|
||||||
* @param parmStorageInfo
|
* @param parmStorageInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean addParmInfo(final GridParmInfo gridParmInfo,
|
private boolean addParmInfo(final ParmStorageInfo parmStorageInfo) {
|
||||||
final ParmStorageInfo parmStorageInfo) {
|
String key = parmStorageInfo.getParmName() + "_"
|
||||||
String key = gridParmInfo.getParmID().getParmName() + "_"
|
+ parmStorageInfo.getParmLevel();
|
||||||
+ gridParmInfo.getParmID().getParmLevel();
|
|
||||||
_gridInfoDict.put(key, gridParmInfo);
|
|
||||||
_parmInfoDict.put(key, parmStorageInfo);
|
_parmInfoDict.put(key, parmStorageInfo);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -258,10 +256,9 @@ public class GridDbConfig {
|
||||||
calcKrunchValues(dataFormat, config.maxAllowedValue,
|
calcKrunchValues(dataFormat, config.maxAllowedValue,
|
||||||
config.minAllowedValue, precision, format);
|
config.minAllowedValue, precision, format);
|
||||||
|
|
||||||
ParmStorageInfo psi = new ParmStorageInfo(dataFormat, config.gridSize,
|
ParmStorageInfo psi = new ParmStorageInfo(dataFormat, gpi,
|
||||||
parmID.getParmName(), parmID.getParmLevel(), format.dataOffset,
|
format.dataOffset, format.dataMultiplier, format.storageFormat);
|
||||||
format.dataMultiplier, format.storageFormat);
|
return addParmInfo(psi);
|
||||||
return addParmInfo(gpi, psi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,7 +277,6 @@ public class GridDbConfig {
|
||||||
this._wxDefinition = wxDef;
|
this._wxDefinition = wxDef;
|
||||||
this._discreteDefinition = dDef;
|
this._discreteDefinition = dDef;
|
||||||
this._projectionData = projectionData;
|
this._projectionData = projectionData;
|
||||||
this._gridInfoDict = new HashMap<String, GridParmInfo>();
|
|
||||||
this._parmInfoDict = new HashMap<String, ParmStorageInfo>();
|
this._parmInfoDict = new HashMap<String, ParmStorageInfo>();
|
||||||
|
|
||||||
for (int i = 0; i < smc.grids.size(); i++) {
|
for (int i = 0; i < smc.grids.size(); i++) {
|
||||||
|
@ -302,8 +298,6 @@ public class GridDbConfig {
|
||||||
this._wxDefinition = orig._wxDefinition;
|
this._wxDefinition = orig._wxDefinition;
|
||||||
this._discreteDefinition = orig._discreteDefinition;
|
this._discreteDefinition = orig._discreteDefinition;
|
||||||
this._projectionData = orig._projectionData;
|
this._projectionData = orig._projectionData;
|
||||||
this._gridInfoDict = (HashMap<String, GridParmInfo>) orig._gridInfoDict
|
|
||||||
.clone();
|
|
||||||
this._parmInfoDict = (HashMap<String, ParmStorageInfo>) orig._parmInfoDict
|
this._parmInfoDict = (HashMap<String, ParmStorageInfo>) orig._parmInfoDict
|
||||||
.clone();
|
.clone();
|
||||||
}
|
}
|
||||||
|
@ -320,7 +314,7 @@ public class GridDbConfig {
|
||||||
public List<String> parmAndLevelList() {
|
public List<String> parmAndLevelList() {
|
||||||
List<String> parmAndLevels = new ArrayList<String>();
|
List<String> parmAndLevels = new ArrayList<String>();
|
||||||
|
|
||||||
for (String key : _gridInfoDict.keySet()) {
|
for (String key : _parmInfoDict.keySet()) {
|
||||||
parmAndLevels.add(key);
|
parmAndLevels.add(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +334,7 @@ public class GridDbConfig {
|
||||||
public GridParmInfo getGridParmInfo(final String parmName,
|
public GridParmInfo getGridParmInfo(final String parmName,
|
||||||
final String level) {
|
final String level) {
|
||||||
String composite = parmName + "_" + 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();
|
StringBuffer s = new StringBuffer();
|
||||||
|
|
||||||
s.append("GRID INFO DICT\n");
|
s.append("GRID INFO DICT\n");
|
||||||
for (Map.Entry<String, GridParmInfo> entry : _gridInfoDict.entrySet()) {
|
for (Map.Entry<String, ParmStorageInfo> entry : _parmInfoDict
|
||||||
s.append(entry.getKey() + ' ' + entry.getValue() + '\n');
|
.entrySet()) {
|
||||||
|
s.append(entry.getKey() + ' ' + entry.getValue().getGridParmInfo()
|
||||||
|
+ '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
s.append("PARM INFO DICT\n");
|
s.append("PARM INFO DICT\n");
|
||||||
|
@ -402,8 +398,4 @@ public class GridDbConfig {
|
||||||
public ProjectionData projectionData() {
|
public ProjectionData projectionData() {
|
||||||
return this._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
|
* 06/24/08 #1160 randerso Added a method to get the Topo dbId
|
||||||
* 07/09/09 #2590 njensen No longer singleton
|
* 07/09/09 #2590 njensen No longer singleton
|
||||||
* 06/24/13 #2044 randerso Renamed satdirs to satdata to match serverConfig.py
|
* 06/24/13 #2044 randerso Renamed satdirs to satdata to match serverConfig.py
|
||||||
|
* 08/14/2013 #1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -453,7 +454,7 @@ public class IFPServerConfig {
|
||||||
|
|
||||||
// common database grid location
|
// common database grid location
|
||||||
ProjectionData dProj = new ProjectionData(config.domain.projectionID,
|
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.latLonUR, config.domain.latLonOrigin,
|
||||||
config.domain.stdParallelOne, config.domain.stdParallelTwo,
|
config.domain.stdParallelOne, config.domain.stdParallelTwo,
|
||||||
config.domain.gridPointLL, config.domain.gridPointUR,
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -32,7 +32,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 03/13/08 #1030 randerso Initial port
|
* 03/13/08 #1030 randerso Initial port
|
||||||
|
* 08/09/2013 #1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -52,9 +53,8 @@ public class SimpleGridLocation {
|
||||||
// ProjectionData
|
// ProjectionData
|
||||||
public String projectionID;
|
public String projectionID;
|
||||||
|
|
||||||
public ProjectionData.ProjectionType projectionType; // NONE,
|
public ProjectionData.ProjectionType projectionType;
|
||||||
|
|
||||||
// // LAMBERT_CONFORMAL, MERCATOR, POLAR_STEOGRAPHIC, LATLON
|
|
||||||
public Coordinate latLonLL;
|
public Coordinate latLonLL;
|
||||||
|
|
||||||
public Coordinate latLonUR;
|
public Coordinate latLonUR;
|
||||||
|
@ -82,14 +82,14 @@ public class SimpleGridLocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleGridLocation(Point gridSize, Coordinate origin,
|
public SimpleGridLocation(Point gridSize, Coordinate origin,
|
||||||
Coordinate extent, String projID, int projType, Coordinate llll,
|
Coordinate extent, String projID, ProjectionType projType,
|
||||||
Coordinate llur, Coordinate llo, float sp1, float sp2, Point gpll,
|
Coordinate llll, Coordinate llur, Coordinate llo, float sp1,
|
||||||
Point gpur, float li, float lc, float lo) {
|
float sp2, Point gpll, Point gpur, float li, float lc, float lo) {
|
||||||
this.gridSize = gridSize;
|
this.gridSize = gridSize;
|
||||||
this.domainOrigin = origin;
|
this.domainOrigin = origin;
|
||||||
this.domainExtent = extent;
|
this.domainExtent = extent;
|
||||||
this.projectionID = projID;
|
this.projectionID = projID;
|
||||||
this.projectionType = ProjectionType.values()[projType];
|
this.projectionType = projType;
|
||||||
this.latLonLL = llll;
|
this.latLonLL = llll;
|
||||||
this.latLonUR = llur;
|
this.latLonUR = llur;
|
||||||
this.latLonOrigin = llo;
|
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.GridDataHistory;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
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.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.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.GridUpdateNotification;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
|
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
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
|
* 07/30/13 #2057 randerso Added support marking and eventually purging obsolete databases
|
||||||
* 08/08/13 DR16485 ryu Remove call to getDatabaseId() from getMaxInsertTimeByDbId()
|
* 08/08/13 DR16485 ryu Remove call to getDatabaseId() from getMaxInsertTimeByDbId()
|
||||||
* so new GFE databases aren't accidentally created.
|
* so new GFE databases aren't accidentally created.
|
||||||
|
* 08/05/13 #1571 randerso Added support for storing GridLocation and ParmStorageInfo in database
|
||||||
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bphillip
|
* @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
|
* @param dbId
|
||||||
* @return the list of ParmIDs for the database
|
* @return the list of ParmStorageInfo for the database
|
||||||
* @throws DataAccessLayerException
|
* @throws DataAccessLayerException
|
||||||
*/
|
*/
|
||||||
public List<ParmID> getParmIds(final DatabaseID dbId)
|
public List<ParmStorageInfo> getParmStorageInfo(final DatabaseID dbId)
|
||||||
throws DataAccessLayerException {
|
throws DataAccessLayerException {
|
||||||
Session sess = null;
|
Session sess = null;
|
||||||
Transaction tx = null;
|
Transaction tx = null;
|
||||||
|
@ -240,11 +244,17 @@ public class GFEDao extends DefaultPluginDao {
|
||||||
// relations
|
// relations
|
||||||
sess.buildLockRequest(LockOptions.NONE).lock(dbId);
|
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);
|
query.setParameter(0, dbId);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<ParmID> list = query.list();
|
List<ParmStorageInfo> list = query.list();
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
|
||||||
|
// initialize the grid location objects
|
||||||
|
for (ParmStorageInfo psi : list) {
|
||||||
|
psi.getGridParmInfo().getGridLoc().init();
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (tx != null) {
|
if (tx != null) {
|
||||||
|
@ -256,7 +266,7 @@ public class GFEDao extends DefaultPluginDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new DataAccessLayerException(
|
throw new DataAccessLayerException(
|
||||||
"Unable to look up parm id inventory for database id "
|
"Unable to retrieve ParmStorageInfos for DatabaseID: "
|
||||||
+ dbId, e);
|
+ dbId, e);
|
||||||
} finally {
|
} finally {
|
||||||
if (sess != null) {
|
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
|
* Returns the database row for the passed parmId. If the row does not
|
||||||
* exist, the row will be created.
|
* exist, the row will be created.
|
||||||
|
@ -353,7 +457,7 @@ public class GFEDao extends DefaultPluginDao {
|
||||||
* transaction.
|
* transaction.
|
||||||
*
|
*
|
||||||
* @param sess
|
* @param sess
|
||||||
* @param dbId
|
* @param parmId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private ParmID getParmId(Session sess, ParmID parmId) {
|
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
|
* Removes all grids associated with a parm
|
||||||
* info
|
|
||||||
*
|
*
|
||||||
* @param parmId
|
* @param parmId
|
||||||
* The parm to delete data for
|
* The parm to delete data for
|
||||||
|
@ -969,20 +1072,8 @@ public class GFEDao extends DefaultPluginDao {
|
||||||
* If errors occur
|
* If errors occur
|
||||||
*/
|
*/
|
||||||
public void removeParmData(ParmID parmId) throws DataAccessLayerException {
|
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);
|
List<TimeRange> trs = this.getTimes(parmId);
|
||||||
this.deleteRecords(parmId, trs);
|
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;
|
package com.raytheon.edex.plugin.gfe.server.database;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
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.dataplugin.gfe.util.GfeUtil;
|
||||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
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.message.WsId;
|
||||||
import com.raytheon.uf.common.time.TimeRange;
|
import com.raytheon.uf.common.time.TimeRange;
|
||||||
import com.raytheon.uf.common.util.Pair;
|
import com.raytheon.uf.common.util.Pair;
|
||||||
|
@ -76,6 +71,8 @@ import com.raytheon.uf.common.util.Pair;
|
||||||
* and cachedParmId
|
* and cachedParmId
|
||||||
* 05/02/13 #1969 randerso Removed unnecessary updateDbs method
|
* 05/02/13 #1969 randerso Removed unnecessary updateDbs method
|
||||||
* 06/13/13 #2044 randerso Code cleanup
|
* 06/13/13 #2044 randerso Code cleanup
|
||||||
|
* 08/13/13 #1571 randerso Moved retrieveFromHDF5 methods into IFPGridDatabase
|
||||||
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bphillip
|
* @author bphillip
|
||||||
|
@ -110,245 +107,19 @@ public abstract class GridDatabase {
|
||||||
*
|
*
|
||||||
* @param dbId
|
* @param dbId
|
||||||
* The database ID for this database
|
* The database ID for this database
|
||||||
* @param gridConfig
|
|
||||||
* The configuration information for this database
|
|
||||||
*/
|
*/
|
||||||
protected GridDatabase(DatabaseID dbId) {
|
protected GridDatabase(DatabaseID dbId) {
|
||||||
this.dbId = dbId;
|
this.dbId = dbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the FloatDataRecord for a grid from HDF5
|
* Returns the mapping of ParmIds and TimeRanges to DataStores and groups
|
||||||
*
|
* where the data should be stored.
|
||||||
* @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
|
|
||||||
*
|
*
|
||||||
* @param parmId
|
* @param parmId
|
||||||
* @param times
|
* @param times
|
||||||
* @return the FloatDataRecords
|
* @return mapping
|
||||||
* @throws GfeException
|
|
||||||
*/
|
*/
|
||||||
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(
|
protected Map<IDataStore, Pair<List<TimeRange>, String[]>> getDataStoreAndGroups(
|
||||||
ParmID parmId, List<TimeRange> times) {
|
ParmID parmId, List<TimeRange> times) {
|
||||||
Map<File, Pair<List<TimeRange>, String[]>> fileMap = GfeUtil
|
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
|
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
# further licensing information.
|
# further licensing information.
|
||||||
##
|
##
|
||||||
|
# doConfig - validate and convert serverConfig into simple Java objects
|
||||||
|
#
|
||||||
# this file was originally config.py
|
# this file was originally config.py
|
||||||
# it was renamed to avoid a conflict with jep's built-in config module
|
# 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
|
import types
|
||||||
|
|
||||||
from java.util import ArrayList,LinkedHashMap
|
from java.util import ArrayList,LinkedHashMap
|
||||||
|
@ -50,10 +63,16 @@ def check(data, fmt, message, allData = None):
|
||||||
if allData is not None:
|
if allData is not None:
|
||||||
m = m + ' All: ' + `allData`
|
m = m + ' All: ' + `allData`
|
||||||
raise AssertionError, m
|
raise AssertionError, m
|
||||||
for i in xrange(len(data)):
|
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, " + \
|
m = message + ": Wrong data type found, " + \
|
||||||
"Expected " + `fmt[i]` + ", got " + `type(data[i])` + \
|
"Expected " + `fmt[i]` + ", got " + `t` + \
|
||||||
" for position #" + `i+1` + " Input: " + `data`
|
" for position #" + `i+1` + " Input: " + `data`
|
||||||
if allData is not None:
|
if allData is not None:
|
||||||
m = m + ' All: ' + `allData`
|
m = m + ' All: ' + `allData`
|
||||||
|
@ -235,8 +254,9 @@ def parseDBItm(site, domain, item):
|
||||||
def updateProjections(projection):
|
def updateProjections(projection):
|
||||||
from com.raytheon.uf.common.dataplugin.gfe.config import ProjectionData
|
from com.raytheon.uf.common.dataplugin.gfe.config import ProjectionData
|
||||||
# extract projection data
|
# extract projection data
|
||||||
projFmt = (str, int, tuple, tuple, tuple, float, float, tuple, tuple,
|
projFmt = (str,
|
||||||
float, float, float)
|
"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, \
|
projID, ptype, pllll, pllur, pllo, pspo, pspt, pgpll, pgpur, pli, \
|
||||||
plc, plo = check(projection, projFmt, "Format error in Projection")
|
plc, plo = check(projection, projFmt, "Format error in Projection")
|
||||||
check(pllll, (float, float),
|
check(pllll, (float, float),
|
||||||
|
@ -276,8 +296,9 @@ def parseGridLocation(domain):
|
||||||
check(origin, (float, float), "Origin format error from SITES", domain)
|
check(origin, (float, float), "Origin format error from SITES", domain)
|
||||||
check(extent, (float, float), "Extent 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,
|
projFmt = (str,
|
||||||
float, float, float)
|
"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 = \
|
projID, projType, llll, llur, llo, sp1, sp2, gpll, gpur, li, lc, lo = \
|
||||||
check(proj, projFmt, "Format error in Projection")
|
check(proj, projFmt, "Format error in Projection")
|
||||||
check(llll, (float, float),
|
check(llll, (float, float),
|
||||||
|
|
|
@ -17,8 +17,21 @@
|
||||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
# further licensing information.
|
# further licensing information.
|
||||||
##
|
##
|
||||||
|
# serverConfig -- base GFE server configuration file
|
||||||
|
#
|
||||||
# NOTE: THIS FILE SHOULD NOT BE USER-MODIFIED. INSTEAD REFER TO THE
|
# NOTE: THIS FILE SHOULD NOT BE USER-MODIFIED. INSTEAD REFER TO THE
|
||||||
# LOCAL CONFIG DOCUMENTATION ON HOW TO OVERRIDE SETTINGS IN THIS FILE.
|
# 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
|
# USEFUL DEFINES
|
||||||
|
@ -458,11 +471,12 @@ if not BASELINE and siteImport('localWxConfig'):
|
||||||
# Projection Configuration section.
|
# Projection Configuration section.
|
||||||
#
|
#
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
NONE = 0
|
from com.raytheon.uf.common.dataplugin.gfe.config import ProjectionData_ProjectionType as ProjectionType
|
||||||
LAMBERT_CONFORMAL = 1
|
NONE = ProjectionType.NONE
|
||||||
MERCATOR = 2
|
LAMBERT_CONFORMAL = ProjectionType.LAMBERT_CONFORMAL
|
||||||
POLAR_STEREOGRAPHIC = 3
|
MERCATOR = ProjectionType.MERCATOR
|
||||||
LATLON = 4
|
POLAR_STEREOGRAPHIC = ProjectionType.POLAR_STEREOGRAPHIC
|
||||||
|
LATLON = ProjectionType.LATLON
|
||||||
|
|
||||||
# projectionID / projectionType / latLonLL / latLonUR /
|
# projectionID / projectionType / latLonLL / latLonUR /
|
||||||
# latLonOrigin / stdParallelOne / stdParallelTwo / gridPointLL / gridPointUR
|
# 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.
|
# 05/23/13 1759 dgilling Remove unnecessary imports.
|
||||||
# 06/13/13 2044 randerso Updated for changes to TopoDatabaseManager
|
# 06/13/13 2044 randerso Updated for changes to TopoDatabaseManager
|
||||||
# 07/25/13 2233 randerso Improved memory utilization and performance
|
# 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())
|
setattr(var, "projectionType", projectionType.toString())
|
||||||
|
|
||||||
# Now store the projection specific attributes
|
# 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, "latLonOrigin", (projectionData.getLatLonOrigin().x, projectionData.getLatLonOrigin().y))
|
||||||
setattr(var, "stdParallelOne", projectionData.getStdParallelOne())
|
setattr(var, "stdParallelOne", projectionData.getStdParallelOne())
|
||||||
setattr(var, "stdParallelTwo", projectionData.getStdParallelTwo())
|
setattr(var, "stdParallelTwo", projectionData.getStdParallelTwo())
|
||||||
|
|
||||||
if projectionType.toString() == "POLAR_STEREOGRAPHIC":
|
if ProjectionType.POLAR_STEREOGRAPHIC.equals(projectionType):
|
||||||
setattr(var, "lonOrigin", projectionData.getLonOrigin())
|
setattr(var, "lonOrigin", projectionData.getLonOrigin())
|
||||||
|
|
||||||
if projectionType.toString() == "MERCATOR":
|
if ProjectionType.MERCATOR.equals(projectionType):
|
||||||
setattr(var, "lonCenter", projectionData.getLonCenter())
|
setattr(var, "lonCenter", projectionData.getLonCenter())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1098,7 +1100,7 @@ def storeDiscreteWE(we, trList, file, timeRange, databaseID, invMask, clipArea):
|
||||||
grid = clipToExtrema(dis[0], clipArea)
|
grid = clipToExtrema(dis[0], clipArea)
|
||||||
byteCube[i] = grid
|
byteCube[i] = grid
|
||||||
keyList.append(dis[1])
|
keyList.append(dis[1])
|
||||||
|
|
||||||
|
|
||||||
# make the variable name
|
# make the variable name
|
||||||
varName = we.getParmid().getParmName() + "_" + we.getParmid().getParmLevel()
|
varName = we.getParmid().getParmName() + "_" + we.getParmid().getParmLevel()
|
||||||
|
@ -1349,8 +1351,8 @@ def main(outputFilename, parmList, databaseID, startTime,
|
||||||
clipArea = extremaOfSetBits(maskGrid)
|
clipArea = extremaOfSetBits(maskGrid)
|
||||||
maskGrid = clipToExtrema(maskGrid, clipArea)
|
maskGrid = clipToExtrema(maskGrid, clipArea)
|
||||||
clippedGridSize = maskGrid.shape
|
clippedGridSize = maskGrid.shape
|
||||||
validPointCount = numpy.add.reduce(numpy.add.reduce(maskGrid))
|
validPointCount = numpy.add.reduce(numpy.add.reduce(maskGrid))
|
||||||
|
|
||||||
#invert the mask grid
|
#invert the mask grid
|
||||||
invMask = numpy.logical_not(maskGrid)
|
invMask = numpy.logical_not(maskGrid)
|
||||||
#del maskGrid
|
#del maskGrid
|
||||||
|
|
|
@ -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.DatabaseID
|
||||||
com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord
|
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.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.ParmID
|
||||||
|
com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmStorageInfo
|
||||||
com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData
|
com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData
|
||||||
com.raytheon.uf.common.dataplugin.gfe.sample.SampleData
|
com.raytheon.uf.common.dataplugin.gfe.sample.SampleData
|
||||||
com.raytheon.uf.common.dataplugin.gfe.server.lock.Lock
|
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.NearestNeighborInterpolation;
|
||||||
import com.raytheon.uf.common.geospatial.interpolation.PrecomputedGridReprojection;
|
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.ByteBufferWrapper;
|
||||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
|
|
||||||
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
|
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
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
|
* 07/09/13 #2044 randerso Made SoftReferences to interp and rotation since
|
||||||
* they can be quite large and may not be needed frequently
|
* they can be quite large and may not be needed frequently
|
||||||
* 07/17/13 #2185 bsteffen Cache computed grid reprojections.
|
* 07/17/13 #2185 bsteffen Cache computed grid reprojections.
|
||||||
|
* 08/13/13 #1571 randerso Passed fill values into interpolator.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -154,7 +154,7 @@ public class RemapGrid {
|
||||||
float max, float min, float outputFill) throws FactoryException,
|
float max, float min, float outputFill) throws FactoryException,
|
||||||
TransformException {
|
TransformException {
|
||||||
|
|
||||||
Grid2DFloat retVal = resample(input);
|
Grid2DFloat retVal = resample(input, inputFill, outputFill);
|
||||||
limitGrid(retVal, inputFill, max, min, outputFill);
|
limitGrid(retVal, inputFill, max, min, outputFill);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class RemapGrid {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal = resample(input);
|
retVal = resample(input, inputFill, outputFill);
|
||||||
|
|
||||||
ByteBuffer buffer = retVal.getBuffer();
|
ByteBuffer buffer = retVal.getBuffer();
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
|
@ -259,7 +259,7 @@ public class RemapGrid {
|
||||||
* The max value for data values
|
* The max value for data values
|
||||||
* @param minLimit
|
* @param minLimit
|
||||||
* The min value for data values
|
* The min value for data values
|
||||||
* @param outputFillValue
|
* @param outputFill
|
||||||
* The output fill value
|
* The output fill value
|
||||||
* @param rotate
|
* @param rotate
|
||||||
* The rotation flag
|
* The rotation flag
|
||||||
|
@ -273,9 +273,9 @@ public class RemapGrid {
|
||||||
* If grid dimensions do not match or resampling fails
|
* If grid dimensions do not match or resampling fails
|
||||||
*/
|
*/
|
||||||
public void remapUV(final Grid2DFloat uinput, final Grid2DFloat vinput,
|
public void remapUV(final Grid2DFloat uinput, final Grid2DFloat vinput,
|
||||||
float inputFill, float maxLimit, float minLimit,
|
float inputFill, float maxLimit, float minLimit, float outputFill,
|
||||||
float outputFillValue, boolean rotate, boolean flip,
|
boolean rotate, boolean flip, Grid2DFloat magGrid,
|
||||||
Grid2DFloat magGrid, Grid2DFloat dirGrid) throws Exception {
|
Grid2DFloat dirGrid) throws Exception {
|
||||||
|
|
||||||
if ((uinput.getXdim() != sourceGloc.getNx())
|
if ((uinput.getXdim() != sourceGloc.getNx())
|
||||||
|| (uinput.getYdim() != sourceGloc.getNy())
|
|| (uinput.getYdim() != sourceGloc.getNy())
|
||||||
|
@ -303,13 +303,13 @@ public class RemapGrid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Grid2DFloat resampledUinput = resample(uinput);
|
Grid2DFloat resampledUinput = resample(uinput, Float.NaN, Float.NaN);
|
||||||
Grid2DFloat resampledVinput = resample(vinput);
|
Grid2DFloat resampledVinput = resample(vinput, Float.NaN, Float.NaN);
|
||||||
|
|
||||||
calculateWindGrid(resampledUinput, resampledVinput, rotate, flip,
|
calculateWindGrid(resampledUinput, resampledVinput, rotate, flip,
|
||||||
magGrid, dirGrid);
|
magGrid, dirGrid);
|
||||||
|
|
||||||
limitGrid(magGrid, inputFill, maxLimit, minLimit, outputFillValue);
|
limitGrid(magGrid, inputFill, maxLimit, minLimit, outputFill);
|
||||||
limitGrid(dirGrid, 0.0f, 360.0f, 0.0f, 0.0f);
|
limitGrid(dirGrid, 0.0f, 360.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,12 +476,16 @@ public class RemapGrid {
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input
|
||||||
* The input data
|
* The input data
|
||||||
|
* @param inputFill
|
||||||
|
* the input fill value
|
||||||
|
* @param outputFill
|
||||||
|
* the output fill value
|
||||||
* @return The resampled data
|
* @return The resampled data
|
||||||
* @throws TransformException
|
* @throws TransformException
|
||||||
* @throws FactoryException
|
* @throws FactoryException
|
||||||
*/
|
*/
|
||||||
private Grid2DByte resample(final Grid2DByte input)
|
private Grid2DByte resample(final Grid2DByte input, float inputFill,
|
||||||
throws FactoryException, TransformException {
|
float outputFill) throws FactoryException, TransformException {
|
||||||
|
|
||||||
GridGeometry2D sourceGeometry = MapUtil.getGridGeometry(sourceGloc);
|
GridGeometry2D sourceGeometry = MapUtil.getGridGeometry(sourceGloc);
|
||||||
|
|
||||||
|
@ -491,10 +495,15 @@ public class RemapGrid {
|
||||||
GridGeometry2D destGeometry = MapUtil.getGridGeometry(destinationGloc);
|
GridGeometry2D destGeometry = MapUtil.getGridGeometry(destinationGloc);
|
||||||
GridReprojection interp = PrecomputedGridReprojection.getReprojection(
|
GridReprojection interp = PrecomputedGridReprojection.getReprojection(
|
||||||
sourceGeometry, destGeometry);
|
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(
|
resampledData = interp.reprojectedGrid(
|
||||||
new NearestNeighborInterpolation(), source,
|
new NearestNeighborInterpolation(), source, dest).getBuffer();
|
||||||
new ByteBufferWrapper(destGeometry)).getBuffer();
|
|
||||||
|
|
||||||
// Remap the the output data into a Grid2DFloat object
|
// Remap the the output data into a Grid2DFloat object
|
||||||
|
|
||||||
|
@ -510,12 +519,16 @@ public class RemapGrid {
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input
|
||||||
* The input data
|
* The input data
|
||||||
|
* @param inputFill
|
||||||
|
* the input fill value
|
||||||
|
* @param outputFill
|
||||||
|
* the output fill value
|
||||||
* @return The resampled data
|
* @return The resampled data
|
||||||
* @throws TransformException
|
* @throws TransformException
|
||||||
* @throws FactoryException
|
* @throws FactoryException
|
||||||
*/
|
*/
|
||||||
private Grid2DFloat resample(final Grid2DFloat input)
|
private Grid2DFloat resample(final Grid2DFloat input, float inputFill,
|
||||||
throws FactoryException, TransformException {
|
float outputFill) throws FactoryException, TransformException {
|
||||||
|
|
||||||
GridGeometry2D sourceGeometry = MapUtil.getGridGeometry(sourceGloc);
|
GridGeometry2D sourceGeometry = MapUtil.getGridGeometry(sourceGloc);
|
||||||
|
|
||||||
|
@ -566,9 +579,16 @@ public class RemapGrid {
|
||||||
|
|
||||||
GridReprojection interp = PrecomputedGridReprojection
|
GridReprojection interp = PrecomputedGridReprojection
|
||||||
.getReprojection(sourceGeometry, destGeometry);
|
.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,
|
f1 = interp.reprojectedGrid(new BilinearInterpolation(), source,
|
||||||
new FloatArrayWrapper(destGeometry)).getArray();
|
dest).getArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remap the the output data into a Grid2DFloat object
|
// 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.awt.Point;
|
||||||
import java.util.HashMap;
|
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.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
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.adapters.PointAdapter;
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
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;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,91 +63,136 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* 03/13/08 #1030 randerso Initial port
|
* 03/13/08 #1030 randerso Initial port
|
||||||
* 04/24/08 #1047 randerso Made all fields private and created getters
|
* 04/24/08 #1047 randerso Made all fields private and created getters
|
||||||
* 04/24/13 #1935 randerso Fixed date line spanning issue
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author randerso
|
* @author randerso
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
@Embeddable
|
||||||
@XmlAccessorType(XmlAccessType.NONE)
|
@XmlAccessorType(XmlAccessType.NONE)
|
||||||
@DynamicSerialize
|
@DynamicSerialize
|
||||||
public class ProjectionData implements ISerializableObject {
|
public class ProjectionData implements ISerializableObject {
|
||||||
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(ProjectionData.class);
|
||||||
|
|
||||||
private static float COMPARISON_THRESHOLD = 0.005f;
|
private static float COMPARISON_THRESHOLD = 0.005f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of supported map projections
|
||||||
|
*/
|
||||||
public static enum ProjectionType {
|
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
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private String projectionID;
|
private String projectionID;
|
||||||
|
|
||||||
|
@Column(length = 20, nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private ProjectionType projectionType;
|
private ProjectionType projectionType;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Coordinate latLonLL;
|
private Coordinate latLonLL;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Coordinate latLonUR;
|
private Coordinate latLonUR;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Coordinate latLonOrigin;
|
private Coordinate latLonOrigin;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private double stdParallelOne;
|
private double stdParallelOne;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private double stdParallelTwo;
|
private double stdParallelTwo;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = PointAdapter.class)
|
@XmlJavaTypeAdapter(value = PointAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Point gridPointLL;
|
private Point gridPointLL;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = PointAdapter.class)
|
@XmlJavaTypeAdapter(value = PointAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Point gridPointUR;
|
private Point gridPointUR;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private double latIntersect;
|
private double latIntersect;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private double lonCenter;
|
private double lonCenter;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private double lonOrigin;
|
private double lonOrigin;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private CoordinateReferenceSystem crs;
|
private CoordinateReferenceSystem crs;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private GridGeometry2D gridGeometry;
|
private GridGeometry2D gridGeometry;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private MathTransform crsToLatLon;
|
private MathTransform crsToLatLon;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private MathTransform latLonToCrs;
|
private MathTransform latLonToCrs;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private HashMap<PixelOrientation, MathTransform> gridToLatLon;
|
private HashMap<PixelOrientation, MathTransform> gridToLatLon;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private HashMap<PixelOrientation, MathTransform> latLonToGrid;
|
private HashMap<PixelOrientation, MathTransform> latLonToGrid;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private HashMap<PixelOrientation, MathTransform> gridToCrs;
|
private HashMap<PixelOrientation, MathTransform> gridToCrs;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
public ProjectionData() {
|
public ProjectionData() {
|
||||||
latLonLL = new Coordinate();
|
latLonLL = new Coordinate();
|
||||||
latLonUR = new Coordinate();
|
latLonUR = new Coordinate();
|
||||||
|
@ -155,17 +207,34 @@ public class ProjectionData implements ISerializableObject {
|
||||||
initialized = false;
|
initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectionData(String projID, int projType, Coordinate latLonLL,
|
/**
|
||||||
Coordinate latLonUR, Coordinate latLonOrig, float stdPar1,
|
* Constructor
|
||||||
float stdPar2, Point gridLL, Point gridUR, float latInt,
|
*
|
||||||
float lonCenter, float lonOrig) {
|
* @param projID
|
||||||
this(projID, ProjectionType.values()[projType], latLonLL, latLonUR,
|
* name associated with this projection
|
||||||
latLonOrig, stdPar1, stdPar2, gridLL, gridUR, latInt,
|
* @param projType
|
||||||
lonCenter, lonOrig);
|
* projection type
|
||||||
|
* @param latLonLL
|
||||||
init();
|
* 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,
|
public ProjectionData(String projID, ProjectionType projType,
|
||||||
Coordinate latLonLL, Coordinate latLonUR, Coordinate latLonOrig,
|
Coordinate latLonLL, Coordinate latLonUR, Coordinate latLonOrig,
|
||||||
float stdPar1, float stdPar2, Point gridLL, Point gridUR,
|
float stdPar1, float stdPar2, Point gridLL, Point gridUR,
|
||||||
|
@ -188,7 +257,10 @@ public class ProjectionData implements ISerializableObject {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
/**
|
||||||
|
* Initialize the object. Must be called after database retrieval
|
||||||
|
*/
|
||||||
|
public void init() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +331,11 @@ public class ProjectionData implements ISerializableObject {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the Coordinate Reference System (CRS) of this projection
|
||||||
|
*
|
||||||
|
* @return the CRS
|
||||||
|
*/
|
||||||
public synchronized CoordinateReferenceSystem getCrs() {
|
public synchronized CoordinateReferenceSystem getCrs() {
|
||||||
if (crs == null) {
|
if (crs == null) {
|
||||||
|
|
||||||
|
@ -310,20 +387,20 @@ public class ProjectionData implements ISerializableObject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(this.latLonLL.y - rhs.latLonLL.y) > 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.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD)
|
||||||
|| Math.abs(this.latLonUR.y - rhs.latLonUR.y) > COMPARISON_THRESHOLD
|
|| (Math.abs(this.latLonUR.y - rhs.latLonUR.y) > COMPARISON_THRESHOLD)
|
||||||
|| Math.abs(this.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD) {
|
|| (Math.abs(this.latLonLL.x - rhs.latLonLL.x) > COMPARISON_THRESHOLD)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// specific projection comparisons
|
// specific projection comparisons
|
||||||
switch (this.projectionType) {
|
switch (this.projectionType) {
|
||||||
case LAMBERT_CONFORMAL:
|
case LAMBERT_CONFORMAL:
|
||||||
return (Math.abs(this.latLonOrigin.y - rhs.latLonOrigin.y) < 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.latLonOrigin.x - rhs.latLonOrigin.x) < COMPARISON_THRESHOLD)
|
||||||
|| Math.abs(this.stdParallelOne - rhs.stdParallelOne) < COMPARISON_THRESHOLD || Math
|
|| (Math.abs(this.stdParallelOne - rhs.stdParallelOne) < COMPARISON_THRESHOLD) || (Math
|
||||||
.abs(this.stdParallelTwo - rhs.stdParallelTwo) < COMPARISON_THRESHOLD);
|
.abs(this.stdParallelTwo - rhs.stdParallelTwo) < COMPARISON_THRESHOLD));
|
||||||
case POLAR_STEREOGRAPHIC:
|
case POLAR_STEREOGRAPHIC:
|
||||||
return (Math.abs(this.lonOrigin - rhs.lonOrigin) < COMPARISON_THRESHOLD);
|
return (Math.abs(this.lonOrigin - rhs.lonOrigin) < COMPARISON_THRESHOLD);
|
||||||
case MERCATOR:
|
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,
|
public Coordinate gridCoordinateToLatLon(Coordinate gridCoord,
|
||||||
PixelOrientation orientation) {
|
PixelOrientation orientation) {
|
||||||
Coordinate latLon = new Coordinate();
|
Coordinate latLon = new Coordinate();
|
||||||
|
@ -354,51 +440,40 @@ public class ProjectionData implements ISerializableObject {
|
||||||
latLon.x = output[0];
|
latLon.x = output[0];
|
||||||
latLon.y = output[1];
|
latLon.y = output[1];
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
statusHandler.error(
|
||||||
e.printStackTrace();
|
"Error computing grid coordinate to lat/lon transform", e);
|
||||||
}
|
}
|
||||||
return latLon;
|
return latLon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Coordinate latLonToGridCoordinate(Coordinate latLon,
|
/**
|
||||||
PixelOrientation orientation) {
|
* Return the math transform from grid coordinate to the specified corner or
|
||||||
Coordinate gridCoord = new Coordinate();
|
* center lat/lon
|
||||||
MathTransform mt = latLonToGrid.get(orientation);
|
*
|
||||||
try {
|
* @param orientation
|
||||||
if (mt == null) {
|
* desired corner or center
|
||||||
init();
|
* @return the transform
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MathTransform getGridToCrs(PixelOrientation orientation) {
|
public MathTransform getGridToCrs(PixelOrientation orientation) {
|
||||||
MathTransform mt = gridToCrs.get(orientation);
|
MathTransform mt = gridToCrs.get(orientation);
|
||||||
try {
|
if (mt == null) {
|
||||||
if (mt == null) {
|
init();
|
||||||
init();
|
mt = gridGeometry.getGridToCRS(orientation);
|
||||||
mt = gridGeometry.getGridToCRS(orientation);
|
gridToCrs.put(orientation, mt);
|
||||||
gridToCrs.put(orientation, mt);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return 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,
|
public Coordinate gridCoordinateToCrs(Coordinate gridCoord,
|
||||||
PixelOrientation orientation) {
|
PixelOrientation orientation) {
|
||||||
Coordinate crsCoordinate = new Coordinate();
|
Coordinate crsCoordinate = new Coordinate();
|
||||||
|
@ -410,114 +485,204 @@ public class ProjectionData implements ISerializableObject {
|
||||||
crsCoordinate.x = output[0];
|
crsCoordinate.x = output[0];
|
||||||
crsCoordinate.y = output[1];
|
crsCoordinate.y = output[1];
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
statusHandler.error(
|
||||||
e.printStackTrace();
|
"Error computing grid coordinate to CRS transform", e);
|
||||||
}
|
}
|
||||||
return crsCoordinate;
|
return crsCoordinate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the projectionID
|
||||||
|
*/
|
||||||
public String getProjectionID() {
|
public String getProjectionID() {
|
||||||
return projectionID;
|
return projectionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the projectionType
|
||||||
|
*/
|
||||||
public ProjectionType getProjectionType() {
|
public ProjectionType getProjectionType() {
|
||||||
return projectionType;
|
return projectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the latLonLL
|
||||||
|
*/
|
||||||
public Coordinate getLatLonLL() {
|
public Coordinate getLatLonLL() {
|
||||||
return latLonLL;
|
return latLonLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the latLonUR
|
||||||
|
*/
|
||||||
public Coordinate getLatLonUR() {
|
public Coordinate getLatLonUR() {
|
||||||
return latLonUR;
|
return latLonUR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the latLonOrigin
|
||||||
|
*/
|
||||||
public Coordinate getLatLonOrigin() {
|
public Coordinate getLatLonOrigin() {
|
||||||
return latLonOrigin;
|
return latLonOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the stdParallelOne
|
||||||
|
*/
|
||||||
public double getStdParallelOne() {
|
public double getStdParallelOne() {
|
||||||
return stdParallelOne;
|
return stdParallelOne;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the stdParallelTwo
|
||||||
|
*/
|
||||||
public double getStdParallelTwo() {
|
public double getStdParallelTwo() {
|
||||||
return stdParallelTwo;
|
return stdParallelTwo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the gridPointLL
|
||||||
|
*/
|
||||||
public Point getGridPointLL() {
|
public Point getGridPointLL() {
|
||||||
return gridPointLL;
|
return gridPointLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the gridPointUR
|
||||||
|
*/
|
||||||
public Point getGridPointUR() {
|
public Point getGridPointUR() {
|
||||||
return gridPointUR;
|
return gridPointUR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the latIntersect
|
||||||
|
*/
|
||||||
public double getLatIntersect() {
|
public double getLatIntersect() {
|
||||||
return latIntersect;
|
return latIntersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lonCenter
|
||||||
|
*/
|
||||||
public double getLonCenter() {
|
public double getLonCenter() {
|
||||||
return lonCenter;
|
return lonCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lonOrigin
|
||||||
|
*/
|
||||||
public double getLonOrigin() {
|
public double getLonOrigin() {
|
||||||
return lonOrigin;
|
return lonOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param projectionID
|
||||||
|
* the projectionID to set
|
||||||
|
*/
|
||||||
public void setProjectionID(String projectionID) {
|
public void setProjectionID(String projectionID) {
|
||||||
this.projectionID = projectionID;
|
this.projectionID = projectionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param projectionType
|
||||||
|
* the projectionType to set
|
||||||
|
*/
|
||||||
public void setProjectionType(ProjectionType projectionType) {
|
public void setProjectionType(ProjectionType projectionType) {
|
||||||
this.projectionType = projectionType;
|
this.projectionType = projectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param latLonLL
|
||||||
|
* the latLonLL to set
|
||||||
|
*/
|
||||||
public void setLatLonLL(Coordinate latLonLL) {
|
public void setLatLonLL(Coordinate latLonLL) {
|
||||||
this.latLonLL = latLonLL;
|
this.latLonLL = latLonLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param latLonUR
|
||||||
|
* the latLonUR to set
|
||||||
|
*/
|
||||||
public void setLatLonUR(Coordinate latLonUR) {
|
public void setLatLonUR(Coordinate latLonUR) {
|
||||||
this.latLonUR = latLonUR;
|
this.latLonUR = latLonUR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param latLonOrigin
|
||||||
|
* the latLonOrigin to set
|
||||||
|
*/
|
||||||
public void setLatLonOrigin(Coordinate latLonOrigin) {
|
public void setLatLonOrigin(Coordinate latLonOrigin) {
|
||||||
this.latLonOrigin = latLonOrigin;
|
this.latLonOrigin = latLonOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stdParallelOne
|
||||||
|
* the stdParallelOne to set
|
||||||
|
*/
|
||||||
public void setStdParallelOne(double stdParallelOne) {
|
public void setStdParallelOne(double stdParallelOne) {
|
||||||
this.stdParallelOne = stdParallelOne;
|
this.stdParallelOne = stdParallelOne;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stdParallelTwo
|
||||||
|
* the stdParallelTwo to set
|
||||||
|
*/
|
||||||
public void setStdParallelTwo(double stdParallelTwo) {
|
public void setStdParallelTwo(double stdParallelTwo) {
|
||||||
this.stdParallelTwo = stdParallelTwo;
|
this.stdParallelTwo = stdParallelTwo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gridPointLL
|
||||||
|
* the gridPointLL to set
|
||||||
|
*/
|
||||||
public void setGridPointLL(Point gridPointLL) {
|
public void setGridPointLL(Point gridPointLL) {
|
||||||
this.gridPointLL = gridPointLL;
|
this.gridPointLL = gridPointLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gridPointUR
|
||||||
|
* the gridPointUR to set
|
||||||
|
*/
|
||||||
public void setGridPointUR(Point gridPointUR) {
|
public void setGridPointUR(Point gridPointUR) {
|
||||||
this.gridPointUR = gridPointUR;
|
this.gridPointUR = gridPointUR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param latIntersect
|
||||||
|
* the latIntersect to set
|
||||||
|
*/
|
||||||
public void setLatIntersect(double latIntersect) {
|
public void setLatIntersect(double latIntersect) {
|
||||||
this.latIntersect = latIntersect;
|
this.latIntersect = latIntersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lonCenter
|
||||||
|
* the lonCenter to set
|
||||||
|
*/
|
||||||
public void setLonCenter(double lonCenter) {
|
public void setLonCenter(double lonCenter) {
|
||||||
this.lonCenter = lonCenter;
|
this.lonCenter = lonCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lonOrigin
|
||||||
|
* the lonOrigin to set
|
||||||
|
*/
|
||||||
public void setLonOrigin(double lonOrigin) {
|
public void setLonOrigin(double lonOrigin) {
|
||||||
this.lonOrigin = lonOrigin;
|
this.lonOrigin = lonOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the width of the projection in grid cells
|
||||||
|
*/
|
||||||
public Integer getNx() {
|
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() {
|
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 java.util.ArrayList;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
import javax.persistence.UniqueConstraint;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
@ -42,7 +50,8 @@ import org.geotools.geometry.GeneralEnvelope;
|
||||||
import org.geotools.referencing.GeodeticCalculator;
|
import org.geotools.referencing.GeodeticCalculator;
|
||||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||||
import org.geotools.referencing.operation.builder.GridToEnvelopeMapper;
|
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.metadata.spatial.PixelOrientation;
|
||||||
import org.opengis.referencing.FactoryException;
|
import org.opengis.referencing.FactoryException;
|
||||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
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/10/13 #2044 randerso Changed constructor to take ISpatialObject instead of GridCoverage
|
||||||
* 07/16/13 #2181 bsteffen Convert geometry types to use hibernate-
|
* 07/16/13 #2181 bsteffen Convert geometry types to use hibernate-
|
||||||
* spatial
|
* spatial
|
||||||
|
* 08/06/13 #1571 randerso Added hibernate annotations, javadoc cleanup,
|
||||||
|
* made init method public for use in GFEDao
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -99,24 +110,27 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "gfe_spatial")
|
@Table(name = "gfe_gridlocation", uniqueConstraints = { @UniqueConstraint(columnNames = { "dbId_id" }) })
|
||||||
@XmlAccessorType(XmlAccessType.NONE)
|
@XmlAccessorType(XmlAccessType.NONE)
|
||||||
@DynamicSerialize
|
@DynamicSerialize
|
||||||
public class GridLocation extends PersistableDataObject implements
|
public class GridLocation extends PersistableDataObject<String> implements
|
||||||
ISpatialObject, ISerializableObject {
|
ISpatialObject, ISerializableObject {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(GridLocation.class);
|
.getHandler(GridLocation.class);
|
||||||
|
|
||||||
private static class PythonNumpyFloatGrid implements INumpyable {
|
/**
|
||||||
private int nx;
|
* Container for lat/lon grids to be returned to python where they are
|
||||||
|
* reshaped using numpy for performance
|
||||||
private int ny;
|
*
|
||||||
|
*/
|
||||||
|
private static class PythonNumpyLatLonGrid implements INumpyable {
|
||||||
private float[] data;
|
private float[] data;
|
||||||
|
|
||||||
public PythonNumpyFloatGrid(int nx, int ny, float[] data) {
|
public PythonNumpyLatLonGrid(int nx, int ny, float[] data) {
|
||||||
this.nx = nx;
|
if ((nx * ny * 2) != data.length) {
|
||||||
this.ny = ny;
|
throw new IllegalArgumentException(
|
||||||
|
"data must be of length nx*ny*2");
|
||||||
|
}
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,24 +158,38 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated surrogate key
|
||||||
|
*/
|
||||||
@Id
|
@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
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private String siteId;
|
private String siteId;
|
||||||
|
|
||||||
/** Number of points along the x-axis */
|
/** Number of points along the x-axis */
|
||||||
@Column
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
protected Integer nx;
|
protected Integer nx;
|
||||||
|
|
||||||
/** Number of points along the y-axis */
|
/** Number of points along the y-axis */
|
||||||
@Column
|
@Column(nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
protected Integer ny;
|
protected Integer ny;
|
||||||
|
|
||||||
@Column
|
@Column(length = 32, nullable = false)
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private String timeZone;
|
private String timeZone;
|
||||||
|
@ -169,31 +197,30 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
@Transient
|
@Transient
|
||||||
private Coordinate gridCellSize;
|
private Coordinate gridCellSize;
|
||||||
|
|
||||||
@Transient
|
@Embedded
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private ProjectionData projection;
|
private ProjectionData projection;
|
||||||
|
|
||||||
@Transient
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Coordinate origin;
|
private Coordinate origin;
|
||||||
|
|
||||||
@Transient
|
@Column(nullable = false)
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
@XmlJavaTypeAdapter(value = CoordAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Coordinate extent;
|
private Coordinate extent;
|
||||||
|
|
||||||
@Column(name = "coverage")
|
@Transient
|
||||||
@Type(type = "org.hibernatespatial.GeometryUserType")
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
|
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private Polygon geometry;
|
private Polygon geometry;
|
||||||
|
|
||||||
@Column(name = "crs", length = 2047)
|
@Transient
|
||||||
@XmlElement
|
@XmlElement
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private String crsWKT;
|
private String crsWKT;
|
||||||
|
@ -201,32 +228,50 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
@Transient
|
@Transient
|
||||||
private CoordinateReferenceSystem crsObject;
|
private CoordinateReferenceSystem crsObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor for serialization
|
||||||
|
*/
|
||||||
public GridLocation() {
|
public GridLocation() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param data
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param proj
|
||||||
* @param gridSize
|
* @param gridSize
|
||||||
* @param domainOrigin
|
* @param domainOrigin
|
||||||
* @param domainExtent
|
* @param domainExtent
|
||||||
|
* @param timeZone
|
||||||
*/
|
*/
|
||||||
public GridLocation(String id, ProjectionData proj,
|
public GridLocation(String id, ProjectionData proj,
|
||||||
java.awt.Point gridSize, Coordinate domainOrigin,
|
java.awt.Point gridSize, Coordinate domainOrigin,
|
||||||
Coordinate domainExtent, String timeZone) {
|
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 {
|
try {
|
||||||
if ((id == null) || id.isEmpty()) {
|
this.projection.init();
|
||||||
throw new IllegalArgumentException(
|
this.crsObject = this.projection.getCrs();
|
||||||
"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.crsWKT = this.crsObject.toWKT();
|
this.crsWKT = this.crsObject.toWKT();
|
||||||
|
|
||||||
// This is here to help find issues where the WKT won't parse.
|
// 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
|
// transform the grid corners from grid coordinates to CRS units
|
||||||
Coordinate ll = domainOrigin;
|
Coordinate ll = this.origin;
|
||||||
Coordinate ur = new Coordinate(domainOrigin.x + domainExtent.x,
|
Coordinate ur = new Coordinate(this.origin.x + this.extent.x,
|
||||||
domainOrigin.y + domainExtent.y);
|
this.origin.y + this.extent.y);
|
||||||
|
|
||||||
Coordinate llCrs = proj.gridCoordinateToCrs(ll,
|
Coordinate llCrs = this.projection.gridCoordinateToCrs(ll,
|
||||||
PixelOrientation.CENTER);
|
PixelOrientation.CENTER);
|
||||||
Coordinate urCrs = proj.gridCoordinateToCrs(ur,
|
Coordinate urCrs = this.projection.gridCoordinateToCrs(ur,
|
||||||
PixelOrientation.CENTER);
|
PixelOrientation.CENTER);
|
||||||
|
|
||||||
// construct the grid geometry that covers the GFE grid
|
// 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) {
|
public GridLocation(ProjectionData proj) {
|
||||||
this(
|
this(
|
||||||
proj.getProjectionID(), //
|
proj.getProjectionID(), //
|
||||||
|
@ -311,6 +359,10 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
"GMT");
|
"GMT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* @param coverage
|
||||||
|
*/
|
||||||
public GridLocation(String id, ISpatialObject coverage) {
|
public GridLocation(String id, ISpatialObject coverage) {
|
||||||
this.siteId = id;
|
this.siteId = id;
|
||||||
this.crsObject = coverage.getCrs();
|
this.crsObject = coverage.getCrs();
|
||||||
|
@ -320,6 +372,11 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
this.ny = coverage.getNy();
|
this.ny = coverage.getNy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* @param gloc
|
||||||
|
* @param subGrid
|
||||||
|
*/
|
||||||
public GridLocation(String id, GridLocation gloc, Rectangle subGrid) {
|
public GridLocation(String id, GridLocation gloc, Rectangle subGrid) {
|
||||||
try {
|
try {
|
||||||
this.siteId = id;
|
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
|
* @return the timeZone
|
||||||
*/
|
*/
|
||||||
|
@ -375,7 +455,7 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return the grid size
|
||||||
*/
|
*/
|
||||||
public java.awt.Point gridSize() {
|
public java.awt.Point gridSize() {
|
||||||
return new java.awt.Point(nx, ny);
|
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.
|
* make sure each point is exactly one point away and save it.
|
||||||
*
|
*
|
||||||
* @param points
|
* @param points
|
||||||
* @return
|
* @return the connected grid points array
|
||||||
*/
|
*/
|
||||||
public java.awt.Point[] connectGridPoints(java.awt.Point points[]) {
|
public java.awt.Point[] connectGridPoints(java.awt.Point points[]) {
|
||||||
if (points.length == 0) {
|
if (points.length == 0) {
|
||||||
|
@ -454,7 +534,7 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
/**
|
/**
|
||||||
* Returns the size in kilometers for each grid cell.
|
* Returns the size in kilometers for each grid cell.
|
||||||
*
|
*
|
||||||
* @return
|
* @return grid cell size in kilometers
|
||||||
*/
|
*/
|
||||||
public Coordinate gridCellSize() {
|
public Coordinate gridCellSize() {
|
||||||
|
|
||||||
|
@ -577,10 +657,23 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
return ref.getGrid();
|
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) {
|
public Point gridCell(float lat, float lon) {
|
||||||
return gridCoordinate(new Coordinate(lon, lat));
|
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) {
|
public Point gridCoordinate(Coordinate lonLat) {
|
||||||
Coordinate gcf = MapUtil.latLonToGridCoordinate(lonLat,
|
Coordinate gcf = MapUtil.latLonToGridCoordinate(lonLat,
|
||||||
PixelOrientation.CENTER, this);
|
PixelOrientation.CENTER, this);
|
||||||
|
@ -589,6 +682,12 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
return new Point(x, y);
|
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) {
|
public Coordinate latLonCenter(Coordinate gridCell) {
|
||||||
return MapUtil.gridCoordinateToLatLon(gridCell,
|
return MapUtil.gridCoordinateToLatLon(gridCell,
|
||||||
PixelOrientation.CENTER, this);
|
PixelOrientation.CENTER, this);
|
||||||
|
@ -605,30 +704,54 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the projection
|
||||||
|
*/
|
||||||
public ProjectionData getProjection() {
|
public ProjectionData getProjection() {
|
||||||
return projection;
|
return projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the origin
|
||||||
|
*/
|
||||||
public Coordinate getOrigin() {
|
public Coordinate getOrigin() {
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the extent
|
||||||
|
*/
|
||||||
public Coordinate getExtent() {
|
public Coordinate getExtent() {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the serialVersionUID
|
||||||
|
*/
|
||||||
public static long getSerialVersionUID() {
|
public static long getSerialVersionUID() {
|
||||||
return serialVersionUID;
|
return serialVersionUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param projection
|
||||||
|
* the projection
|
||||||
|
*/
|
||||||
public void setProjection(ProjectionData projection) {
|
public void setProjection(ProjectionData projection) {
|
||||||
this.projection = projection;
|
this.projection = projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param origin
|
||||||
|
* the origin
|
||||||
|
*/
|
||||||
public void setOrigin(Coordinate origin) {
|
public void setOrigin(Coordinate origin) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param extent
|
||||||
|
* the extent
|
||||||
|
*/
|
||||||
public void setExtent(Coordinate extent) {
|
public void setExtent(Coordinate extent) {
|
||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
}
|
}
|
||||||
|
@ -701,11 +824,11 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projection == null) {
|
if (crsWKT == null) {
|
||||||
if (other.projection != null) {
|
if (other.crsWKT != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (!projection.equals(other.projection)) {
|
} else if (!crsWKT.equals(other.crsWKT)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -761,47 +884,91 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
return ny;
|
return ny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the siteId
|
||||||
|
*/
|
||||||
public String getSiteId() {
|
public String getSiteId() {
|
||||||
return siteId;
|
return siteId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param siteId
|
||||||
|
* the siteId
|
||||||
|
*/
|
||||||
public void setSiteId(String siteId) {
|
public void setSiteId(String siteId) {
|
||||||
this.siteId = siteId;
|
this.siteId = siteId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the crsWKT
|
||||||
|
*/
|
||||||
public String getCrsWKT() {
|
public String getCrsWKT() {
|
||||||
return crsWKT;
|
return crsWKT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param crsWKT
|
||||||
|
* the crsWKT
|
||||||
|
*/
|
||||||
public void setCrsWKT(String crsWKT) {
|
public void setCrsWKT(String crsWKT) {
|
||||||
this.crsWKT = crsWKT;
|
this.crsWKT = crsWKT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the crs
|
||||||
|
*/
|
||||||
public CoordinateReferenceSystem getCrsObject() {
|
public CoordinateReferenceSystem getCrsObject() {
|
||||||
return getCrs();
|
return getCrs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param crsObject
|
||||||
|
* the crs
|
||||||
|
*/
|
||||||
public void setCrsObject(CoordinateReferenceSystem crsObject) {
|
public void setCrsObject(CoordinateReferenceSystem crsObject) {
|
||||||
this.crsObject = crsObject;
|
this.crsObject = crsObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nx
|
||||||
|
* the nx
|
||||||
|
*/
|
||||||
public void setNx(Integer nx) {
|
public void setNx(Integer nx) {
|
||||||
this.nx = nx;
|
this.nx = nx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ny
|
||||||
|
* the ny
|
||||||
|
*/
|
||||||
public void setNy(Integer ny) {
|
public void setNy(Integer ny) {
|
||||||
this.ny = ny;
|
this.ny = ny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param geometry
|
||||||
|
*/
|
||||||
public void setGeometry(Geometry geometry) {
|
public void setGeometry(Geometry geometry) {
|
||||||
this.geometry = (Polygon) geometry;
|
this.geometry = (Polygon) geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param geometry
|
||||||
|
*/
|
||||||
public void setGeometry(Polygon geometry) {
|
public void setGeometry(Polygon geometry) {
|
||||||
this.geometry = 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];
|
float[] gridCells = new float[2 * nx * ny];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (float x = 0; x < nx; x++) {
|
for (float x = 0; x < nx; x++) {
|
||||||
|
@ -820,13 +987,16 @@ public class GridLocation extends PersistableDataObject implements
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PythonNumpyFloatGrid(nx, ny, latLon);
|
return new PythonNumpyLatLonGrid(nx, ny, latLon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ProjectionData grid211 = new ProjectionData("Grid211",
|
ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459,
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
12.190), new Coordinate(-49.385, 57.290),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
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 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);
|
latLon = MapUtil.gridCoordinateToLatLon(gridCoord, orientation, gloc);
|
||||||
System.out.println(gridCoord.x + "," + gridCoord.y + " " + latLon);
|
System.out.println(gridCoord.x + "," + gridCoord.y + " " + latLon);
|
||||||
|
|
||||||
PythonNumpyFloatGrid latLonGrid = gloc.getLatLonGrid();
|
PythonNumpyLatLonGrid latLonGrid = gloc.getLatLonGrid();
|
||||||
float[] data = (float[]) latLonGrid.getNumPy()[0];
|
float[] data = (float[]) latLonGrid.getNumPy()[0];
|
||||||
for (int x = 0; x < gloc.getNx(); x++) {
|
for (int x = 0; x < gloc.getNx(); x++) {
|
||||||
for (int y = 0; y < gloc.getNy(); y++) {
|
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.SI;
|
||||||
import javax.measure.unit.Unit;
|
import javax.measure.unit.Unit;
|
||||||
import javax.measure.unit.UnitFormat;
|
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.db.objects.GFERecord.GridType;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
|
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,
|
* 03/20/2013 #1774 randerso Removed unnecessary XML annotations,
|
||||||
* added isValid method to match A1
|
* added isValid method to match A1
|
||||||
* 04/02/2013 #1774 randerso Improved error message in validCheck
|
* 04/02/2013 #1774 randerso Improved error message in validCheck
|
||||||
|
* 08/06/13 #1571 randerso Added hibernate annotations, javadoc cleanup
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -59,6 +74,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
@DynamicSerialize
|
@DynamicSerialize
|
||||||
public class GridParmInfo implements Cloneable, ISerializableObject {
|
public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
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 */
|
/** 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
|
@DynamicSerializeElement
|
||||||
private ParmID parmID;
|
private ParmID parmID;
|
||||||
|
|
||||||
/** The grid location associated with this grid parm info */
|
/** The grid location associated with this grid parm info */
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
|
@PrimaryKeyJoinColumn
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private GridLocation gridLoc;
|
private GridLocation gridLoc;
|
||||||
|
|
||||||
/** The grid type */
|
/** The grid type */
|
||||||
|
@Column(length = 8, nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private GridType gridType;
|
private GridType gridType;
|
||||||
|
|
||||||
/** The parameter descriptive name */
|
/** The parameter descriptive name */
|
||||||
|
@Column(length = 64, nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private String descriptiveName;
|
private String descriptiveName;
|
||||||
|
|
||||||
/** The units associated with the parameter */
|
/** The units associated with the parameter */
|
||||||
|
@Column(length = 64, nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private String unitString;
|
private String unitString;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private Unit<?> unitObject;
|
private Unit<?> unitObject;
|
||||||
|
|
||||||
/** The minimum allowed value */
|
/** The minimum allowed value */
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private float minValue;
|
private float minValue;
|
||||||
|
|
||||||
/** The maximum allowed value */
|
/** The maximum allowed value */
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private float maxValue;
|
private float maxValue;
|
||||||
|
|
||||||
/** The precision of the value */
|
/** The precision of the value */
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private int precision;
|
private int precision;
|
||||||
|
|
||||||
/** Is value a rate parameter */
|
/** Is value a rate parameter */
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private boolean rateParm;
|
private boolean rateParm;
|
||||||
|
|
||||||
/** Time Constraints */
|
/** Time Constraints */
|
||||||
|
@Embedded
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private TimeConstraints timeConstraints;
|
private TimeConstraints timeConstraints;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private boolean timeIndependentParm;
|
private boolean timeIndependentParm;
|
||||||
|
|
||||||
|
@Transient
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor for serialization
|
||||||
|
*/
|
||||||
public GridParmInfo() {
|
public GridParmInfo() {
|
||||||
gridType = GridType.NONE;
|
gridType = GridType.NONE;
|
||||||
timeIndependentParm = false;
|
timeIndependentParm = false;
|
||||||
|
@ -150,6 +187,11 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
timeConstraints = null;
|
timeConstraints = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy constructor
|
||||||
|
*
|
||||||
|
* @param orig
|
||||||
|
*/
|
||||||
public GridParmInfo(GridParmInfo orig) {
|
public GridParmInfo(GridParmInfo orig) {
|
||||||
this.parmID = orig.parmID;
|
this.parmID = orig.parmID;
|
||||||
this.gridLoc = orig.gridLoc;
|
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,
|
public GridParmInfo(ParmID id, GridLocation gridLoc, GridType gridType,
|
||||||
String unit, String descriptiveName, float minValue,
|
String unit, String descriptiveName, float minValue,
|
||||||
float maxValue, int precision, boolean timeIndependentParm,
|
float maxValue, int precision, boolean timeIndependentParm,
|
||||||
|
@ -255,7 +311,7 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
// units defined
|
// units defined
|
||||||
if (unitString == null || unitString.isEmpty()) {
|
if ((unitString == null) || unitString.isEmpty()) {
|
||||||
sb.append("GridParmInfo.Units are not defined.\n");
|
sb.append("GridParmInfo.Units are not defined.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +325,7 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
// precision check
|
// precision check
|
||||||
if (precision < -2 || precision > 5) {
|
if ((precision < -2) || (precision > 5)) {
|
||||||
sb.append("GridParmInfo is invalid. Precision out of limits. ");
|
sb.append("GridParmInfo is invalid. Precision out of limits. ");
|
||||||
sb.append(" Precision is: ");
|
sb.append(" Precision is: ");
|
||||||
sb.append(precision);
|
sb.append(precision);
|
||||||
|
@ -317,6 +373,9 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
return unitString;
|
return unitString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the unitObject
|
||||||
|
*/
|
||||||
public synchronized Unit<?> getUnitObject() {
|
public synchronized Unit<?> getUnitObject() {
|
||||||
if (unitObject == null) {
|
if (unitObject == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -378,6 +437,9 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
return new GridParmInfo(this);
|
return new GridParmInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the parmID
|
||||||
|
*/
|
||||||
public ParmID getParmID() {
|
public ParmID getParmID() {
|
||||||
return parmID;
|
return parmID;
|
||||||
}
|
}
|
||||||
|
@ -391,20 +453,21 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result
|
result = (prime * result)
|
||||||
+ ((descriptiveName == null) ? 0 : descriptiveName.hashCode());
|
+ ((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());
|
+ ((gridType == null) ? 0 : gridType.hashCode());
|
||||||
result = prime * result + Float.floatToIntBits(maxValue);
|
result = (prime * result) + Float.floatToIntBits(maxValue);
|
||||||
result = prime * result + Float.floatToIntBits(minValue);
|
result = (prime * result) + Float.floatToIntBits(minValue);
|
||||||
result = prime * result + ((parmID == null) ? 0 : parmID.hashCode());
|
result = (prime * result) + ((parmID == null) ? 0 : parmID.hashCode());
|
||||||
result = prime * result + precision;
|
result = (prime * result) + precision;
|
||||||
result = prime * result + (rateParm ? 1231 : 1237);
|
result = (prime * result) + (rateParm ? 1231 : 1237);
|
||||||
result = prime * result
|
result = (prime * result)
|
||||||
+ ((timeConstraints == null) ? 0 : timeConstraints.hashCode());
|
+ ((timeConstraints == null) ? 0 : timeConstraints.hashCode());
|
||||||
result = prime * result + (timeIndependentParm ? 1231 : 1237);
|
result = (prime * result) + (timeIndependentParm ? 1231 : 1237);
|
||||||
result = prime * result
|
result = (prime * result)
|
||||||
+ ((unitString == null) ? 0 : unitString.hashCode());
|
+ ((unitString == null) ? 0 : unitString.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -502,6 +565,11 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
return timeIndependentParm;
|
return timeIndependentParm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the parmId
|
||||||
|
*
|
||||||
|
* @param parmId
|
||||||
|
*/
|
||||||
public void resetParmID(ParmID parmId) {
|
public void resetParmID(ParmID parmId) {
|
||||||
this.parmID = parmId;
|
this.parmID = parmId;
|
||||||
}
|
}
|
||||||
|
@ -516,50 +584,98 @@ public class GridParmInfo implements Cloneable, ISerializableObject {
|
||||||
+ " GridType: " + gridType;
|
+ " GridType: " + gridType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parmID
|
||||||
|
* the parmID to set
|
||||||
|
*/
|
||||||
public void setParmID(ParmID parmID) {
|
public void setParmID(ParmID parmID) {
|
||||||
this.parmID = parmID;
|
this.parmID = parmID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gridLoc
|
||||||
|
* the gridLoc to set
|
||||||
|
*/
|
||||||
public void setGridLoc(GridLocation gridLoc) {
|
public void setGridLoc(GridLocation gridLoc) {
|
||||||
this.gridLoc = gridLoc;
|
this.gridLoc = gridLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gridType
|
||||||
|
* the gridType to set
|
||||||
|
*/
|
||||||
public void setGridType(GridType gridType) {
|
public void setGridType(GridType gridType) {
|
||||||
this.gridType = gridType;
|
this.gridType = gridType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param descriptiveName
|
||||||
|
* the descriptiveName to set
|
||||||
|
*/
|
||||||
public void setDescriptiveName(String descriptiveName) {
|
public void setDescriptiveName(String descriptiveName) {
|
||||||
this.descriptiveName = descriptiveName;
|
this.descriptiveName = descriptiveName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param unitString
|
||||||
|
* the unitString to set
|
||||||
|
*/
|
||||||
public void setUnitString(String unitString) {
|
public void setUnitString(String unitString) {
|
||||||
this.unitString = unitString;
|
this.unitString = unitString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param unitObject
|
||||||
|
* the unitObject to set
|
||||||
|
*/
|
||||||
public void setUnitObject(Unit<?> unitObject) {
|
public void setUnitObject(Unit<?> unitObject) {
|
||||||
this.unitObject = unitObject;
|
this.unitObject = unitObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param minValue
|
||||||
|
* the minValue to set
|
||||||
|
*/
|
||||||
public void setMinValue(float minValue) {
|
public void setMinValue(float minValue) {
|
||||||
this.minValue = minValue;
|
this.minValue = minValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param maxValue
|
||||||
|
* the maxValue to set
|
||||||
|
*/
|
||||||
public void setMaxValue(float maxValue) {
|
public void setMaxValue(float maxValue) {
|
||||||
this.maxValue = maxValue;
|
this.maxValue = maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param precision
|
||||||
|
* the precision to set
|
||||||
|
*/
|
||||||
public void setPrecision(int precision) {
|
public void setPrecision(int precision) {
|
||||||
this.precision = precision;
|
this.precision = precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rateParm
|
||||||
|
* the rateParm to set
|
||||||
|
*/
|
||||||
public void setRateParm(boolean rateParm) {
|
public void setRateParm(boolean rateParm) {
|
||||||
this.rateParm = rateParm;
|
this.rateParm = rateParm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param timeConstraints
|
||||||
|
* the timeConstraints to set
|
||||||
|
*/
|
||||||
public void setTimeConstraints(TimeConstraints timeConstraints) {
|
public void setTimeConstraints(TimeConstraints timeConstraints) {
|
||||||
this.timeConstraints = timeConstraints;
|
this.timeConstraints = timeConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param timeIndependentParm
|
||||||
|
* the timeIndependentParm to set
|
||||||
|
*/
|
||||||
public void setTimeIndependentParm(boolean timeIndependentParm) {
|
public void setTimeIndependentParm(boolean timeIndependentParm) {
|
||||||
this.timeIndependentParm = 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.Date;
|
||||||
import java.util.List;
|
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.dataplugin.gfe.serialize.TimeConstraintsAdapter;
|
||||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
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
|
* 2/19/2008 chammack Ported from AWIPS I
|
||||||
* 03/20/2013 #1774 randerso Added isValid method, use TimeUtil constants,
|
* 03/20/2013 #1774 randerso Added isValid method, use TimeUtil constants,
|
||||||
* added serialization adapter, removed setters.
|
* added serialization adapter, removed setters.
|
||||||
|
* 08/06/13 #1571 randerso Added hibernate annotations, javadoc cleanup
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -50,21 +54,26 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
@DynamicSerialize
|
@DynamicSerialize
|
||||||
@DynamicSerializeTypeAdapter(factory = TimeConstraintsAdapter.class)
|
@DynamicSerializeTypeAdapter(factory = TimeConstraintsAdapter.class)
|
||||||
public class TimeConstraints implements ISerializableObject {
|
public class TimeConstraints implements ISerializableObject {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(TimeConstraints.class);
|
.getHandler(TimeConstraints.class);
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private int duration;
|
private int duration;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private int repeatInterval;
|
private int repeatInterval;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private int startTime;
|
private int startTime;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
boolean valid;
|
boolean valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,21 +86,28 @@ public class TimeConstraints implements ISerializableObject {
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param duration
|
||||||
|
* @param repeatInterval
|
||||||
|
* @param startTime
|
||||||
|
*/
|
||||||
public TimeConstraints(int duration, int repeatInterval, int startTime) {
|
public TimeConstraints(int duration, int repeatInterval, int startTime) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.repeatInterval = repeatInterval;
|
this.repeatInterval = repeatInterval;
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
|
|
||||||
if (this.duration == 0 && this.repeatInterval == 0
|
if ((this.duration == 0) && (this.repeatInterval == 0)
|
||||||
&& this.startTime == 0) {
|
&& (this.startTime == 0)) {
|
||||||
valid = true;
|
valid = true;
|
||||||
} else {
|
} else {
|
||||||
if (repeatInterval <= 0
|
if ((repeatInterval <= 0)
|
||||||
|| repeatInterval > TimeUtil.SECONDS_PER_DAY
|
|| (repeatInterval > TimeUtil.SECONDS_PER_DAY)
|
||||||
|| TimeUtil.SECONDS_PER_DAY % repeatInterval != 0
|
|| ((TimeUtil.SECONDS_PER_DAY % repeatInterval) != 0)
|
||||||
|| repeatInterval < duration || startTime < 0
|
|| (repeatInterval < duration) || (startTime < 0)
|
||||||
|| startTime > TimeUtil.SECONDS_PER_DAY || duration < 0
|
|| (startTime > TimeUtil.SECONDS_PER_DAY) || (duration < 0)
|
||||||
|| duration > TimeUtil.SECONDS_PER_DAY) {
|
|| (duration > TimeUtil.SECONDS_PER_DAY)) {
|
||||||
statusHandler.warn("Bad init values for TimeConstraints: "
|
statusHandler.warn("Bad init values for TimeConstraints: "
|
||||||
+ this);
|
+ this);
|
||||||
valid = false;
|
valid = false;
|
||||||
|
@ -112,6 +128,7 @@ public class TimeConstraints implements ISerializableObject {
|
||||||
*
|
*
|
||||||
* @param absTime
|
* @param absTime
|
||||||
* the time that the range should contain
|
* the time that the range should contain
|
||||||
|
* @return the time range
|
||||||
*/
|
*/
|
||||||
public TimeRange constraintTime(Date absTime) {
|
public TimeRange constraintTime(Date absTime) {
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
|
@ -127,17 +144,18 @@ public class TimeConstraints implements ISerializableObject {
|
||||||
|
|
||||||
int tStart = startTime - repeatInterval;
|
int tStart = startTime - repeatInterval;
|
||||||
|
|
||||||
while (tStart + duration >= 0) {
|
while ((tStart + duration) >= 0) {
|
||||||
// tstart+duration is ending time
|
// tstart+duration is ending time
|
||||||
tStart -= repeatInterval; // keep going until below 0
|
tStart -= repeatInterval; // keep going until below 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tStart < TimeUtil.SECONDS_PER_DAY) {
|
while (tStart < TimeUtil.SECONDS_PER_DAY) {
|
||||||
int tEnd = tStart + duration;
|
int tEnd = tStart + duration;
|
||||||
if ((tStart * TimeUtil.MILLIS_PER_SECOND) <= secSinceMidnight
|
if (((tStart * TimeUtil.MILLIS_PER_SECOND) <= secSinceMidnight)
|
||||||
&& secSinceMidnight < (tEnd * TimeUtil.MILLIS_PER_SECOND)) {
|
&& (secSinceMidnight < (tEnd * TimeUtil.MILLIS_PER_SECOND))) {
|
||||||
return new TimeRange(midnight + TimeUtil.MILLIS_PER_SECOND
|
return new TimeRange(midnight
|
||||||
* tStart, midnight + TimeUtil.MILLIS_PER_SECOND * tEnd);
|
+ (TimeUtil.MILLIS_PER_SECOND * tStart), midnight
|
||||||
|
+ (TimeUtil.MILLIS_PER_SECOND * tEnd));
|
||||||
}
|
}
|
||||||
tStart += repeatInterval;
|
tStart += repeatInterval;
|
||||||
}
|
}
|
||||||
|
@ -197,8 +215,8 @@ public class TimeConstraints implements ISerializableObject {
|
||||||
|
|
||||||
TimeConstraints rhs = (TimeConstraints) obj;
|
TimeConstraints rhs = (TimeConstraints) obj;
|
||||||
|
|
||||||
return (valid == rhs.valid && duration == rhs.duration
|
return ((valid == rhs.valid) && (duration == rhs.duration)
|
||||||
&& repeatInterval == rhs.repeatInterval && startTime == rhs.startTime);
|
&& (repeatInterval == rhs.repeatInterval) && (startTime == rhs.startTime));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +225,7 @@ public class TimeConstraints implements ISerializableObject {
|
||||||
*
|
*
|
||||||
* @param tr
|
* @param tr
|
||||||
* the time range
|
* the time range
|
||||||
* @return
|
* @return true if the input time range matches the time constraints
|
||||||
*/
|
*/
|
||||||
public boolean validTR(final TimeRange tr) {
|
public boolean validTR(final TimeRange tr) {
|
||||||
if (!anyConstraints()) {
|
if (!anyConstraints()) {
|
||||||
|
@ -251,9 +269,8 @@ public class TimeConstraints implements ISerializableObject {
|
||||||
// is beyond the time range given
|
// is beyond the time range given
|
||||||
List<TimeRange> sbs = new ArrayList<TimeRange>(); // returned value
|
List<TimeRange> sbs = new ArrayList<TimeRange>(); // returned value
|
||||||
TimeRange tr = firstSB(timeRange.getStart());
|
TimeRange tr = firstSB(timeRange.getStart());
|
||||||
while (timeRange.getEnd().getTime()
|
while ((timeRange.getEnd().getTime() + (duration * TimeUtil.MILLIS_PER_SECOND)) > tr
|
||||||
+ (duration * TimeUtil.MILLIS_PER_SECOND) > tr.getEnd()
|
.getEnd().getTime()) {
|
||||||
.getTime()) {
|
|
||||||
if (tr.overlaps(timeRange)) {
|
if (tr.overlaps(timeRange)) {
|
||||||
sbs.add(tr);
|
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
|
* 06/10/2009 2159 rjpeter Updated checkDims to check grid for null
|
||||||
* 01/30/2013 15719 jdynina Allowed more than 128 char width wx
|
* 01/30/2013 15719 jdynina Allowed more than 128 char width wx
|
||||||
* string
|
* string
|
||||||
|
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
|
||||||
|
* debugger when trying to display the grid
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -167,8 +169,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
||||||
|
|
||||||
if (gsDiscreteGrid != null) {
|
if (gsDiscreteGrid != null) {
|
||||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||||
if (discreteGrid.getXdim() != gsDiscreteGrid.getXdim()
|
if ((discreteGrid.getXdim() != gsDiscreteGrid.getXdim())
|
||||||
|| discreteGrid.getYdim() != gsDiscreteGrid.getYdim()) {
|
|| (discreteGrid.getYdim() != gsDiscreteGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Supplied grid is not of same dimension");
|
"Supplied grid is not of same dimension");
|
||||||
}
|
}
|
||||||
|
@ -302,8 +304,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
||||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||||
Point gridSize = new Point(discreteGrid.getXdim(),
|
Point gridSize = new Point(discreteGrid.getXdim(),
|
||||||
discreteGrid.getYdim());
|
discreteGrid.getYdim());
|
||||||
if (editArea.getXdim() != gridSize.x
|
if ((editArea.getXdim() != gridSize.x)
|
||||||
|| editArea.getYdim() != gridSize.y) {
|
|| (editArea.getYdim() != gridSize.y)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,8 +355,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
||||||
*/
|
*/
|
||||||
public boolean assign(DiscreteGridSlice gs, Grid2DBit editArea) {
|
public boolean assign(DiscreteGridSlice gs, Grid2DBit editArea) {
|
||||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||||
if (editArea.getXdim() != discreteGrid.getXdim()
|
if ((editArea.getXdim() != discreteGrid.getXdim())
|
||||||
|| editArea.getYdim() != discreteGrid.getYdim()) {
|
|| (editArea.getYdim() != discreteGrid.getYdim())) {
|
||||||
return false;
|
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
|
* for duplicate keys, set all locations in grid that match that key to
|
||||||
* the "first" of the duplicate keys
|
* 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++) {
|
for (int j = i; j < key.length; j++) {
|
||||||
if (key[i].equals(key[j])) {
|
if (key[i].equals(key[j])) {
|
||||||
discreteGrid.setAllOfValue((byte) j, (byte) i);
|
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);
|
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() {
|
private String checkDims() {
|
||||||
Grid2DByte discreteGrid = getDiscreteGrid();
|
Grid2DByte discreteGrid = getDiscreteGrid();
|
||||||
if (discreteGrid == null) {
|
if (discreteGrid == null) {
|
||||||
|
@ -712,8 +704,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
||||||
int x = discreteGrid.getXdim();
|
int x = discreteGrid.getXdim();
|
||||||
int y = discreteGrid.getYdim();
|
int y = discreteGrid.getYdim();
|
||||||
|
|
||||||
if (x != gridParmInfo.getGridLoc().getNx()
|
if ((x != gridParmInfo.getGridLoc().getNx())
|
||||||
|| y != gridParmInfo.getGridLoc().getNy()) {
|
|| (y != gridParmInfo.getGridLoc().getNy())) {
|
||||||
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
||||||
+ x
|
+ x
|
||||||
+ ","
|
+ ","
|
||||||
|
@ -733,7 +725,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
|
||||||
* @return the discrete grid
|
* @return the discrete grid
|
||||||
*/
|
*/
|
||||||
public Grid2DByte getDiscreteGrid() {
|
public Grid2DByte getDiscreteGrid() {
|
||||||
if (useCache && cacheId != null) {
|
if (useCache && (cacheId != null)) {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
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
|
* 01/30/2008 chammack Stubbed-out class based on AWIPS I
|
||||||
* 02/20/2008 879 rbell Legacy conversion
|
* 02/20/2008 879 rbell Legacy conversion
|
||||||
* 06/10/2009 2159 rjpeter Updated checkDims to check scalarGrid for null
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -172,8 +174,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
|
|
||||||
if (rhsScalarGrid != null) {
|
if (rhsScalarGrid != null) {
|
||||||
Grid2DFloat scalarGrid = getScalarGrid();
|
Grid2DFloat scalarGrid = getScalarGrid();
|
||||||
if (scalarGrid.getXdim() != rhsScalarGrid.getXdim()
|
if ((scalarGrid.getXdim() != rhsScalarGrid.getXdim())
|
||||||
|| scalarGrid.getYdim() != rhsScalarGrid.getYdim()) {
|
|| (scalarGrid.getYdim() != rhsScalarGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Supplied grid is not of same dimension");
|
"Supplied grid is not of same dimension");
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,7 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
* @return the scalar grid
|
* @return the scalar grid
|
||||||
*/
|
*/
|
||||||
public Grid2DFloat getScalarGrid() {
|
public Grid2DFloat getScalarGrid() {
|
||||||
if (useCache && cacheId != null) {
|
if (useCache && (cacheId != null)) {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
||||||
|
@ -304,8 +306,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
Grid2DFloat thisGrid = getScalarGrid();
|
Grid2DFloat thisGrid = getScalarGrid();
|
||||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||||
|
|
||||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This grid and supplied grid have different dimensions");
|
"This grid and supplied grid have different dimensions");
|
||||||
}
|
}
|
||||||
|
@ -370,8 +372,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
@Override
|
@Override
|
||||||
public void limitValue(float minValue, float maxValue, Grid2DBit editArea) {
|
public void limitValue(float minValue, float maxValue, Grid2DBit editArea) {
|
||||||
Grid2DFloat grid = getScalarGrid();
|
Grid2DFloat grid = getScalarGrid();
|
||||||
if (editArea.getXdim() != grid.getXdim()
|
if ((editArea.getXdim() != grid.getXdim())
|
||||||
|| editArea.getYdim() != grid.getYdim()) {
|
|| (editArea.getYdim() != grid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This grid and edit area have different dimensions");
|
"This grid and edit area have different dimensions");
|
||||||
}
|
}
|
||||||
|
@ -425,8 +427,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
Grid2DFloat thisGrid = getScalarGrid();
|
Grid2DFloat thisGrid = getScalarGrid();
|
||||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||||
|
|
||||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This and supplied GridSlice are different dimensions");
|
"This and supplied GridSlice are different dimensions");
|
||||||
}
|
}
|
||||||
|
@ -458,8 +460,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
|
|
||||||
Grid2DFloat thisGrid = getScalarGrid();
|
Grid2DFloat thisGrid = getScalarGrid();
|
||||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This and supplied GridSlice are different dimensions");
|
"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) {
|
public void operateEquals(Op op, float value, Grid2DBit editArea) {
|
||||||
Grid2DFloat grid = getScalarGrid();
|
Grid2DFloat grid = getScalarGrid();
|
||||||
|
|
||||||
if (grid.getXdim() != editArea.getXdim()
|
if ((grid.getXdim() != editArea.getXdim())
|
||||||
|| grid.getYdim() != editArea.getYdim()) {
|
|| (grid.getYdim() != editArea.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This grid and edit area have different dimensions");
|
"This grid and edit area have different dimensions");
|
||||||
}
|
}
|
||||||
|
@ -577,13 +579,13 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
Grid2DFloat thisGrid = getScalarGrid();
|
Grid2DFloat thisGrid = getScalarGrid();
|
||||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||||
|
|
||||||
if (thisGrid.getXdim() != editArea.getXdim()
|
if ((thisGrid.getXdim() != editArea.getXdim())
|
||||||
|| thisGrid.getYdim() != editArea.getYdim()) {
|
|| (thisGrid.getYdim() != editArea.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This grid and edit area have different dimensions");
|
"This grid and edit area have different dimensions");
|
||||||
}
|
}
|
||||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This grid and supplied grid have different dimensions");
|
"This grid and supplied grid have different dimensions");
|
||||||
}
|
}
|
||||||
|
@ -649,8 +651,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
Grid2DFloat thisGrid = getScalarGrid();
|
Grid2DFloat thisGrid = getScalarGrid();
|
||||||
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
Grid2DFloat rhsGrid = rhs.getScalarGrid();
|
||||||
|
|
||||||
if (thisGrid.getXdim() != rhsGrid.getXdim()
|
if ((thisGrid.getXdim() != rhsGrid.getXdim())
|
||||||
|| thisGrid.getYdim() != rhsGrid.getYdim()) {
|
|| (thisGrid.getYdim() != rhsGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"This grid and supplied grid have different dimensions");
|
"This grid and supplied grid have different dimensions");
|
||||||
}
|
}
|
||||||
|
@ -742,15 +744,6 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder rVal = new StringBuilder(super.toString());
|
|
||||||
|
|
||||||
rVal.append(" Scalar grid: ").append(getScalarGrid()).append("\n");
|
|
||||||
|
|
||||||
return rVal.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
|
@ -810,8 +803,8 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
x = grid.getXdim();
|
x = grid.getXdim();
|
||||||
y = grid.getYdim();
|
y = grid.getYdim();
|
||||||
|
|
||||||
if (x != gridParmInfo.getGridLoc().getNx()
|
if ((x != gridParmInfo.getGridLoc().getNx())
|
||||||
|| y != gridParmInfo.getGridLoc().getNy()) {
|
|| (y != gridParmInfo.getGridLoc().getNy())) {
|
||||||
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
||||||
+ x
|
+ x
|
||||||
+ ","
|
+ ","
|
||||||
|
@ -844,7 +837,7 @@ public class ScalarGridSlice extends AbstractGridSlice implements
|
||||||
float f;
|
float f;
|
||||||
for (int i = 0; i < b.capacity(); i++) {
|
for (int i = 0; i < b.capacity(); i++) {
|
||||||
f = b.get(i);
|
f = b.get(i);
|
||||||
if (f < minV || f > maxV) {
|
if ((f < minV) || (f > maxV)) {
|
||||||
return "Data Values Exceeded in Grid at coordinate: "
|
return "Data Values Exceeded in Grid at coordinate: "
|
||||||
+ (i % grid.getXdim()) + ',' + (i / grid.getXdim())
|
+ (i % grid.getXdim()) + ',' + (i / grid.getXdim())
|
||||||
+ " Value=" + f + " MinAllowed=" + minV
|
+ " Value=" + f + " MinAllowed=" + minV
|
||||||
|
|
|
@ -55,6 +55,9 @@ import com.raytheon.uf.common.time.TimeRange;
|
||||||
* 02/22/2008 879 rbell Legacy conversion, extended ScalarSlice
|
* 02/22/2008 879 rbell Legacy conversion, extended ScalarSlice
|
||||||
* 06/10/2009 2159 rjpeter Updated checkDims to check dirGrid for null
|
* 06/10/2009 2159 rjpeter Updated checkDims to check dirGrid for null
|
||||||
* 04/23/2013 1949 rjpeter Updated wind checks to keep float precision.
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -315,23 +318,6 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
||||||
return thisDirGrid.equals(rhsDirGrid);
|
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.
|
* Makes a vector grid slice from u and v components.
|
||||||
*
|
*
|
||||||
|
@ -356,8 +342,8 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
||||||
magGrid.set(
|
magGrid.set(
|
||||||
i,
|
i,
|
||||||
j,
|
j,
|
||||||
(float) Math.sqrt(u.get(i, j) * u.get(i, j)
|
(float) Math.sqrt((u.get(i, j) * u.get(i, j))
|
||||||
+ v.get(i, j) * v.get(i, j)));
|
+ (v.get(i, j) * v.get(i, j))));
|
||||||
float dir = (float) Math.toDegrees(Math.atan2(u.get(i, j),
|
float dir = (float) Math.toDegrees(Math.atan2(u.get(i, j),
|
||||||
v.get(i, j)));
|
v.get(i, j)));
|
||||||
while (dir < 0.0f) {
|
while (dir < 0.0f) {
|
||||||
|
@ -401,8 +387,8 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
||||||
magGrid.set(
|
magGrid.set(
|
||||||
i,
|
i,
|
||||||
j,
|
j,
|
||||||
(float) Math.sqrt(u.get(i, j) * u.get(i, j)
|
(float) Math.sqrt((u.get(i, j) * u.get(i, j))
|
||||||
+ v.get(i, j) * v.get(i, j)));
|
+ (v.get(i, j) * v.get(i, j))));
|
||||||
float dir = (float) Math.toDegrees(Math.atan2(u.get(i, j),
|
float dir = (float) Math.toDegrees(Math.atan2(u.get(i, j),
|
||||||
v.get(i, j)));
|
v.get(i, j)));
|
||||||
while (dir < 0.0f) {
|
while (dir < 0.0f) {
|
||||||
|
@ -613,8 +599,8 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
|
||||||
|
|
||||||
// u and v components
|
// u and v components
|
||||||
// (convert from knots to meters per second 1.94384 knots / m/s )
|
// (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 uw = (float) ((Math.sin(rads) * mGrid.get(xc, yc)) / 1.94384);
|
||||||
float vw = (float) (Math.cos(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;
|
// (you might already have uw and vw to work with;
|
||||||
// make sure they are in meters per second.)
|
// 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
|
// multiply (dot product) wind vector by slope vector
|
||||||
// to get the value of the vertical air motion.
|
// 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.
|
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;
|
import com.raytheon.uf.common.time.TimeRange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Weather Grid Slize
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -53,7 +53,9 @@ import com.raytheon.uf.common.time.TimeRange;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 15, 2011 randerso Initial creation
|
* Mar 15, 2011 randerso Initial creation
|
||||||
* Jan 30, 2013 15719 jdynina Allowed more than 128 char wx string
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -168,8 +170,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
|
|
||||||
if (gsWeatherGrid != null) {
|
if (gsWeatherGrid != null) {
|
||||||
Grid2DByte weatherGrid = getWeatherGrid();
|
Grid2DByte weatherGrid = getWeatherGrid();
|
||||||
if (weatherGrid.getXdim() != gsWeatherGrid.getXdim()
|
if ((weatherGrid.getXdim() != gsWeatherGrid.getXdim())
|
||||||
|| weatherGrid.getYdim() != gsWeatherGrid.getYdim()) {
|
|| (weatherGrid.getYdim() != gsWeatherGrid.getYdim())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Supplied grid is not of same dimension");
|
"Supplied grid is not of same dimension");
|
||||||
}
|
}
|
||||||
|
@ -228,8 +230,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grid.getXdim() != rhsGrid.getXdim()
|
if ((grid.getXdim() != rhsGrid.getXdim())
|
||||||
|| grid.getYdim() != rhsGrid.getYdim()) {
|
|| (grid.getYdim() != rhsGrid.getYdim())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +305,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
|
|
||||||
Grid2DByte weatherGrid = getWeatherGrid();
|
Grid2DByte weatherGrid = getWeatherGrid();
|
||||||
Point gridSize = new Point(weatherGrid.getXdim(), weatherGrid.getYdim());
|
Point gridSize = new Point(weatherGrid.getXdim(), weatherGrid.getYdim());
|
||||||
if (editArea.getXdim() != gridSize.x
|
if ((editArea.getXdim() != gridSize.x)
|
||||||
|| editArea.getYdim() != gridSize.y) {
|
|| (editArea.getYdim() != gridSize.y)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,8 +356,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
*/
|
*/
|
||||||
public boolean assign(WeatherGridSlice gs, Grid2DBit editArea) {
|
public boolean assign(WeatherGridSlice gs, Grid2DBit editArea) {
|
||||||
Grid2DByte weatherGrid = getWeatherGrid();
|
Grid2DByte weatherGrid = getWeatherGrid();
|
||||||
if (editArea.getXdim() != weatherGrid.getXdim()
|
if ((editArea.getXdim() != weatherGrid.getXdim())
|
||||||
|| editArea.getYdim() != weatherGrid.getYdim()) {
|
|| (editArea.getYdim() != weatherGrid.getYdim())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,14 +720,6 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
return new WeatherGridSlice(aValidTime, aGpi, aHistory, aGrid, aKey);
|
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() {
|
private String checkDims() {
|
||||||
Grid2DByte weatherGrid = getWeatherGrid();
|
Grid2DByte weatherGrid = getWeatherGrid();
|
||||||
if (weatherGrid == null) {
|
if (weatherGrid == null) {
|
||||||
|
@ -735,8 +729,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
int x = weatherGrid.getXdim();
|
int x = weatherGrid.getXdim();
|
||||||
int y = weatherGrid.getYdim();
|
int y = weatherGrid.getYdim();
|
||||||
|
|
||||||
if (x != gridParmInfo.getGridLoc().getNx()
|
if ((x != gridParmInfo.getGridLoc().getNx())
|
||||||
|| y != gridParmInfo.getGridLoc().getNy()) {
|
|| (y != gridParmInfo.getGridLoc().getNy())) {
|
||||||
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
return "Grid Dimensions and GridParmInfo Dimensions are not identical GridDim: "
|
||||||
+ x
|
+ x
|
||||||
+ ","
|
+ ","
|
||||||
|
@ -756,7 +750,7 @@ public class WeatherGridSlice extends AbstractGridSlice {
|
||||||
* @return the discrete grid
|
* @return the discrete grid
|
||||||
*/
|
*/
|
||||||
public Grid2DByte getWeatherGrid() {
|
public Grid2DByte getWeatherGrid() {
|
||||||
if (useCache && cacheId != null) {
|
if (useCache && (cacheId != null)) {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ICache<IGrid2D> diskCache = CacheFactory.getInstance()
|
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.raytheon.uf.common.dataplugin.gfe.config.ProjectionData.ProjectionType;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
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 {
|
public class ProjectionDataTest {
|
||||||
private static final double TOLERANCE = 1e-3;
|
private static final double TOLERANCE = 1e-3;
|
||||||
|
|
||||||
|
@ -53,11 +70,11 @@ public class ProjectionDataTest {
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new ProjectionData("Grid211",
|
new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(),
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(
|
||||||
new Coordinate(-133.459, 12.190), new Coordinate(
|
-133.459, 12.190), new Coordinate(-49.385,
|
||||||
-49.385, 57.290), new Coordinate(-95.0,
|
57.290), new Coordinate(-95.0, 25.0),
|
||||||
25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65),
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f),
|
0.0f, 0.0f, 0.0f),
|
||||||
|
|
||||||
new Coordinate[][] {
|
new Coordinate[][] {
|
||||||
{ new Coordinate(1, 1),
|
{ new Coordinate(1, 1),
|
||||||
|
@ -72,11 +89,11 @@ public class ProjectionDataTest {
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new ProjectionData("Grid203",
|
new ProjectionData("Grid203",
|
||||||
ProjectionType.POLAR_STEREOGRAPHIC.ordinal(),
|
ProjectionType.POLAR_STEREOGRAPHIC, new Coordinate(
|
||||||
new Coordinate(-185.837, 19.132), new Coordinate(
|
-185.837, 19.132), new Coordinate(-53.660,
|
||||||
-53.660, 57.634), new Coordinate(0.0, 0.0),
|
57.634), new Coordinate(0.0, 0.0), 0.0f,
|
||||||
0.0f, 0.0f, new Point(1, 1), new Point(45, 39),
|
0.0f, new Point(1, 1), new Point(45, 39), 0.0f,
|
||||||
0.0f, 0.0f, -150.0f),
|
0.0f, -150.0f),
|
||||||
|
|
||||||
new Coordinate[][] {
|
new Coordinate[][] {
|
||||||
{ new Coordinate(1, 1),
|
{ new Coordinate(1, 1),
|
||||||
|
@ -90,11 +107,12 @@ public class ProjectionDataTest {
|
||||||
), //
|
), //
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new ProjectionData("Grid204", ProjectionType.MERCATOR
|
new ProjectionData("Grid204", ProjectionType.MERCATOR,
|
||||||
.ordinal(), new Coordinate(-250.0, -25.0),
|
new Coordinate(-250.0, -25.0), new Coordinate(
|
||||||
new Coordinate(-109.129, 60.644), new Coordinate(
|
-109.129, 60.644),
|
||||||
0.0, 0.0), 0.0f, 0.0f, new Point(1, 1),
|
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1,
|
||||||
new Point(93, 68), 0.0f, -179.564f, 0.0f),
|
1), new Point(93, 68), 0.0f, -179.564f,
|
||||||
|
0.0f),
|
||||||
|
|
||||||
new Coordinate[][] {
|
new Coordinate[][] {
|
||||||
{ new Coordinate(1, 1),
|
{ new Coordinate(1, 1),
|
||||||
|
@ -109,11 +127,12 @@ public class ProjectionDataTest {
|
||||||
|
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new ProjectionData("Grid208", ProjectionType.MERCATOR
|
new ProjectionData("Grid208", ProjectionType.MERCATOR,
|
||||||
.ordinal(), new Coordinate(-167.315, 9.343),
|
new Coordinate(-167.315, 9.343), new Coordinate(
|
||||||
new Coordinate(-145.878, 28.092), new Coordinate(
|
-145.878, 28.092),
|
||||||
0.0, 0.0), 0.0f, 0.0f, new Point(1, 1),
|
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1,
|
||||||
new Point(29, 27), 0.0f, -157.082f, 0.0f),
|
1), new Point(29, 27), 0.0f, -157.082f,
|
||||||
|
0.0f),
|
||||||
|
|
||||||
new Coordinate[][] {
|
new Coordinate[][] {
|
||||||
{ new Coordinate(1, 1),
|
{ new Coordinate(1, 1),
|
||||||
|
@ -128,11 +147,11 @@ public class ProjectionDataTest {
|
||||||
|
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new ProjectionData("Grid210", ProjectionType.MERCATOR
|
new ProjectionData("Grid210", ProjectionType.MERCATOR,
|
||||||
.ordinal(), new Coordinate(-77.000, 9.000),
|
new Coordinate(-77.000, 9.000), new Coordinate(
|
||||||
new Coordinate(-58.625, 26.422), new Coordinate(
|
-58.625, 26.422), new Coordinate(0.0, 0.0),
|
||||||
0.0, 0.0), 0.0f, 0.0f, new Point(1, 1),
|
0.0f, 0.0f, new Point(1, 1), new Point(25, 25),
|
||||||
new Point(25, 25), 0.0f, -67.812f, 0.0f),
|
0.0f, -67.812f, 0.0f),
|
||||||
|
|
||||||
new Coordinate[][] {
|
new Coordinate[][] {
|
||||||
{ new Coordinate(1, 1),
|
{ new Coordinate(1, 1),
|
||||||
|
@ -148,11 +167,11 @@ public class ProjectionDataTest {
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new ProjectionData("Grid214AK",
|
new ProjectionData("Grid214AK",
|
||||||
ProjectionType.POLAR_STEREOGRAPHIC.ordinal(),
|
ProjectionType.POLAR_STEREOGRAPHIC, new Coordinate(
|
||||||
new Coordinate(-178.571, 40.5301), new Coordinate(
|
-178.571, 40.5301), new Coordinate(-93.689,
|
||||||
-93.689, 63.975), new Coordinate(0.0, 0.0),
|
63.975), new Coordinate(0.0, 0.0), 0.0f,
|
||||||
0.0f, 0.0f, new Point(1, 1), new Point(104, 70),
|
0.0f, new Point(1, 1), new Point(104, 70), 0.0f,
|
||||||
0.0f, 0.0f, -150.0f),
|
0.0f, -150.0f),
|
||||||
|
|
||||||
new Coordinate[][] {
|
new Coordinate[][] {
|
||||||
{ new Coordinate(1, 1),
|
{ new Coordinate(1, 1),
|
||||||
|
@ -167,6 +186,9 @@ public class ProjectionDataTest {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test grid coordinate to lat/lon conversion
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGridCoordinateToLatLon() {
|
public void testGridCoordinateToLatLon() {
|
||||||
PixelOrientation orientation = PixelOrientation.CENTER;
|
PixelOrientation orientation = PixelOrientation.CENTER;
|
||||||
|
@ -181,34 +203,11 @@ public class ProjectionDataTest {
|
||||||
gridCoord, orientation);
|
gridCoord, orientation);
|
||||||
System.out.println(gridCoord + " " + latLon);
|
System.out.println(gridCoord + " " + latLon);
|
||||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
Assert.assertTrue("expected: " + expected.x + ", got: "
|
||||||
+ latLon.x, withinTolerance(latLon.x, expected.x,
|
+ latLon.x,
|
||||||
TOLERANCE));
|
withinTolerance(latLon.x, expected.x, TOLERANCE));
|
||||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
Assert.assertTrue("expected: " + expected.y + ", got: "
|
||||||
+ latLon.y, withinTolerance(latLon.y, expected.y,
|
+ latLon.y,
|
||||||
TOLERANCE));
|
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,22 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
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 {
|
public class GridLocationTest {
|
||||||
private static final double LATLON_TOLERANCE = 1e-3;
|
private static final double LATLON_TOLERANCE = 1e-3;
|
||||||
|
|
||||||
|
@ -43,30 +59,28 @@ public class GridLocationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private static final ProjectionData grid204 = new ProjectionData("Grid204",
|
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,
|
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);
|
0.0f, new Point(1, 1), new Point(93, 68), 0.0f, -179.564f, 0.0f);
|
||||||
|
|
||||||
private static final ProjectionData grid208 = new ProjectionData("Grid208",
|
private static final ProjectionData grid208 = new ProjectionData("Grid208",
|
||||||
ProjectionType.MERCATOR.ordinal(),
|
ProjectionType.MERCATOR, new Coordinate(-166.219, 10.656),
|
||||||
new Coordinate(-166.219, 10.656), new Coordinate(-147.844, 27.917),
|
new Coordinate(-147.844, 27.917), new Coordinate(0.0, 0.0), 0.0f,
|
||||||
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1, 1), new Point(
|
0.0f, new Point(1, 1), new Point(25, 25), 0.0f, -157.082f, 0.0f);
|
||||||
25, 25), 0.0f, -157.082f, 0.0f);
|
|
||||||
|
|
||||||
private static final ProjectionData grid210 = new ProjectionData("Grid210",
|
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,
|
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);
|
0.0f, new Point(1, 1), new Point(25, 25), 0.0f, -67.812f, 0.0f);
|
||||||
|
|
||||||
private static final ProjectionData grid214AK = new ProjectionData(
|
private static final ProjectionData grid214AK = new ProjectionData(
|
||||||
"Grid214AK", ProjectionType.POLAR_STEREOGRAPHIC.ordinal(),
|
"Grid214AK", ProjectionType.POLAR_STEREOGRAPHIC, new Coordinate(
|
||||||
new Coordinate(-178.571, 40.5301), new Coordinate(-93.689, 63.975),
|
-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(
|
new Coordinate(0.0, 0.0), 0.0f, 0.0f, new Point(1, 1), new Point(
|
||||||
104, 70), 0.0f, 0.0f, -150.0f);
|
104, 70), 0.0f, 0.0f, -150.0f);
|
||||||
|
|
||||||
|
@ -116,7 +130,7 @@ public class GridLocationTest {
|
||||||
),
|
),
|
||||||
|
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new GridLocation("HFO", grid208, new Point(321, 225),
|
new GridLocation("HFO", grid208, new Point(321, 225),
|
||||||
new Coordinate(7.00, 11.00), new Coordinate(10.0,
|
new Coordinate(7.00, 11.00), new Coordinate(10.0,
|
||||||
7.0), "Pacific/Honolulu"),
|
7.0), "Pacific/Honolulu"),
|
||||||
|
@ -133,7 +147,7 @@ public class GridLocationTest {
|
||||||
),
|
),
|
||||||
|
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new GridLocation("SJU", grid210, new Point(32, 28),
|
new GridLocation("SJU", grid210, new Point(32, 28),
|
||||||
new Coordinate(10.0, 10.0),
|
new Coordinate(10.0, 10.0),
|
||||||
new Coordinate(8.0, 7.0), "America/Puerto_Rico"),
|
new Coordinate(8.0, 7.0), "America/Puerto_Rico"),
|
||||||
|
@ -150,7 +164,7 @@ public class GridLocationTest {
|
||||||
),
|
),
|
||||||
|
|
||||||
new TestCase(
|
new TestCase(
|
||||||
//
|
//
|
||||||
new GridLocation("AJK", grid214AK, new Point(337, 241),
|
new GridLocation("AJK", grid214AK, new Point(337, 241),
|
||||||
new Coordinate(62.0, 23.0), new Coordinate(21.0,
|
new Coordinate(62.0, 23.0), new Coordinate(21.0,
|
||||||
15.0), "America/Juneau"),
|
15.0), "America/Juneau"),
|
||||||
|
@ -179,11 +193,11 @@ public class GridLocationTest {
|
||||||
orientation, testCase.gloc);
|
orientation, testCase.gloc);
|
||||||
System.out.println(gridCoord + " " + latLon);
|
System.out.println(gridCoord + " " + latLon);
|
||||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
Assert.assertTrue("expected: " + expected.x + ", got: "
|
||||||
+ latLon.x, withinTolerance(latLon.x, expected.x,
|
+ latLon.x,
|
||||||
LATLON_TOLERANCE));
|
withinTolerance(latLon.x, expected.x, LATLON_TOLERANCE));
|
||||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
Assert.assertTrue("expected: " + expected.y + ", got: "
|
||||||
+ latLon.y, withinTolerance(latLon.y, expected.y,
|
+ latLon.y,
|
||||||
LATLON_TOLERANCE));
|
withinTolerance(latLon.y, expected.y, LATLON_TOLERANCE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,12 +215,14 @@ public class GridLocationTest {
|
||||||
orientation, testCase.gloc);
|
orientation, testCase.gloc);
|
||||||
System.out.println(String.format("(%.3f,%.3f) (%.4f,%.4f)",
|
System.out.println(String.format("(%.3f,%.3f) (%.4f,%.4f)",
|
||||||
gridCoord.x, gridCoord.y, latLon.x, latLon.y));
|
gridCoord.x, gridCoord.y, latLon.x, latLon.y));
|
||||||
Assert.assertTrue("expected: " + expected.x + ", got: "
|
Assert.assertTrue(
|
||||||
+ gridCoord.x, withinTolerance(gridCoord.x, expected.x,
|
"expected: " + expected.x + ", got: " + gridCoord.x,
|
||||||
GRIDCELL_TOLERANCE));
|
withinTolerance(gridCoord.x, expected.x,
|
||||||
Assert.assertTrue("expected: " + expected.y + ", got: "
|
GRIDCELL_TOLERANCE));
|
||||||
+ gridCoord.y, withinTolerance(gridCoord.y, expected.y,
|
Assert.assertTrue(
|
||||||
GRIDCELL_TOLERANCE));
|
"expected: " + expected.y + ", got: " + gridCoord.y,
|
||||||
|
withinTolerance(gridCoord.y, expected.y,
|
||||||
|
GRIDCELL_TOLERANCE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 02/27/2008 879 rbell Initial Creation.
|
* 02/27/2008 879 rbell Initial Creation.
|
||||||
* 01/30/2013 15719 jdynina Allowed more than 128 chars in wx string
|
* 01/30/2013 15719 jdynina Allowed more than 128 chars in wx string
|
||||||
|
* 08/14/2013 1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -244,10 +245,9 @@ public class DiscreteGridSliceTest {
|
||||||
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
||||||
|
|
||||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
||||||
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
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.
|
* 03/03/2008 879 rbell Initial Creation.
|
||||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||||
|
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -73,10 +74,9 @@ public class ScalarGridSliceTest {
|
||||||
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
||||||
|
|
||||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
||||||
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
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.raytheon.uf.common.time.TimeRange;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
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?
|
// TODO fix?
|
||||||
@Ignore
|
@Ignore
|
||||||
public class VectorGridSliceTest {
|
public class VectorGridSliceTest {
|
||||||
|
@ -61,10 +77,9 @@ public class VectorGridSliceTest {
|
||||||
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
private final TimeRange testTR1 = new TimeRange(new Date(), 1000);
|
||||||
|
|
||||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
private final GridLocation gloc = new GridLocation("BOU", grid211,
|
||||||
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
new Point(4, 4), new Coordinate(38, 27), new Coordinate(9, 9),
|
||||||
|
|
|
@ -56,8 +56,9 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 26, 2008 rbell Initial creation
|
* Mar 26, 2008 rbell Initial creation
|
||||||
* Mar 20, 2013 #1774 randerso Use TimeUtil constants
|
* Mar 20, 2013 #1774 randerso Use TimeUtil constants
|
||||||
|
* Aug 14, 2013 #1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -102,8 +103,8 @@ public class ScalarGridDataTest {
|
||||||
ParmID.defaultLevel());
|
ParmID.defaultLevel());
|
||||||
|
|
||||||
ProjectionData grid211 = new ProjectionData("Grid211",
|
ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459,
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
12.190), new Coordinate(-49.385, 57.290),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
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 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 26, 2008 rbell Initial creation
|
||||||
* Mar 20, 2013 #1774 randerso Use TimeUtil constants
|
* Mar 20, 2013 #1774 randerso Use TimeUtil constants
|
||||||
|
* Aug 14, 2013 #1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -70,7 +71,7 @@ public class VectorGridDataTest {
|
||||||
|
|
||||||
private final float testFA1[] = new float[145 * 145];
|
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,
|
this.testFA1[i] = (float) (i + (i / (Math.pow(10.0,
|
||||||
(i + "").length()))));
|
(i + "").length()))));
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ public class VectorGridDataTest {
|
||||||
|
|
||||||
private final float testFA1b[] = new float[145 * 145];
|
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;
|
this.testFA1b[i] = i % 365;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,10 +100,9 @@ public class VectorGridDataTest {
|
||||||
"OAX_GRID__Practice_00000000_0000", ParmID.defaultLevel());
|
"OAX_GRID__Practice_00000000_0000", ParmID.defaultLevel());
|
||||||
|
|
||||||
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
private final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private final GridLocation testGL1 = new GridLocation("OAX", this.grid211,
|
private final GridLocation testGL1 = new GridLocation("OAX", this.grid211,
|
||||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
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];
|
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[i] = 0;
|
||||||
}
|
}
|
||||||
this.testFA1[0] = 1;
|
this.testFA1[0] = 1;
|
||||||
|
@ -136,7 +136,7 @@ public class VectorGridDataTest {
|
||||||
|
|
||||||
private final float testFA2[] = new float[145 * 145];
|
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;
|
this.testFA1[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,13 +54,14 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
import com.vividsolutions.jts.geom.Envelope;
|
import com.vividsolutions.jts.geom.Envelope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* ReferenceSetManager Unit Test
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Apr 8, 2008 randerso Initial creation
|
* Apr 8, 2008 randerso Initial creation
|
||||||
|
* Aug 14, 2013 1571 randerso Changed to use ProjectionType enum
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -133,10 +134,9 @@ public class ReferenceSetManagerTest {
|
||||||
private static final RefIDChangedListener refIDChangedListener = new RefIDChangedListener();
|
private static final RefIDChangedListener refIDChangedListener = new RefIDChangedListener();
|
||||||
|
|
||||||
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
private static final ProjectionData grid211 = new ProjectionData("Grid211",
|
||||||
ProjectionType.LAMBERT_CONFORMAL.ordinal(), new Coordinate(
|
ProjectionType.LAMBERT_CONFORMAL, new Coordinate(-133.459, 12.190),
|
||||||
-133.459, 12.190), new Coordinate(-49.385, 57.290),
|
new Coordinate(-49.385, 57.290), new Coordinate(-95.0, 25.0),
|
||||||
new Coordinate(-95.0, 25.0), 25.0f, 25.0f, new Point(1, 1),
|
25.0f, 25.0f, new Point(1, 1), new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
||||||
new Point(93, 65), 0.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
private static final GridLocation gloc = new GridLocation("OAX", grid211,
|
||||||
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
new Point(145, 145), new Coordinate(45, 30), new Coordinate(9, 9),
|
||||||
|
@ -184,7 +184,7 @@ public class ReferenceSetManagerTest {
|
||||||
static {
|
static {
|
||||||
Grid2DBit grid = new Grid2DBit(gloc1.getNx(), gloc1.getNy(), true);
|
Grid2DBit grid = new Grid2DBit(gloc1.getNx(), gloc1.getNy(), true);
|
||||||
for (int i = 0; i < grid.getXdim(); i++) {
|
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++) {
|
for (int j = 0; j < grid.getYdim(); j++) {
|
||||||
grid.clear(i, j);
|
grid.clear(i, j);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue