Merge "Issue #1260 Changed D2DGridDatabase to do slab requests. Added GFEPerformance logging statements." into development
Former-commit-id:3f3b2aed85
[formerlyacc4307eb0
] [formerly3f3b2aed85
[formerlyacc4307eb0
] [formerly7eea6e631b
[formerly 6f972ca812fbc83598c50b40241c1d65714d11e4]]] Former-commit-id:7eea6e631b
Former-commit-id:ac2b6e3230
[formerlyc94809b7f2
] Former-commit-id:45c315a4e6
This commit is contained in:
commit
fe997b553c
12 changed files with 270 additions and 111 deletions
|
@ -56,6 +56,20 @@
|
|||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- GFEPerformance log -->
|
||||
<appender name="GFEPerformanceLog" class="org.apache.log4j.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
|
||||
<param name="FileNamePattern" value="${edex.home}/logs/edex-ingest-GFEPerformance-%d{yyyyMMdd}.log"/>
|
||||
</rollingPolicy>
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="GFEPerformanceLogAsync" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="GFEPerformanceLog" />
|
||||
</appender>
|
||||
|
||||
<!-- Purge log -->
|
||||
<appender name="PurgeLog" class="org.apache.log4j.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
|
||||
|
@ -264,6 +278,11 @@
|
|||
<appender-ref ref="FailedTriggerLog"/>
|
||||
</logger>
|
||||
|
||||
<logger name="GFEPerformanceLogger" additivity="false">
|
||||
<level value="Debug"/>
|
||||
<appender-ref ref="GFEPerformanceLogAsync" />
|
||||
</logger>
|
||||
|
||||
<!-- default logging -->
|
||||
<root>
|
||||
<level value="INFO"/>
|
||||
|
|
|
@ -41,6 +41,20 @@
|
|||
<appender-ref ref="ThriftSrvRequestLog" />
|
||||
</appender>
|
||||
|
||||
<!-- GFEPerformance log -->
|
||||
<appender name="GFEPerformanceLog" class="org.apache.log4j.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
|
||||
<param name="FileNamePattern" value="${edex.home}/logs/edex-request-GFEPerformance-%d{yyyyMMdd}.log"/>
|
||||
</rollingPolicy>
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="GFEPerformanceLogAsync" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="GFEPerformanceLog" />
|
||||
</appender>
|
||||
|
||||
<logger name="ProductSrvRequestLogger" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="ProductSrvRequestLogAsync"/>
|
||||
|
@ -51,6 +65,10 @@
|
|||
<appender-ref ref="ThriftSrvRequestLogAsync" />
|
||||
</logger>
|
||||
|
||||
<logger name="GFEPerformanceLogger" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="GFEPerformanceLogAsync" />
|
||||
</logger>
|
||||
|
||||
<logger name="com.raytheon">
|
||||
<level value="INFO"/>
|
||||
|
|
|
@ -67,6 +67,7 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID.DataType;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
|
||||
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.exception.GfeException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
||||
|
@ -102,9 +103,11 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
* 06/17/08 #940 bphillip Implemented GFE Locking
|
||||
* 06/17/09 #2380 randerso Removed purging of grid history.
|
||||
* Should cascade when record deleted.
|
||||
* 08/07/09 #2763 njensen Refactored queryByD2DParmId
|
||||
* 09/10/12 DR15137 ryu Changed for MOSGuide D2D mxt/mnt grids for consistency
|
||||
* with A1.
|
||||
* 08/07/09 #2763 njensen Refactored queryByD2DParmId
|
||||
* 09/10/12 DR15137 ryu Changed for MOSGuide D2D mxt/mnt grids for consistency
|
||||
* with A1.
|
||||
* 10/10/12 #1260 randerso Added check to ensure db can be created before
|
||||
* adding it to the inventory
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -923,10 +926,15 @@ public class GFEDao extends DefaultPluginDao {
|
|||
DatabaseID dbId = null;
|
||||
dbId = new DatabaseID(siteID, DataType.GRID, "D2D", gfeModel,
|
||||
(Date) result.getRowColumnValue(i, 0));
|
||||
if (!dbInventory.contains(dbId)) {
|
||||
dbInventory.add(dbId);
|
||||
try {
|
||||
GridDatabase db = GridParmManager.getDb(dbId);
|
||||
if (db != null && !dbInventory.contains(dbId)) {
|
||||
dbInventory.add(dbId);
|
||||
}
|
||||
} catch (GfeException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
|
||||
}
|
||||
return dbInventory;
|
||||
}
|
||||
|
|
|
@ -76,8 +76,10 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 04/08/08 #875 bphillip Initial Creation
|
||||
* 06/17/08 #940 bphillip Implemented GFE Locking
|
||||
* 07/09/09 #2590 njensen Changed from singleton to static
|
||||
* 07/12/12 15162 ryu added check for invalid db
|
||||
* 07/09/09 #2590 njensen Changed from singleton to static
|
||||
* 07/12/12 15162 ryu added check for invalid db
|
||||
* 10/10/12 #1260 randerso Added exception handling for domain not
|
||||
* overlapping the dataset
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1134,7 +1136,13 @@ public class GridParmManager {
|
|||
if (db == null) {
|
||||
IFPServerConfig serverConfig = IFPServerConfigManager
|
||||
.getServerConfig(siteId);
|
||||
db = new D2DGridDatabase(serverConfig, dbId);
|
||||
try {
|
||||
db = new D2DGridDatabase(serverConfig, dbId);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage());
|
||||
db = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Check for topo type
|
||||
|
@ -1142,18 +1150,18 @@ public class GridParmManager {
|
|||
.getModelName();
|
||||
if (topoModel.equals(modelName)) {
|
||||
db = TopoDatabaseManager.getTopoDatabase(dbId.getSiteId());
|
||||
|
||||
} else {
|
||||
db = new IFPGridDatabase(dbId);
|
||||
if (db.databaseIsValid()) {
|
||||
((IFPGridDatabase) db).updateDbs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isIFP = (db == null);
|
||||
if (db == null) {
|
||||
db = new IFPGridDatabase(dbId);
|
||||
if (db.databaseIsValid())
|
||||
((IFPGridDatabase) db).updateDbs();
|
||||
}
|
||||
|
||||
if (!isIFP || db.databaseIsValid())
|
||||
if ((db != null) && db.databaseIsValid()) {
|
||||
dbMap.put(dbId, db);
|
||||
}
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package com.raytheon.edex.plugin.gfe.server.database;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -61,9 +62,12 @@ import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
||||
import com.raytheon.uf.common.dataplugin.grib.GribPathProvider;
|
||||
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
|
||||
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
|
||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.message.WsId;
|
||||
|
@ -82,12 +86,15 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/16/08 875 bphillip Initial Creation
|
||||
* 06/17/08 #940 bphillip Implemented GFE Locking
|
||||
* 07/23/09 2342 ryu Check for null gridConfig in getGridParmInfo
|
||||
* 03/02/12 DR14651 ryu change time independency of staticTopo, staticCoriolis, staticSpacing
|
||||
* 05/04/12 #574 dgilling Implement missing methods from GridDatabase.
|
||||
* 09/12/12 #1117 dgilling Fix getParmList() so it returns all parms defined
|
||||
* in the GribParamInfo file.
|
||||
* 06/17/08 #940 bphillip Implemented GFE Locking
|
||||
* 07/23/09 2342 ryu Check for null gridConfig in getGridParmInfo
|
||||
* 03/02/12 DR14651 ryu change time independency of staticTopo, staticCoriolis, staticSpacing
|
||||
* 05/04/12 #574 dgilling Implement missing methods from GridDatabase.
|
||||
* 09/12/12 #1117 dgilling Fix getParmList() so it returns all parms defined
|
||||
* in the GribParamInfo file.
|
||||
* 10/10/12 #1260 randerso Changed to only retrieve slab containing overlapping
|
||||
* data instead of full grid. Added logging to support
|
||||
* GFE performance testing
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -98,6 +105,10 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(D2DGridDatabase.class);
|
||||
|
||||
// separate logger for GFE performance logging
|
||||
private static final IUFStatusHandler gfePerformanceLogger = UFStatus
|
||||
.getNamedHandler("GFEPerformanceLogger");
|
||||
|
||||
/** The remap object used for resampling grids */
|
||||
private RemapGrid remap;
|
||||
|
||||
|
@ -147,13 +158,29 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
+ d2dModelName + "] returned null");
|
||||
}
|
||||
|
||||
inputLoc = GfeUtil.transformGridCoverage(awipsGrid);
|
||||
inputLoc = new GridLocation(d2dModelName, awipsGrid);
|
||||
inputLoc.setSiteId(d2dModelName);
|
||||
locCache.addGridLocation(gfeModelName, inputLoc);
|
||||
}
|
||||
|
||||
outputLoc = this.config.dbDomain();
|
||||
|
||||
remap = new RemapGrid(inputLoc, outputLoc);
|
||||
Rectangle subdomain = NetCDFUtils.getSubGridDims(this.inputLoc,
|
||||
this.outputLoc);
|
||||
|
||||
// fix up coordinates for 0,0 in upper left in A2
|
||||
subdomain.y = inputLoc.gridSize().y - subdomain.y
|
||||
- subdomain.height;
|
||||
|
||||
if (subdomain.isEmpty()) {
|
||||
valid = false;
|
||||
throw new GfeException("Unable to create " + this.dbId
|
||||
+ ". GFE domain does not overlap dataset domain.");
|
||||
}
|
||||
|
||||
this.remap = new RemapGrid(NetCDFUtils.subGridGL(dbId.toString(),
|
||||
this.inputLoc, subdomain), this.outputLoc);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,7 +466,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
* @throws GfeException
|
||||
* If the grid slice cannot be constructed
|
||||
*/
|
||||
public IGridSlice getGridSlice(ParmID parmId, GridParmInfo gpi,
|
||||
private IGridSlice getGridSlice(ParmID parmId, GridParmInfo gpi,
|
||||
TimeRange time, boolean convertUnit) throws GfeException {
|
||||
IGridSlice gs = null;
|
||||
GridDataHistory[] gdh = { new GridDataHistory(
|
||||
|
@ -482,11 +509,12 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
* @throws GfeException
|
||||
* If the grid data cannot be retrieved
|
||||
*/
|
||||
public Grid2DFloat getGrid(ParmID parmId, TimeRange time, GridParmInfo gpi,
|
||||
boolean convertUnit) throws GfeException {
|
||||
private Grid2DFloat getGrid(ParmID parmId, TimeRange time,
|
||||
GridParmInfo gpi, boolean convertUnit) throws GfeException {
|
||||
Grid2DFloat bdata = null;
|
||||
GribRecord d2dRecord = null;
|
||||
|
||||
long t0 = System.currentTimeMillis();
|
||||
GFEDao dao = null;
|
||||
try {
|
||||
dao = (GFEDao) PluginFactory.getInstance().getPluginDao("gfe");
|
||||
|
@ -501,6 +529,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
throw new GfeException(
|
||||
"Error retrieving D2D Grid record from database", e);
|
||||
}
|
||||
long t1 = System.currentTimeMillis();
|
||||
|
||||
if (d2dRecord == null) {
|
||||
throw new GfeException("No data available for " + parmId
|
||||
|
@ -509,6 +538,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
|
||||
// Gets the raw data from the D2D grib HDF5 file
|
||||
bdata = getRawGridData(d2dRecord);
|
||||
long t2 = System.currentTimeMillis();
|
||||
|
||||
float fillV = Float.MAX_VALUE;
|
||||
ParameterInfo atts = GribParamInfoLookup.getInstance()
|
||||
|
@ -525,16 +555,21 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
retVal = this.remap.remap(bdata, fillV, gpi.getMaxValue(),
|
||||
gpi.getMinValue(), gpi.getMinValue());
|
||||
if (convertUnit && d2dRecord != null) {
|
||||
long t5 = System.currentTimeMillis();
|
||||
convertUnits(d2dRecord, retVal, gpi.getUnitObject());
|
||||
long t6 = System.currentTimeMillis();
|
||||
statusHandler
|
||||
.info("Time spent converting units on d2d grid data: "
|
||||
+ (t6 - t5));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GfeException("Unable to get Grid", e);
|
||||
}
|
||||
long t3 = System.currentTimeMillis();
|
||||
|
||||
if (gfePerformanceLogger.isPriorityEnabled(Priority.DEBUG)) {
|
||||
gfePerformanceLogger.handle(Priority.DEBUG,
|
||||
"D2DGridDatabase.getGrid" + //
|
||||
" metaData: " + (t1 - t0) + //
|
||||
" hdf5: " + (t2 - t1) + //
|
||||
" remap: " + (t3 - t2) + //
|
||||
" total: " + (t3 - t0));
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
@ -702,21 +737,47 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
* @param d2dRecord
|
||||
* The grib metadata
|
||||
* @return The raw data
|
||||
* @throws GfeException
|
||||
*/
|
||||
private Grid2DFloat getRawGridData(GribRecord d2dRecord) {
|
||||
FloatDataRecord hdf5Record;
|
||||
private Grid2DFloat getRawGridData(GribRecord d2dRecord)
|
||||
throws GfeException {
|
||||
try {
|
||||
GribDao dao = new GribDao();
|
||||
IDataRecord[] hdf5Data = dao.getHDF5Data(d2dRecord, -1);
|
||||
hdf5Record = (FloatDataRecord) hdf5Data[0];
|
||||
} catch (PluginException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to get grib hdf5 record", e);
|
||||
return null;
|
||||
}
|
||||
return new Grid2DFloat((int) hdf5Record.getSizes()[0],
|
||||
(int) hdf5Record.getSizes()[1], hdf5Record.getFloatData());
|
||||
// reimplementing this call here with subgrid support
|
||||
// dao.getHDF5Data(d2dRecord, -1);
|
||||
// TODO should we add subgrid support to GribDao or PluginDao
|
||||
IDataStore dataStore = dao.getDataStore(d2dRecord);
|
||||
|
||||
GridLocation gloc = this.remap.getSourceGloc();
|
||||
|
||||
String abbrev = d2dRecord.getModelInfo().getParameterAbbreviation();
|
||||
String group, dataset;
|
||||
if (GribPathProvider.STATIC_PARAMETERS.contains(abbrev)) {
|
||||
group = "/";
|
||||
dataset = abbrev;
|
||||
} else {
|
||||
group = d2dRecord.getDataURI();
|
||||
dataset = DataStoreFactory.DEF_DATASET_NAME;
|
||||
}
|
||||
|
||||
IDataRecord record = dataStore.retrieve(group, dataset, Request
|
||||
.buildSlab(
|
||||
new int[] { (int) Math.floor(gloc.getOrigin().x),
|
||||
(int) Math.floor(gloc.getOrigin().y), },
|
||||
new int[] {
|
||||
(int) Math.ceil(gloc.getOrigin().x
|
||||
+ gloc.getExtent().x),
|
||||
(int) Math.ceil(gloc.getOrigin().y
|
||||
+ gloc.getExtent().y), }));
|
||||
|
||||
FloatDataRecord hdf5Record = (FloatDataRecord) record;
|
||||
return new Grid2DFloat((int) hdf5Record.getSizes()[0],
|
||||
(int) hdf5Record.getSizes()[1], hdf5Record.getFloatData());
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new GfeException("Error retrieving hdf5 record. "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,8 +51,9 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 16, 2011 bphillip Initial creation
|
||||
* May 04, 2012 #574 dgilling Add unimplemented methods from GridDatabase.
|
||||
* May 16, 2011 bphillip Initial creation
|
||||
* May 04, 2012 #574 dgilling Add unimplemented methods from GridDatabase.
|
||||
* Oct 10 2012 #1260 randerso Added code to set valid flag
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -81,6 +82,7 @@ public class D2DSatDatabase extends VGridDatabase {
|
|||
super(config);
|
||||
this.dbId = new DatabaseID(config.getSiteID().get(0), DataType.GRID,
|
||||
"D2D", "Satellite", "00000000_0000");
|
||||
this.valid = this.dbId.isValid();
|
||||
parms = new ArrayList<D2DSatParm>();
|
||||
for (int i = 0; i < productURIs.size(); i++) {
|
||||
D2DSatParm parm = new D2DSatParm(config, productURIs.get(i),
|
||||
|
|
|
@ -45,7 +45,9 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 17, 2012 randerso Initial creation
|
||||
* May 17, 2012 randerso Initial creation
|
||||
* Oct 10 2012 #1260 randerso Added exception handling for domain not
|
||||
* overlapping the dataset
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -142,10 +144,15 @@ public class NetCDFDatabaseManager {
|
|||
if (file.isValid()) {
|
||||
DatabaseID dbId = NetCDFGridDatabase.getDBID(file, config);
|
||||
|
||||
NetCDFGridDatabase db = new NetCDFGridDatabase(config, file);
|
||||
statusHandler.handle(Priority.EVENTB, "New netCDF Database: "
|
||||
+ dbId);
|
||||
databaseMap.put(dbId, db);
|
||||
try {
|
||||
NetCDFGridDatabase db = new NetCDFGridDatabase(config, file);
|
||||
statusHandler.handle(Priority.EVENTB,
|
||||
"New netCDF Database: " + dbId);
|
||||
databaseMap.put(dbId, db);
|
||||
} catch (GfeException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 14, 2012 randerso Initial creation
|
||||
* May 14, 2012 randerso Initial creation
|
||||
* Oct 10 2012 #1260 randerso Added check for domain not overlapping the dataset
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -165,7 +166,8 @@ public class NetCDFGridDatabase extends VGridDatabase {
|
|||
|
||||
private RemapGrid remap;
|
||||
|
||||
public NetCDFGridDatabase(IFPServerConfig config, NetCDFFile file) {
|
||||
public NetCDFGridDatabase(IFPServerConfig config, NetCDFFile file)
|
||||
throws GfeException {
|
||||
super(config);
|
||||
this.valid = true;
|
||||
this.file = file;
|
||||
|
@ -197,8 +199,16 @@ public class NetCDFGridDatabase extends VGridDatabase {
|
|||
if (this.valid) {
|
||||
this.subdomain = NetCDFUtils.getSubGridDims(this.inputGloc,
|
||||
this.outputGloc);
|
||||
this.remap = new RemapGrid(NetCDFUtils.subGridGL(this.inputGloc,
|
||||
this.subdomain), this.outputGloc);
|
||||
|
||||
if (this.subdomain.isEmpty()) {
|
||||
valid = false;
|
||||
throw new GfeException("Unable to create " + this.dbId
|
||||
+ ". GFE domain does not overlap dataset domain.");
|
||||
}
|
||||
|
||||
this.remap = new RemapGrid(NetCDFUtils.subGridGL(
|
||||
this.dbId.toString(), this.inputGloc, this.subdomain),
|
||||
this.outputGloc);
|
||||
loadParms();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.opengis.metadata.spatial.PixelOrientation;
|
||||
|
||||
import ucar.ma2.ArrayFloat;
|
||||
import ucar.ma2.DataType;
|
||||
import ucar.nc2.Attribute;
|
||||
|
@ -45,7 +43,6 @@ import com.raytheon.uf.common.dataplugin.gfe.config.ProjectionData.ProjectionTyp
|
|||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +54,9 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 14, 2012 randerso Initial creation
|
||||
* May 14, 2012 randerso Initial creation
|
||||
* Oct 10 2012 #1260 randerso Cleaned up getSubGridDims to better match A1
|
||||
* Changed subGridGl to use new GridLocation constructor
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -331,41 +330,25 @@ public class NetCDFUtils {
|
|||
List<Integer> xindex = new ArrayList<Integer>();
|
||||
List<Integer> yindex = new ArrayList<Integer>();
|
||||
for (int x = 0; x < ogloc.gridSize().x; x++) {
|
||||
Coordinate ll = MapUtil.gridCoordinateToLatLon(
|
||||
new Coordinate(x, 0), PixelOrientation.CENTER, ogloc);
|
||||
Coordinate ll = ogloc.latLonCenter(new Coordinate(x, 0));
|
||||
|
||||
Coordinate c = MapUtil.latLonToGridCoordinate(ll,
|
||||
PixelOrientation.CENTER, igloc);
|
||||
Point igc = new Point((int) (c.x > -0.5 ? c.x + 0.5 : c.x - 0.5),
|
||||
(int) (c.y > -0.5 ? c.y + 0.5 : c.y - 0.5));
|
||||
Point igc = igloc.gridCell((float) ll.y, (float) ll.x);
|
||||
xindex.add(igc.x);
|
||||
yindex.add(igc.y);
|
||||
|
||||
ll = MapUtil.gridCoordinateToLatLon(
|
||||
new Coordinate(x, ogloc.gridSize().y - 1),
|
||||
PixelOrientation.CENTER, ogloc);
|
||||
c = MapUtil.latLonToGridCoordinate(ll, PixelOrientation.CENTER,
|
||||
igloc);
|
||||
igc = new Point((int) (c.x > -0.5 ? c.x + 0.5 : c.x - 0.5),
|
||||
(int) (c.y > -0.5 ? c.y + 0.5 : c.y - 0.5));
|
||||
ll = ogloc.latLonCenter(new Coordinate(x, ogloc.gridSize().y - 1));
|
||||
igc = igloc.gridCell((float) ll.y, (float) ll.x);
|
||||
xindex.add(igc.x);
|
||||
yindex.add(igc.y);
|
||||
}
|
||||
for (int y = 0; y < ogloc.gridSize().y; y++) {
|
||||
Coordinate ll = MapUtil.gridCoordinateToLatLon(
|
||||
new Coordinate(0, y), PixelOrientation.CENTER, ogloc);
|
||||
Coordinate c = MapUtil.latLonToGridCoordinate(ll,
|
||||
PixelOrientation.CENTER, igloc);
|
||||
Point igc = new Point((int) c.x, (int) c.y);
|
||||
Coordinate ll = ogloc.latLonCenter(new Coordinate(0, y));
|
||||
Point igc = igloc.gridCell((float) ll.y, (float) ll.x);
|
||||
xindex.add(igc.x);
|
||||
yindex.add(igc.y);
|
||||
|
||||
ll = MapUtil.gridCoordinateToLatLon(new Coordinate(
|
||||
ogloc.gridSize().x - 1, y), PixelOrientation.CENTER, ogloc);
|
||||
c = MapUtil.latLonToGridCoordinate(ll, PixelOrientation.CENTER,
|
||||
igloc);
|
||||
igc = new Point((int) (c.x > -0.5 ? c.x + 0.5 : c.x - 0.5),
|
||||
(int) (c.y > -0.5 ? c.y + 0.5 : c.y - 0.5));
|
||||
ll = ogloc.latLonCenter(new Coordinate(ogloc.gridSize().x - 1, y));
|
||||
igc = igloc.gridCell((float) ll.y, (float) ll.x);
|
||||
xindex.add(igc.x);
|
||||
yindex.add(igc.y);
|
||||
}
|
||||
|
@ -388,16 +371,14 @@ public class NetCDFUtils {
|
|||
return rval;
|
||||
}
|
||||
|
||||
public static GridLocation subGridGL(GridLocation igloc, Rectangle subd) {
|
||||
public static GridLocation subGridGL(String id, GridLocation igloc,
|
||||
Rectangle subd) {
|
||||
// Coordinate nwo = igloc.worldCoordinate(subd.origin());
|
||||
// Coordinate nwe = igloc.worldCoordinate(subd.upperRight());
|
||||
// CartDomain2D<float> swd (nwo, nwe - nwo);
|
||||
// return GridLocation(igloc.projection()->pdata(),
|
||||
// subd.extent() + Point (1, 1), swd);
|
||||
|
||||
return new GridLocation(igloc.getProjection().getProjectionID(),
|
||||
igloc.getProjection(), new Point(subd.width, subd.height),
|
||||
new Coordinate(subd.x, subd.y), new Coordinate(subd.width,
|
||||
subd.height), "GMT");
|
||||
return new GridLocation(id, igloc, subd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 5/16/08 875 bphillip Initial Creation.
|
||||
* 10/10/12 #1260 randerso Added getters for source and destination glocs
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -107,6 +108,14 @@ public class RemapGrid {
|
|||
this.rescale = rescale;
|
||||
}
|
||||
|
||||
public GridLocation getSourceGloc() {
|
||||
return sourceGloc;
|
||||
}
|
||||
|
||||
public GridLocation getDestinationGloc() {
|
||||
return destinationGloc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Grid2D<float> that has been remapped from the input grid in the
|
||||
* source GridLocation domain space to the destination GridLocation domain
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.common.dataplugin.gfe.db.objects;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
@ -56,6 +57,7 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBit;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.CoordinateType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
|
||||
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
||||
import com.raytheon.uf.common.geospatial.CRSCache;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
|
@ -86,6 +88,7 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 04/24/08 @1047 randerso Added fields to store projection information
|
||||
* 10/10/12 #1260 randerso Added new constructor that takes a GridCoverage
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -235,9 +238,6 @@ public class GridLocation extends PersistableDataObject implements
|
|||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
double[] latLon = new double[8];
|
||||
|
||||
// transform the grid corners from grid coordinates to CRS units
|
||||
Coordinate ll = domainOrigin;
|
||||
Coordinate ur = new Coordinate(domainOrigin.x + domainExtent.x,
|
||||
|
@ -270,11 +270,13 @@ public class GridLocation extends PersistableDataObject implements
|
|||
PixelInCell.CELL_CORNER, mt, ge, null);
|
||||
|
||||
// set up the transform from grid coordinates to lon/lat
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
mt = dmtf.createConcatenatedTransform(
|
||||
gridGeom.getGridToCRS(PixelOrientation.UPPER_LEFT),
|
||||
MapUtil.getTransformToLatLon(crsObject));
|
||||
|
||||
// transform grid corner points to Lat/Lon
|
||||
double[] latLon = new double[8];
|
||||
mt.transform(new double[] { 0, this.ny, 0, 0, this.nx, 0, this.nx,
|
||||
this.ny }, 0, latLon, 0, 4);
|
||||
|
||||
|
@ -307,6 +309,54 @@ public class GridLocation extends PersistableDataObject implements
|
|||
"GMT");
|
||||
}
|
||||
|
||||
public GridLocation(String id, GridCoverage coverage) {
|
||||
this.siteId = id;
|
||||
this.crsObject = coverage.getCrs();
|
||||
this.crsWKT = this.crsObject.toWKT();
|
||||
this.geometry = (Polygon) coverage.getGeometry();
|
||||
this.nx = coverage.getNx();
|
||||
this.ny = coverage.getNy();
|
||||
}
|
||||
|
||||
public GridLocation(String id, GridLocation gloc, Rectangle subGrid) {
|
||||
try {
|
||||
this.siteId = id;
|
||||
this.crsObject = gloc.crsObject;
|
||||
this.crsWKT = gloc.crsWKT;
|
||||
this.nx = subGrid.width;
|
||||
this.ny = subGrid.height;
|
||||
this.origin = new Coordinate(subGrid.x, subGrid.y);
|
||||
this.extent = new Coordinate(subGrid.width, subGrid.height);
|
||||
|
||||
GridGeometry2D gridGeom = MapUtil.getGridGeometry(gloc);
|
||||
|
||||
// set up the transform from grid coordinates to lon/lat
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
MathTransform mt = dmtf.createConcatenatedTransform(
|
||||
gridGeom.getGridToCRS(PixelOrientation.UPPER_LEFT),
|
||||
MapUtil.getTransformToLatLon(crsObject));
|
||||
|
||||
// transform grid corner points to Lat/Lon
|
||||
double[] latLon = new double[8];
|
||||
mt.transform(new double[] { subGrid.x, subGrid.y + subGrid.height,
|
||||
subGrid.x, subGrid.y, subGrid.x + subGrid.width, subGrid.y,
|
||||
subGrid.x + subGrid.width, subGrid.y + subGrid.height }, 0,
|
||||
latLon, 0, 4);
|
||||
|
||||
Coordinate[] corners = new Coordinate[] {
|
||||
MapUtil.getCoordinate(latLon[0], latLon[1]),
|
||||
MapUtil.getCoordinate(latLon[2], latLon[3]),
|
||||
MapUtil.getCoordinate(latLon[4], latLon[5]),
|
||||
MapUtil.getCoordinate(latLon[6], latLon[7]),
|
||||
MapUtil.getCoordinate(latLon[0], latLon[1]) };
|
||||
|
||||
this.geometry = MapUtil.getPolygon(corners);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.CRITICAL,
|
||||
"Error creating GridLocation", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the timeZone
|
||||
*/
|
||||
|
@ -430,8 +480,9 @@ public class GridLocation extends PersistableDataObject implements
|
|||
Math.abs(out1[0] - out2[0]) / 1000.0, Math.abs(out1[1]
|
||||
- out2[1]) / 1000.0);
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.error(
|
||||
"Error computing gridCellSize: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
|||
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.grid.Grid2DBit;
|
||||
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
@ -61,6 +60,8 @@ import com.vividsolutions.jts.operation.polygonize.Polygonizer;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 04/08/08 #875 bphillip Initial Creation
|
||||
* 10/10/12 #1260 randerso Removed transformGridCoverage in
|
||||
* favor of new GridLocation constructor
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -224,22 +225,6 @@ public class GfeUtil {
|
|||
return cal.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a D2D grid coverage object into a GFE grid location object
|
||||
*
|
||||
* @param coverage
|
||||
* The D2D grid coverage object
|
||||
* @return The GFE grid location object
|
||||
*/
|
||||
public static GridLocation transformGridCoverage(GridCoverage coverage) {
|
||||
GridLocation location = new GridLocation();
|
||||
location.setCrsObject(coverage.getCrs());
|
||||
location.setGeometry(coverage.getGeometry());
|
||||
location.setNx(coverage.getNx());
|
||||
location.setNy(coverage.getNy());
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a grid for the specified GridLocation that has all bits set that
|
||||
* are inside the provided polygon.
|
||||
|
|
Loading…
Add table
Reference in a new issue