Issue #189 migrate d2d graph adapters to grid.
Former-commit-id: 6ffd19010837d81bf548863144f4c525ed332a7c
This commit is contained in:
parent
9632663c0a
commit
25d99f66f9
5 changed files with 370 additions and 261 deletions
|
@ -9,71 +9,33 @@ Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.uf.viz.core
|
||||||
Eclipse-BuddyPolicy: ext, global
|
Eclipse-BuddyPolicy: ext, global
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
com.raytheon.uf.viz.xy.crosssection;bundle-version="1.0.0",
|
com.raytheon.uf.viz.xy.crosssection;bundle-version="1.0.0",
|
||||||
com.raytheon.uf.viz.xy.timeheight;bundle-version="1.0.0",
|
com.raytheon.uf.viz.xy.varheight;bundle-version="1.12.1174",
|
||||||
com.raytheon.uf.viz.xy.varheight;bundle-version="1.12.1174"
|
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
|
||||||
|
com.raytheon.uf.viz.xy;bundle-version="1.12.1174",
|
||||||
|
com.raytheon.viz.core;bundle-version="1.12.1174",
|
||||||
|
com.raytheon.viz.core.graphing;bundle-version="1.12.1174",
|
||||||
|
com.raytheon.uf.viz.xy.timeseries;bundle-version="1.12.1174",
|
||||||
|
javax.measure;bundle-version="1.0.0"
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Import-Package: com.raytheon.edex.plugin.bufrmos.common,
|
Import-Package: com.raytheon.uf.common.dataplugin,
|
||||||
com.raytheon.edex.plugin.modelsounding.common,
|
com.raytheon.uf.common.dataplugin.grid,
|
||||||
com.raytheon.edex.util,
|
|
||||||
com.raytheon.uf.common.dataplugin,
|
|
||||||
com.raytheon.uf.common.dataplugin.acarssounding,
|
|
||||||
com.raytheon.uf.common.dataplugin.bufrua,
|
|
||||||
com.raytheon.uf.common.dataplugin.goessounding,
|
|
||||||
com.raytheon.uf.common.dataplugin.grib,
|
|
||||||
com.raytheon.uf.common.dataplugin.level,
|
com.raytheon.uf.common.dataplugin.level,
|
||||||
com.raytheon.uf.common.dataplugin.obs.metar,
|
|
||||||
com.raytheon.uf.common.dataplugin.profiler,
|
|
||||||
com.raytheon.uf.common.dataplugin.radar,
|
com.raytheon.uf.common.dataplugin.radar,
|
||||||
com.raytheon.uf.common.dataplugin.radar.util,
|
com.raytheon.uf.common.dataplugin.radar.util,
|
||||||
com.raytheon.uf.common.dataquery.requests,
|
com.raytheon.uf.common.dataquery.requests,
|
||||||
com.raytheon.uf.common.datastorage,
|
com.raytheon.uf.common.datastorage,
|
||||||
com.raytheon.uf.common.datastorage.records,
|
com.raytheon.uf.common.datastorage.records,
|
||||||
com.raytheon.uf.common.geospatial,
|
com.raytheon.uf.common.geospatial,
|
||||||
|
com.raytheon.uf.common.gridcoverage,
|
||||||
|
com.raytheon.uf.common.parameter,
|
||||||
com.raytheon.uf.common.pointdata,
|
com.raytheon.uf.common.pointdata,
|
||||||
com.raytheon.uf.common.serialization,
|
|
||||||
com.raytheon.uf.common.status,
|
com.raytheon.uf.common.status,
|
||||||
com.raytheon.uf.common.time,
|
com.raytheon.uf.common.time,
|
||||||
com.raytheon.uf.viz.core,
|
|
||||||
com.raytheon.uf.viz.core.catalog,
|
|
||||||
com.raytheon.uf.viz.core.datastructure,
|
|
||||||
com.raytheon.uf.viz.core.exception,
|
|
||||||
com.raytheon.uf.viz.core.interp,
|
|
||||||
com.raytheon.uf.viz.core.level,
|
|
||||||
com.raytheon.uf.viz.core.map,
|
|
||||||
com.raytheon.uf.viz.core.rsc,
|
|
||||||
com.raytheon.uf.viz.core.rsc.capabilities,
|
|
||||||
com.raytheon.uf.viz.core.style.level,
|
|
||||||
com.raytheon.uf.viz.d2d.xy.adapters,
|
|
||||||
com.raytheon.uf.viz.objectiveanalysis.rsc,
|
com.raytheon.uf.viz.objectiveanalysis.rsc,
|
||||||
com.raytheon.uf.viz.xy,
|
|
||||||
com.raytheon.uf.viz.xy.crosssection.adapter,
|
|
||||||
com.raytheon.uf.viz.xy.crosssection.rsc,
|
|
||||||
com.raytheon.uf.viz.xy.graph,
|
|
||||||
com.raytheon.uf.viz.xy.timeseries.adapter,
|
|
||||||
com.raytheon.uf.viz.xy.timeseries.rsc,
|
|
||||||
com.raytheon.uf.viz.xy.varheight.adapter,
|
|
||||||
com.raytheon.uf.viz.xy.varheight.rsc,
|
|
||||||
com.raytheon.viz.core.graphing.util,
|
|
||||||
com.raytheon.viz.core.graphing.xy,
|
|
||||||
com.raytheon.viz.core.map,
|
|
||||||
com.raytheon.viz.core.slice.request,
|
|
||||||
com.raytheon.viz.grid,
|
com.raytheon.viz.grid,
|
||||||
com.raytheon.viz.grid.inv,
|
com.raytheon.viz.grid.inv,
|
||||||
com.raytheon.viz.radar.util,
|
com.raytheon.viz.radar.util,
|
||||||
com.vividsolutions.jts.geom,
|
org.eclipse.swt.graphics
|
||||||
javax.measure.converter,
|
|
||||||
javax.measure.unit,
|
|
||||||
org.eclipse.swt.graphics,
|
|
||||||
org.geotools.coverage.grid,
|
|
||||||
org.geotools.geometry,
|
|
||||||
org.geotools.referencing,
|
|
||||||
org.geotools.referencing.operation.matrix,
|
|
||||||
org.geotools.referencing.operation.transform,
|
|
||||||
org.opengis.metadata.spatial,
|
|
||||||
org.opengis.referencing,
|
|
||||||
org.opengis.referencing.crs,
|
|
||||||
org.opengis.referencing.datum,
|
|
||||||
org.opengis.referencing.operation
|
|
||||||
Export-Package: com.raytheon.uf.viz.d2d.xy.adapters,
|
Export-Package: com.raytheon.uf.viz.d2d.xy.adapters,
|
||||||
com.raytheon.uf.viz.d2d.xy.adapters.crosssection,
|
com.raytheon.uf.viz.d2d.xy.adapters.crosssection,
|
||||||
com.raytheon.uf.viz.d2d.xy.adapters.timeseries,
|
com.raytheon.uf.viz.d2d.xy.adapters.timeseries,
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
<extension
|
<extension
|
||||||
point="com.raytheon.uf.viz.xy.crosssection.crosssectionadapter">
|
point="com.raytheon.uf.viz.xy.crosssection.crosssectionadapter">
|
||||||
<crossSectionAdapter
|
<crossSectionAdapter
|
||||||
adapter="com.raytheon.uf.viz.d2d.xy.adapters.crosssection.GribCSAdapter"
|
adapter="com.raytheon.uf.viz.d2d.xy.adapters.crosssection.GridCSAdapter"
|
||||||
class="com.raytheon.uf.common.dataplugin.grib.GribRecord"
|
class="com.raytheon.uf.common.dataplugin.grid.GridRecord"
|
||||||
name="Grib Cross Section Adapter">
|
name="Grid Cross Section Adapter">
|
||||||
</crossSectionAdapter>
|
</crossSectionAdapter>
|
||||||
<crossSectionAdapter
|
<crossSectionAdapter
|
||||||
adapter="com.raytheon.uf.viz.d2d.xy.adapters.crosssection.PointCSAdapter"
|
adapter="com.raytheon.uf.viz.d2d.xy.adapters.crosssection.PointCSAdapter"
|
||||||
|
@ -60,9 +60,9 @@
|
||||||
<extension
|
<extension
|
||||||
point="com.raytheon.uf.viz.xy.timeseries.timeseriesadapter">
|
point="com.raytheon.uf.viz.xy.timeseries.timeseriesadapter">
|
||||||
<timeSeriesAdapter
|
<timeSeriesAdapter
|
||||||
adapter="com.raytheon.uf.viz.d2d.xy.adapters.timeseries.GribTimeSeriesAdapter"
|
adapter="com.raytheon.uf.viz.d2d.xy.adapters.timeseries.GridTimeSeriesAdapter"
|
||||||
class="com.raytheon.uf.common.dataplugin.grib.GribRecord"
|
class="com.raytheon.uf.common.dataplugin.grid.GridRecord"
|
||||||
name="Grib Time Series Adapter">
|
name="Grid Time Series Adapter">
|
||||||
</timeSeriesAdapter>
|
</timeSeriesAdapter>
|
||||||
<timeSeriesAdapter
|
<timeSeriesAdapter
|
||||||
adapter="com.raytheon.uf.viz.d2d.xy.adapters.timeseries.DmdTimeSeriesAdapter"
|
adapter="com.raytheon.uf.viz.d2d.xy.adapters.timeseries.DmdTimeSeriesAdapter"
|
||||||
|
@ -126,9 +126,9 @@
|
||||||
<extension
|
<extension
|
||||||
point="com.raytheon.uf.viz.xy.varheight.varheightadapter">
|
point="com.raytheon.uf.viz.xy.varheight.varheightadapter">
|
||||||
<varHeightAdapter
|
<varHeightAdapter
|
||||||
adapter="com.raytheon.uf.viz.d2d.xy.adapters.varheight.GribVarHeightAdapter"
|
adapter="com.raytheon.uf.viz.d2d.xy.adapters.varheight.GridVarHeightAdapter"
|
||||||
class="com.raytheon.uf.common.dataplugin.grib.GribRecord"
|
class="com.raytheon.uf.common.dataplugin.grid.GridRecord"
|
||||||
name="Grib Var Height Adapter">
|
name="Grid Var Height Adapter">
|
||||||
</varHeightAdapter>
|
</varHeightAdapter>
|
||||||
<varHeightAdapter
|
<varHeightAdapter
|
||||||
adapter="com.raytheon.uf.viz.d2d.xy.adapters.varheight.PointDataVarHeightAdapter"
|
adapter="com.raytheon.uf.viz.d2d.xy.adapters.varheight.PointDataVarHeightAdapter"
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.measure.unit.Unit;
|
import javax.measure.unit.Unit;
|
||||||
|
@ -35,16 +36,15 @@ import org.geotools.geometry.DirectPosition2D;
|
||||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||||
import com.raytheon.uf.common.dataplugin.grib.GribModel;
|
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||||
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
|
|
||||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||||
import com.raytheon.uf.common.datastorage.Request;
|
import com.raytheon.uf.common.datastorage.Request;
|
||||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
import com.raytheon.uf.common.geospatial.PointUtil;
|
import com.raytheon.uf.common.geospatial.PointUtil;
|
||||||
|
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||||
import com.raytheon.uf.common.time.DataTime;
|
import com.raytheon.uf.common.time.DataTime;
|
||||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||||
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
|
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
|
||||||
|
@ -60,7 +60,7 @@ import com.raytheon.viz.grid.inv.GridInventory;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Adapter providing CrossSections of grid data.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -78,18 +78,21 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
public class GridCSAdapter extends AbstractCrossSectionAdapter<GridRecord> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected String yParameter = null;
|
protected String yParameter = null;
|
||||||
|
|
||||||
protected Map<DataTime, Set<GribRecord>> yRecords = new HashMap<DataTime, Set<GribRecord>>();
|
protected Map<DataTime, Set<GridRecord>> yRecords = new HashMap<DataTime, Set<GridRecord>>();
|
||||||
|
|
||||||
private Unit<?> unit;
|
private Unit<?> unit;
|
||||||
|
|
||||||
private CoordinateReferenceSystem crs;
|
private CoordinateReferenceSystem crs;
|
||||||
|
|
||||||
|
private Map<GridCoverage, Map<DataTime, Rectangle>> rectangleCache = new HashMap<GridCoverage, Map<DataTime, Rectangle>>(
|
||||||
|
4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -101,10 +104,9 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
public String getParameterName() {
|
public String getParameterName() {
|
||||||
String name = null;
|
String name = null;
|
||||||
if (records != null && !records.isEmpty()) {
|
if (records != null && !records.isEmpty()) {
|
||||||
GribModel modelInfo = records.get(0).getModelInfo();
|
name = records.get(0).getParameter().getName();
|
||||||
name = modelInfo.getParameterName();
|
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
name = modelInfo.getParameterAbbreviation();
|
name = records.get(0).getParameter().getAbbreviation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
@ -134,13 +136,13 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
throws VizException {
|
throws VizException {
|
||||||
DataTime recordTime = currentTime.clone();
|
DataTime recordTime = currentTime.clone();
|
||||||
recordTime.setLevelValue(null);
|
recordTime.setLevelValue(null);
|
||||||
Set<GribRecord> yRecords = getYRecords(recordTime);
|
Set<GridRecord> yRecords = getYRecords(recordTime);
|
||||||
Map<Level, GribRecord> xMap = new HashMap<Level, GribRecord>();
|
Map<Level, GridRecord> xMap = new HashMap<Level, GridRecord>();
|
||||||
|
|
||||||
synchronized (records) {
|
synchronized (records) {
|
||||||
for (GribRecord rec : records) {
|
for (GridRecord rec : records) {
|
||||||
if (rec.getDataTime().equals(recordTime)) {
|
if (rec.getDataTime().equals(recordTime)) {
|
||||||
xMap.put(rec.getModelInfo().getLevel(), rec);
|
xMap.put(rec.getLevel(), rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,10 +151,10 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Level, GribRecord> yMap = new HashMap<Level, GribRecord>();
|
Map<Level, GridRecord> yMap = new HashMap<Level, GridRecord>();
|
||||||
for (GribRecord rec : yRecords) {
|
for (GridRecord rec : yRecords) {
|
||||||
if (rec.getDataTime().equals(recordTime)) {
|
if (rec.getDataTime().equals(recordTime)) {
|
||||||
yMap.put(rec.getModelInfo().getLevel(), rec);
|
yMap.put(rec.getLevel(), rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,76 +167,66 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
|
|
||||||
int nx = (int) geometry.getGridRange2D().getWidth();
|
int nx = (int) geometry.getGridRange2D().getWidth();
|
||||||
int ny = (int) geometry.getGridRange2D().getHeight();
|
int ny = (int) geometry.getGridRange2D().getHeight();
|
||||||
|
Map<GridCoverage, List<PluginDataObject>> recordsByLocation = new HashMap<GridCoverage, List<PluginDataObject>>();
|
||||||
ISpatialObject area = records.get(0).getSpatialObject();
|
for (GridRecord record : xMap.values()) {
|
||||||
|
List<PluginDataObject> list = recordsByLocation.get(record
|
||||||
Rectangle requestArea = null;
|
.getLocation());
|
||||||
Coordinate[] coordinates = GeoUtil.splitLine(nx,
|
if (list == null) {
|
||||||
descriptor.getLine(currentTime).getCoordinates());
|
list = new ArrayList<PluginDataObject>();
|
||||||
|
recordsByLocation.put(record.getLocation(), list);
|
||||||
for (Coordinate c : coordinates) {
|
|
||||||
DirectPosition2D point = null;
|
|
||||||
try {
|
|
||||||
point = PointUtil.determineExactIndex(c, area.getCrs(),
|
|
||||||
MapUtil.getGridGeometry(area));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new VizException(e);
|
|
||||||
}
|
|
||||||
if (requestArea == null) {
|
|
||||||
requestArea = new Rectangle((int) Math.floor(point.x),
|
|
||||||
(int) Math.floor(point.y), 1, 1);
|
|
||||||
} else {
|
|
||||||
requestArea.add(point);
|
|
||||||
}
|
}
|
||||||
|
list.add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestArea.height += 1;
|
for (GridRecord record : yMap.values()) {
|
||||||
requestArea.width += 1;
|
List<PluginDataObject> list = recordsByLocation.get(record
|
||||||
requestArea = requestArea.intersection(new Rectangle(0, 0,
|
.getLocation());
|
||||||
area.getNx(), area.getNy()));
|
if (list == null) {
|
||||||
if (requestArea.isEmpty()) {
|
list = new ArrayList<PluginDataObject>();
|
||||||
throw new VizException(
|
recordsByLocation.put(record.getLocation(), list);
|
||||||
"Invalid line position. Check that the line is within the grib boundaries.");
|
|
||||||
}
|
|
||||||
Request request = Request.buildSlab(
|
|
||||||
new int[] { (int) requestArea.getMinX(),
|
|
||||||
(int) requestArea.getMinY() },
|
|
||||||
new int[] { (int) requestArea.getMaxX(),
|
|
||||||
(int) requestArea.getMaxY() });
|
|
||||||
List<PluginDataObject> pdos = new ArrayList<PluginDataObject>(
|
|
||||||
xMap.size() * 2);
|
|
||||||
pdos.addAll(xMap.values());
|
|
||||||
pdos.addAll(yMap.values());
|
|
||||||
|
|
||||||
DataCubeContainer.getDataRecords(pdos, request, null);
|
|
||||||
|
|
||||||
List<float[]> result = new ArrayList<float[]>();
|
|
||||||
for (int i = 0; i < nx; i++) {
|
|
||||||
DirectPosition2D point = null;
|
|
||||||
try {
|
|
||||||
point = PointUtil.determineExactIndex(coordinates[i],
|
|
||||||
area.getCrs(), MapUtil.getGridGeometry(area));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new VizException(e);
|
|
||||||
}
|
}
|
||||||
if (!requestArea.contains(point)) {
|
list.add(record);
|
||||||
|
}
|
||||||
|
for (Entry<GridCoverage, List<PluginDataObject>> entry : recordsByLocation
|
||||||
|
.entrySet()) {
|
||||||
|
Request request = getRequest(entry.getKey(), currentTime, geometry);
|
||||||
|
if (request == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
DataCubeContainer.getDataRecords(entry.getValue(), request, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
Coordinate[] coordinates = GeoUtil.splitLine(nx,
|
||||||
|
descriptor.getLine(currentTime).getCoordinates());
|
||||||
|
List<float[]> result = new ArrayList<float[]>();
|
||||||
|
for (int i = 0; i < nx; i++) {
|
||||||
List<List<XYData>> dataLists = new ArrayList<List<XYData>>(
|
List<List<XYData>> dataLists = new ArrayList<List<XYData>>(
|
||||||
result.size());
|
result.size());
|
||||||
for (Level level : xMap.keySet()) {
|
for (Level level : xMap.keySet()) {
|
||||||
GribRecord yRecord = yMap.get(level);
|
GridRecord yRecord = yMap.get(level);
|
||||||
FloatDataRecord yRec = (FloatDataRecord) (((IDataRecord[]) yRecord
|
FloatDataRecord yRec = (FloatDataRecord) (((IDataRecord[]) yRecord
|
||||||
.getMessageData())[0]);
|
.getMessageData())[0]);
|
||||||
GribRecord xRecord = xMap.get(level);
|
GridRecord xRecord = xMap.get(level);
|
||||||
IDataRecord[] results = (IDataRecord[]) xRecord
|
IDataRecord[] results = (IDataRecord[]) xRecord
|
||||||
.getMessageData();
|
.getMessageData();
|
||||||
|
DirectPosition2D yPoint = null;
|
||||||
float yVal = InterpUtils.getInterpolatedData(requestArea,
|
try {
|
||||||
point.x, point.y, yRec.getFloatData());
|
yPoint = PointUtil.determineExactIndex(coordinates[i],
|
||||||
|
yRecord.getLocation().getCrs(),
|
||||||
|
MapUtil.getGridGeometry(yRecord.getLocation()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VizException(e);
|
||||||
|
}
|
||||||
|
Rectangle yRect = getRectangle(yRecord.getLocation(),
|
||||||
|
currentTime, geometry);
|
||||||
|
if (!yRect.contains(yPoint)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float yVal = InterpUtils.getInterpolatedData(yRect, yPoint.x,
|
||||||
|
yPoint.y, yRec.getFloatData());
|
||||||
yVal = (float) yRecord
|
yVal = (float) yRecord
|
||||||
.getModelInfo()
|
.getParameter()
|
||||||
.getParameterUnitObject()
|
.getUnit()
|
||||||
.getConverterTo(
|
.getConverterTo(
|
||||||
descriptor.getHeightScale().getParameterUnit())
|
descriptor.getHeightScale().getParameterUnit())
|
||||||
.convert(yVal);
|
.convert(yVal);
|
||||||
|
@ -244,12 +236,23 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
while (dataLists.size() < results.length) {
|
while (dataLists.size() < results.length) {
|
||||||
dataLists.add(new ArrayList<XYData>());
|
dataLists.add(new ArrayList<XYData>());
|
||||||
}
|
}
|
||||||
double speed = Float.NaN;
|
DirectPosition2D xPoint = null;
|
||||||
double direction = Double.NaN;
|
try {
|
||||||
|
xPoint = PointUtil.determineExactIndex(coordinates[i],
|
||||||
|
xRecord.getLocation().getCrs(),
|
||||||
|
MapUtil.getGridGeometry(xRecord.getLocation()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VizException(e);
|
||||||
|
}
|
||||||
|
Rectangle xRect = getRectangle(xRecord.getLocation(),
|
||||||
|
currentTime, geometry);
|
||||||
|
if (!xRect.contains(xPoint)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int c = 0; c < results.length; c++) {
|
for (int c = 0; c < results.length; c++) {
|
||||||
FloatDataRecord xRec = (FloatDataRecord) results[c];
|
FloatDataRecord xRec = (FloatDataRecord) results[c];
|
||||||
float xVal = InterpUtils.getInterpolatedData(requestArea,
|
float xVal = InterpUtils.getInterpolatedData(xRect,
|
||||||
point.x, point.y, xRec.getFloatData());
|
xPoint.x, xPoint.y, xRec.getFloatData());
|
||||||
if (xVal <= -9999) {
|
if (xVal <= -9999) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -267,20 +270,72 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
float[] column = InterpUtils.makeColumn(dataList, ny, graph,
|
float[] column = InterpUtils.makeColumn(dataList, ny, graph,
|
||||||
descriptor.getHeightScale().getMinVal() < descriptor
|
descriptor.getHeightScale().getMinVal() < descriptor
|
||||||
.getHeightScale().getMaxVal(), -999999f);
|
.getHeightScale().getMaxVal(), -999999f);
|
||||||
|
|
||||||
for (int j = 0; j < column.length; j++) {
|
for (int j = 0; j < column.length; j++) {
|
||||||
floatData[j * nx + i] = column[j];
|
floatData[j * nx + i] = column[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Rectangle getRectangle(GridCoverage location, DataTime time,
|
||||||
|
GridGeometry2D geometry) throws VizException {
|
||||||
|
Map<DataTime, Rectangle> timeCache = rectangleCache.get(location);
|
||||||
|
if (timeCache == null) {
|
||||||
|
timeCache = new HashMap<DataTime, Rectangle>();
|
||||||
|
rectangleCache.put(location, timeCache);
|
||||||
|
}
|
||||||
|
Rectangle rectangle = timeCache.get(time);
|
||||||
|
if (rectangle == null) {
|
||||||
|
Coordinate[] coordinates = GeoUtil.splitLine(geometry
|
||||||
|
.getGridRange2D().width, descriptor.getLine(time)
|
||||||
|
.getCoordinates());
|
||||||
|
|
||||||
|
for (Coordinate c : coordinates) {
|
||||||
|
DirectPosition2D point = null;
|
||||||
|
try {
|
||||||
|
point = PointUtil.determineExactIndex(c, location.getCrs(),
|
||||||
|
MapUtil.getGridGeometry(location));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VizException(e);
|
||||||
|
}
|
||||||
|
if (rectangle == null) {
|
||||||
|
rectangle = new Rectangle((int) Math.floor(point.x),
|
||||||
|
(int) Math.floor(point.y), 1, 1);
|
||||||
|
} else {
|
||||||
|
rectangle.add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rectangle.height += 1;
|
||||||
|
rectangle.width += 1;
|
||||||
|
rectangle = rectangle.intersection(new Rectangle(0, 0, location
|
||||||
|
.getNx(), location.getNy()));
|
||||||
|
timeCache.put(time, rectangle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Request getRequest(GridCoverage location, DataTime time,
|
||||||
|
GridGeometry2D geometry) throws VizException {
|
||||||
|
Rectangle rectangle = getRectangle(location, time, geometry);
|
||||||
|
if (rectangle.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Request.buildSlab(
|
||||||
|
new int[] { (int) rectangle.getMinX(),
|
||||||
|
(int) rectangle.getMinY() },
|
||||||
|
new int[] { (int) rectangle.getMaxX(),
|
||||||
|
(int) rectangle.getMaxY() });
|
||||||
|
}
|
||||||
|
|
||||||
public void addRecord(PluginDataObject pdo) {
|
public void addRecord(PluginDataObject pdo) {
|
||||||
super.addRecord(pdo);
|
super.addRecord(pdo);
|
||||||
if (pdo != null && pdo instanceof GribRecord) {
|
if (pdo != null && pdo instanceof GridRecord) {
|
||||||
unit = ((GribRecord) pdo).getModelInfo().getParameterUnitObject();
|
unit = ((GridRecord) pdo).getParameter().getUnit();
|
||||||
crs = ((GribRecord) pdo).getSpatialObject().getCrs();
|
crs = ((GridRecord) pdo).getSpatialObject().getCrs();
|
||||||
}
|
}
|
||||||
yRecords.remove(pdo.getDataTime());
|
yRecords.remove(pdo.getDataTime());
|
||||||
}
|
}
|
||||||
|
@ -290,9 +345,9 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
super.remove(time);
|
super.remove(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<GribRecord> getYRecords(DataTime time) throws VizException {
|
private Set<GridRecord> getYRecords(DataTime time) throws VizException {
|
||||||
synchronized (yRecords) {
|
synchronized (yRecords) {
|
||||||
Set<GribRecord> yRecords = this.yRecords.get(time);
|
Set<GridRecord> yRecords = this.yRecords.get(time);
|
||||||
if (yRecords != null) {
|
if (yRecords != null) {
|
||||||
return yRecords;
|
return yRecords;
|
||||||
}
|
}
|
||||||
|
@ -313,9 +368,9 @@ public class GribCSAdapter extends AbstractCrossSectionAdapter<GribRecord> {
|
||||||
property.setSelectedEntryTimes(new DataTime[] { time });
|
property.setSelectedEntryTimes(new DataTime[] { time });
|
||||||
|
|
||||||
List<Object> recs = DataCubeContainer.getData(property, 60000);
|
List<Object> recs = DataCubeContainer.getData(property, 60000);
|
||||||
yRecords = new HashSet<GribRecord>(recs.size());
|
yRecords = new HashSet<GridRecord>(recs.size());
|
||||||
for (Object obj : recs) {
|
for (Object obj : recs) {
|
||||||
yRecords.add((GribRecord) obj);
|
yRecords.add((GridRecord) obj);
|
||||||
}
|
}
|
||||||
this.yRecords.put(time, yRecords);
|
this.yRecords.put(time, yRecords);
|
||||||
if (yRecords.isEmpty()) {
|
if (yRecords.isEmpty()) {
|
|
@ -23,6 +23,7 @@ import java.awt.Point;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -31,13 +32,14 @@ import javax.measure.converter.UnitConverter;
|
||||||
import javax.measure.unit.Unit;
|
import javax.measure.unit.Unit;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||||
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
|
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||||
import com.raytheon.uf.common.datastorage.Request;
|
import com.raytheon.uf.common.datastorage.Request;
|
||||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
import com.raytheon.uf.common.geospatial.PointUtil;
|
import com.raytheon.uf.common.geospatial.PointUtil;
|
||||||
|
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
|
@ -54,7 +56,7 @@ import com.raytheon.viz.core.graphing.xy.XYWindImageData;
|
||||||
import com.raytheon.viz.grid.GridLevelTranslator;
|
import com.raytheon.viz.grid.GridLevelTranslator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Adapter providing a TimeSeries view of GridData.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -69,14 +71,14 @@ import com.raytheon.viz.grid.GridLevelTranslator;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GribTimeSeriesAdapter extends
|
public class GridTimeSeriesAdapter extends
|
||||||
AbstractTimeSeriesAdapter<GribRecord> {
|
AbstractTimeSeriesAdapter<GridRecord> {
|
||||||
private static final IUFStatusHandler statusHandler = UFStatus
|
private static final IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(GribTimeSeriesAdapter.class);
|
.getHandler(GridTimeSeriesAdapter.class);
|
||||||
|
|
||||||
private Map<GribRecord, IDataRecord[]> cache = new WeakHashMap<GribRecord, IDataRecord[]>();
|
private Map<GridRecord, IDataRecord[]> cache = new WeakHashMap<GridRecord, IDataRecord[]>();
|
||||||
|
|
||||||
protected Map<DataTime, Set<GribRecord>> recordsByTime = new HashMap<DataTime, Set<GribRecord>>();
|
protected Map<DataTime, Set<GridRecord>> recordsByTime = new HashMap<DataTime, Set<GridRecord>>();
|
||||||
|
|
||||||
/** the level I would prefer to use **/
|
/** the level I would prefer to use **/
|
||||||
protected Level preferredLevel = null;
|
protected Level preferredLevel = null;
|
||||||
|
@ -127,30 +129,29 @@ public class GribTimeSeriesAdapter extends
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public XYDataList loadData() throws VizException {
|
public XYDataList loadData() throws VizException {
|
||||||
ArrayList<GribRecord> gribs = null;
|
ArrayList<GridRecord> gribs = null;
|
||||||
synchronized (recordsByTime) {
|
synchronized (recordsByTime) {
|
||||||
// get available times
|
// get available times
|
||||||
Set<DataTime> times = recordsByTime.keySet();
|
Set<DataTime> times = recordsByTime.keySet();
|
||||||
// set initial size of gribs
|
// set initial size of gribs
|
||||||
gribs = new ArrayList<GribRecord>(times.size());
|
gribs = new ArrayList<GridRecord>(times.size());
|
||||||
// get the best record from each time ( use only one record for a
|
// get the best record from each time ( use only one record for a
|
||||||
// point in time )
|
// point in time )
|
||||||
for (DataTime key : times) {
|
for (DataTime key : times) {
|
||||||
Set<GribRecord> records = recordsByTime.get(key);
|
Set<GridRecord> records = recordsByTime.get(key);
|
||||||
GribRecord[] allRecords = records
|
GridRecord[] allRecords = records
|
||||||
.toArray(new GribRecord[records.size()]);
|
.toArray(new GridRecord[records.size()]);
|
||||||
GribRecord bestRecord = null;
|
GridRecord bestRecord = null;
|
||||||
// if only one record, use it
|
// if only one record, use it
|
||||||
if (allRecords.length == 1) {
|
if (allRecords.length == 1) {
|
||||||
bestRecord = allRecords[0];
|
bestRecord = allRecords[0];
|
||||||
} else if (records.size() > 1) {
|
} else if (records.size() > 1) {
|
||||||
// get the first record, or the one that matches the
|
// get the first record, or the one that matches the
|
||||||
// preferredLevel
|
// preferredLevel
|
||||||
for (GribRecord rec : allRecords) {
|
for (GridRecord rec : allRecords) {
|
||||||
if (bestRecord == null) {
|
if (bestRecord == null) {
|
||||||
bestRecord = rec;
|
bestRecord = rec;
|
||||||
} else if (rec.getModelInfo().getLevel()
|
} else if (rec.getLevel().equals(preferredLevel)) {
|
||||||
.equals(preferredLevel)) {
|
|
||||||
bestRecord = rec;
|
bestRecord = rec;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,26 @@ public class GribTimeSeriesAdapter extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return loadInternal(gribs.toArray(new GribRecord[gribs.size()]));
|
HashMap<GridCoverage, List<GridRecord>> gridsByLocation = new HashMap<GridCoverage, List<GridRecord>>();
|
||||||
|
for (GridRecord grid : gribs) {
|
||||||
|
List<GridRecord> list = gridsByLocation.get(grid.getLocation());
|
||||||
|
if (list == null) {
|
||||||
|
list = new ArrayList<GridRecord>();
|
||||||
|
gridsByLocation.put(grid.getLocation(), list);
|
||||||
|
}
|
||||||
|
list.add(grid);
|
||||||
|
}
|
||||||
|
XYDataList result = null;
|
||||||
|
for (List<GridRecord> list : gridsByLocation.values()) {
|
||||||
|
XYDataList newResult = loadInternal(list
|
||||||
|
.toArray(new GridRecord[list.size()]));
|
||||||
|
if (result == null) {
|
||||||
|
result = newResult;
|
||||||
|
} else {
|
||||||
|
result.getData().addAll(newResult.getData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,26 +195,25 @@ public class GribTimeSeriesAdapter extends
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public XYDataList loadRecord(PluginDataObject pdo) throws VizException {
|
public XYDataList loadRecord(PluginDataObject pdo) throws VizException {
|
||||||
GribRecord[] gribs = new GribRecord[1];
|
GridRecord[] gribs = new GridRecord[1];
|
||||||
gribs[0] = (GribRecord) pdo;
|
gribs[0] = (GridRecord) pdo;
|
||||||
return loadInternal(gribs);
|
return loadInternal(gribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRecord(PluginDataObject pdo) {
|
public void addRecord(PluginDataObject pdo) {
|
||||||
// store off records by level
|
// store off records by level
|
||||||
if (pdo instanceof GribRecord) {
|
if (pdo instanceof GridRecord) {
|
||||||
synchronized (recordsByTime) {
|
synchronized (recordsByTime) {
|
||||||
GribRecord record = (GribRecord) pdo;
|
GridRecord record = (GridRecord) pdo;
|
||||||
|
|
||||||
// set preferredLevel to first level
|
// set preferredLevel to first level
|
||||||
if (preferredLevel == null) {
|
if (preferredLevel == null) {
|
||||||
preferredLevel = record.getModelInfo().getLevel();
|
preferredLevel = record.getLevel();
|
||||||
preferredUnit = record.getModelInfo()
|
preferredUnit = record.getParameter().getUnit();
|
||||||
.getParameterUnitObject();
|
parameterName = record.getParameter().getName();
|
||||||
parameterName = record.getModelInfo().getParameterName();
|
parameterAbbreviation = record.getParameter()
|
||||||
parameterAbbreviation = record.getModelInfo()
|
.getAbbreviation();
|
||||||
.getParameterAbbreviation();
|
|
||||||
if (parameterName == null || parameterName.isEmpty()) {
|
if (parameterName == null || parameterName.isEmpty()) {
|
||||||
if (parameterAbbreviation == null) {
|
if (parameterAbbreviation == null) {
|
||||||
parameterAbbreviation = "";
|
parameterAbbreviation = "";
|
||||||
|
@ -204,27 +223,27 @@ public class GribTimeSeriesAdapter extends
|
||||||
}
|
}
|
||||||
|
|
||||||
// add Unit to levelUnitMap if needed ( quick look-ups )
|
// add Unit to levelUnitMap if needed ( quick look-ups )
|
||||||
Level lvl = record.getModelInfo().getLevel();
|
Level lvl = record.getLevel();
|
||||||
Unit<?> unit = levelUnitMap.get(lvl);
|
Unit<?> unit = levelUnitMap.get(lvl);
|
||||||
if (unit == null) {
|
if (unit == null) {
|
||||||
unit = record.getModelInfo().getParameterUnitObject();
|
unit = record.getParameter().getUnit();
|
||||||
levelUnitMap.put(lvl, unit);
|
levelUnitMap.put(lvl, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add record to records by time
|
// add record to records by time
|
||||||
Set<GribRecord> recordsAtTime = recordsByTime.get(record
|
Set<GridRecord> recordsAtTime = recordsByTime.get(record
|
||||||
.getDataTime());
|
.getDataTime());
|
||||||
if (recordsAtTime == null) {
|
if (recordsAtTime == null) {
|
||||||
recordsAtTime = new HashSet<GribRecord>();
|
recordsAtTime = new HashSet<GridRecord>();
|
||||||
recordsByTime.put(record.getDataTime(), recordsAtTime);
|
recordsByTime.put(record.getDataTime(), recordsAtTime);
|
||||||
}
|
}
|
||||||
recordsAtTime.add(record);
|
recordsAtTime.add(record);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this shouldn't happen, code expects all pdo's for
|
// this shouldn't happen, code expects all pdo's for
|
||||||
// GribTimeSeriesAdapter to be GribRecords
|
// GribTimeSeriesAdapter to be GridRecords
|
||||||
String message = "Unexpected PluginDataObject type; got "
|
String message = "Unexpected PluginDataObject type; got "
|
||||||
+ pdo.getClass().getName() + " expected GribRecord";
|
+ pdo.getClass().getName() + " expected GridRecord";
|
||||||
statusHandler.handle(Priority.PROBLEM, message, new Exception(
|
statusHandler.handle(Priority.PROBLEM, message, new Exception(
|
||||||
message));
|
message));
|
||||||
}
|
}
|
||||||
|
@ -233,7 +252,7 @@ public class GribTimeSeriesAdapter extends
|
||||||
@Override
|
@Override
|
||||||
public boolean hasRecord(PluginDataObject pdo) {
|
public boolean hasRecord(PluginDataObject pdo) {
|
||||||
synchronized (recordsByTime) {
|
synchronized (recordsByTime) {
|
||||||
Set<GribRecord> possibleRecords = recordsByTime.get(pdo
|
Set<GridRecord> possibleRecords = recordsByTime.get(pdo
|
||||||
.getDataTime());
|
.getDataTime());
|
||||||
if (possibleRecords != null && possibleRecords.contains(pdo)) {
|
if (possibleRecords != null && possibleRecords.contains(pdo)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -242,7 +261,7 @@ public class GribTimeSeriesAdapter extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private XYDataList loadInternal(GribRecord[] gribs) throws VizException {
|
private XYDataList loadInternal(GridRecord[] gribs) throws VizException {
|
||||||
ArrayList<XYData> data = new ArrayList<XYData>();
|
ArrayList<XYData> data = new ArrayList<XYData>();
|
||||||
|
|
||||||
ISpatialObject area = gribs[0].getSpatialObject();
|
ISpatialObject area = gribs[0].getSpatialObject();
|
||||||
|
@ -266,7 +285,7 @@ public class GribTimeSeriesAdapter extends
|
||||||
|
|
||||||
boolean isIcon = displayType == DisplayType.ICON;
|
boolean isIcon = displayType == DisplayType.ICON;
|
||||||
|
|
||||||
for (GribRecord rec : gribs) {
|
for (GridRecord rec : gribs) {
|
||||||
|
|
||||||
IDataRecord[] records = cache.get(rec);
|
IDataRecord[] records = cache.get(rec);
|
||||||
if (records == null) {
|
if (records == null) {
|
||||||
|
@ -278,15 +297,8 @@ public class GribTimeSeriesAdapter extends
|
||||||
|
|
||||||
// received a (wind) vector result
|
// received a (wind) vector result
|
||||||
if (records.length > 1) {
|
if (records.length > 1) {
|
||||||
double rotation = 0;
|
|
||||||
if ((rec.getResCompFlags() == null)
|
|
||||||
|| (rec.getResCompFlags() & 8) != 0) {
|
|
||||||
rotation = 180 - MapUtil.rotation(
|
|
||||||
resourceData.getCoordinate(),
|
|
||||||
rec.getSpatialObject());
|
|
||||||
}
|
|
||||||
float[] vectorDirections = (float[]) records[1].getDataObject();
|
float[] vectorDirections = (float[]) records[1].getDataObject();
|
||||||
vectorDirection = vectorDirections[0] + rotation;
|
vectorDirection = vectorDirections[0];
|
||||||
isVectorData = true;
|
isVectorData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,9 +310,8 @@ public class GribTimeSeriesAdapter extends
|
||||||
XYData dataPoint = null;
|
XYData dataPoint = null;
|
||||||
|
|
||||||
// do I need to convert?
|
// do I need to convert?
|
||||||
if (!rec.getModelInfo().getLevel().equals(preferredLevel)) {
|
if (!rec.getLevel().equals(preferredLevel)) {
|
||||||
Unit<?> dataUnit = levelUnitMap.get(rec.getModelInfo()
|
Unit<?> dataUnit = levelUnitMap.get(rec.getLevel());
|
||||||
.getLevel());
|
|
||||||
if (!dataUnit.equals(preferredUnit)) {
|
if (!dataUnit.equals(preferredUnit)) {
|
||||||
// convert
|
// convert
|
||||||
UnitConverter conv = dataUnit.getConverterTo(preferredUnit);
|
UnitConverter conv = dataUnit.getConverterTo(preferredUnit);
|
|
@ -21,10 +21,12 @@ package com.raytheon.uf.viz.d2d.xy.adapters.varheight;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.measure.unit.Unit;
|
import javax.measure.unit.Unit;
|
||||||
|
@ -32,15 +34,17 @@ import javax.measure.unit.Unit;
|
||||||
import org.geotools.geometry.DirectPosition2D;
|
import org.geotools.geometry.DirectPosition2D;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||||
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
|
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||||
import com.raytheon.uf.common.datastorage.Request;
|
import com.raytheon.uf.common.datastorage.Request;
|
||||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
|
||||||
import com.raytheon.uf.common.geospatial.PointUtil;
|
import com.raytheon.uf.common.geospatial.PointUtil;
|
||||||
|
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.time.DataTime;
|
import com.raytheon.uf.common.time.DataTime;
|
||||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||||
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
|
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
|
||||||
|
@ -54,7 +58,8 @@ import com.raytheon.viz.core.slice.request.HeightScale;
|
||||||
import com.raytheon.viz.grid.inv.GridInventory;
|
import com.raytheon.viz.grid.inv.GridInventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Adapter for Grid data that returns the value of a variable at multiple
|
||||||
|
* heights.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -69,9 +74,11 @@ import com.raytheon.viz.grid.inv.GridInventory;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
public class GridVarHeightAdapter extends AbstractVarHeightAdapter<GridRecord> {
|
||||||
|
private static final IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(GridVarHeightAdapter.class);
|
||||||
|
|
||||||
protected HashMap<DataTime, Set<GribRecord>> yRecordMap = new HashMap<DataTime, Set<GribRecord>>();
|
protected HashMap<DataTime, Set<GridRecord>> yRecordMap = new HashMap<DataTime, Set<GridRecord>>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
@ -83,11 +90,11 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
@Override
|
@Override
|
||||||
public String getParameterName() {
|
public String getParameterName() {
|
||||||
synchronized (records) {
|
synchronized (records) {
|
||||||
String name = ((GribRecord) records.iterator().next())
|
String name = ((GridRecord) records.iterator().next())
|
||||||
.getModelInfo().getParameterName();
|
.getParameter().getName();
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
name = ((GribRecord) records.iterator().next()).getModelInfo()
|
name = ((GridRecord) records.iterator().next()).getParameter()
|
||||||
.getParameterAbbreviation();
|
.getAbbreviation();
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
|
@ -106,8 +113,8 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
if (records == null || records.size() == 0) {
|
if (records == null || records.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ((GribRecord) records.iterator().next()).getModelInfo()
|
return ((GridRecord) records.iterator().next()).getParameter()
|
||||||
.getParameterUnitObject();
|
.getUnit();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,10 +133,10 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
|
|
||||||
Set<DataTime> keys = yRecordMap.keySet();
|
Set<DataTime> keys = yRecordMap.keySet();
|
||||||
for (DataTime key : keys) {
|
for (DataTime key : keys) {
|
||||||
Set<GribRecord> aRecord = yRecordMap.get(key);
|
Set<GridRecord> aRecord = yRecordMap.get(key);
|
||||||
if (!aRecord.isEmpty()) {
|
if (!aRecord.isEmpty()) {
|
||||||
return ((GribRecord) aRecord.iterator().next()).getModelInfo()
|
return ((GridRecord) aRecord.iterator().next()).getParameter()
|
||||||
.getParameterUnitObject();
|
.getUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -146,33 +153,31 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
public List<XYData> loadData(DataTime currentTime) throws VizException {
|
public List<XYData> loadData(DataTime currentTime) throws VizException {
|
||||||
populateYRecords();
|
populateYRecords();
|
||||||
|
|
||||||
ArrayList<GribRecord> needsRequested = new ArrayList<GribRecord>();
|
ArrayList<GridRecord> hasData = new ArrayList<GridRecord>(
|
||||||
|
records.size());
|
||||||
|
|
||||||
Map<Level, GribRecord> xMap = new HashMap<Level, GribRecord>();
|
Map<Level, GridRecord> xMap = new HashMap<Level, GridRecord>();
|
||||||
ISpatialObject area = null;
|
|
||||||
synchronized (records) {
|
synchronized (records) {
|
||||||
|
|
||||||
for (GribRecord rec : records) {
|
for (GridRecord rec : records) {
|
||||||
area = rec.getSpatialObject();
|
|
||||||
if (rec.getDataTime().equals(currentTime)) {
|
if (rec.getDataTime().equals(currentTime)) {
|
||||||
xMap.put(rec.getModelInfo().getLevel(), rec);
|
xMap.put(rec.getLevel(), rec);
|
||||||
if (rec.getMessageData() == null) {
|
if (rec.getMessageData() != null) {
|
||||||
needsRequested.add(rec);
|
hasData.add(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<Level, GribRecord> yMap = new HashMap<Level, GribRecord>();
|
Map<Level, GridRecord> yMap = new HashMap<Level, GridRecord>();
|
||||||
|
|
||||||
synchronized (yRecordMap) {
|
synchronized (yRecordMap) {
|
||||||
|
|
||||||
Set<GribRecord> yRecords = yRecordMap.get(currentTime);
|
Set<GridRecord> yRecords = yRecordMap.get(currentTime);
|
||||||
|
|
||||||
if (yRecords != null) {
|
if (yRecords != null) {
|
||||||
for (GribRecord rec : yRecords) {
|
for (GridRecord rec : yRecords) {
|
||||||
yMap.put(rec.getModelInfo().getLevel(), rec);
|
yMap.put(rec.getLevel(), rec);
|
||||||
if (rec.getMessageData() == null) {
|
if (rec.getMessageData() != null) {
|
||||||
needsRequested.add(rec);
|
hasData.add(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,62 +193,74 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectPosition2D point = null;
|
Map<GridCoverage, List<PluginDataObject>> recordsByLocation = new HashMap<GridCoverage, List<PluginDataObject>>(
|
||||||
try {
|
4);
|
||||||
point = PointUtil.determineExactIndex(resourceData.getPoint(),
|
for (GridRecord record : xMap.values()) {
|
||||||
area.getCrs(), MapUtil.getGridGeometry(area));
|
if (hasData.contains(record)) {
|
||||||
} catch (Exception e) {
|
continue;
|
||||||
throw new VizException(e);
|
}
|
||||||
|
List<PluginDataObject> list = recordsByLocation.get(record
|
||||||
|
.getLocation());
|
||||||
|
if (list == null) {
|
||||||
|
list = new ArrayList<PluginDataObject>(xMap.size() * 2);
|
||||||
|
recordsByLocation.put(record.getLocation(), list);
|
||||||
|
}
|
||||||
|
list.add(record);
|
||||||
}
|
}
|
||||||
Rectangle requestArea = new Rectangle((int) Math.floor(point.x),
|
|
||||||
(int) Math.floor(point.y), 2, 2);
|
for (GridRecord record : yMap.values()) {
|
||||||
requestArea = requestArea.intersection(new Rectangle(0, 0,
|
if (hasData.contains(record)) {
|
||||||
area.getNx(), area.getNy()));
|
continue;
|
||||||
if (requestArea.isEmpty()) {
|
}
|
||||||
throw new VizException("Invalid point position("
|
List<PluginDataObject> list = recordsByLocation.get(record
|
||||||
+ resourceData.getPoint()
|
.getLocation());
|
||||||
+ "). Check that the point is within the grib boundaries.");
|
if (list == null) {
|
||||||
|
list = new ArrayList<PluginDataObject>(yMap.size());
|
||||||
|
recordsByLocation.put(record.getLocation(), list);
|
||||||
|
}
|
||||||
|
list.add(record);
|
||||||
}
|
}
|
||||||
Request request = Request.buildSlab(
|
|
||||||
new int[] { (int) requestArea.getMinX(),
|
|
||||||
(int) requestArea.getMinY() },
|
|
||||||
new int[] { (int) requestArea.getMaxX(),
|
|
||||||
(int) requestArea.getMaxY() });
|
|
||||||
|
|
||||||
List<PluginDataObject> pdos = new ArrayList<PluginDataObject>(
|
for (Entry<GridCoverage, List<PluginDataObject>> entry : recordsByLocation
|
||||||
xMap.size() * 2);
|
.entrySet()) {
|
||||||
pdos.addAll(xMap.values());
|
Request request = getRequest(entry.getKey());
|
||||||
pdos.addAll(yMap.values());
|
if (request == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DataCubeContainer.getDataRecords(entry.getValue(), request, null);
|
||||||
|
|
||||||
// only request pdos without data
|
}
|
||||||
pdos.retainAll(needsRequested);
|
|
||||||
|
|
||||||
DataCubeContainer.getDataRecords(pdos, request, null);
|
|
||||||
|
|
||||||
for (Level level : xMap.keySet()) {
|
for (Level level : xMap.keySet()) {
|
||||||
GribRecord yRecord = yMap.get(level);
|
GridRecord yRecord = yMap.get(level);
|
||||||
|
|
||||||
FloatDataRecord yRec = (FloatDataRecord) ((IDataRecord[]) yRecord
|
FloatDataRecord yRec = (FloatDataRecord) ((IDataRecord[]) yRecord
|
||||||
.getMessageData())[0];
|
.getMessageData())[0];
|
||||||
float yVal = InterpUtils.getInterpolatedData(requestArea, point.x,
|
DirectPosition2D yPoint = getPoint(yRecord.getLocation());
|
||||||
point.y, yRec.getFloatData());
|
Rectangle yRect = getRectangle(yRecord.getLocation());
|
||||||
|
float yVal = InterpUtils.getInterpolatedData(yRect, yPoint.x,
|
||||||
|
yPoint.y, yRec.getFloatData());
|
||||||
if (yVal <= -9999) {
|
if (yVal <= -9999) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GribRecord xRecord = xMap.get(level);
|
GridRecord xRecord = xMap.get(level);
|
||||||
|
DirectPosition2D xPoint = getPoint(xRecord.getLocation());
|
||||||
|
Rectangle xRect = getRectangle(xRecord.getLocation());
|
||||||
IDataRecord[] results = ((IDataRecord[]) xRecord.getMessageData());
|
IDataRecord[] results = ((IDataRecord[]) xRecord.getMessageData());
|
||||||
if (results.length == 4) {
|
if (results == null) {
|
||||||
|
continue;
|
||||||
|
} else if (results.length == 4) {
|
||||||
FloatDataRecord speedRec = (FloatDataRecord) results[0];
|
FloatDataRecord speedRec = (FloatDataRecord) results[0];
|
||||||
FloatDataRecord dirRec = (FloatDataRecord) results[1];
|
FloatDataRecord dirRec = (FloatDataRecord) results[1];
|
||||||
float speed = InterpUtils.getInterpolatedData(requestArea,
|
float speed = InterpUtils.getInterpolatedData(xRect, xPoint.x,
|
||||||
point.x, point.y, speedRec.getFloatData());
|
xPoint.y, speedRec.getFloatData());
|
||||||
float dir = InterpUtils.getInterpolatedData(requestArea,
|
float dir = InterpUtils.getInterpolatedData(xRect, xPoint.x,
|
||||||
point.x, point.y, dirRec.getFloatData());
|
xPoint.y, dirRec.getFloatData());
|
||||||
dataList.add(new XYWindImageData(speed, yVal, speed, dir));
|
dataList.add(new XYWindImageData(speed, yVal, speed, dir));
|
||||||
} else {
|
} else {
|
||||||
FloatDataRecord xRec = (FloatDataRecord) results[0];
|
FloatDataRecord xRec = (FloatDataRecord) results[0];
|
||||||
float xVal = InterpUtils.getInterpolatedData(requestArea,
|
float xVal = InterpUtils.getInterpolatedData(xRect, xPoint.x,
|
||||||
point.x, point.y, xRec.getFloatData());
|
xPoint.y, xRec.getFloatData());
|
||||||
if (xVal <= -9999) {
|
if (xVal <= -9999) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -251,9 +268,73 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataList.isEmpty()) {
|
||||||
|
statusHandler.handle(Priority.INFO, "No data found for point "
|
||||||
|
+ resourceData.getPoint() + ", at time " + currentTime
|
||||||
|
+ ", please verify point is within bounds of the data.");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrive the coordinate in grid space(defined by location) where this
|
||||||
|
* adapter is expected to load data.
|
||||||
|
*
|
||||||
|
* @param location
|
||||||
|
* @return
|
||||||
|
* @throws VizException
|
||||||
|
*/
|
||||||
|
private DirectPosition2D getPoint(GridCoverage location)
|
||||||
|
throws VizException {
|
||||||
|
try {
|
||||||
|
return PointUtil.determineExactIndex(resourceData.getPoint(),
|
||||||
|
location.getCrs(), location.getGridGeometry());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VizException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find the rectangle in grid space(defined by location) where this adapter
|
||||||
|
* should request data, the rectangle is formed by adding enough space
|
||||||
|
* around the point to perform bilinear interpolation.
|
||||||
|
*
|
||||||
|
* @param location
|
||||||
|
* @return
|
||||||
|
* @throws VizException
|
||||||
|
*/
|
||||||
|
private Rectangle getRectangle(GridCoverage location) throws VizException {
|
||||||
|
DirectPosition2D point = getPoint(location);
|
||||||
|
Rectangle rectangle = new Rectangle((int) Math.floor(point.x),
|
||||||
|
(int) Math.floor(point.y), 2, 2);
|
||||||
|
rectangle = rectangle.intersection(new Rectangle(0, 0,
|
||||||
|
location.getNx(), location.getNy()));
|
||||||
|
return rectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the datastore request needed to get data for GridRecords with the
|
||||||
|
* provided location.
|
||||||
|
*
|
||||||
|
* @param location
|
||||||
|
* @return
|
||||||
|
* @throws VizException
|
||||||
|
*/
|
||||||
|
private Request getRequest(GridCoverage location) throws VizException {
|
||||||
|
Rectangle rectangle = getRectangle(location);
|
||||||
|
if (rectangle.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Request.buildSlab(
|
||||||
|
new int[] { (int) rectangle.getMinX(),
|
||||||
|
(int) rectangle.getMinY() },
|
||||||
|
new int[] { (int) rectangle.getMaxX(),
|
||||||
|
(int) rectangle.getMaxY() });
|
||||||
|
}
|
||||||
|
|
||||||
public void addRecord(PluginDataObject pdo) {
|
public void addRecord(PluginDataObject pdo) {
|
||||||
DataTime key = pdo.getDataTime().clone();
|
DataTime key = pdo.getDataTime().clone();
|
||||||
key.setLevelValue(null);
|
key.setLevelValue(null);
|
||||||
|
@ -309,13 +390,13 @@ public class GribVarHeightAdapter extends AbstractVarHeightAdapter<GribRecord> {
|
||||||
List<Object> recs = DataCubeContainer.getData(property, 60000);
|
List<Object> recs = DataCubeContainer.getData(property, 60000);
|
||||||
|
|
||||||
for (Object obj : recs) {
|
for (Object obj : recs) {
|
||||||
GribRecord gRecord = (GribRecord) obj;
|
GridRecord gRecord = (GridRecord) obj;
|
||||||
Set<GribRecord> recordSet = yRecordMap.get(gRecord
|
Set<GridRecord> recordSet = yRecordMap.get(gRecord
|
||||||
.getDataTime());
|
.getDataTime());
|
||||||
if (recordSet != null) {
|
if (recordSet != null) {
|
||||||
recordSet.add(gRecord);
|
recordSet.add(gRecord);
|
||||||
} else {
|
} else {
|
||||||
recordSet = new HashSet<GribRecord>();
|
recordSet = new HashSet<GridRecord>();
|
||||||
recordSet.add(gRecord);
|
recordSet.add(gRecord);
|
||||||
yRecordMap.put(gRecord.getDataTime(), recordSet);
|
yRecordMap.put(gRecord.getDataTime(), recordSet);
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue