From a8f3d295c963e293b17162fc5ec69919e6195602 Mon Sep 17 00:00:00 2001 From: Joshua Huber Date: Thu, 11 Jun 2015 15:30:24 +0000 Subject: [PATCH] Merging RM #7787 and #7788 Former-commit-id: e982930e89122c027984b6a14c3e75bf3451a63f --- .../display/D2DNsharpHandleArchiveFile.java | 108 +++++++++--------- .../nsharp/rsc/GribNSharpResourceData.java | 15 ++- 2 files changed, 70 insertions(+), 53 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/display/D2DNsharpHandleArchiveFile.java b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/display/D2DNsharpHandleArchiveFile.java index c1b6928e59..369aa543fd 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/display/D2DNsharpHandleArchiveFile.java +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/display/D2DNsharpHandleArchiveFile.java @@ -24,6 +24,7 @@ import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; import gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor; import gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpResourceHandler; import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpDataHandling; +import gov.noaa.nws.ncep.ui.nsharp.view.NsharpHandleArchiveFile; import java.io.BufferedReader; import java.io.File; @@ -59,6 +60,9 @@ import com.raytheon.uf.viz.core.exception.VizException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 31, 2011 bsteffen Initial creation + * 2/23/2015 RM#5694,7788 Chin Chen Use NCP's Nsharp text file loader + * and comment out openNspFile() + * * * * @@ -114,7 +118,7 @@ public class D2DNsharpHandleArchiveFile { if (isTabular) { openTabularFile(lines); } else { - openNspFile(lines); + NsharpHandleArchiveFile.nsharpParseAndLoadTextFile(fileName);////Task#5694 } } catch (IOException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); @@ -124,57 +128,57 @@ public class D2DNsharpHandleArchiveFile { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } } - - public static void openNspFile(List lines) throws ParseException, - VizException { - // It would have been great to reuse some ncep code here but the parsing - // code is tied to the dialog/loading code. - if (lines.size() < 3) { - throw new VizException("Unrecognized file format"); - } - NsharpStationInfo stninfo = new NsharpStationInfo(); - - // First line is all the metadata - String line = lines.remove(0); - line = line.replaceAll(" +", " "); - String[] values = line.split(" "); - if (values.length == 7) { - stninfo.setSndType(values[1]); - String stationId = values[2]; - String yearMonthDay = values[3]; - String hourMinuteSecond = values[4]; - // looks like "LAT=44.847" - String lat = values[5]; - // looks like "LON=-93.564" - String lon = values[6]; - String dateStr = yearMonthDay + " " + hourMinuteSecond; - Date date = ncepDataFormat.parse(dateStr); - stninfo.setReftime(new Timestamp(date.getTime())); - stninfo.setRangestarttime(new Timestamp(date.getTime())); - stninfo.setStnDisplayInfo(stationId + " " + dateStr); - lat = lat.replace("LAT=", ""); - lon = lon.replace("LON=", ""); - stninfo.setLatitude(Float.parseFloat(lat)); - stninfo.setLongitude(Float.parseFloat(lon)); - } else { - // TODO it might be possible to look at each token and throw - // something together - throw new VizException("Unrecognized data headings"); - } - // Second line is the headings - String headingLine = lines.remove(0); - // The rest of the lines should be data lines. - List dataLines = new ArrayList(); - line = lines.remove(0); - while (!lines.isEmpty()) { - dataLines.add(line); - line = lines.remove(0); - } - - List layers = parseLayers(headingLine, dataLines); - - load(stninfo, layers); - } + //Task#5694: openNspFile() is no longer used. +// public static void openNspFile(List lines) throws ParseException, +// VizException { +// // It would have been great to reuse some ncep code here but the parsing +// // code is tied to the dialog/loading code. +// if (lines.size() < 3) { +// throw new VizException("Unrecognized file format"); +// } +// NsharpStationInfo stninfo = new NsharpStationInfo(); +// +// // First line is all the metadata +// String line = lines.remove(0); +// line = line.replaceAll(" +", " "); +// String[] values = line.split(" "); +// if (values.length == 7) { +// stninfo.setSndType(values[1]); +// String stationId = values[2]; +// String yearMonthDay = values[3]; +// String hourMinuteSecond = values[4]; +// // looks like "LAT=44.847" +// String lat = values[5]; +// // looks like "LON=-93.564" +// String lon = values[6]; +// String dateStr = yearMonthDay + " " + hourMinuteSecond; +// Date date = ncepDataFormat.parse(dateStr); +// stninfo.setReftime(new Timestamp(date.getTime())); +// stninfo.setRangestarttime(new Timestamp(date.getTime())); +// stninfo.setStnDisplayInfo(stationId + " " + dateStr); +// lat = lat.replace("LAT=", ""); +// lon = lon.replace("LON=", ""); +// stninfo.setLatitude(Float.parseFloat(lat)); +// stninfo.setLongitude(Float.parseFloat(lon)); +// } else { +// // TODO it might be possible to look at each token and throw +// // something together +// throw new VizException("Unrecognized data headings"); +// } +// // Second line is the headings +// String headingLine = lines.remove(0); +// // The rest of the lines should be data lines. +// List dataLines = new ArrayList(); +// line = lines.remove(0); +// while (!lines.isEmpty()) { +// dataLines.add(line); +// line = lines.remove(0); +// } +// +// List layers = parseLayers(headingLine, dataLines); +// +// load(stninfo, layers); +// } public static void openTabularFile(List lines) throws ParseException, VizException { diff --git a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/GribNSharpResourceData.java b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/GribNSharpResourceData.java index 9c1abb3efe..b3cfa7d68c 100644 --- a/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/GribNSharpResourceData.java +++ b/cave/com.raytheon.uf.viz.d2d.nsharp/src/com/raytheon/uf/viz/d2d/nsharp/rsc/GribNSharpResourceData.java @@ -22,6 +22,8 @@ package com.raytheon.uf.viz.d2d.nsharp.rsc; import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingCube; import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer; import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConfigManager; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore; import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; @@ -49,6 +51,8 @@ import com.raytheon.uf.viz.core.exception.VizException; * Jul 26, 2011 bsteffen Initial creation * Feb 15, 2013 1638 mschenke Got rid of viz/edex topo classes * and moved into common + * 04/27/2015 RM#6674&7787 Chin Chen support model sounding query data interpolation and nearest point option + * * * * @@ -82,9 +86,18 @@ public class GribNSharpResourceData extends D2DNSharpResourceData { float[][] latLon = { { (float) coordinate.y, (float) coordinate.x } }; String refTimeStr = formatTimestamp(stnInfo.getReftime()); String validTimeStr = formatTimestamp(stnInfo.getRangestarttime()); + //RM#6674 + NsharpConfigManager mgr =NsharpConfigManager.getInstance(); + NsharpConfigStore configStore = mgr.retrieveNsharpConfigStoreFromFs(); + boolean gridInterpolation; + if(configStore != null){ + gridInterpolation = configStore.getGraphProperty().isGridInterpolation(); + } + else + gridInterpolation = true; //by default NcSoundingCube cube = NcSoundingQuery.mdlSoundingQueryByLatLon( refTimeStr, validTimeStr, latLon, "grid", getSoundingType(), - false, "-1"); + false, "-1", gridInterpolation); if ((cube != null) && !cube.getSoundingProfileList().isEmpty()) { NcSoundingProfile profileList = cube.getSoundingProfileList() .get(0);