diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/IPlotModelGeneratorCaller.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/IPlotModelGeneratorCaller.java index db1ebce4d0..9357496134 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/IPlotModelGeneratorCaller.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/IPlotModelGeneratorCaller.java @@ -29,7 +29,8 @@ import com.raytheon.uf.viz.core.drawables.IImage; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 16, 2009 mschenke Initial creation + * Sep 16, 2009 mschenke Initial creation + * Jun 25, 2013 1869 bsteffen Fix plot sampling. * * * @@ -42,5 +43,5 @@ public interface IPlotModelGeneratorCaller { public void clearImages(); - public void messageGenerated(String dataURI, String message); + public void messageGenerated(PlotInfo[] key, String message); } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java index 9c01553d64..d80816d76a 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang.Validate; @@ -94,6 +93,7 @@ import com.vividsolutions.jts.geom.Coordinate; * May 14, 2013 1869 bsteffen Get plots working without dataURI * Jun 06, 2013 2072 bsteffen Fix concurrency problems when init is * called before time matching is done. + * Jun 25, 2013 1869 bsteffen Fix plot sampling. * * * @@ -125,8 +125,6 @@ public class PlotResource2 extends private JobPool frameRetrievalPool = new JobPool("Retrieving plot frame", 8, true); - private TreeMap rawMessageMap = new TreeMap(); - private class FrameRetriever implements Runnable { private DataTime dataTime; @@ -144,13 +142,36 @@ public class PlotResource2 extends } + /** + * A station represents all the data for a single location(station) for a + * single frame + * + */ public static class Station { + /* + * Contains all PlotInfo objects for the same stationId with the same + * normalized time(real time will be different) + */ public PlotInfo[] info; + /* + * The image to display for this plot + */ public PointImage plotImage; + /* + * Sampling text for this plot + */ + public String rawMessage; + + /* + * Information used be the progressive disclosure algorithm + */ public Object progDiscInfo; + /* + * Location of the plot in descriptor grid space. + */ public Coordinate pixelLocation; } @@ -504,32 +525,25 @@ public class PlotResource2 extends } } - PlotInfo[] inspectPlot = null; + Station inspectPlot = null; if (availableStations.size() == 1) { - inspectPlot = availableStations.get(0).info; + inspectPlot = availableStations.get(0); } else if (availableStations.size() > 1) { int index = findClosestPlot(latlon, availableStations); if (index != -1) { - inspectPlot = availableStations.get(index).info; + inspectPlot = availableStations.get(index); } } if (inspectPlot != null) { - String dataURI = inspectPlot[0].dataURI; - if (rawMessageMap.containsKey(dataURI)) { - if (rawMessageMap.get(dataURI) != null) { - message = rawMessageMap.get(dataURI); - } - } else { + message = inspectPlot.rawMessage; + if (message == null) { message = "Generating..."; - synchronized (rawMessageMap) { - rawMessageMap.put(dataURI, message); - } - List list = new ArrayList(); - list.add(inspectPlot); + List list = new ArrayList(1); + list.add(inspectPlot.info); Params params = Params.PLOT_AND_SAMPLE; - if (inspectPlot[0].pdv != null) { + if (inspectPlot.info[0].pdv != null) { params = Params.SAMPLE_ONLY; } GetDataTask task = new GetDataTask(list, params); @@ -725,11 +739,20 @@ public class PlotResource2 extends } @Override - public void messageGenerated(String dataURI, String message) { - synchronized (rawMessageMap) { - rawMessageMap.put(dataURI, message); + public void messageGenerated(PlotInfo[] key, String message) { + // Key will be the same PlotInfo[] provided to the generator(which will + // be all the PlotInfo[] from a single station) and message will be the + // sample text. + DataTime normTime = getNormalizedTime(key[0].dataTime); + FrameInformation frameInfo = this.frameMap.get(normTime); + if (frameInfo != null) { + Station s = frameInfo.stationMap.get(key[0].stationId); + if (s != null) { + s.rawMessage = message; + issueRefresh(); + } } - issueRefresh(); } + } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/thread/PlotSampleGeneratorJob.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/thread/PlotSampleGeneratorJob.java index a1b8a02a1c..957a71314d 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/thread/PlotSampleGeneratorJob.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/thread/PlotSampleGeneratorJob.java @@ -43,6 +43,7 @@ import com.raytheon.viz.pointdata.PlotModelFactory2; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 13, 2011 njensen Initial creation + * Jun 25, 2013 1869 bsteffen Fix plot sampling. * * * @@ -82,7 +83,7 @@ public class PlotSampleGeneratorJob extends Job { String message = plotFactory.getStationMessage(infos[0].pdv, infos[0].dataURI); - caller.messageGenerated(infos[0].dataURI, message); + caller.messageGenerated(infos, message); } catch (Exception e) { statusHandler.error("Error creating plot", e); } diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java b/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java index 8c8344d3d4..0ab116e203 100644 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java +++ b/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java @@ -119,6 +119,7 @@ import static java.lang.System.out; * (this fixes the issue of slow performance when zooming all the way in, when Data Area is set) * 10/18/2012 896 sgurung Refactored PlotResource2 to use new generator class: NcPlotDataThreadPool. Added FrameLoaderJob to populate all frames. * Added code to plot stations within 25% of the area outside of the current display area. + * Jun 25, 2013 1869 bsteffen Fix plot sampling. * * * @author brockwoo @@ -1232,7 +1233,7 @@ public class NcPlotResource2 extends AbstractNatlCntrsResource 0.10 * (this fixes the issue of slow performance when zooming all the way in, when Data Area is set) * 11/04/2012 #944 ghull add query for Fcst Plot resources + * Jun 25, 2013 1869 bsteffen Fix plot sampling. * * * @author brockwoo @@ -1084,7 +1085,7 @@ public class PlotResource2 extends AbstractNatlCntrsResource