Merge branch 'omaha_16.2.1' into omaha_16.2.1-lx

Conflicts:
	cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java


Former-commit-id: 8a69fb3ce7c65b73e4f7bc760400cf064a72d40e
This commit is contained in:
Steve Harris 2016-04-26 16:10:22 -05:00
commit 7faad794f1
2 changed files with 41 additions and 15 deletions

View file

@ -20,8 +20,16 @@
package com.raytheon.viz.hydrobase.data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.viz.hydrocommon.util.HrapUtil;
@ -41,6 +49,8 @@ import com.vividsolutions.jts.geom.Polygon;
* Dec 18, 2015 5217 mpduff Initial creation
* Mar 08, 2016 5217 mpduff Fixed column values to be full hrap columns rather
* than relative to the subgrid.
* Apr 07, 2016 5217 mpduff Fixed an issue calculating hrap column.
* Apr 15, 2016 5217 mpduff Need to reproject the basin polygon into HRAP CRS.
*
* </pre>
*
@ -76,18 +86,28 @@ public class HydroGeoProcessor {
*/
public HrapBinList getHrapBinList(GeoAreaData geoData) throws Exception {
List<Coordinate> coords = getPointsFromArea(geoData);
Coordinate[] minMaxXY = getMinMaxXY(coords);
Polygon poly = MapUtil.getPolygon(coords.toArray(new Coordinate[0]));
Coordinate minC = minMaxXY[0];
Coordinate maxC = minMaxXY[1];
/*
* Reproject the polygon to the same map space as the HRAP grid.
*/
HRAP hrap = HRAP.getInstance();
GridGeometry2D hrapGridGeometry = hrap.getGridGeometry();
CoordinateReferenceSystem latLonCRS = DefaultGeographicCRS.WGS84;
CoordinateReferenceSystem hrapCRS = hrap.getGridGeometry()
.getCoordinateReferenceSystem();
MathTransform transform = CRS.findMathTransform(latLonCRS, hrapCRS);
Geometry crsGeometry = JTS.transform(poly, transform);
Geometry gridSpaceGeometry = JTS.transform(crsGeometry,
hrapGridGeometry.getCRSToGrid2D());
Coordinate[] gridSpaceCoords = gridSpaceGeometry.getCoordinates();
Coordinate[] minMaxXY = getMinMaxXY(Arrays.asList(gridSpaceCoords));
Coordinate hrapMin = minMaxXY[0];
Coordinate hrapMax = minMaxXY[1];
Coordinate hrapMin = HrapUtil.latLonToHrap(minC);
Coordinate hrapMax = HrapUtil.latLonToHrap(maxC);
int maxRow = (int) Math.floor(hrapMax.y);
int maxCol = (int) Math.floor(hrapMax.x);
int maxRow = (int) Math.ceil(hrapMax.y);
int maxCol = (int) Math.ceil(hrapMax.x);
int minRow = (int) Math.floor(hrapMin.y);
int minCol = (int) Math.floor(hrapMin.x);
@ -109,7 +129,6 @@ public class HydroGeoProcessor {
double area = 0;
HrapBinList binList = new HrapBinList();
for (int r = 0; r < rows; r++) {
rowNum = r + minRow;
startCol = -1;
@ -122,11 +141,11 @@ public class HydroGeoProcessor {
.getGridCellPolygon(coord);
}
if (poly.intersects(hrapGeometries[rowNum][colNum])) {
endCol = c + cols;
endCol = c;
binCtr++;
if (startCol == -1) {
// First cell in the row
startCol = c + cols;
startCol = c;
rowCtr++;
}
area += HrapUtil.getHrapBinArea(coord);
@ -208,13 +227,13 @@ public class HydroGeoProcessor {
* for each input point from the database, starting with the second
* point
*/
// Add the first point every time.
points.add(new Coordinate(lon[0], lat[0]));
for (int i = 1; i < data.getNumberPoints(); i++) {
/* if input points are different */
if ((lat[i] != lat[i - 1]) || (lon[i] != lon[i - 1])) {
coord = new Coordinate(lon[i], lat[i]);
points.add(coord);
}
coord = new Coordinate(lon[i], lat[i]);
points.add(coord);
}
/*

View file

@ -96,6 +96,7 @@ import com.raytheon.viz.lightning.cache.LightningFrameRetriever;
* Sep 10, 2015 4856 njensen synchronize in remove(DataTime)
* Sep 25, 2015 4605 bsteffen repeat binning
* Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling
* Apr 26, 2016 5597 bsteffen Include update interval in legend.
*
* </pre>
*
@ -184,6 +185,9 @@ public class LightningResource extends
int absTimeInterval = Math.abs(resourceData.getRepeatingBinOffset()
.getInterval());
int updateInterval = Math
.abs(resourceData.getBinOffset().getInterval());
// If a virtual offset is provided, it is aged lightning, so use
// the virtual offset to provide the "Old" time
int virtualOffset = resourceData.getBinOffset().getVirtualOffset();
@ -201,6 +205,9 @@ public class LightningResource extends
if (source != null) {
rval += source + ' ';
}
if (updateInterval != absTimeInterval) {
rval += convertTimeIntervalToString(updateInterval) + "Update ";
}
return rval;
}