Commit cff2ffcf authored by rink's avatar rink
Browse files

Add support for continuous tracer streaming from a spatial location. Allow start points to have an

initial time at which a trajectory will be created.
parent c55794d2
......@@ -69,6 +69,7 @@ public class TrajectoryManager {
public static int[] o_i = new int[] {0, 1, 0, 1};
float[][] startPts;
double[] startTimes;
byte[][] startClrs;
......@@ -91,6 +92,7 @@ public class TrajectoryManager {
boolean manualIntrpPts;
boolean trajDoIntrp = true;
boolean trajCachingEnabled = false;
boolean trcrStreamingEnabled;
//boolean doHysplit = false;
//boolean doRK4 = true;
float trcrSize = 1f;
......@@ -134,6 +136,8 @@ public class TrajectoryManager {
FlatField terrain = null;
Gridded1DSet anim1DdomainSet;
//- Listener per FlowControl for ProjectionControl events to auto resize tracer geometry.
public static HashMap<FlowControl, ControlListener> scaleChangeListeners = new HashMap<FlowControl, ControlListener>();
......@@ -142,11 +146,12 @@ public class TrajectoryManager {
public TrajectoryManager(DataRenderer renderer, TrajectoryParams trajParams, ArrayList<FlowInfo> flowInfoList, int dataDomainLength, double time) throws VisADException {
this(renderer, trajParams, flowInfoList, dataDomainLength, time, null, null);
this(renderer, trajParams, flowInfoList, dataDomainLength, time, null, null, null);
}
public TrajectoryManager(DataRenderer renderer, TrajectoryParams trajParams, ArrayList<FlowInfo> flowInfoList, int dataDomainLength, double time, ScalarMap altToZ, CoordinateSystem dspCoordSys) throws VisADException {
public TrajectoryManager(DataRenderer renderer, TrajectoryParams trajParams, ArrayList<FlowInfo> flowInfoList, int dataDomainLength, double time, ScalarMap altToZ, CoordinateSystem dspCoordSys, Gridded1DSet anim1DdomainSet) throws VisADException {
this.flowInfoList = flowInfoList;
this.anim1DdomainSet = anim1DdomainSet;
FlowInfo info = flowInfoList.get(0);
this.dataDomainLength = dataDomainLength;
......@@ -164,6 +169,7 @@ public class TrajectoryManager {
trcrSize = trajParams.getMarkerSize();
trcrEnabled = trajParams.getMarkerEnabled();
trajCachingEnabled = trajParams.getCachingEnabled();
trcrStreamingEnabled = trajParams.getTracerStreamingEnabled();
terrainFollowEnabled = trajParams.getTerrainFollowing();
trajForm = trajParams.getTrajectoryForm();
cylWidth = trajParams.getCylinderWidth();
......@@ -208,9 +214,12 @@ public class TrajectoryManager {
startClrs = new byte[clrDim][];
double[][] tmp = new double[1][];
if (startPts == null) {
try {
startPts = getStartPointsFromFile(renderer, altToZ, startClrs);
startPts = getStartPointsFromFile(renderer, altToZ, startClrs, tmp);
startTimes = tmp[0];
}
catch (Exception e) {
e.printStackTrace();
......@@ -296,7 +305,7 @@ public class TrajectoryManager {
/* initialize and create a Trajectory for each start point */
trajectories = new ArrayList<Trajectory>();
java.util.Arrays.fill(markGrid, false);
makeTrajectories(direction*time, startPts, startClrs, spatialSetTraj);
makeTrajectories(direction*time, startPts, startTimes, startClrs, spatialSetTraj);
}
public void addPair(float[] startPt, float[] stopPt, byte[] startColor, byte[] stopColor) {
......@@ -395,7 +404,15 @@ public class TrajectoryManager {
if ((timeAccum >= trajRefreshInterval)) { // for non steady state trajectories (refresh frequency)
trajectories = new ArrayList<Trajectory>();
java.util.Arrays.fill(markGrid, false);
makeTrajectories(direction*times[i], startPts, startClrs, spatialSetTraj);
makeTrajectories(direction*times[i], startPts, startTimes, startClrs, spatialSetTraj);
}
else if (trcrStreamingEnabled) {
java.util.Arrays.fill(markGrid, false);
makeTrajectories(direction*times[i], startPts, null, startClrs, spatialSetTraj);
}
else if (startTimes != null) {
java.util.Arrays.fill(markGrid, false);
makeTrajectories(direction*times[i], startPts, startTimes, startClrs, spatialSetTraj);
}
if (trajForm == POINT) {
......@@ -545,7 +562,7 @@ public class TrajectoryManager {
return arrays;
}
public void makeTrajectories(double time, float[][] startPts, byte[][] color_values, GriddedSet spatial_set) throws VisADException {
public void makeTrajectories(double time, float[][] startPts, double[] startTimes, byte[][] color_values, GriddedSet spatial_set) throws VisADException {
int num = startPts[0].length;
clrDim = color_values.length;
......@@ -576,8 +593,10 @@ public class TrajectoryManager {
}
if (indices[k] != null) {
Trajectory traj = new Trajectory(this, startX, startY, startZ, indices[k], weights[k], startColor, time);
trajectories.add(traj);
if ((startTimes == null) || (startTimes != null && startTimes[k] <= time)) {
Trajectory traj = new Trajectory(this, startX, startY, startZ, indices[k], weights[k], startColor, time);
trajectories.add(traj);
}
}
}
}
......@@ -2400,7 +2419,12 @@ public class TrajectoryManager {
propStr = prop.getProperty("TerrainFollow");
if (propStr != null) {
trajParams.setTerrainFollowing(Boolean.valueOf(propStr.trim()));
}
}
propStr = prop.getProperty("TracerStreaming");
if (propStr != null) {
trajParams.setTracerStreamingEnabled(Boolean.valueOf(propStr.trim()));
}
propStr = prop.getProperty("NumIntrpPts");
if (propStr != null) {
......@@ -2494,7 +2518,7 @@ public class TrajectoryManager {
return trajParams;
}
public float[][] getStartPointsFromFile(DataRenderer renderer, ScalarMap altToZ, byte[][] colors) throws VisADException, RemoteException {
public float[][] getStartPointsFromFile(DataRenderer renderer, ScalarMap altToZ, byte[][] colors, double[][] times) throws VisADException, RemoteException {
String filename = null;
try {
......@@ -2517,24 +2541,42 @@ public class TrajectoryManager {
return null;
}
RealTupleType rngTupType = (RealTupleType) ((FunctionType)data.getType()).getRange();
int lonIdx = rngTupType.getIndex(RealType.Longitude);
int latIdx = rngTupType.getIndex(RealType.Latitude);
int altIdx = rngTupType.getIndex(RealType.Altitude);
int timeIdx = rngTupType.getIndex(RealType.Time);
int numPts = data.getLength();
ArrayList<float[]> keepPts = new ArrayList();
ArrayList<Float> keepVal = new ArrayList();
ArrayList<Double> keepTime = new ArrayList();
for (int k=0; k<numPts; k++) {
RealTuple tup = (RealTuple) data.getSample(k);
double[] vals = tup.getValues();
float[] locVal = new float[3];
locVal[0] = (float) vals[0];
locVal[1] = (float) vals[1];
locVal[2] = (float) vals[2];
locVal[0] = (float) vals[lonIdx];
locVal[1] = (float) vals[latIdx];
locVal[2] = (float) vals[altIdx];
keepPts.add(locVal);
if (vals.length > 3) {
keepVal.add((float)vals[3]);
}
if (timeIdx >= 0) {
keepTime.add(vals[timeIdx]);
}
else {
keepVal.add((float)vals[3]);
}
}
else if (vals.length > 4) {
keepTime.add(vals[timeIdx]);
keepVal.add((float)vals[4]);
}
}
if ((keepVal.size() != 0 ) && keepPts.size() != keepVal.size()) {
throw new VisADException("Trajectory start point file problem: all points must be specified as either lon,lat,alt or lon,lat, alt, val");
if ((keepVal.size() != 0 ) && ((keepPts.size() != keepVal.size()) || (keepPts.size() != keepTime.size()))) {
throw new VisADException("Trajectory start point file problem: all points must be specified as either lon,lat,alt or lon,lat,alt,val or lon,lat,alt,time or lon,lat,alt,time,value");
}
float[][] latlonalt = new float[3][keepPts.size()];
......@@ -2586,7 +2628,17 @@ public class TrajectoryManager {
for (int i=0; i<latlonalt.length; i++) {
System.arraycopy(latlonalt[i], 0, fltVals[i], 0, fltVals[i].length);
}
float[][] xyz = dspCoordSys.toReference(fltVals);
float[][] xyz = dspCoordSys.toReference(fltVals);
int tSize = keepTime.size();
double[] timeVals = null;
if (tSize > 0) {
timeVals = new double[tSize];
}
for (int k=0; k<tSize; k++) {
timeVals[k] = keepTime.get(k);
}
times[0] = timeVals;
return xyz;
}
......
......@@ -81,6 +81,7 @@ public class TrajectoryParams {
boolean autoSizeMarker = true;
boolean cachingEnabled = true;
boolean terrainFollowEnabled = true;
boolean trcrStreamingEnabled = false;
int trajForm = LINE;
float cylWidth = 0.00014f;
......@@ -126,6 +127,7 @@ public class TrajectoryParams {
this.terrainFollowEnabled = params.getTerrainFollowing();
this.method = params.getMethod();
this.interpMethod = params.getInterpolationMethod();
this.trcrStreamingEnabled = params.getTracerStreamingEnabled();
}
public TrajectoryParams(double trajVisibilityTimeWindow, double trajRefreshInterval, int numIntrpPts, int startSkip, SmoothParams smoothParams) {
......@@ -363,6 +365,14 @@ public class TrajectoryParams {
return this.cachingEnabled;
}
public boolean getTracerStreamingEnabled() {
return this.trcrStreamingEnabled;
}
public void setTracerStreamingEnabled(boolean yesno) {
this.trcrStreamingEnabled = yesno;
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof TrajectoryParams)) {
return false;
......@@ -417,6 +427,9 @@ public class TrajectoryParams {
else if (this.method != trajParams.method) {
return false;
}
else if (this.trcrStreamingEnabled != trajParams.trcrStreamingEnabled) {
return false;
}
}
return true;
}
......
......@@ -1404,7 +1404,7 @@ System.out.println("Texture.BASE_LEVEL_LINEAR = " + Texture.BASE_LEVEL_LINEAR);
double[] times = TrajectoryManager.getTimes((Gridded1DSet)anim1DdomainSet);
double[] timeSteps = TrajectoryManager.getTimeSteps((Gridded1DSet)anim1DdomainSet);
TrajectoryManager trajMan = new TrajectoryManager(renderer, trajParams, flowInfoList, dataDomainLength, times[0], altitudeToDisplayZ, dspCoordSys);
TrajectoryManager trajMan = new TrajectoryManager(renderer, trajParams, flowInfoList, dataDomainLength, times[0], altitudeToDisplayZ, dspCoordSys, (Gridded1DSet)anim1DdomainSet);
trcrEnabled = (trcrEnabled && (trajForm == TrajectoryManager.LINE)) && trajForm != TrajectoryManager.POINT;
if (trajForm == TrajectoryManager.TRACER || trajForm == TrajectoryManager.TRACER_POINT) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment