Issue #2157: Remove meteolib dependencies from viz.core.contours plugin.
Change-Id: Id749151ca9af702614a4b0a8fa7d037c71576e6f Former-commit-id: b25274c599179eea5bc07d76bc369b0d0e934237
This commit is contained in:
parent
581a8e6be2
commit
bc84e874a4
3 changed files with 11 additions and 171 deletions
|
@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
||||||
com.raytheon.uf.common.util;bundle-version="1.12.1174",
|
com.raytheon.uf.common.util;bundle-version="1.12.1174",
|
||||||
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
|
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
|
||||||
com.raytheon.edex.meteolib;bundle-version="1.12.1174"
|
com.raytheon.uf.common.wxmath;bundle-version="1.0.0"
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package: com.raytheon.viz.core.contours,
|
Export-Package: com.raytheon.viz.core.contours,
|
||||||
com.raytheon.viz.core.contours.rsc.displays,
|
com.raytheon.viz.core.contours.rsc.displays,
|
||||||
|
|
|
@ -30,10 +30,10 @@ import org.geotools.geometry.DirectPosition2D;
|
||||||
import org.geotools.geometry.jts.JTS;
|
import org.geotools.geometry.jts.JTS;
|
||||||
import org.opengis.referencing.operation.MathTransform;
|
import org.opengis.referencing.operation.MathTransform;
|
||||||
|
|
||||||
import com.raytheon.edex.meteoLib.Controller;
|
|
||||||
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.MapUtil;
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
|
import com.raytheon.uf.common.wxmath.DistFilter;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||||
import com.raytheon.uf.viz.core.PixelExtent;
|
import com.raytheon.uf.viz.core.PixelExtent;
|
||||||
|
@ -60,6 +60,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jul 10, 2008 #1233 chammack Initial creation
|
* Jul 10, 2008 #1233 chammack Initial creation
|
||||||
* Jul 18, 2013 #2199 mschenke Made code only smooth data once
|
* Jul 18, 2013 #2199 mschenke Made code only smooth data once
|
||||||
|
* Aug 23, 2013 #2157 dgilling Remove meteolib dependency.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -439,7 +440,7 @@ public abstract class ContourRenderable implements IRenderable {
|
||||||
data[j] = 1.0E37f;
|
data[j] = 1.0E37f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data = Controller.dist_filter(data, npts, nx, 0, 0, nx, ny);
|
data = DistFilter.filter(data, npts, nx, ny, 1);
|
||||||
// Replace their NaN with our NaN
|
// Replace their NaN with our NaN
|
||||||
for (int j = 0; j < data.length; j++) {
|
for (int j = 0; j < data.length; j++) {
|
||||||
if (data[j] == 1.0E37f) {
|
if (data[j] == 1.0E37f) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.opengis.referencing.datum.PixelInCell;
|
||||||
import org.opengis.referencing.operation.MathTransform;
|
import org.opengis.referencing.operation.MathTransform;
|
||||||
import org.opengis.referencing.operation.TransformException;
|
import org.opengis.referencing.operation.TransformException;
|
||||||
|
|
||||||
import com.raytheon.edex.meteoLib.Controller;
|
|
||||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||||
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;
|
||||||
|
@ -51,7 +50,6 @@ import com.raytheon.uf.common.geospatial.util.WorldWrapChecker;
|
||||||
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;
|
||||||
import com.raytheon.uf.common.util.ArraysUtil;
|
|
||||||
import com.raytheon.uf.common.util.GridUtil;
|
import com.raytheon.uf.common.util.GridUtil;
|
||||||
import com.raytheon.uf.viz.core.DrawableString;
|
import com.raytheon.uf.viz.core.DrawableString;
|
||||||
import com.raytheon.uf.viz.core.IExtent;
|
import com.raytheon.uf.viz.core.IExtent;
|
||||||
|
@ -96,6 +94,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
||||||
* with java port.
|
* with java port.
|
||||||
*
|
*
|
||||||
* Jul 18, 2013 2199 mschenke Ensured contouring is only occurring over visible area
|
* Jul 18, 2013 2199 mschenke Ensured contouring is only occurring over visible area
|
||||||
|
* Jul 23, 2013 #2157 dgilling Remove legacy stream line drawing code.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -107,13 +106,6 @@ public class ContourSupport {
|
||||||
.getHandler(ContourSupport.class);
|
.getHandler(ContourSupport.class);
|
||||||
|
|
||||||
private static float smallestContourValue = GridUtil.GRID_FILL_VALUE - 1;
|
private static float smallestContourValue = GridUtil.GRID_FILL_VALUE - 1;
|
||||||
|
|
||||||
private static final String STREAM_LINES_PROPERTY_NAME = "viz.use.legacy.streamlines";
|
|
||||||
|
|
||||||
private static final String LEGACY_STEAMLINES_ON = "true";
|
|
||||||
|
|
||||||
private static final String LEGACY_STEAMLINES_OFF = "false";
|
|
||||||
|
|
||||||
|
|
||||||
private static float largestContourValue = GridUtil.GRID_FILL_VALUE + 1;
|
private static float largestContourValue = GridUtil.GRID_FILL_VALUE + 1;
|
||||||
|
|
||||||
|
@ -642,17 +634,9 @@ public class ContourSupport {
|
||||||
int maxX = (int) Math.ceil(Math.min(env.getMaximum(0), sz[0] - 1));
|
int maxX = (int) Math.ceil(Math.min(env.getMaximum(0), sz[0] - 1));
|
||||||
int maxY = (int) Math.ceil(Math.min(env.getMaximum(1), sz[1] - 1));
|
int maxY = (int) Math.ceil(Math.min(env.getMaximum(1), sz[1] - 1));
|
||||||
|
|
||||||
if (LEGACY_STEAMLINES_ON.equals(System.getProperty(
|
makeStreamLines(uW, vW, minX, minY, maxX, maxY, sz, contourGroup,
|
||||||
STREAM_LINES_PROPERTY_NAME, LEGACY_STEAMLINES_OFF)
|
currentMagnification, zoom, contourGroup.lastDensity,
|
||||||
.toLowerCase())) {
|
rastPosToWorldGrid);
|
||||||
makeStreamLinesLegacy(uW, vW, minX, minY, maxX, maxY, sz,
|
|
||||||
contourGroup, currentMagnification, zoom,
|
|
||||||
contourGroup.lastDensity, rastPosToWorldGrid);
|
|
||||||
} else {
|
|
||||||
makeStreamLinesNew(uW, vW, minX, minY, maxX, maxY, sz,
|
|
||||||
contourGroup, currentMagnification, zoom,
|
|
||||||
contourGroup.lastDensity, rastPosToWorldGrid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return contourGroup;
|
return contourGroup;
|
||||||
|
@ -1103,17 +1087,8 @@ public class ContourSupport {
|
||||||
int maxX = (int) (sz[0] - 1);
|
int maxX = (int) (sz[0] - 1);
|
||||||
int maxY = (int) (sz[1] - 1);
|
int maxY = (int) (sz[1] - 1);
|
||||||
|
|
||||||
if (LEGACY_STEAMLINES_ON.equals(System.getProperty(
|
makeStreamLines(uW, vW, minX, minY, maxX, maxY, sz, contourGroup,
|
||||||
STREAM_LINES_PROPERTY_NAME, LEGACY_STEAMLINES_OFF)
|
1, 1, contourGroup.lastDensity * 2, gridToPixel);
|
||||||
.toLowerCase())) {
|
|
||||||
makeStreamLinesLegacy(uW, vW, minX, minY, maxX, maxY, sz,
|
|
||||||
contourGroup, 1, 1, contourGroup.lastDensity * 2,
|
|
||||||
gridToPixel);
|
|
||||||
} else {
|
|
||||||
makeStreamLinesNew(uW, vW, minX, minY, maxX, maxY, sz,
|
|
||||||
contourGroup, 1, 1, contourGroup.lastDensity * 2,
|
|
||||||
gridToPixel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return contourGroup;
|
return contourGroup;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1124,143 +1099,7 @@ public class ContourSupport {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove this function once use of Java ported version of this
|
private static void makeStreamLines(float[] uW, float[] vW, int minX,
|
||||||
// algorithm is accepted by end-users
|
|
||||||
private static void makeStreamLinesLegacy(float[] uW, float[] vW, int minX,
|
|
||||||
int minY, int maxX, int maxY, long[] sz, ContourGroup contourGroup,
|
|
||||||
double currentMagnification, float zoom, double density,
|
|
||||||
MathTransform rastPosToWorldGrid) throws VizException {
|
|
||||||
|
|
||||||
int szX = (maxX - minX) + 1;
|
|
||||||
int szY = (maxY - minY) + 1;
|
|
||||||
int totalSz = szX * szY;
|
|
||||||
if (totalSz <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int x = (int) sz[0];
|
|
||||||
int y = (int) sz[1];
|
|
||||||
|
|
||||||
float[] adjustedUw = new float[totalSz];
|
|
||||||
float[] adjustedVw = new float[totalSz];
|
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
for (int j = 0; j < szY; j++) {
|
|
||||||
for (int i = 0; i < szX; i++) {
|
|
||||||
|
|
||||||
adjustedUw[n] = uW[(x * (j + minY)) + (i + minX)];
|
|
||||||
adjustedVw[n] = vW[(x * (j + minY)) + (i + minX)];
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ArraysUtil.flipVert(adjustedUw, szY, szX);
|
|
||||||
ArraysUtil.flipVert(adjustedVw, szY, szX);
|
|
||||||
|
|
||||||
int arrSz = Math.max(10 * adjustedUw.length, uW.length);
|
|
||||||
|
|
||||||
int[] work = new int[arrSz];
|
|
||||||
float[] xPoints = new float[arrSz];
|
|
||||||
float[] yPoints = new float[arrSz];
|
|
||||||
int[] numPoints = new int[1];
|
|
||||||
|
|
||||||
// Use ported legacy code to determine contour interval
|
|
||||||
long t0 = System.currentTimeMillis();
|
|
||||||
|
|
||||||
double[] center = new double[2];
|
|
||||||
double[] offCenter = new double[2];
|
|
||||||
|
|
||||||
try {
|
|
||||||
rastPosToWorldGrid.transform(new double[] { x / 2.0, y / 2.0 }, 0,
|
|
||||||
center, 0, 1);
|
|
||||||
rastPosToWorldGrid.transform(new double[] { (x / 2.0) + 1.0,
|
|
||||||
y / 2.0 }, 0, offCenter, 0, 1);
|
|
||||||
} catch (TransformException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
double gridPixelSize = offCenter[0] - center[0];
|
|
||||||
double gridPixelMax = 2000.;
|
|
||||||
|
|
||||||
// If gridPixelSize is large, arrows on streamline will be too small, so
|
|
||||||
// adjust here
|
|
||||||
if (gridPixelSize > gridPixelMax) {
|
|
||||||
gridPixelSize = gridPixelSize / 5;
|
|
||||||
}
|
|
||||||
float arrowSize = (float) (currentMagnification * 5 / zoom / gridPixelSize);
|
|
||||||
|
|
||||||
double spadiv = zoom * density * gridPixelSize / 25;
|
|
||||||
|
|
||||||
double minSpacing = 1.0 / spadiv;
|
|
||||||
double maxSpacing = 3.0 / spadiv;
|
|
||||||
float minspc = 0;
|
|
||||||
float maxspc = 0;
|
|
||||||
|
|
||||||
if (minSpacing > 1) {
|
|
||||||
minspc = (float) Math.sqrt(minSpacing);
|
|
||||||
}
|
|
||||||
if (minspc < 0.1) {
|
|
||||||
minspc = 0.1f;
|
|
||||||
}
|
|
||||||
if (maxSpacing > 1) {
|
|
||||||
maxspc = (float) Math.sqrt(maxSpacing);
|
|
||||||
}
|
|
||||||
if (maxspc < 0.25) {
|
|
||||||
maxspc = 0.25f;
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller.strmpak(adjustedUw, adjustedVw, work, szX, szX, szY,
|
|
||||||
arrowSize, xPoints, yPoints, numPoints, minspc, maxspc,
|
|
||||||
-1000000f, -999998f);
|
|
||||||
|
|
||||||
long t1 = System.currentTimeMillis();
|
|
||||||
System.out.println("Contouring took: " + (t1 - t0));
|
|
||||||
|
|
||||||
List<double[]> vals = new ArrayList<double[]>();
|
|
||||||
|
|
||||||
long tAccum = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (int i = 0; i < numPoints[0] && i < xPoints.length; i++) {
|
|
||||||
if (xPoints[i] == -99999.0) {
|
|
||||||
if (vals.size() > 0) {
|
|
||||||
double[][] valsArr = vals.toArray(new double[vals
|
|
||||||
.size()][2]);
|
|
||||||
contourGroup.posValueShape.addLineSegment(valsArr);
|
|
||||||
vals.clear();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
double[] out = new double[2];
|
|
||||||
try {
|
|
||||||
long tZ0 = System.currentTimeMillis();
|
|
||||||
rastPosToWorldGrid.transform(new double[] {
|
|
||||||
maxX - xPoints[i] + 1, yPoints[i] + minY - 1 },
|
|
||||||
0, out, 0, 1);
|
|
||||||
long tZ1 = System.currentTimeMillis();
|
|
||||||
tAccum += (tZ1 - tZ0);
|
|
||||||
} catch (TransformException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
vals.add(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("streamline transformation time: " + tAccum);
|
|
||||||
|
|
||||||
if (vals.size() > 0) {
|
|
||||||
|
|
||||||
double[][] valsArr = vals.toArray(new double[vals.size()][2]);
|
|
||||||
contourGroup.posValueShape.addLineSegment(valsArr);
|
|
||||||
vals.clear();
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw new VizException("Error postprocessing contours", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void makeStreamLinesNew(float[] uW, float[] vW, int minX,
|
|
||||||
int minY, int maxX, int maxY, long[] sz, ContourGroup contourGroup,
|
int minY, int maxX, int maxY, long[] sz, ContourGroup contourGroup,
|
||||||
double currentMagnification, float zoom, double density,
|
double currentMagnification, float zoom, double density,
|
||||||
MathTransform rastPosToWorldGrid) throws VizException {
|
MathTransform rastPosToWorldGrid) throws VizException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue