VLab Issue #3721 - NCEP CAVE plugin delivery for 14.3.1
Updates to various resource plugins such as ncgrid, plotdata, ncscat, and ntrans Change-Id: Ie04200519fad583d2b252ea161cb5c72eb90732c Former-commit-id:2ed94d9f2a
[formerlydc67d789ca
[formerly 6833256be339a9512e9ba11fc018b037ca67f6d9]] Former-commit-id:dc67d789ca
Former-commit-id:1b1996c2be
This commit is contained in:
parent
b3cd8b5f01
commit
458b5eedec
48 changed files with 12024 additions and 8089 deletions
|
@ -2,45 +2,68 @@
|
|||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.gempak.parameterconversionlibrary;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Collections;
|
||||
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer;
|
||||
/**
|
||||
* @author archana
|
||||
*
|
||||
* gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer
|
||||
*
|
||||
* This java class provides sounding data data structure for used with NC sounding query.
|
||||
* Each NcSoundingLayer contain one layer of sounding information (pressure, height, temp, dewpt, windS, windD) for
|
||||
* one point (lat/lon) at a particular time (timeLine) and particular height.
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------- ------- -------- -----------
|
||||
* A. Subramanian Created
|
||||
* 03/2014 1116 T. Lee Added DPD to NcSoundingLayer
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
public class PSLibrary {
|
||||
|
||||
/**
|
||||
* Computes the cross totals index
|
||||
* @param td850 - dewpoint at 850 mb ( in Celsius )
|
||||
* @param t500 - temperature at 500 mb ( in Celsius )
|
||||
* @return the difference between the dewpoint and the temperature if neither of them are missing
|
||||
* and RMISSD ( -9999 ) otherwise.
|
||||
*
|
||||
* @param td850
|
||||
* - dewpoint at 850 mb ( in Celsius )
|
||||
* @param t500
|
||||
* - temperature at 500 mb ( in Celsius )
|
||||
* @return the difference between the dewpoint and the temperature if
|
||||
* neither of them are missing and RMISSD ( -9999 ) otherwise.
|
||||
*/
|
||||
public static float psCtot(float td850, float t500) {
|
||||
|
||||
/*
|
||||
* Compute the cross totals index by subtracting 500 mb
|
||||
* temperature from the 850 mb dewpoint.
|
||||
* Compute the cross totals index by subtracting 500 mb temperature from
|
||||
* the 850 mb dewpoint.
|
||||
*/
|
||||
return ( ( !MissingValueTester.isDataValueMissing(td850)
|
||||
&& !MissingValueTester.isDataValueMissing(t500) )
|
||||
? ( td850 - t500 ) : GempakConstants.RMISSD ) ;
|
||||
return ((!MissingValueTester.isDataValueMissing(td850) && !MissingValueTester
|
||||
.isDataValueMissing(t500)) ? (td850 - t500)
|
||||
: GempakConstants.RMISSD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes low, middle, and high elevation Haines indices
|
||||
* from the temperature and the dewpoint.
|
||||
* @param tc1 - temperature ( in Celsius )
|
||||
* @param tc2 - temperature ( in Celsius )
|
||||
* @param dwpc - dewpoint ( in Celsius )
|
||||
* @param itype - Haines index:
|
||||
* 1- Low
|
||||
* 2 - Middle
|
||||
* 3 - High
|
||||
* Computes low, middle, and high elevation Haines indices from the
|
||||
* temperature and the dewpoint.
|
||||
*
|
||||
* @param tc1
|
||||
* - temperature ( in Celsius )
|
||||
* @param tc2
|
||||
* - temperature ( in Celsius )
|
||||
* @param dwpc
|
||||
* - dewpoint ( in Celsius )
|
||||
* @param itype
|
||||
* - Haines index: 1- Low 2 - Middle 3 - High
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -56,12 +79,10 @@ public class PSLibrary {
|
|||
if (itype == 1) {
|
||||
a = ((tc2 - tc1) - 3) * (2 / 5) + 1;
|
||||
b = ((tc1 - dwpc) - 5) * (2 / 5) + 1;
|
||||
}
|
||||
else if ( itype == 2 ) {
|
||||
} else if (itype == 2) {
|
||||
a = ((tc1 - tc2) - 5) * (2 / 6) + 1;
|
||||
b = ((tc1 - dwpc) - 5) * (2 / 8) + 1;
|
||||
}
|
||||
else if ( itype == 3 ) {
|
||||
} else if (itype == 3) {
|
||||
a = ((tc1 - tc2) - 17) * (2 / 5) + 1;
|
||||
b = ((tc1 - dwpc) - 14) * (2 / 7) + 1;
|
||||
}
|
||||
|
@ -78,15 +99,22 @@ public class PSLibrary {
|
|||
/**
|
||||
*
|
||||
* Computes the 'K' index
|
||||
* @param t850 - 850 mb temperature ( in Celsius )
|
||||
* @param t700 - 700 mb temperature ( in Celsius )
|
||||
* @param t500 - 500 mb temperature ( in Celsius )
|
||||
* @param td850 - 850 mb dewpoint ( in Celsius )
|
||||
* @param td700 - 700 mb dewpoint ( in Celsius )
|
||||
*
|
||||
* @param t850
|
||||
* - 850 mb temperature ( in Celsius )
|
||||
* @param t700
|
||||
* - 700 mb temperature ( in Celsius )
|
||||
* @param t500
|
||||
* - 500 mb temperature ( in Celsius )
|
||||
* @param td850
|
||||
* - 850 mb dewpoint ( in Celsius )
|
||||
* @param td700
|
||||
* - 700 mb dewpoint ( in Celsius )
|
||||
* @return returns the 'K' index if all the input values are valid and
|
||||
* RMISSD ( -9999 ) otherwise
|
||||
*/
|
||||
public static float pskinx ( float t850, float t700, float t500, float td850, float td700) {
|
||||
public static float pskinx(float t850, float t700, float t500, float td850,
|
||||
float td700) {
|
||||
float pskinx = GempakConstants.RMISSD;
|
||||
if (!MissingValueTester.isDataValueMissing(td700)
|
||||
&& !MissingValueTester.isDataValueMissing(td850)
|
||||
|
@ -98,14 +126,18 @@ public class PSLibrary {
|
|||
return pskinx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computes the Showalter index
|
||||
* @param t850 - 850 mb temperature ( in Celsius )
|
||||
* @param td850 - 850 mb dewpoint ( in Celsius )
|
||||
* @param t500 - 500 mb temperature ( in Celsius )
|
||||
* @return the Showalter index if all the three input parameters are valid and the parcel temperature is computed correctly.
|
||||
* Otherwise, it returns RMISSD (-9999).
|
||||
*
|
||||
* @param t850
|
||||
* - 850 mb temperature ( in Celsius )
|
||||
* @param td850
|
||||
* - 850 mb dewpoint ( in Celsius )
|
||||
* @param t500
|
||||
* - 500 mb temperature ( in Celsius )
|
||||
* @return the Showalter index if all the three input parameters are valid
|
||||
* and the parcel temperature is computed correctly. Otherwise, it
|
||||
* returns RMISSD (-9999).
|
||||
*/
|
||||
public static float psShow(float t850, float td850, float t500) {
|
||||
float psshow = GempakConstants.RMISSD;
|
||||
|
@ -121,13 +153,18 @@ public class PSLibrary {
|
|||
*/
|
||||
float thtlcl = PRLibrary.prThte(p850, t850, td850);
|
||||
|
||||
/*Find parcel temperature along pseudoadiabat at 500 mb.
|
||||
* The parcel temperature tp is the temperature in Celsius at 500 mb of a parcel,
|
||||
* which lies on the moist adiabat determined by the sounding at 850 mb
|
||||
/*
|
||||
* Find parcel temperature along pseudoadiabat at 500 mb. The parcel
|
||||
* temperature tp is the temperature in Celsius at 500 mb of a
|
||||
* parcel, which lies on the moist adiabat determined by the
|
||||
* sounding at 850 mb
|
||||
*/
|
||||
float tp = PRLibrary.prTmst(thtlcl, p500, guess);
|
||||
|
||||
/*Subtract the parcel temperature from the temperature at 500 mb, is the parcel temperature is valid*/
|
||||
/*
|
||||
* Subtract the parcel temperature from the temperature at 500 mb,
|
||||
* is the parcel temperature is valid
|
||||
*/
|
||||
if (!MissingValueTester.isDataValueMissing(tp)) {
|
||||
psshow = PRLibrary.prTmck(t500) - tp;
|
||||
}
|
||||
|
@ -137,24 +174,33 @@ public class PSLibrary {
|
|||
|
||||
/**
|
||||
* Computes the vertical totals index
|
||||
* @param t850 - 850 mb temperature ( in Celsius )
|
||||
* @param t500 - 500 mb temperature ( in Celsius )
|
||||
* @return the verticl totals index as a difference of the temperature at 850 mb and the temperature at 500 mb, if neither value is missing.
|
||||
* Else it returns RMISSD (-9999)
|
||||
*
|
||||
* @param t850
|
||||
* - 850 mb temperature ( in Celsius )
|
||||
* @param t500
|
||||
* - 500 mb temperature ( in Celsius )
|
||||
* @return the verticl totals index as a difference of the temperature at
|
||||
* 850 mb and the temperature at 500 mb, if neither value is
|
||||
* missing. Else it returns RMISSD (-9999)
|
||||
*/
|
||||
public static float psVtot(float t850, float t500) {
|
||||
return ( ( !MissingValueTester.isDataValueMissing( t500 ) && !MissingValueTester.isDataValueMissing( t850 ) )
|
||||
? t850 - t500 : GempakConstants.RMISSD );
|
||||
return ((!MissingValueTester.isDataValueMissing(t500) && !MissingValueTester
|
||||
.isDataValueMissing(t850)) ? t850 - t500
|
||||
: GempakConstants.RMISSD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the total Totals index from the temperature and dewpoint at 850 mb and the temperature at 500 mb
|
||||
* Computes the total Totals index from the temperature and dewpoint at 850
|
||||
* mb and the temperature at 500 mb
|
||||
*
|
||||
* @param t850 - 850 mb temperature ( in Celsius )
|
||||
* @param td850 - 850 mb dewpoint ( in Celsius )
|
||||
* @param t500 - 500 mb temperature ( in Celsius )
|
||||
* @return the total totals index if none of the input parameters are missing and
|
||||
* RMISSD (-9999) otherwise
|
||||
* @param t850
|
||||
* - 850 mb temperature ( in Celsius )
|
||||
* @param td850
|
||||
* - 850 mb dewpoint ( in Celsius )
|
||||
* @param t500
|
||||
* - 500 mb temperature ( in Celsius )
|
||||
* @return the total totals index if none of the input parameters are
|
||||
* missing and RMISSD (-9999) otherwise
|
||||
*/
|
||||
public static float psTotl(float t850, float td850, float t500) {
|
||||
float pstotl = GempakConstants.RMISSD;
|
||||
|
@ -178,16 +224,26 @@ public class PSLibrary {
|
|||
|
||||
/**
|
||||
* Computes the SWEAT index. Winds must be input in m/sec
|
||||
* @param t850 - 850 mb temperature
|
||||
* @param td850 - 850 mb dewpoint
|
||||
* @param t500 - 500 mb temperature
|
||||
* @param spd850 - 850 mb windspeed ( in m/sec )
|
||||
* @param spd500 - 500 mb windspeed ( in m/sec )
|
||||
* @param dir850 - 850 mb wind direction
|
||||
* @param dir500 - 500 mb wind direction
|
||||
* @return the SWEAT index if none of the inputs are missing and RMISSD ( -9999 ) otherwise
|
||||
*
|
||||
* @param t850
|
||||
* - 850 mb temperature
|
||||
* @param td850
|
||||
* - 850 mb dewpoint
|
||||
* @param t500
|
||||
* - 500 mb temperature
|
||||
* @param spd850
|
||||
* - 850 mb windspeed ( in m/sec )
|
||||
* @param spd500
|
||||
* - 500 mb windspeed ( in m/sec )
|
||||
* @param dir850
|
||||
* - 850 mb wind direction
|
||||
* @param dir500
|
||||
* - 500 mb wind direction
|
||||
* @return the SWEAT index if none of the inputs are missing and RMISSD (
|
||||
* -9999 ) otherwise
|
||||
*/
|
||||
public static float psSwet ( float t850, float td850, float t500, float spd850, float spd500, float dir850, float dir500 ){
|
||||
public static float psSwet(float t850, float td850, float t500,
|
||||
float spd850, float spd500, float dir850, float dir500) {
|
||||
float pssweat = GempakConstants.RMISSD;
|
||||
if (!MissingValueTester.isDataValueMissing(dir500)
|
||||
&& !MissingValueTester.isDataValueMissing(dir850)
|
||||
|
@ -197,10 +253,9 @@ public class PSLibrary {
|
|||
&& !MissingValueTester.isDataValueMissing(td850)
|
||||
&& !MissingValueTester.isDataValueMissing(t850)) {
|
||||
/*
|
||||
* (Non-Javadoc):
|
||||
* All computations are from
|
||||
* Miller, R.C., 1972: Notes on Severe Storm Forecasting Procedures of
|
||||
* the Air Force Global Weather Central, AWS Tech. Report 200
|
||||
* (Non-Javadoc): All computations are from Miller, R.C., 1972:
|
||||
* Notes on Severe Storm Forecasting Procedures of the Air Force
|
||||
* Global Weather Central, AWS Tech. Report 200
|
||||
*/
|
||||
/* Convert meters per second to knots */
|
||||
float skt850 = PRLibrary.prMskn(spd850);
|
||||
|
@ -240,17 +295,27 @@ public class PSLibrary {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds the most unstable level of a sounding from the surface to the input pressure level.
|
||||
* @param listOfNcSoundingLayer - the list of NcSoundingLayer to search
|
||||
* @param plev - input pressure level
|
||||
* @return the most unstable level of a sounding from the surface to the input pressure level (plev),
|
||||
* if plev is not -1 and all computations fall through correctly.Else it returns an empty NcSoundingLayer object
|
||||
* Finds the most unstable level of a sounding from the surface to the input
|
||||
* pressure level.
|
||||
*
|
||||
* @param listOfNcSoundingLayer
|
||||
* - the list of NcSoundingLayer to search
|
||||
* @param plev
|
||||
* - input pressure level
|
||||
* @return the most unstable level of a sounding from the surface to the
|
||||
* input pressure level (plev), if plev is not -1 and all
|
||||
* computations fall through correctly.Else it returns an empty
|
||||
* NcSoundingLayer object
|
||||
*/
|
||||
public static NcSoundingLayer psUstb(List<NcSoundingLayer> listOfNcSoundingLayer, float plev ){
|
||||
public static NcSoundingLayer psUstb(
|
||||
List<NcSoundingLayer> listOfNcSoundingLayer, float plev) {
|
||||
// TODO: update to find pressure value between 2 levels
|
||||
NcSoundingLayer outputNcSoundingLayer = new NcSoundingLayer(GempakConstants.RMISSD, GempakConstants.RMISSD,GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD,GempakConstants.RMISSD,GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD,GempakConstants.RMISSD,GempakConstants.RMISSD,
|
||||
NcSoundingLayer outputNcSoundingLayer = new NcSoundingLayer(
|
||||
GempakConstants.RMISSD, GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD, GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD, GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD, GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD, GempakConstants.RMISSD,
|
||||
GempakConstants.RMISSD, GempakConstants.RMISSD);
|
||||
class PressureComparator implements Comparator<NcSoundingLayer> {
|
||||
public int compare(NcSoundingLayer n1, NcSoundingLayer n2) {
|
||||
|
@ -259,9 +324,12 @@ public class PSLibrary {
|
|||
}
|
||||
if (listOfNcSoundingLayer != null && listOfNcSoundingLayer.size() > 0) {
|
||||
Collections.sort(listOfNcSoundingLayer, new PressureComparator());
|
||||
NcSoundingLayer surfaceLevelNcSoundingLayer = listOfNcSoundingLayer.get( 0 );
|
||||
float pressureAtSurfaceLevel = surfaceLevelNcSoundingLayer.getPressure();
|
||||
NcSoundingLayer topLevelNcSoundingLayer = PCLibrary.pcFtop( listOfNcSoundingLayer );
|
||||
NcSoundingLayer surfaceLevelNcSoundingLayer = listOfNcSoundingLayer
|
||||
.get(0);
|
||||
float pressureAtSurfaceLevel = surfaceLevelNcSoundingLayer
|
||||
.getPressure();
|
||||
NcSoundingLayer topLevelNcSoundingLayer = PCLibrary
|
||||
.pcFtop(listOfNcSoundingLayer);
|
||||
float pressureAtTopLevel = topLevelNcSoundingLayer.getPressure();
|
||||
|
||||
if (plev > pressureAtSurfaceLevel)
|
||||
|
@ -269,14 +337,14 @@ public class PSLibrary {
|
|||
else if (plev == -1 || plev <= pressureAtTopLevel)
|
||||
plev = pressureAtTopLevel;
|
||||
|
||||
|
||||
int sizeOfList = listOfNcSoundingLayer.size();
|
||||
boolean done = false;
|
||||
int lev = 0;
|
||||
float eps = GempakConstants.RMISSD;
|
||||
|
||||
while (!done && lev < sizeOfList) {
|
||||
NcSoundingLayer currNcSoundingLayer = listOfNcSoundingLayer.get(lev);
|
||||
NcSoundingLayer currNcSoundingLayer = listOfNcSoundingLayer
|
||||
.get(lev);
|
||||
|
||||
float pressure = currNcSoundingLayer.getPressure();
|
||||
float tmpc = currNcSoundingLayer.getTemperature();
|
||||
|
@ -286,16 +354,26 @@ public class PSLibrary {
|
|||
System.out.println("thwc = " + thwc);
|
||||
if (thwc > eps && (pressure >= plev)) {
|
||||
eps = thwc;
|
||||
outputNcSoundingLayer.setPressure( currNcSoundingLayer.getPressure() );
|
||||
outputNcSoundingLayer.setTemperature( currNcSoundingLayer.getTemperature() );
|
||||
outputNcSoundingLayer.setDewpoint( currNcSoundingLayer.getDewpoint() );
|
||||
outputNcSoundingLayer.setWindSpeed( currNcSoundingLayer.getWindSpeed() );
|
||||
outputNcSoundingLayer.setWindDirection( currNcSoundingLayer.getWindDirection() );
|
||||
outputNcSoundingLayer.setWindU( currNcSoundingLayer.getWindU() );
|
||||
outputNcSoundingLayer.setWindV( currNcSoundingLayer.getWindV() );
|
||||
outputNcSoundingLayer.setGeoHeight( currNcSoundingLayer.getGeoHeight() );
|
||||
outputNcSoundingLayer.setOmega( currNcSoundingLayer.getOmega() );
|
||||
outputNcSoundingLayer.setSpecHumidity( currNcSoundingLayer.getSpecHumidity() );
|
||||
outputNcSoundingLayer.setPressure(currNcSoundingLayer
|
||||
.getPressure());
|
||||
outputNcSoundingLayer.setTemperature(currNcSoundingLayer
|
||||
.getTemperature());
|
||||
outputNcSoundingLayer.setDewpoint(currNcSoundingLayer
|
||||
.getDewpoint());
|
||||
outputNcSoundingLayer.setWindSpeed(currNcSoundingLayer
|
||||
.getWindSpeed());
|
||||
outputNcSoundingLayer.setWindDirection(currNcSoundingLayer
|
||||
.getWindDirection());
|
||||
outputNcSoundingLayer.setWindU(currNcSoundingLayer
|
||||
.getWindU());
|
||||
outputNcSoundingLayer.setWindV(currNcSoundingLayer
|
||||
.getWindV());
|
||||
outputNcSoundingLayer.setGeoHeight(currNcSoundingLayer
|
||||
.getGeoHeight());
|
||||
outputNcSoundingLayer.setOmega(currNcSoundingLayer
|
||||
.getOmega());
|
||||
outputNcSoundingLayer.setSpecHumidity(currNcSoundingLayer
|
||||
.getSpecHumidity());
|
||||
System.out.println("Outdat: "
|
||||
+ outputNcSoundingLayer.getPressure() + " "
|
||||
+ outputNcSoundingLayer.getTemperature() + " "
|
||||
|
@ -320,33 +398,4 @@ public class PSLibrary {
|
|||
return outputNcSoundingLayer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import gov.noaa.nws.ncep.gempak.parameters.core.contourinterval.ContourStringParser;
|
||||
|
||||
/**
|
||||
* CINT accepts strings (in its overloaded constructor) matching one of the two formats below:
|
||||
* CINT accepts strings (in its overloaded constructor) matching one of the two
|
||||
* formats below:
|
||||
*
|
||||
* <pre>
|
||||
* <tt> contourInterval/minimumContourValue/maximumContourValue/numPaddingDigits<p>
|
||||
* contourVal1;contourVal2;...;contourValn
|
||||
|
@ -26,6 +26,7 @@ import gov.noaa.nws.ncep.gempak.parameters.core.contourinterval.ContourStringPar
|
|||
* advised that the user checks the result of the method <tt>isCINTStringParsed()</tt>.
|
||||
* </pre>
|
||||
* <p>
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
|
@ -44,9 +45,12 @@ import gov.noaa.nws.ncep.gempak.parameters.core.contourinterval.ContourStringPar
|
|||
* min and max contour values separately from each zoom level.
|
||||
* Implemented each zoom level as a CNT object in a list of CINT objects.
|
||||
* 17-May-2011 M. Li Created a parseCINT to simplify CINT parsing.
|
||||
* 07-Apr-2014 TTR-938 D.Sushon Added check for null string to constructor, fixing NullPointerException
|
||||
* thrown when attempting to initialize with null String.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author Archana.S
|
||||
* @version 1
|
||||
* @see $GEMPAK/help/hlx/cint.hl2
|
||||
|
@ -71,13 +75,15 @@ public class CINT {
|
|||
/** Boolean flag to validate that the CINT string was parsed correctly */
|
||||
private boolean isCINTStringParsed;
|
||||
|
||||
/**An integer that decides the minimum number of digits in an integer contour label*/
|
||||
/**
|
||||
* An integer that decides the minimum number of digits in an integer
|
||||
* contour label
|
||||
*/
|
||||
private Integer numPaddingDigits;
|
||||
|
||||
/**The un-parsed CINT string entered by the user */
|
||||
/** The unparsed CINT string entered by the user */
|
||||
String userInputString;
|
||||
|
||||
|
||||
public String getUserInputString() {
|
||||
return userInputString;
|
||||
}
|
||||
|
@ -95,7 +101,10 @@ public class CINT {
|
|||
/** The list of contour values represented as String objects */
|
||||
private List<String> contourValuesListAsString;
|
||||
|
||||
/**The list of extracted contour labels. For CINT strings without labels, it is the contour value stored as its String equivalent*/
|
||||
/**
|
||||
* The list of extracted contour labels. For CINT strings without labels, it
|
||||
* is the contour value stored as its String equivalent
|
||||
*/
|
||||
private List<String> contourLabelList;
|
||||
|
||||
private List<String> getContourLabelList() {
|
||||
|
@ -115,20 +124,25 @@ public class CINT {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code HashMap<Double, String>} of the contour values and labels for a specific zoom level
|
||||
* @param The zoom level
|
||||
* @return The {@code HashMap<Double, String>} of the contour values and labels for the input zoom level
|
||||
* if the CINT object for that zoom level exists or an empty map otherwise.
|
||||
* Gets the {@code HashMap<Double, String>} of the contour values and labels
|
||||
* for a specific zoom level
|
||||
*
|
||||
* @param The
|
||||
* zoom level
|
||||
* @return The {@code HashMap<Double, String>} of the contour values and
|
||||
* labels for the input zoom level if the CINT object for that zoom
|
||||
* level exists or an empty map otherwise.
|
||||
* */
|
||||
public Map<Double, String> getCintHashMap(ZoomLevel zLevel) {
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
Map <Double,String> thisMap = new HashMap<Double,String>(this.listOfCINTObjects.get( zLevel.zoomLevel - 1).cintHashMap);
|
||||
Map<Double, String> thisMap = new HashMap<Double, String>(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).cintHashMap);
|
||||
if (thisMap.size() > 0) {
|
||||
return (thisMap);
|
||||
}
|
||||
}
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -139,23 +153,27 @@ public class CINT {
|
|||
this.cintHashMap = cintHashMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the {@code List<Double>} of the contour values for a specific zoom level
|
||||
* @param the zoom level
|
||||
* @return The {@code List<Double>} of the contour values for the input zoom level
|
||||
* if the CINT object for that zoom level exists or an empty list otherwise.
|
||||
* Gets the {@code List<Double>} of the contour values for a specific zoom
|
||||
* level
|
||||
*
|
||||
* @param the
|
||||
* zoom level
|
||||
* @return The {@code List<Double>} of the contour values for the input zoom
|
||||
* level if the CINT object for that zoom level exists or an empty
|
||||
* list otherwise.
|
||||
* */
|
||||
public List<Double> getContourValuesListAsDouble(ZoomLevel zLevel) {
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
List<Double> cList = new ArrayList<Double>(this.listOfCINTObjects.get(zLevel.zoomLevel - 1).contourValuesList);
|
||||
List<Double> cList = new ArrayList<Double>(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).contourValuesList);
|
||||
if (cList.size() > 0) {
|
||||
return (new ArrayList<Double>(cList));
|
||||
}
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -170,9 +188,11 @@ public class CINT {
|
|||
public static enum ZoomLevel {
|
||||
FIRST(1), SECOND(2), THIRD(3), FOURTH(4), FIFTH(5);
|
||||
private int zoomLevel;
|
||||
|
||||
private ZoomLevel(int index) {
|
||||
this.zoomLevel = index;
|
||||
}
|
||||
|
||||
public int getZoomLevelAsInt() {
|
||||
return zoomLevel;
|
||||
}
|
||||
|
@ -193,44 +213,61 @@ public class CINT {
|
|||
/** Zoom constant representing the fifth zoom level */
|
||||
public static final ZoomLevel FIFTH_ZOOM_LEVEL = ZoomLevel.FIFTH;
|
||||
|
||||
/**Zoom constant representing the first zoom level as the minimum level of zoom*/
|
||||
/**
|
||||
* Zoom constant representing the first zoom level as the minimum level of
|
||||
* zoom
|
||||
*/
|
||||
public static final ZoomLevel MIN_ZOOM_LEVEL = ZoomLevel.FIRST;
|
||||
|
||||
/**Zoom constant representing the fifth zoom levelas the maximum level of zooom*/
|
||||
/**
|
||||
* Zoom constant representing the fifth zoom level as the maximum level of
|
||||
* zoom
|
||||
*/
|
||||
public static final ZoomLevel MAX_ZOOM_LEVEL = ZoomLevel.FIFTH;
|
||||
|
||||
/**
|
||||
* Gets the {@code List<String>} of the contour values for a specific zoom level
|
||||
* @param the zoom level
|
||||
* @return The {@code List<String>} of the contour values for the input zoom level
|
||||
* if the CINT object for that zoom level exists or an empty list otherwise.
|
||||
* Gets the {@code List<String>} of the contour values for a specific zoom
|
||||
* level
|
||||
*
|
||||
* @param the
|
||||
* zoom level
|
||||
* @return The {@code List<String>} of the contour values for the input zoom
|
||||
* level if the CINT object for that zoom level exists or an empty
|
||||
* list otherwise.
|
||||
* */
|
||||
public List<String> getContourValuesListAsString(ZoomLevel zLevel) {
|
||||
List<String> cvList = Collections.EMPTY_LIST;
|
||||
List<String> cvList = Collections.emptyList();
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize > 0 && listSize >= zLevel.zoomLevel) {
|
||||
cvList = new ArrayList<String>(this.listOfCINTObjects.get(zLevel.zoomLevel - 1).contourValuesListAsString);
|
||||
cvList = new ArrayList<String>(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).contourValuesListAsString);
|
||||
}
|
||||
return cvList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code List<String>} of the contour labels for a specific zoom level
|
||||
* @param the zoom level
|
||||
* @return The {@code List<String>} of the contour labels for the input zoom level
|
||||
* if the CINT object for that zoom level exists or an empty list otherwise.
|
||||
* Gets the {@code List<String>} of the contour labels for a specific zoom
|
||||
* level
|
||||
*
|
||||
* @param the
|
||||
* zoom level
|
||||
* @return The {@code List<String>} of the contour labels for the input zoom
|
||||
* level if the CINT object for that zoom level exists or an empty
|
||||
* list otherwise.
|
||||
* */
|
||||
public List<String> getContourLabelsForZoomLevel(ZoomLevel zLevel) {
|
||||
List<String> cintLabelList = new ArrayList<String>(0);
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
cintLabelList = new ArrayList<String>(this.listOfCINTObjects.get( zLevel.zoomLevel-1).getContourLabelList());
|
||||
cintLabelList = new ArrayList<String>(this.listOfCINTObjects.get(
|
||||
zLevel.zoomLevel - 1).getContourLabelList());
|
||||
}
|
||||
return cintLabelList;
|
||||
}
|
||||
|
||||
/**
|
||||
*The default constructor initializes the instance variables to their defaults
|
||||
* The default constructor initializes the instance variables to their
|
||||
* defaults
|
||||
**/
|
||||
public CINT() {
|
||||
setContourInterval(Double.NaN);
|
||||
|
@ -244,15 +281,14 @@ public class CINT {
|
|||
contourLabelList = new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// *The overloaded constructor accepts the CINT string as an input and calls the parse method of the
|
||||
// *ContourStringParser on it.
|
||||
// *If the parsing is successful, the contour interval, minimum contour level, maximum
|
||||
// *contour level and the list of contour values will be populated by the corresponding parsed
|
||||
// *data from the ContourStringParser object.
|
||||
// *
|
||||
// **/
|
||||
/**
|
||||
* The overloaded constructor accepts the CINT string as an input and calls
|
||||
* the parse method of the ContourStringParser on it. If the parsing is
|
||||
* successful, the contour interval, minimum contour level, maximum contour
|
||||
* level and the list of contour values will be populated by the
|
||||
* corresponding parsed data from the ContourStringParser object.
|
||||
*
|
||||
**/
|
||||
public CINT(String contourIntervalString) {
|
||||
|
||||
/* Initialize instance variables */
|
||||
|
@ -263,13 +299,43 @@ public class CINT {
|
|||
contourValuesListAsString = new ArrayList<String>(0);
|
||||
contourLabelList = new ArrayList<String>(0);
|
||||
|
||||
if (null == contourIntervalString) {
|
||||
isCINTStringParsed = false;
|
||||
cintParser = new ContourStringParser();
|
||||
cintHashMap = new HashMap<Double, String>(0);
|
||||
} else {
|
||||
setUserInputString(contourIntervalString);
|
||||
cintParser = new ContourStringParser();
|
||||
}
|
||||
|
||||
parseAndSetAttributes(contourIntervalString);
|
||||
|
||||
}
|
||||
|
||||
public static List<Double> parseCINT(String cint, int zoomLevelIndex, float minValue, float maxValue) {
|
||||
public static List<Double> parseCINT(String cint, int zoomLevelIndex,
|
||||
float minValue, float maxValue) {
|
||||
|
||||
List<Double> cvalues = null;
|
||||
Double dcint = null;
|
||||
int comparison = 0;
|
||||
|
||||
/*
|
||||
* Check cint for a zero value
|
||||
*/
|
||||
|
||||
try {
|
||||
dcint = new Double(cint);
|
||||
comparison = dcint.compareTo(new Double(0));
|
||||
|
||||
if (comparison == 0) {
|
||||
// cint is zero, return an empty list, no contours
|
||||
cvalues = new ArrayList<Double>(0);
|
||||
return cvalues;
|
||||
}
|
||||
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert zoomLevel index
|
||||
|
@ -294,31 +360,37 @@ public class CINT {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get contour values from CINT
|
||||
*/
|
||||
List<Double> cvalues = null;
|
||||
|
||||
Double cmin = new Double(minValue);
|
||||
Double cmax = new Double(maxValue);
|
||||
Double interval = null;
|
||||
|
||||
if (cint == null || cint.trim().length() < 1) {
|
||||
interval = (cmax - cmin) / 10.0;
|
||||
CINT contourInfo = new CINT(interval.toString()+"/"+cmin.toString()+"/"+cmax.toString());
|
||||
cvalues = contourInfo.getUniqueSortedContourValuesFromAllZoomLevels();
|
||||
}
|
||||
else {
|
||||
CINT contourInfo = new CINT(interval.toString() + "/"
|
||||
+ cmin.toString() + "/" + cmax.toString());
|
||||
cvalues = contourInfo
|
||||
.getUniqueSortedContourValuesFromAllZoomLevels();
|
||||
} else {
|
||||
CINT contourInfo = new CINT(cint);
|
||||
cvalues = contourInfo.getContourValuesListAsDouble(zoomLevel);
|
||||
|
||||
if (cvalues == null || cvalues.size() < 1 /*|| contourInfo.getContourInterval(zoomLevel) == 0.0*/) {
|
||||
if (cvalues == null || cvalues.size() < 1 /*
|
||||
* || contourInfo.
|
||||
* getContourInterval
|
||||
* (zoomLevel) == 0.0
|
||||
*/) {
|
||||
|
||||
cmin = contourInfo.getMinContourValue(zoomLevel);
|
||||
if (cmin == null || cmin.isNaN()) cmin = new Double( minValue );
|
||||
if (cmin == null || cmin.isNaN())
|
||||
cmin = new Double(minValue);
|
||||
|
||||
cmax = contourInfo.getMaxContourValue(zoomLevel);
|
||||
if (cmax == null || cmax.isNaN()) cmax = new Double( maxValue );
|
||||
if (cmax == null || cmax.isNaN())
|
||||
cmax = new Double(maxValue);
|
||||
|
||||
interval = contourInfo.getContourInterval(zoomLevel);
|
||||
if (interval == null || interval.isNaN()) {
|
||||
|
@ -326,11 +398,14 @@ public class CINT {
|
|||
}
|
||||
|
||||
// Only allow less than 50 contour levels
|
||||
if ((cmax - cmin)/interval > 50) interval = (cmax - cmin)/50;
|
||||
if ((cmax - cmin) / interval > 50)
|
||||
interval = (cmax - cmin) / 50;
|
||||
|
||||
// System.out.println(" cmax=="+cmax);
|
||||
contourInfo = new CINT(interval.toString()+"/"+cmin.toString()+"/"+cmax.toString());
|
||||
cvalues = contourInfo.getUniqueSortedContourValuesFromAllZoomLevels();
|
||||
contourInfo = new CINT(interval.toString() + "/"
|
||||
+ cmin.toString() + "/" + cmax.toString());
|
||||
cvalues = contourInfo
|
||||
.getUniqueSortedContourValuesFromAllZoomLevels();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,74 +418,81 @@ public class CINT {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return The portion of the parsed CINT string specific to a zoom level
|
||||
* if the CINT object for that zoom level exists or an empty String otherwise.
|
||||
* @return The portion of the parsed CINT string specific to a zoom level if
|
||||
* the CINT object for that zoom level exists or an empty String
|
||||
* otherwise.
|
||||
* */
|
||||
public String getCINTString(ZoomLevel zLevel) {
|
||||
String currentCINTString = "";
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
currentCINTString = new String ( this.listOfCINTObjects.get(zLevel.zoomLevel-1).contourIntervalString);
|
||||
currentCINTString = new String(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).contourIntervalString);
|
||||
}
|
||||
return currentCINTString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The contour interval specific to a zoom level
|
||||
* if the CINT object for that zoom level exists or NaN otherwise.
|
||||
* @return The contour interval specific to a zoom level if the CINT object
|
||||
* for that zoom level exists or NaN otherwise.
|
||||
* */
|
||||
public Double getContourInterval(ZoomLevel zLevel) {
|
||||
Double currentContourInterval = Double.NaN;
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
currentContourInterval = new Double ( this.listOfCINTObjects.get(zLevel.zoomLevel-1).contourInterval);
|
||||
currentContourInterval = new Double(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).contourInterval);
|
||||
}
|
||||
return currentContourInterval;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The minimum contour value specific to a zoom level
|
||||
* if the CINT object for that zoom level exists or NaN otherwise.
|
||||
* @return The minimum contour value specific to a zoom level if the CINT
|
||||
* object for that zoom level exists or NaN otherwise.
|
||||
* */
|
||||
public Double getMinContourValue(ZoomLevel zLevel) {
|
||||
Double currentMinContourValue = Double.NaN;
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
currentMinContourValue = new Double ( this.listOfCINTObjects.get(zLevel.zoomLevel-1).minContourValue);
|
||||
currentMinContourValue = new Double(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).minContourValue);
|
||||
}
|
||||
return currentMinContourValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The maximum contour value specific to a zoom level
|
||||
* if the CINT object for that zoom level exists or NaN otherwise.
|
||||
* @return The maximum contour value specific to a zoom level if the CINT
|
||||
* object for that zoom level exists or NaN otherwise.
|
||||
* */
|
||||
public Double getMaxContourValue(ZoomLevel zLevel) {
|
||||
Double currentMaxContourValue = Double.NaN;
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
currentMaxContourValue = new Double ( this.listOfCINTObjects.get(zLevel.zoomLevel-1).maxContourValue);
|
||||
currentMaxContourValue = new Double(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).maxContourValue);
|
||||
}
|
||||
return currentMaxContourValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The minimum digits in the label for contour values specific to a zoom level
|
||||
* if the CINT object for that zoom level exists or 0 otherwise.
|
||||
* @return The minimum digits in the label for contour values specific to a
|
||||
* zoom level if the CINT object for that zoom level exists or 0
|
||||
* otherwise.
|
||||
* */
|
||||
public Integer getNumPaddingDigits(ZoomLevel zLevel) {
|
||||
Integer currentNumPaddingDigits = new Integer(0);
|
||||
int listSize = this.listOfCINTObjects.size();
|
||||
if (listSize >= zLevel.zoomLevel) {
|
||||
currentNumPaddingDigits = new Integer ( this.listOfCINTObjects.get(zLevel.zoomLevel-1).numPaddingDigits);
|
||||
currentNumPaddingDigits = new Integer(
|
||||
this.listOfCINTObjects.get(zLevel.zoomLevel - 1).numPaddingDigits);
|
||||
}
|
||||
return currentNumPaddingDigits;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return a list String objects representing the unique contour values from all zoom levels
|
||||
* @return a list String objects representing the unique contour values from
|
||||
* all zoom levels
|
||||
*/
|
||||
public List<String> getUniqueSortedContourValuesFromAllZoomLevelsAsString() {
|
||||
List<Double> sortedKeySet = getUniqueSortedContourValuesFromAllZoomLevels();
|
||||
|
@ -425,7 +507,8 @@ public class CINT {
|
|||
|
||||
/***
|
||||
*
|
||||
* @return a list of Double objects representing the unique contour values from all zoom levels
|
||||
* @return a list of Double objects representing the unique contour values
|
||||
* from all zoom levels
|
||||
*/
|
||||
public List<Double> getUniqueSortedContourValuesFromAllZoomLevels() {
|
||||
Set<Double> setOfUnqiueContourValues = new HashSet<Double>(0);
|
||||
|
@ -442,7 +525,8 @@ public class CINT {
|
|||
return sortedList;
|
||||
}
|
||||
|
||||
private void setContourValuesListAsString(List<String> contourValuesListAsString) {
|
||||
private void setContourValuesListAsString(
|
||||
List<String> contourValuesListAsString) {
|
||||
this.contourValuesListAsString = contourValuesListAsString;
|
||||
}
|
||||
|
||||
|
@ -451,28 +535,41 @@ public class CINT {
|
|||
this.isCINTStringParsed = isCINTStringParsed;
|
||||
}
|
||||
|
||||
/**@param String cintString*/
|
||||
/**
|
||||
* @param String
|
||||
* cintString
|
||||
*/
|
||||
private void setCINTString(String cintString) {
|
||||
contourIntervalString = new String(cintString);
|
||||
}
|
||||
|
||||
/**@param Double contourInterval*/
|
||||
/**
|
||||
* @param Double
|
||||
* contourInterval
|
||||
*/
|
||||
private void setContourInterval(Double contourInterval) {
|
||||
this.contourInterval = new Double(contourInterval);
|
||||
}
|
||||
|
||||
/**@param Double minContourValue*/
|
||||
/**
|
||||
* @param Double
|
||||
* minContourValue
|
||||
*/
|
||||
private void setMinContourValue(Double minContourValue) {
|
||||
this.minContourValue = new Double(minContourValue);
|
||||
}
|
||||
|
||||
/**@param Double maxContourValue */
|
||||
/**
|
||||
* @param Double
|
||||
* maxContourValue
|
||||
*/
|
||||
private void setMaxContourValue(Double maxContourValue) {
|
||||
this.maxContourValue = new Double(maxContourValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*@param Integer numPaddingDigits
|
||||
* @param Integer
|
||||
* numPaddingDigits
|
||||
**/
|
||||
private void setNumPaddingDigits(Integer numPaddingDigits) {
|
||||
this.numPaddingDigits = new Integer(numPaddingDigits);
|
||||
|
@ -491,7 +588,8 @@ public class CINT {
|
|||
lengthOfContourLevelStringsArray = CINT.MAX_ZOOM_LEVEL.zoomLevel;
|
||||
}
|
||||
|
||||
listOfCINTObjects = new ArrayList<CINT>(lengthOfContourLevelStringsArray);
|
||||
listOfCINTObjects = new ArrayList<CINT>(
|
||||
lengthOfContourLevelStringsArray);
|
||||
|
||||
for (int index = 0; index < lengthOfContourLevelStringsArray; index++) {
|
||||
|
||||
|
@ -500,25 +598,41 @@ public class CINT {
|
|||
|
||||
// create the CINT object for the current zoom level
|
||||
CINT currentCINTObj = new CINT();
|
||||
currentCINTObj.setCINTStringParsed(cintParser.isContourStringParsed());
|
||||
currentCINTObj.setCINTStringParsed(cintParser
|
||||
.isContourStringParsed());
|
||||
|
||||
/*If the parse operation was successful, extract the numeric
|
||||
*data and set the corresponding instance variables of currentCINTObj*/
|
||||
/*
|
||||
* If the parse operation was successful, extract the numeric
|
||||
* data and set the corresponding instance variables of
|
||||
* currentCINTObj
|
||||
*/
|
||||
|
||||
if (currentCINTObj.isCINTStringParsed()) {
|
||||
currentCINTObj.setCINTString(contourLevelStringsArray[index]);
|
||||
currentCINTObj.setContourInterval(cintParser.getContourInterval());
|
||||
currentCINTObj.setMinContourValue(cintParser.getMinContourLevel());
|
||||
currentCINTObj.setMaxContourValue(cintParser.getMaxContourLevel());
|
||||
currentCINTObj.setNumPaddingDigits(cintParser.getNumPaddingDigits());
|
||||
currentCINTObj.setContourValuesList(cintParser.getContourValuesList());
|
||||
currentCINTObj.setCintHashMap(cintParser.getLabeledContourValuesHashMap());
|
||||
Set<Double> tempKeySet = new LinkedHashSet<Double>(currentCINTObj.cintHashMap.keySet());
|
||||
currentCINTObj.setContourValuesList( new ArrayList<Double>(tempKeySet));
|
||||
currentCINTObj
|
||||
.setCINTString(contourLevelStringsArray[index]);
|
||||
currentCINTObj.setContourInterval(cintParser
|
||||
.getContourInterval());
|
||||
currentCINTObj.setMinContourValue(cintParser
|
||||
.getMinContourLevel());
|
||||
currentCINTObj.setMaxContourValue(cintParser
|
||||
.getMaxContourLevel());
|
||||
currentCINTObj.setNumPaddingDigits(cintParser
|
||||
.getNumPaddingDigits());
|
||||
currentCINTObj.setContourValuesList(cintParser
|
||||
.getContourValuesList());
|
||||
currentCINTObj.setCintHashMap(cintParser
|
||||
.getLabeledContourValuesHashMap());
|
||||
Set<Double> tempKeySet = new LinkedHashSet<Double>(
|
||||
currentCINTObj.cintHashMap.keySet());
|
||||
currentCINTObj.setContourValuesList(new ArrayList<Double>(
|
||||
tempKeySet));
|
||||
for (Double contourValue : tempKeySet) {
|
||||
currentCINTObj.contourValuesListAsString.add(contourValue.toString());
|
||||
currentCINTObj.contourValuesListAsString
|
||||
.add(contourValue.toString());
|
||||
}
|
||||
currentCINTObj.contourLabelList = new ArrayList<String>( new LinkedHashSet<String>(currentCINTObj.cintHashMap.values()));
|
||||
currentCINTObj.contourLabelList = new ArrayList<String>(
|
||||
new LinkedHashSet<String>(
|
||||
currentCINTObj.cintHashMap.values()));
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
|
@ -527,7 +641,8 @@ public class CINT {
|
|||
isParsed = isParsed & currentCINTObj.isCINTStringParsed();
|
||||
}
|
||||
|
||||
//Sets the status of the parse operations across all zoom levels (i.e. for all CINT objects in the list)
|
||||
// Sets the status of the parse operations across all zoom
|
||||
// levels (i.e. for all CINT objects in the list)
|
||||
this.setCINTStringParsed(isParsed);
|
||||
|
||||
// finally add currentCINTObj to the list of CINT objects
|
||||
|
@ -537,4 +652,3 @@ public class CINT {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,17 +3,20 @@ package gov.noaa.nws.ncep.gempak.parameters.core.contourinterval;
|
|||
import gov.noaa.nws.ncep.gempak.parameters.core.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
*<tt>ContourStringParser</tt> should be used only in conjunction with a <tt>FINT</tt> or a <tt>CINT</tt> object.
|
||||
* It serves the purpose of parsing the contour interval string passed to the constructor of a
|
||||
* <tt>FINT</tt> or a <tt>CINT</tt>object.Thereafter the instance variables of each of these
|
||||
* two classes is populated by the data extracted by <tt>ContourStringParser</tt>, from the parsed string.
|
||||
* <tt>ContourStringParser</tt> should be used only in conjunction with a
|
||||
* <tt>FINT</tt> or a <tt>CINT</tt> object. It serves the purpose of parsing the
|
||||
* contour interval string passed to the constructor of a <tt>FINT</tt> or a
|
||||
* <tt>CINT</tt>object.Thereafter the instance variables of each of these two
|
||||
* classes is populated by the data extracted by <tt>ContourStringParser</tt>,
|
||||
* from the parsed string.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
|
@ -45,7 +48,12 @@ import java.util.regex.Pattern;
|
|||
* values into a HashMap(String,Double).
|
||||
* 14-Jun-2010 174 Archana.S Redesigned class to support multiple zoom levels
|
||||
* 02-Aug-2010 174 Archana.S Updated code to parse a single real number as the contour interval
|
||||
* 07-Apr-2014 TTR-938 D.Sushon Fixes to parseContourString:
|
||||
* correctly parse CINTs of form: 1/-23.5/-22.5 1/22.5/23.5 (TTR-938)
|
||||
* single numbers (i.e. 0.7) not parsed correctly, fixed to follow same execution path as #// (i.e. 0.7//)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author Archana.S
|
||||
* @version 1.0
|
||||
* @see $GEMPAK/help/hlx/cint.hl2
|
||||
|
@ -63,7 +71,10 @@ public class ContourStringParser {
|
|||
/** A real number that represents the maximum contour level */
|
||||
private Double maxContourLevel;
|
||||
|
||||
/**An integer that decides the minimum number of digits in an integer contour label*/
|
||||
/**
|
||||
* An integer that decides the minimum number of digits in an integer
|
||||
* contour label
|
||||
*/
|
||||
private Integer numPaddingDigits;
|
||||
|
||||
/** The generated list of contour levels */
|
||||
|
@ -72,18 +83,34 @@ public class ContourStringParser {
|
|||
/** A HashMap of the labels and their respective contour values */
|
||||
private Map<Double, String> labeledContourValuesHashMap;
|
||||
|
||||
/**A string that contains the extracted contour label from a single contour level*/
|
||||
/**
|
||||
* A string that contains the extracted contour label from a single contour
|
||||
* level
|
||||
*/
|
||||
private String contourIntervalLabel;
|
||||
|
||||
/** Boolean flag to validate that the contour data string was parsed correctly*/
|
||||
/**
|
||||
* Boolean flag to validate that the contour data string was parsed
|
||||
* correctly
|
||||
*/
|
||||
private boolean isContourStringParsed;
|
||||
|
||||
private String LIST_OF_CONTOUR_VALUES = "(-?\\d*\\.?\\d*;-?\\d*\\.?\\d*)+"; //The list must have atleast 2 numbers separated by a semi-colon
|
||||
/**
|
||||
* The LIST_OF_CONTOUR_VALUES must have at least 2 numbers separated by a
|
||||
* semicolon
|
||||
*/
|
||||
private String LIST_OF_CONTOUR_VALUES = "(-?\\d*\\.?\\d*;-?\\d*\\.?\\d*)+";
|
||||
|
||||
private String REAL_NUMBER = "-?\\d*\\.?\\d*;?";
|
||||
|
||||
private String INTEGER = "-?\\d+";
|
||||
|
||||
private String LABELLED_CONTOUR_VALUE = "(-?\\d*\\.?\\d*=[\\w\\p{Punct}]*;*)+";
|
||||
|
||||
/**The default constructor just initializes the instance variables to their defaults*/
|
||||
/**
|
||||
* The default constructor just initializes the instance variables to their
|
||||
* defaults
|
||||
*/
|
||||
public ContourStringParser() {
|
||||
contourInterval = Double.NaN;
|
||||
minContourLevel = Double.NaN;
|
||||
|
@ -101,7 +128,8 @@ public class ContourStringParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param labeledContourValuesHashMap the labeledContourValuesHashMap to set
|
||||
* @param labeledContourValuesHashMap
|
||||
* the labeledContourValuesHashMap to set
|
||||
*/
|
||||
private void setLabeledContourValuesHashMap(
|
||||
Map<Double, String> labeledContourValuesHashMap) {
|
||||
|
@ -111,53 +139,70 @@ public class ContourStringParser {
|
|||
public boolean isContourStringParsed() {
|
||||
return isContourStringParsed;
|
||||
}
|
||||
|
||||
/** @return List of Double - contourValuesList */
|
||||
public List<Double> getContourValuesList() {
|
||||
return contourValuesList;
|
||||
}
|
||||
|
||||
|
||||
/** The method getContourInterval returns the contour interval value
|
||||
/**
|
||||
* The method getContourInterval returns the contour interval value
|
||||
*
|
||||
* @return Double contourInterval
|
||||
**/
|
||||
public Double getContourInterval() {
|
||||
return contourInterval;
|
||||
}
|
||||
|
||||
/** The method getContourIntervalLabel returns the contour interval value
|
||||
/**
|
||||
* The method getContourIntervalLabel returns the contour interval value
|
||||
*
|
||||
* @return String contourIntervalLabel
|
||||
**/
|
||||
public String getContourIntervalLabel() {
|
||||
return contourIntervalLabel;
|
||||
}
|
||||
|
||||
/**The method getMinContourLevel returns the value of the minimum contour level
|
||||
/**
|
||||
* The method getMinContourLevel returns the value of the minimum contour
|
||||
* level
|
||||
*
|
||||
* @return Double minContourLevel
|
||||
**/
|
||||
public Double getMinContourLevel() {
|
||||
return minContourLevel;
|
||||
}
|
||||
|
||||
/**The method getMaxContourLevel returns the value of the maximum contour level
|
||||
/**
|
||||
* The method getMaxContourLevel returns the value of the maximum contour
|
||||
* level
|
||||
*
|
||||
* @return Double maxContourLevel
|
||||
**/
|
||||
public Double getMaxContourLevel() {
|
||||
return maxContourLevel;
|
||||
}
|
||||
|
||||
/** The method getNumPaddingDigits returns the value of the Integer numPaddingDigits
|
||||
/**
|
||||
* The method getNumPaddingDigits returns the value of the Integer
|
||||
* numPaddingDigits
|
||||
*
|
||||
* @return Integer numPaddingDigits
|
||||
**/
|
||||
public Integer getNumPaddingDigits() {
|
||||
return numPaddingDigits;
|
||||
}
|
||||
|
||||
/**The method <tt>parse</tt> checks if the input string contains blanks.
|
||||
*If so it invokes the method <tt>removeBlanksWithinString </tt> on the string
|
||||
*and then invokes the method <tt>parseContourString</tt> on it. Else, the method <tt>parseContourString</tt>
|
||||
*is directly invoked on the input string
|
||||
/**
|
||||
* The method <tt>parse</tt> checks if the input string contains blanks. If
|
||||
* so it invokes the method <tt>removeBlanksWithinString </tt> on the string
|
||||
* and then invokes the method <tt>parseContourString</tt> on it. Else, the
|
||||
* method <tt>parseContourString</tt> is directly invoked on the input
|
||||
* string
|
||||
* <p>
|
||||
*@param String contourStringToParse
|
||||
*
|
||||
* @param String
|
||||
* contourStringToParse
|
||||
**/
|
||||
public void parse(String contourStringToParse) {
|
||||
|
||||
|
@ -171,44 +216,67 @@ public class ContourStringParser {
|
|||
if (contourStringToParse.contains(" ")) {
|
||||
String strWithoutBlanks = StringUtil
|
||||
.removeBlanksWithinString(contourStringToParse);
|
||||
isContourStringParsed = this.parseContourString(strWithoutBlanks);
|
||||
}
|
||||
else {
|
||||
isContourStringParsed = this.parseContourString(contourStringToParse);
|
||||
isContourStringParsed = this
|
||||
.parseContourString(strWithoutBlanks);
|
||||
} else {
|
||||
isContourStringParsed = this
|
||||
.parseContourString(contourStringToParse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**The method <tt>parseContourString</tt>
|
||||
*@param String contourStringToParse
|
||||
/**
|
||||
* The method <tt>parseContourString</tt>
|
||||
*
|
||||
* @param String
|
||||
* contourStringToParse
|
||||
* @return boolean isInputContourStringParsed
|
||||
*<p>The method <tt>parseContourString</tt> accepts the contour data string fed as an input
|
||||
*from the method <tt>parse()</tt>.
|
||||
*A valid contour string can take only one of the formats listed below:<P>
|
||||
*1. contourInterval/minimumContourLevel/maximumContourLevel/numPaddingdigits <P>
|
||||
*2. contourValue1;contourValue2;contourValue3;contourValue4;contourValue5.......<p>
|
||||
*3. contourValue1=label1/contourValue1/contourValue1<p>
|
||||
*4. contourValue1=label1;contourValue2=label2;contourValue3=label3;............<p>
|
||||
*5. contourInterval/minimumContourLevel/maximumContourLevel<p>
|
||||
* <p>
|
||||
* The method <tt>parseContourString</tt> accepts the contour data
|
||||
* string fed as an input from the method <tt>parse()</tt>. A valid
|
||||
* contour string can take only one of the formats listed below:
|
||||
* <P>
|
||||
* 1. contourInterval/minimumContourLevel/maximumContourLevel/
|
||||
* numPaddingdigits
|
||||
* <P>
|
||||
* 2. contourValue1;contourValue2;contourValue3;contourValue4;
|
||||
* contourValue5.......
|
||||
* <p>
|
||||
* 3. contourValue1=label1/contourValue1/contourValue1
|
||||
* <p>
|
||||
* 4.
|
||||
* contourValue1=label1;contourValue2=label2;contourValue3=label3;
|
||||
* ............
|
||||
* <p>
|
||||
* 5. contourInterval/minimumContourLevel/maximumContourLevel
|
||||
* <p>
|
||||
* <p>
|
||||
* If the input string is entered in the first or the fifth format,
|
||||
*<tt>contourStringToParse</tt> is parsed using the "/" character as a delimiter.
|
||||
*All numeric data is extracted and stored.
|
||||
* <tt>contourStringToParse</tt> is parsed using the "/" character
|
||||
* as a delimiter. All numeric data is extracted and stored.
|
||||
* <p>
|
||||
*If the second format is chosen, the string contourStringParam is parsed using the ";" character
|
||||
*as a delimiter.<p>
|
||||
*The method<tt>generateContourValuesList</tt> is invoked to compute the range of contour values.
|
||||
*The method setContourValuesList is invoked to store the computed range of contour values.
|
||||
* If the second format is chosen, the string contourStringParam is
|
||||
* parsed using the ";" character as a delimiter.
|
||||
* <p>
|
||||
*If the parsing and subsequent numeric data retrieval is successful,
|
||||
*the boolean isInputContourStringParsed is set to true.
|
||||
* The method<tt>generateContourValuesList</tt> is invoked to
|
||||
* compute the range of contour values. The method
|
||||
* setContourValuesList is invoked to store the computed range of
|
||||
* contour values.
|
||||
* <p>
|
||||
* If the parsing and subsequent numeric data retrieval is
|
||||
* successful, the boolean isInputContourStringParsed is set to
|
||||
* true.
|
||||
* <P>
|
||||
***/
|
||||
private boolean parseContourString(String contourStringToParse) {
|
||||
String contourStringsTokens[];
|
||||
boolean isInputContourStringParsed = false;
|
||||
// /*If the input string contains a list of contour values separated
|
||||
// * by a ';' character as a delimiter*/
|
||||
boolean possibleFallThrough = false;
|
||||
String tempForReprocess = contourStringToParse;
|
||||
/*
|
||||
* If the input string contains a list of contour values separated by a
|
||||
* ';' character as a delimiter
|
||||
*/
|
||||
if (Pattern.matches(REAL_NUMBER, contourStringToParse)) {
|
||||
try {
|
||||
String[] tempStr = contourStringToParse.split(";");
|
||||
|
@ -216,19 +284,24 @@ public class ContourStringParser {
|
|||
Double d = Double.parseDouble(tempStr[0]);
|
||||
setContourInterval(d.doubleValue());
|
||||
isInputContourStringParsed = true;
|
||||
// System.out.println(tempStr[0]);
|
||||
possibleFallThrough = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
isInputContourStringParsed = false;
|
||||
}
|
||||
}
|
||||
else if(Pattern.matches(LABELLED_CONTOUR_VALUE, contourStringToParse)) {
|
||||
} else if (Pattern
|
||||
.matches(LABELLED_CONTOUR_VALUE, contourStringToParse)) {
|
||||
if (contourStringToParse.contains(";")) {
|
||||
contourStringsTokens = contourStringToParse.split(";");
|
||||
for (String s : contourStringsTokens) {
|
||||
isInputContourStringParsed = this.parseContourStringContainingLabel(s);
|
||||
isInputContourStringParsed = this
|
||||
.parseContourStringContainingLabel(s);
|
||||
|
||||
/*TODO add code to store the labels in a list or in a HashMap with the
|
||||
*corresponding contour values*/
|
||||
/*
|
||||
* TODO add code to store the labels in a list or in a
|
||||
* HashMap with the corresponding contour values
|
||||
*/
|
||||
|
||||
if (!isInputContourStringParsed) {
|
||||
System.out.println("INVALID STRING");
|
||||
|
@ -236,54 +309,73 @@ public class ContourStringParser {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
isInputContourStringParsed = this.parseContourStringContainingLabel(contourStringToParse);
|
||||
isInputContourStringParsed = this
|
||||
.parseContourStringContainingLabel(contourStringToParse);
|
||||
}
|
||||
}
|
||||
else if(Pattern.matches(LIST_OF_CONTOUR_VALUES, contourStringToParse)){
|
||||
} else if (Pattern
|
||||
.matches(LIST_OF_CONTOUR_VALUES, contourStringToParse)) {
|
||||
if (contourStringToParse.contains(";")) {
|
||||
|
||||
/*Split the input string into tokens using the ';' character as a delimiter*/
|
||||
/*
|
||||
* Split the input string into tokens using the ';' character as
|
||||
* a delimiter
|
||||
*/
|
||||
contourStringsTokens = contourStringToParse.split(";");
|
||||
for (String s : contourStringsTokens) {
|
||||
/*for each string token, attempt to extract the contour value from it to
|
||||
* the map of contour values*/
|
||||
isInputContourStringParsed = this.extractContourValueFromStringAndAddToHashMap(s);
|
||||
/*
|
||||
* for each string token, attempt to extract the contour
|
||||
* value from it to the map of contour values
|
||||
*/
|
||||
isInputContourStringParsed = this
|
||||
.extractContourValueFromStringAndAddToHashMap(s);
|
||||
if (!isInputContourStringParsed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isInputContourStringParsed = this.extractContourValueFromStringAndAddToHashMap(contourStringToParse);
|
||||
isInputContourStringParsed = this
|
||||
.extractContourValueFromStringAndAddToHashMap(contourStringToParse);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (contourStringToParse.contains("/")) {
|
||||
contourStringsTokens = contourStringToParse.split("/");
|
||||
|
||||
Double tempContourParam[] = new Double[3];
|
||||
int i = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
try {
|
||||
tempContourParam[i] = Double.parseDouble(contourStringsTokens[i]);
|
||||
tempContourParam[i] = Double
|
||||
.parseDouble(contourStringsTokens[i]);
|
||||
isInputContourStringParsed = true;
|
||||
|
||||
} catch (NumberFormatException nfe) {
|
||||
tempContourParam[i] = Double.NaN;
|
||||
// exceptions should be used to handle exceptional
|
||||
// situations rather than as a branching mechanism
|
||||
} catch (Exception e) {
|
||||
tempContourParam[i] = Double.NaN;
|
||||
// exceptions should be used to handle exceptional
|
||||
// situations rather than as a branching mechanism
|
||||
}
|
||||
}
|
||||
|
||||
/*Store extracted numeric data as minContourLevel and maxContouLevel */
|
||||
/*
|
||||
* Store extracted numeric data as minContourLevel and
|
||||
* maxContouLevel
|
||||
*/
|
||||
setMinContourLevel(tempContourParam[1]);
|
||||
setMaxContourLevel(tempContourParam[2]);
|
||||
|
||||
/*If the maxContourLevel value is different from the minContourLevel value,
|
||||
*store the contourInterval value as retrieved from the corresponding string token.
|
||||
**/
|
||||
if(this.getMaxContourLevel().doubleValue() != this.getMinContourLevel().doubleValue()){
|
||||
/*
|
||||
* If the maxContourLevel value is different from the
|
||||
* minContourLevel value,store the contourInterval value as
|
||||
* retrieved from the corresponding string token.
|
||||
*/
|
||||
if (this.getMaxContourLevel().doubleValue() != this
|
||||
.getMinContourLevel().doubleValue()) {
|
||||
setContourInterval(tempContourParam[0]);
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
|
||||
/* Special case: check for a label in a single contour value */
|
||||
if (contourStringsTokens[0].contains("=")) {
|
||||
|
@ -293,46 +385,63 @@ public class ContourStringParser {
|
|||
setContourInterval(this.getMinContourLevel());
|
||||
}
|
||||
} else {
|
||||
/* Since both maxContourLevel and minContourLevel are equal, and there
|
||||
* is no contour label, the contour interval is set to 0.
|
||||
/*
|
||||
* Since both maxContourLevel and minContourLevel are
|
||||
* equal, and there is no contour label, the contour
|
||||
* interval is set to 0??. seems like should be
|
||||
* Double.NaN..
|
||||
*/
|
||||
setContourInterval(0.0);
|
||||
setContourInterval(Double.NaN);
|
||||
}
|
||||
}
|
||||
|
||||
if (Double.isNaN(this.getContourInterval())
|
||||
&& Double.isNaN(this.getMinContourLevel())
|
||||
&& Double.isNaN(this.getMaxContourLevel())) {
|
||||
isInputContourStringParsed = false; /* All three parameters cannot be undefined in a successful parse operation*/
|
||||
}
|
||||
else{
|
||||
isInputContourStringParsed = false; /*
|
||||
* All three parameters
|
||||
* cannot be undefined
|
||||
* in a successful parse
|
||||
* operation
|
||||
*/
|
||||
} else {
|
||||
isInputContourStringParsed = true;
|
||||
}
|
||||
|
||||
/*If the parsing has been successful, generate the list of contour values*/
|
||||
/*
|
||||
* If the parsing has been successful, generate the list of
|
||||
* contour values
|
||||
*/
|
||||
if ((isInputContourStringParsed)) {
|
||||
|
||||
/*For CINT alone, a digit defining the minimum number of digits
|
||||
*in a label is to be extracted from the 4th token, is it exists*/
|
||||
/*
|
||||
* For CINT alone, a digit defining the minimum number of
|
||||
* digits in a label is to be extracted from the 4th token,
|
||||
* is it exists
|
||||
*/
|
||||
|
||||
if (contourStringsTokens.length >= 4) {
|
||||
try {
|
||||
/*Check that the 4th string token is an integer:
|
||||
/*
|
||||
* Check that the 4th string token is an integer:
|
||||
*
|
||||
*INTEGER is a regular expression of the form: \\d+ */
|
||||
* INTEGER is a regular expression of the form: \\d+
|
||||
*/
|
||||
if (Pattern.matches(INTEGER,
|
||||
contourStringsTokens[3])) {
|
||||
setNumPaddingDigits(Integer.parseInt(contourStringsTokens[3]));
|
||||
setNumPaddingDigits(Integer
|
||||
.parseInt(contourStringsTokens[3]));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
isInputContourStringParsed = false;
|
||||
}
|
||||
} else {
|
||||
setNumPaddingDigits(0);
|
||||
}
|
||||
|
||||
Map<Double,String> tempContourValMap = generateContourValuesMap(this.getContourInterval(),
|
||||
Map<Double, String> tempContourValMap = generateContourValuesMap(
|
||||
this.getContourInterval(),
|
||||
this.getMinContourLevel(),
|
||||
this.getMaxContourLevel(),
|
||||
this.getNumPaddingDigits());
|
||||
|
@ -342,25 +451,133 @@ public class ContourStringParser {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* case for lone contour interval entered without "//", retry parse as
|
||||
* "contourInterval//"
|
||||
*/
|
||||
if (true == possibleFallThrough
|
||||
&& (false == tempForReprocess.contains(";"))) {
|
||||
Double foo = Double.NaN;
|
||||
try {
|
||||
|
||||
foo = Double.parseDouble(tempForReprocess);
|
||||
} catch (NumberFormatException nfe) {
|
||||
//
|
||||
} catch (Exception genericException) {
|
||||
//
|
||||
}
|
||||
|
||||
String reparse = new String(foo + "//");
|
||||
isInputContourStringParsed = false;
|
||||
|
||||
contourStringsTokens = reparse.split("/");
|
||||
|
||||
Double tempContourParam[] = new Double[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
tempContourParam[i] = Double
|
||||
.parseDouble(contourStringsTokens[i]);
|
||||
isInputContourStringParsed = true;
|
||||
|
||||
} catch (NumberFormatException nfe) {
|
||||
tempContourParam[i] = Double.NaN;
|
||||
// exceptions should be used to handle exceptional
|
||||
// situations rather than as a branching mechanism
|
||||
} catch (Exception e) {
|
||||
tempContourParam[i] = Double.NaN;
|
||||
// exceptions should be used to handle exceptional
|
||||
// situations rather than as a branching mechanism
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Store extracted numeric data as minContourLevel and
|
||||
* maxContouLevel
|
||||
*/
|
||||
setMinContourLevel(tempContourParam[1]);
|
||||
setMaxContourLevel(tempContourParam[2]);
|
||||
|
||||
/*
|
||||
* If the maxContourLevel value is different from the
|
||||
* minContourLevel value,store the contourInterval value as
|
||||
* retrieved from the corresponding string token.
|
||||
*/
|
||||
if (this.getMaxContourLevel().doubleValue() != this
|
||||
.getMinContourLevel().doubleValue()) {
|
||||
setContourInterval(tempContourParam[0]);
|
||||
} else {
|
||||
|
||||
/* Special case: check for a label in a single contour value */
|
||||
if (contourStringsTokens[0].contains("=")) {
|
||||
isInputContourStringParsed = parseContourStringContainingLabel(contourStringsTokens[0]);
|
||||
|
||||
if (isInputContourStringParsed) {
|
||||
setContourInterval(this.getMinContourLevel());
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Since both maxContourLevel and minContourLevel are equal,
|
||||
* and there is no contour label, the contour interval is
|
||||
* set to 0??. seems like should be Double.NaN..
|
||||
*/
|
||||
// setContourInterval(0.0);
|
||||
setContourInterval(Double.NaN);
|
||||
}
|
||||
}
|
||||
|
||||
if (Double.isNaN(this.getContourInterval())
|
||||
&& Double.isNaN(this.getMinContourLevel())
|
||||
&& Double.isNaN(this.getMaxContourLevel())) {
|
||||
isInputContourStringParsed = false; /*
|
||||
* All three parameters
|
||||
* cannot be undefined in a
|
||||
* successful parse
|
||||
* operation
|
||||
*/
|
||||
} else {
|
||||
isInputContourStringParsed = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the parsing has been successful, generate the list of contour
|
||||
* values
|
||||
*/
|
||||
if ((isInputContourStringParsed)) {
|
||||
setNumPaddingDigits(0);
|
||||
|
||||
Map<Double, String> tempContourValMap = generateContourValuesMap(
|
||||
this.getContourInterval(), this.getMinContourLevel(),
|
||||
this.getMaxContourLevel(), this.getNumPaddingDigits());
|
||||
|
||||
setLabeledContourValuesHashMap(tempContourValMap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return isInputContourStringParsed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param String contourString
|
||||
* @param String
|
||||
* contourString
|
||||
* @return boolean isContourValueExists
|
||||
* <p>
|
||||
* The method <tt>extractContourValueFromStringAndAddToHashMap</tt> is used to
|
||||
* extract a real number (the contour value) from the input string.
|
||||
* If the extraction is successful, the real number is added to a HashMap of contour values.
|
||||
* If the extraction is successful, the method returns <tt>true</tt>, else <tt>false</tt>.
|
||||
* The method <tt>extractContourValueFromStringAndAddToHashMap</tt>
|
||||
* is used to extract a real number (the contour value) from the
|
||||
* input string. If the extraction is successful, the real number is
|
||||
* added to a HashMap of contour values. If the extraction is
|
||||
* successful, the method returns <tt>true</tt>, else <tt>false</tt>.
|
||||
* */
|
||||
private boolean extractContourValueFromStringAndAddToHashMap(String contourString){
|
||||
private boolean extractContourValueFromStringAndAddToHashMap(
|
||||
String contourString) {
|
||||
Double tempContourValue;
|
||||
boolean isContourValueExists = false;
|
||||
try {
|
||||
tempContourValue = Double.parseDouble(contourString);
|
||||
/*If the parse is successful, add the contour value to the list of contour values*/
|
||||
/*
|
||||
* If the parse is successful, add the contour value to the list of
|
||||
* contour values
|
||||
*/
|
||||
isContourValueExists = true;
|
||||
} catch (Exception e) {
|
||||
tempContourValue = Double.NaN;
|
||||
|
@ -369,7 +586,8 @@ public class ContourStringParser {
|
|||
|
||||
if (isContourValueExists) {
|
||||
// this.getContourValuesList().add(tempContourValue);
|
||||
this.getLabeledContourValuesHashMap().put(tempContourValue, contourString);
|
||||
this.getLabeledContourValuesHashMap().put(tempContourValue,
|
||||
contourString);
|
||||
this.contourInterval = tempContourValue;
|
||||
}
|
||||
|
||||
|
@ -377,31 +595,40 @@ public class ContourStringParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param String contourValueWithLabel
|
||||
* @param String
|
||||
* contourValueWithLabel
|
||||
* @return boolean isLabelExists
|
||||
* <p>
|
||||
* The method <tt>parseContourStringContainingLabel</tt> is used to
|
||||
* parse the input string into it constituent contour value(a real number)
|
||||
* and a string representing its label.
|
||||
* If the extraction is successful, the method returns true, else false.
|
||||
* parse the input string into it constituent contour value(a real
|
||||
* number) and a string representing its label. If the extraction is
|
||||
* successful, the method returns true, else false.
|
||||
**/
|
||||
private boolean parseContourStringContainingLabel(String contourValueWithLabel){
|
||||
private boolean parseContourStringContainingLabel(
|
||||
String contourValueWithLabel) {
|
||||
String singleContourLevelToken[];
|
||||
boolean isLabelAndContourValueExists = false;
|
||||
Double key = Double.NaN;
|
||||
String value = "";
|
||||
/*check for the "=" delimiter, to see if the string contains a label for the contour value*/
|
||||
/*
|
||||
* check for the "=" delimiter, to see if the string contains a label
|
||||
* for the contour value
|
||||
*/
|
||||
if (contourValueWithLabel.contains("=")) {
|
||||
|
||||
/* If yes, split the string using the delimiter "=" */
|
||||
singleContourLevelToken = contourValueWithLabel.split("=");
|
||||
|
||||
/*Extract the contour value from the numeric data in the first string token*/
|
||||
/*
|
||||
* Extract the contour value from the numeric data in the first
|
||||
* string token
|
||||
*/
|
||||
if (Pattern.matches(REAL_NUMBER, singleContourLevelToken[0])) {
|
||||
|
||||
if (singleContourLevelToken.length > 1) {
|
||||
isLabelAndContourValueExists = true;
|
||||
String contourLabelIntervalValue[] = singleContourLevelToken[1].split("/");
|
||||
String contourLabelIntervalValue[] = singleContourLevelToken[1]
|
||||
.split("/");
|
||||
value = new String(contourLabelIntervalValue[0]);
|
||||
try {
|
||||
key = Double.parseDouble(singleContourLevelToken[0]);
|
||||
|
@ -412,17 +639,20 @@ public class ContourStringParser {
|
|||
}
|
||||
|
||||
if (isLabelAndContourValueExists) {
|
||||
/*If the parse is successful, add the contour value to the list of contour values*/
|
||||
/*
|
||||
* If the parse is successful, add the contour value to the
|
||||
* list of contour values
|
||||
*/
|
||||
this.getContourValuesList().add(key);
|
||||
labeledContourValuesHashMap.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
/*No numeric data was found in the string token
|
||||
* Set the boolean flag to false, to indicate an error.
|
||||
* */
|
||||
} else {
|
||||
/*
|
||||
* No numeric data was found in the string token Set the boolean
|
||||
* flag to false, to indicate an error.
|
||||
*/
|
||||
isLabelAndContourValueExists = false;
|
||||
}
|
||||
if (labeledContourValuesHashMap.size() == 1) {
|
||||
|
@ -436,29 +666,37 @@ public class ContourStringParser {
|
|||
|
||||
/**
|
||||
* Generates a Map of Contour values of the form Map(Double, String)
|
||||
*@param Double contourInterval
|
||||
*@param Double minContourValue
|
||||
*@param Double maxContourValue
|
||||
*
|
||||
* @param Double
|
||||
* contourInterval
|
||||
* @param Double
|
||||
* minContourValue
|
||||
* @param Double
|
||||
* maxContourValue
|
||||
* @param numLeadingZeros
|
||||
* @return a Map of type (Double, String)
|
||||
* <p>
|
||||
*The method <tt>generateContourValuesMap</tt> accepts as input the <tt>contourInterval</tt>
|
||||
*and the minimum and maximum contour values.
|
||||
*It generates a Map (Double, String) representing the contour levels
|
||||
*that lie in the range specified by <tt>minContourValue</tt> and <tt>maxContourValue</tt>.
|
||||
* The String value of each entry in the map represents the contour value's String equivalent,
|
||||
* after appending it with leading zeros depending on the value of numLeadingZeros
|
||||
* The method <tt>generateContourValuesMap</tt> accepts as input the
|
||||
* <tt>contourInterval</tt> and the minimum and maximum contour
|
||||
* values. It generates a Map (Double, String) representing the
|
||||
* contour levels that lie in the range specified by
|
||||
* <tt>minContourValue</tt> and <tt>maxContourValue</tt>. The String
|
||||
* value of each entry in the map represents the contour value's
|
||||
* String equivalent, after appending it with leading zeros
|
||||
* depending on the value of numLeadingZeros
|
||||
* <p>
|
||||
*Each contour level is separated from its neighboring contour values by the value of the contourInterval.
|
||||
*If <tt>minContourValue</tt> and <tt>maxContourValue</tt> are not exact multiples of <tt>contourInterval</tt>,
|
||||
*then they are set to the next neighboring values that are exact multiples of the <tt>contourInterval</tt>.
|
||||
* Each contour level is separated from its neighboring contour
|
||||
* values by the value of the contourInterval. If
|
||||
* <tt>minContourValue</tt> and <tt>maxContourValue</tt> are not
|
||||
* exact multiples of <tt>contourInterval</tt>, then they are set to
|
||||
* the next neighboring values that are exact multiples of the
|
||||
* <tt>contourInterval</tt>.
|
||||
* <p>
|
||||
*
|
||||
***/
|
||||
private Map<Double, String> generateContourValuesMap(Double contourInterval,
|
||||
Double minContourValue,
|
||||
Double maxContourValue,
|
||||
Integer numLeadingZeros){
|
||||
private Map<Double, String> generateContourValuesMap(
|
||||
Double contourInterval, Double minContourValue,
|
||||
Double maxContourValue, Integer numLeadingZeros) {
|
||||
|
||||
Map<Double, String> contourValMap = new LinkedHashMap<Double, String>();
|
||||
/* If contourInterval is negative, multiply it by -1 */
|
||||
|
@ -472,9 +710,10 @@ public class ContourStringParser {
|
|||
if (!(Double.isNaN(maxContourValue))
|
||||
&& !(Double.isNaN(minContourValue))) {
|
||||
|
||||
/*Even if the values of minContourValue and maxContourValue parameters are exchanged
|
||||
*Swap them and then generate the list
|
||||
**/
|
||||
/*
|
||||
* Even if the values of minContourValue and maxContourValue
|
||||
* parameters are exchangedSwap them and then generate the list
|
||||
*/
|
||||
if (minContourValue.compareTo(maxContourValue) > 0) {
|
||||
|
||||
Double tempContourVal = new Double(minContourValue);
|
||||
|
@ -484,96 +723,127 @@ public class ContourStringParser {
|
|||
setMaxContourLevel(maxContourValue);
|
||||
}
|
||||
|
||||
/*If minContourValue and maxContourValue are not exact multiples of contourInterval
|
||||
* they are set to neighboring values that are exact multiples of the contourInterval.
|
||||
**/
|
||||
/*
|
||||
* If minContourValue and maxContourValue are not exact
|
||||
* multiples of contourInterval they are set to neighboring
|
||||
* values that are exact multiples of the contourInterval.
|
||||
*/
|
||||
// if(Pattern.matches(INTEGER, ))
|
||||
|
||||
Double d1 = minContourValue / contourInterval;
|
||||
Double d2 = maxContourValue / contourInterval;
|
||||
int intMinContourValueAdjFactor = 0;
|
||||
int intMaxContourValueAdjFactor = 0;
|
||||
|
||||
// if (!Pattern.matches(INTEGER, d1.toString())
|
||||
// && d1.doubleValue() != 0) {
|
||||
// intMinContourValueAdjFactor = (int) d1.doubleValue();
|
||||
// }
|
||||
//
|
||||
// if (!Pattern.matches(INTEGER, d2.toString())
|
||||
// && d2.doubleValue() != 0) {
|
||||
// intMaxContourValueAdjFactor = (int) d2.doubleValue();
|
||||
// }
|
||||
|
||||
if (!Pattern.matches(INTEGER, d1.toString())
|
||||
&& d1.doubleValue() != 0) {
|
||||
intMinContourValueAdjFactor = (int) d1.doubleValue();
|
||||
intMinContourValueAdjFactor = (int) StrictMath.ceil(d1
|
||||
.doubleValue());
|
||||
}
|
||||
|
||||
if (!Pattern.matches(INTEGER, d2.toString())
|
||||
&& d2.doubleValue() != 0) {
|
||||
intMaxContourValueAdjFactor = (int) d2.doubleValue();
|
||||
intMaxContourValueAdjFactor = (int) StrictMath.floor(d2
|
||||
.doubleValue());
|
||||
}
|
||||
|
||||
if (intMinContourValueAdjFactor != 0) {
|
||||
minContourValue = new Double( intMinContourValueAdjFactor * contourInterval);
|
||||
minContourValue = new Double(intMinContourValueAdjFactor
|
||||
* contourInterval);
|
||||
}
|
||||
|
||||
if (intMaxContourValueAdjFactor != 0) {
|
||||
maxContourValue = new Double(intMaxContourValueAdjFactor * contourInterval);
|
||||
maxContourValue = new Double(intMaxContourValueAdjFactor
|
||||
* contourInterval);
|
||||
}
|
||||
/*Starting from minContourValue, until maxContourValue is reached, each contourValue is added to the map
|
||||
*and the next contourValue in the range is computed by adding the contourInterval to the current contour value.
|
||||
*Finally, the last element in the range - maxContourValue is also added to the map.
|
||||
**/
|
||||
while (minContourValue.compareTo(maxContourValue) < 0) {
|
||||
String contourLabel = addLeadingZerosToContourValue(numLeadingZeros, minContourValue);
|
||||
contourValMap.put(minContourValue, contourLabel);
|
||||
minContourValue = new Double(contourInterval + minContourValue.doubleValue());
|
||||
}
|
||||
String contourLabel = addLeadingZerosToContourValue(numLeadingZeros, maxContourValue);
|
||||
contourValMap.put(maxContourValue, contourLabel);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(minContourValue.doubleValue() == maxContourValue.doubleValue()){
|
||||
/*When minContourValue is equal to maxContourValue,
|
||||
* even if the contour interval is undefined
|
||||
* the contour values list will contain one element
|
||||
* namely the contour level specified by either
|
||||
* minContourValue or maxContourValue(since they are the same).
|
||||
/*
|
||||
* Starting from minContourValue, until maxContourValue is
|
||||
* reached, each contourValue is added to the mapand the next
|
||||
* contourValue in the range is computed by adding the
|
||||
* contourInterval to the current contour value.Finally, the
|
||||
* last element in the range - maxContourValue is also added to
|
||||
* the map.
|
||||
*/
|
||||
String contourLabel = addLeadingZerosToContourValue(numLeadingZeros, minContourValue);
|
||||
while (minContourValue.compareTo(maxContourValue) <= 0) {
|
||||
String contourLabel = addLeadingZerosToContourValue(
|
||||
numLeadingZeros, minContourValue);
|
||||
contourValMap.put(minContourValue, contourLabel);
|
||||
minContourValue = new Double(contourInterval
|
||||
+ minContourValue.doubleValue());
|
||||
}
|
||||
// String contourLabel = addLeadingZerosToContourValue(
|
||||
// numLeadingZeros, maxContourValue);
|
||||
// contourValMap.put(maxContourValue, contourLabel);
|
||||
}
|
||||
} else {
|
||||
if (minContourValue.doubleValue() == maxContourValue.doubleValue()) {
|
||||
/*
|
||||
* When minContourValue is equal to maxContourValue, even if the
|
||||
* contour interval is undefined the contour values list will
|
||||
* contain one element namely the contour level specified by
|
||||
* either minContourValue or maxContourValue(since they are the
|
||||
* same).
|
||||
*/
|
||||
String contourLabel = addLeadingZerosToContourValue(
|
||||
numLeadingZeros, minContourValue);
|
||||
contourValMap.put(minContourValue, contourLabel);
|
||||
} else {
|
||||
/*TODO Add code to generate the contour values list
|
||||
* when contourInterval is NAN or 0 but
|
||||
* minContourValue is not equal to maxContourValue*/
|
||||
/*
|
||||
* TODO Add code to generate the contour values list when
|
||||
* contourInterval is NAN or 0 but minContourValue is not equal
|
||||
* to maxContourValue
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
return contourValMap;
|
||||
}
|
||||
|
||||
/**@param List of Double - contourValuesList*/
|
||||
/**
|
||||
* @param List
|
||||
* of Double - contourValuesList
|
||||
*/
|
||||
private void setContourValuesList(List<Double> contourValuesList) {
|
||||
this.contourValuesList = contourValuesList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@param Double contourInterval
|
||||
* @param Double
|
||||
* contourInterval
|
||||
**/
|
||||
private void setContourInterval(Double contourInterval) {
|
||||
this.contourInterval = contourInterval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*@param Double minContourLevel
|
||||
* @param Double
|
||||
* minContourLevel
|
||||
**/
|
||||
private void setMinContourLevel(Double minContourLevel) {
|
||||
this.minContourLevel = minContourLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param Double maxContourLevel
|
||||
* @param Double
|
||||
* maxContourLevel
|
||||
**/
|
||||
private void setMaxContourLevel(Double maxContourLevel) {
|
||||
this.maxContourLevel = maxContourLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param Integer numPaddingDigits
|
||||
* @param Integer
|
||||
* numPaddingDigits
|
||||
**/
|
||||
private void setNumPaddingDigits(Integer numPaddingDigits) {
|
||||
this.numPaddingDigits = new Integer(numPaddingDigits);
|
||||
|
@ -582,14 +852,19 @@ public class ContourStringParser {
|
|||
/**
|
||||
* Creates and returns a String representation of the input contour value
|
||||
* after adding leading zeros to it.
|
||||
* @param nPaddingDigits - the number of leading zeros to add
|
||||
* @param inputDblVal - the contour value to which leading zeros might need to be added
|
||||
*
|
||||
* @return The String representation of the input Double value, after padding it
|
||||
* with leading zeros if its integer portion has less number of digits than the
|
||||
* number of padding digits
|
||||
* @param nPaddingDigits
|
||||
* - the number of leading zeros to add
|
||||
* @param inputDblVal
|
||||
* - the contour value to which leading zeros might need to be
|
||||
* added
|
||||
*
|
||||
* @return The String representation of the input Double value, after
|
||||
* padding it with leading zeros if its integer portion has less
|
||||
* number of digits than the number of padding digits
|
||||
*/
|
||||
private String addLeadingZerosToContourValue(int nPaddingDigits, Double inputDblVal){
|
||||
private String addLeadingZerosToContourValue(int nPaddingDigits,
|
||||
Double inputDblVal) {
|
||||
Integer intVal = new Integer(inputDblVal.intValue());
|
||||
boolean isNegative = false;
|
||||
if (inputDblVal < 0) {
|
||||
|
@ -614,22 +889,3 @@ public class ContourStringParser {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ Import-Package: com.vividsolutions.jts.geom,
|
|||
com.vividsolutions.jts.operation.valid,
|
||||
gov.noaa.nws.ncep.common.dataplugin.aww,
|
||||
gov.noaa.nws.ncep.ui.pgen,
|
||||
gov.noaa.nws.ncep.staticdataprovider,
|
||||
gov.noaa.nws.ncep.viz.common.dbQuery,
|
||||
gov.noaa.nws.ncep.viz.localization,
|
||||
gov.noaa.nws.ncep.viz.resources,
|
||||
|
|
|
@ -8,6 +8,20 @@
|
|||
|
||||
package gov.noaa.nws.ncep.staticdataprovider;
|
||||
|
||||
import gov.noaa.nws.ncep.common.staticdata.CostalWater;
|
||||
import gov.noaa.nws.ncep.common.staticdata.Cwa;
|
||||
import gov.noaa.nws.ncep.common.staticdata.FAArea;
|
||||
import gov.noaa.nws.ncep.common.staticdata.FARegion;
|
||||
import gov.noaa.nws.ncep.common.staticdata.GreatLake;
|
||||
import gov.noaa.nws.ncep.common.staticdata.IStaticDataProvider;
|
||||
import gov.noaa.nws.ncep.common.staticdata.Rfc;
|
||||
import gov.noaa.nws.ncep.common.staticdata.SPCCounty;
|
||||
import gov.noaa.nws.ncep.common.staticdata.USState;
|
||||
import gov.noaa.nws.ncep.edex.common.stationTables.StationTable;
|
||||
import gov.noaa.nws.ncep.viz.common.dbQuery.NcDirectDbQuery;
|
||||
import gov.noaa.nws.ncep.viz.localization.NcPathManager;
|
||||
import gov.noaa.nws.ncep.viz.localization.NcPathManager.NcPathConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,22 +41,9 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
import com.vividsolutions.jts.geom.MultiPolygon;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
|
||||
import gov.noaa.nws.ncep.common.staticdata.CostalWater;
|
||||
import gov.noaa.nws.ncep.common.staticdata.Cwa;
|
||||
import gov.noaa.nws.ncep.common.staticdata.FAArea;
|
||||
import gov.noaa.nws.ncep.common.staticdata.FARegion;
|
||||
import gov.noaa.nws.ncep.common.staticdata.GreatLake;
|
||||
import gov.noaa.nws.ncep.common.staticdata.IStaticDataProvider;
|
||||
import gov.noaa.nws.ncep.common.staticdata.Rfc;
|
||||
import gov.noaa.nws.ncep.common.staticdata.SPCCounty;
|
||||
import gov.noaa.nws.ncep.common.staticdata.USState;
|
||||
import gov.noaa.nws.ncep.edex.common.stationTables.StationTable;
|
||||
import gov.noaa.nws.ncep.viz.common.dbQuery.NcDirectDbQuery;
|
||||
import gov.noaa.nws.ncep.viz.localization.NcPathManager;
|
||||
import gov.noaa.nws.ncep.viz.localization.NcPathManager.NcPathConstants;
|
||||
|
||||
/**
|
||||
* Implementation of IStaticdataProvder interface. It contains methods that load static data.
|
||||
* Implementation of IStaticdataProvder interface. It contains methods that load
|
||||
* static data.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
|
@ -52,7 +53,8 @@ import gov.noaa.nws.ncep.viz.localization.NcPathManager.NcPathConstants;
|
|||
* 06/12 734 J. Zeng add getAllRfcs() and getAllCwas()
|
||||
* 08/12 #770 Q. Zhou added loadContWatchNum()
|
||||
* 01/13 #966 B. Yin Added methods to load bounds info.
|
||||
|
||||
* 04/14 TRAC 1112 S. Russell Added getActiveCounties()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author B. Yin
|
||||
|
@ -63,7 +65,8 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
static private StaticDataProvider dataProvider;
|
||||
|
||||
static public IStaticDataProvider getInstance() {
|
||||
if (dataProvider == null) dataProvider = new StaticDataProvider();
|
||||
if (dataProvider == null)
|
||||
dataProvider = new StaticDataProvider();
|
||||
return dataProvider;
|
||||
}
|
||||
|
||||
|
@ -144,33 +147,27 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
|
||||
@Override
|
||||
public File getGeogFile() {
|
||||
return NcPathManager.getInstance().getStaticFile(
|
||||
NcPathConstants.GEOG_TBL );
|
||||
return NcPathManager.getInstance().getStaticFile(NcPathConstants.GEOG_TBL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSfcStnFile() {
|
||||
return NcPathManager.getInstance().getStaticFile(
|
||||
NcPathConstants.SFSTNS_TBL );
|
||||
return NcPathManager.getInstance().getStaticFile(NcPathConstants.SFSTNS_TBL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalizationContext getLocalizationContext(LocalizationType type,
|
||||
LocalizationLevel level) {
|
||||
public LocalizationContext getLocalizationContext(LocalizationType type, LocalizationLevel level) {
|
||||
return NcPathManager.getInstance().getContext(type, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalizationFile getLocalizationFile(LocalizationContext context,
|
||||
String fileName) {
|
||||
return NcPathManager.getInstance().getLocalizationFile(context,
|
||||
fileName);
|
||||
public LocalizationFile getLocalizationFile(LocalizationContext context, String fileName) {
|
||||
return NcPathManager.getInstance().getLocalizationFile(context, fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFirBoundsFile() {
|
||||
return NcPathManager.getInstance().getStaticFile(
|
||||
NcPathConstants.PGEN_FIR_BOUNDS) ;
|
||||
return NcPathManager.getInstance().getStaticFile(NcPathConstants.PGEN_FIR_BOUNDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -180,8 +177,7 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
|
||||
try {
|
||||
list = NcDirectDbQuery.executeQuery(query, "ncep", QueryLanguage.SQL);
|
||||
}
|
||||
catch (Exception e ){
|
||||
} catch (Exception e) {
|
||||
System.out.println("___ Error: SigmetCommAttrDlg: initAllStates(): " + e.getMessage());
|
||||
list = new ArrayList<Object[]>();
|
||||
}
|
||||
|
@ -193,7 +189,8 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
public HashMap<String, String> getZoneMap() {
|
||||
|
||||
// query used to grab forecast zones from EDEX Database
|
||||
// TODO - move column/table names to config file so query is not hardwired in code
|
||||
// TODO - move column/table names to config file so query is not
|
||||
// hardwired in code
|
||||
String zoneQuery = "select state,zone,cwa from mapdata.zone;";
|
||||
|
||||
HashMap<String, String> zoneMap = new HashMap<String, String>();
|
||||
|
@ -212,8 +209,7 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
zoneMap.put(state.toString() + "Z" + zone.toString(), cwa.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( VizException ve ) {
|
||||
} catch (VizException ve) {
|
||||
ve.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -235,7 +231,6 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
return USStateProvider.statesInGeometry(geo);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Rfc> getAllRfcs() {
|
||||
return RfcProvider.getAllRfcs();
|
||||
|
@ -251,6 +246,12 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
return RfcProvider.rfcsInGeometry(geo);
|
||||
}
|
||||
|
||||
// TRAC 1112
|
||||
@Override
|
||||
public List<String> getActiveCounties(int watchNum, List<SPCCounty> oldCountyList) {
|
||||
return new WatchActiveCounties().getActiveCounties(watchNum, oldCountyList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cwa> getAllCwas() {
|
||||
return CwaProvider.getAllCwas();
|
||||
|
@ -260,6 +261,7 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
public List<Cwa> loadCwaTable() {
|
||||
return CwaProvider.loadCwaTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Cwa> cwasInGeometry(Geometry geo) {
|
||||
return CwaProvider.cwasInGeometry(geo);
|
||||
|
@ -270,16 +272,14 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
HashMap<String, String> stMap = new HashMap<String, String>();
|
||||
String queryStates = "Select state,name FROM mapdata.states;";
|
||||
try {
|
||||
List<Object[]> states = NcDirectDbQuery.executeQuery(
|
||||
queryStates, "maps", QueryLanguage.SQL);
|
||||
List<Object[]> states = NcDirectDbQuery.executeQuery(queryStates, "maps", QueryLanguage.SQL);
|
||||
|
||||
for (Object[] st : states) {
|
||||
if (st[0] != null && st[1] != null) {
|
||||
stMap.put((String) st[0], (String) st[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e ){
|
||||
} catch (Exception e) {
|
||||
System.out.println("db exception reading state tables!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -315,8 +315,7 @@ public class StaticDataProvider implements IStaticDataProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<MultiPolygon> getG2GBounds(String tableAlias,
|
||||
String columnName, String columnValue) {
|
||||
public ArrayList<MultiPolygon> getG2GBounds(String tableAlias, String columnName, String columnValue) {
|
||||
return G2GBoundsProvider.getG2GBounds(tableAlias, columnName, columnValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,351 @@
|
|||
package gov.noaa.nws.ncep.staticdataprovider;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwFips;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwUgc;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwVtec;
|
||||
import gov.noaa.nws.ncep.common.staticdata.SPCCounty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest.OrderMode;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* Data retrieval from the AWW tables by report type (WCN) and by watch number.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 2104 Mar 21 TRAC 1112 srussell Initial creation
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Possible aw_vtec.action values:
|
||||
* ----------------------------------------------------------------------------
|
||||
* NEW - Brand new product
|
||||
* CON - Continues for a subset of counties (usually issued in segmented
|
||||
* fashion with CAN).
|
||||
* CAN - Cancels part or all of the area in the product.
|
||||
* EXP - Watch expiration statement, this is different than a CAN in the
|
||||
* sense that it does not stop immediately but at the initial
|
||||
* expiration time of the watch.
|
||||
* EXT - Extends the time a watch is valid for
|
||||
* EXA - Extends the area a watch is valid for
|
||||
* EXB - Extends the area and time a watch is valid for
|
||||
*
|
||||
* http://www.nws.noaa.gov/directives/sym/pd01005011curr.pdf
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author srussell
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class WatchActiveCounties {
|
||||
|
||||
private final static TimeZone utc = TimeZone.getTimeZone("UTC");
|
||||
|
||||
/* Queries Aww tables by report type and by watch number. Once it gets the
|
||||
* AWW records, it will loop through the records and get the latest county
|
||||
* UGCs. It will skip the UGCs with the action code “CAN” (canceled). It
|
||||
* will return a list of active county UGCs. */
|
||||
|
||||
public List<String> getActiveCounties(int watchNum, List<SPCCounty> watchBoxCountyList) {
|
||||
|
||||
List<String> ugcList = new ArrayList<String>();
|
||||
List<WatchRecord> watchRecords = new ArrayList<WatchRecord>();
|
||||
HashMap<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
|
||||
String pluginName = "aww";
|
||||
String reportType = "WATCH COUNTY NOTIFICATION";
|
||||
String orderBy = "issueTime,issueOffice";
|
||||
|
||||
String likeClause = "%" + watchNum + "%";
|
||||
ConstraintType like = ConstraintType.LIKE;
|
||||
|
||||
constraints.put("pluginName", new RequestConstraint(pluginName));
|
||||
constraints.put("reportType", new RequestConstraint(reportType));
|
||||
constraints.put("watchNumber", new RequestConstraint(likeClause, like));
|
||||
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setConstraints(constraints);
|
||||
request.setOrderByField(orderBy, OrderMode.ASC);
|
||||
|
||||
try {
|
||||
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient.sendRequest(request);
|
||||
|
||||
if (response == null) {
|
||||
return ugcList;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> responseList = response.getResults();
|
||||
AwwRecord awwRecord = null;
|
||||
|
||||
// Retrieve the latest watch records from the database for this watch
|
||||
for (Map<String, Object> eachResponse : responseList) {
|
||||
|
||||
Collection<Object> recordObj = eachResponse.values();
|
||||
|
||||
for (Object pdo : recordObj) {
|
||||
|
||||
if (pdo instanceof AwwRecord) {
|
||||
awwRecord = (AwwRecord) pdo;
|
||||
addWatchRecord(watchRecords, awwRecord, watchNum);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the county ID strings out of the watch box county list
|
||||
for (SPCCounty county : watchBoxCountyList) {
|
||||
ugcList.add(county.getUgcId());
|
||||
}
|
||||
|
||||
// Update the list of counties from the watch box list, with values
|
||||
// the values retrieved from the database.
|
||||
updateWatchBoxCountyList(ugcList, watchRecords);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ugcList;
|
||||
}
|
||||
|
||||
private static void updateWatchBoxCountyList(List<String> ugcList, List<WatchRecord> watchRecords) {
|
||||
|
||||
String ugc = null;
|
||||
String action = null;
|
||||
Calendar eventEndTime = null;
|
||||
Calendar currentTime = null;
|
||||
|
||||
for (WatchRecord wr : watchRecords) {
|
||||
ugc = wr.getUgc();
|
||||
action = wr.getAction();
|
||||
|
||||
// New county put into the watch
|
||||
if (action.equalsIgnoreCase("NEW")) {
|
||||
if (!ugcList.contains(ugc)) {
|
||||
ugcList.add(ugc);
|
||||
}
|
||||
}
|
||||
|
||||
// County watch cancelled
|
||||
else if (action.equalsIgnoreCase("CAN")) {
|
||||
ugcList.remove(ugc);
|
||||
}
|
||||
|
||||
// County watch "expired"
|
||||
else if (action.equalsIgnoreCase("EXP")) {
|
||||
|
||||
eventEndTime = wr.getEventEndTime();
|
||||
eventEndTime.setTimeZone(utc);
|
||||
currentTime = Calendar.getInstance(utc);
|
||||
|
||||
if (ugcList.contains(ugc) && eventEndTime.before(currentTime)) {
|
||||
ugcList.remove(ugc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addWatchRecord(List<WatchRecord> watchRecords, AwwRecord aww, int watchNum) {
|
||||
|
||||
if (aww == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
WatchRecord county = null;
|
||||
int watchNumInUGC = -1;
|
||||
Set<AwwUgc> ugcSet = aww.getAwwUGC();
|
||||
String wfo = aww.getIssueOffice();
|
||||
Calendar issueTime = aww.getIssueTime();
|
||||
|
||||
// For each AwwUgc
|
||||
for (AwwUgc ugc : ugcSet) {
|
||||
watchNumInUGC = -1;
|
||||
|
||||
try {
|
||||
// Get the watch number from the UGC
|
||||
watchNumInUGC = Integer.parseInt(ugc.getEventTrackingNumber());
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If watch number in the UGC does NOT match the one in the query
|
||||
if (watchNumInUGC != watchNum) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<AwwVtec> vtec = ugc.getAwwVtecLine();
|
||||
if (vtec.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the vtec.action
|
||||
AwwVtec one_vtec = vtec.iterator().next();
|
||||
String action = one_vtec.getAction();
|
||||
|
||||
// Get the UGC
|
||||
Set<AwwFips> fipsSet = ugc.getAwwFIPS();
|
||||
for (AwwFips fips : fipsSet) {
|
||||
county = this.new WatchRecord();
|
||||
county.setUgc(fips.getFips());
|
||||
county.setWfo(wfo);
|
||||
county.setAction(action);
|
||||
county.setIssueTIme(issueTime);
|
||||
if (action.equalsIgnoreCase("EXP")) {
|
||||
county.setEventEndTime(one_vtec.getEventEndTime());
|
||||
}
|
||||
if (!watchRecords.contains(county)) {
|
||||
watchRecords.add(county);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}// end function addAwwUgc
|
||||
|
||||
private class WatchRecord {
|
||||
private String ugc = null;
|
||||
|
||||
private String wfo = null;
|
||||
|
||||
private String action = null;
|
||||
|
||||
private Calendar eventEndTime = null;
|
||||
|
||||
private Calendar issueTime = null;
|
||||
|
||||
public WatchRecord() {
|
||||
}
|
||||
|
||||
public String getUgc() {
|
||||
return ugc;
|
||||
}
|
||||
|
||||
public void setUgc(String ugc) {
|
||||
this.ugc = ugc;
|
||||
}
|
||||
|
||||
public String getWfo() {
|
||||
return wfo;
|
||||
}
|
||||
|
||||
public void setWfo(String wfo) {
|
||||
this.wfo = wfo;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Calendar getEventEndTime() {
|
||||
return eventEndTime;
|
||||
}
|
||||
|
||||
public void setEventEndTime(Calendar eventEndTime) {
|
||||
this.eventEndTime = eventEndTime;
|
||||
}
|
||||
|
||||
public Calendar getIssueTime() {
|
||||
return issueTime;
|
||||
}
|
||||
|
||||
public void setIssueTIme(Calendar issueTime) {
|
||||
this.issueTime = issueTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + getOuterType().hashCode();
|
||||
result = prime * result + ((action == null) ? 0 : action.hashCode());
|
||||
result = prime * result + ((eventEndTime == null) ? 0 : eventEndTime.hashCode());
|
||||
result = prime * result + ((issueTime == null) ? 0 : issueTime.hashCode());
|
||||
result = prime * result + ((ugc == null) ? 0 : ugc.hashCode());
|
||||
result = prime * result + ((wfo == null) ? 0 : wfo.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof WatchRecord)) {
|
||||
return false;
|
||||
}
|
||||
WatchRecord other = (WatchRecord) obj;
|
||||
if (!getOuterType().equals(other.getOuterType())) {
|
||||
return false;
|
||||
}
|
||||
if (action == null) {
|
||||
if (other.action != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!action.equals(other.action)) {
|
||||
return false;
|
||||
}
|
||||
if (eventEndTime == null) {
|
||||
if (other.eventEndTime != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!eventEndTime.equals(other.eventEndTime)) {
|
||||
return false;
|
||||
}
|
||||
if (issueTime == null) {
|
||||
if (other.issueTime != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!issueTime.equals(other.issueTime)) {
|
||||
return false;
|
||||
}
|
||||
if (ugc == null) {
|
||||
if (other.ugc != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!ugc.equals(other.ugc)) {
|
||||
return false;
|
||||
}
|
||||
if (wfo == null) {
|
||||
if (other.wfo != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!wfo.equals(other.wfo)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private WatchActiveCounties getOuterType() {
|
||||
return WatchActiveCounties.this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}// end class WatchActiveCounties
|
|
@ -1,5 +1,7 @@
|
|||
package gov.noaa.nws.ncep.viz.common.area;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.util.McidasCRSBuilder;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridEnvelope2D;
|
||||
|
@ -25,6 +27,7 @@ import com.raytheon.uf.common.serialization.adapters.GridGeometrySerialized;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 11/2013 1066 G. Hull Created.
|
||||
* 03/2014 TTR957 B. Yin Handle native satellite navigation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,7 +55,7 @@ public class NcGridGeometryAdapter extends GridGeometryAdapter {
|
|||
try {
|
||||
crs = CRS.parseWKT(v.CRS);
|
||||
} catch (Exception e) {
|
||||
crs = null;
|
||||
crs = McidasCRSBuilder.constructCRSfromWKT(v.CRS);
|
||||
}
|
||||
|
||||
if (crs == null) {
|
||||
|
|
|
@ -17,6 +17,7 @@ package gov.noaa.nws.ncep.viz.common.ui;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 3,2010 324 X. Guo Initial Creation
|
||||
* Dec 6,2010 X. Guo Change clean up function
|
||||
* Apr22,2014 1129 B. Hebbard Move maxHi/maxLo from here to GridRelativeHiLoDisplay so can handle relative to current extent
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -25,6 +26,7 @@ package gov.noaa.nws.ncep.viz.common.ui;
|
|||
*/
|
||||
|
||||
public class HILORelativeMinAndMaxLocator {
|
||||
|
||||
// Grid point values array
|
||||
protected float[] grid;
|
||||
|
||||
|
@ -40,12 +42,6 @@ public class HILORelativeMinAndMaxLocator {
|
|||
// Search Interpolation
|
||||
private boolean gridInterp;
|
||||
|
||||
// Maximum number of highs
|
||||
private int gridMaxHi;
|
||||
|
||||
// Maximum number of lows
|
||||
private int gridMaxLo;
|
||||
|
||||
// Lower bound on maximum
|
||||
private float gridLowerMax;
|
||||
|
||||
|
@ -119,8 +115,8 @@ public class HILORelativeMinAndMaxLocator {
|
|||
|
||||
// HILO Min/Max locator construct
|
||||
public HILORelativeMinAndMaxLocator(float[] gridData, int col, int row,
|
||||
int radius, boolean interp, int maxHi, int maxLo, float maxLowerBd,
|
||||
float maxUpperBd, float minLowerBd, float minUpperBd) {
|
||||
int radius, boolean interp, float maxLowerBd, float maxUpperBd,
|
||||
float minLowerBd, float minUpperBd) {
|
||||
|
||||
isHiLoRelativeMinAndMaxLocated = false;
|
||||
grid = gridData;
|
||||
|
@ -130,8 +126,6 @@ public class HILORelativeMinAndMaxLocator {
|
|||
if ((isHiLoRelativeMinAndMaxLocated = checkGridValues())) {
|
||||
setGridRadius(radius);
|
||||
gridInterp = interp;
|
||||
gridMaxHi = maxHi;
|
||||
gridMaxLo = maxLo;
|
||||
gridLowerMax = maxLowerBd;
|
||||
gridUpperMax = maxUpperBd;
|
||||
gridLowerMin = minLowerBd;
|
||||
|
@ -153,10 +147,10 @@ public class HILORelativeMinAndMaxLocator {
|
|||
}
|
||||
|
||||
/**
|
||||
* 9999 Find the extrema
|
||||
* Find the extrema
|
||||
*/
|
||||
private boolean findExtrema() {
|
||||
int mm, nextr;
|
||||
int mm;
|
||||
float rmin, rmax;
|
||||
xExtr = new float[GRID_MXM];
|
||||
yExtr = new float[GRID_MXM];
|
||||
|
@ -166,30 +160,27 @@ public class HILORelativeMinAndMaxLocator {
|
|||
if (mm == 0) {
|
||||
rmin = gridLowerMin;
|
||||
rmax = gridUpperMin;
|
||||
nextr = gridMaxLo;
|
||||
} else {
|
||||
rmin = gridLowerMax;
|
||||
rmax = gridUpperMax;
|
||||
nextr = gridMaxHi;
|
||||
}
|
||||
|
||||
chkGribPoint(mm, rmin, rmax);
|
||||
// Sort extrema
|
||||
sortExtrema(mm);
|
||||
clusterLocator();
|
||||
int ifinct = Math.min(numOfExtr, nextr);
|
||||
|
||||
if (mm == 0) {
|
||||
loadMinGridValues(ifinct);
|
||||
loadMinGridValues();
|
||||
} else {
|
||||
loadMaxGridValues(ifinct);
|
||||
loadMaxGridValues();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check each point and see if it is present and visible
|
||||
* Check each point and see if it is present
|
||||
*/
|
||||
private void chkGribPoint(int mm, float min, float max) {
|
||||
int i, j, cidx, cidx1, ii, jj;
|
||||
|
@ -201,7 +192,8 @@ public class HILORelativeMinAndMaxLocator {
|
|||
for (j = gridRadius + 1; j <= gridRow - gridRadius; j++) {
|
||||
for (i = gridRadius + 1; i <= gridCol - gridRadius; i++) {
|
||||
cidx = (j - 1) * gridCol + i - 1;
|
||||
// Check the grid point is present and visible
|
||||
// Check the grid point is present. (No visibility check
|
||||
// possible at this stage.)
|
||||
if (!checkGridMissingValues(grid[cidx])) {
|
||||
ok = true;
|
||||
alleq = true;
|
||||
|
@ -293,11 +285,11 @@ public class HILORelativeMinAndMaxLocator {
|
|||
/**
|
||||
* Load minimum grid values
|
||||
*/
|
||||
private void loadMinGridValues(int ifinct) {
|
||||
dgMinCol = new float[ifinct];
|
||||
dgMinRow = new float[ifinct];
|
||||
dgMinVal = new float[ifinct];
|
||||
for (int k = 0; k < ifinct; k++) {
|
||||
private void loadMinGridValues() {
|
||||
dgMinCol = new float[numOfExtr];
|
||||
dgMinRow = new float[numOfExtr];
|
||||
dgMinVal = new float[numOfExtr];
|
||||
for (int k = 0; k < numOfExtr; k++) {
|
||||
dgMinCol[k] = xExtr[k];
|
||||
dgMinRow[k] = yExtr[k];
|
||||
dgMinVal[k] = vExtr[k];
|
||||
|
@ -307,11 +299,11 @@ public class HILORelativeMinAndMaxLocator {
|
|||
/**
|
||||
* Load maximum grid values
|
||||
*/
|
||||
private void loadMaxGridValues(int ifinct) {
|
||||
dgMaxCol = new float[ifinct];
|
||||
dgMaxRow = new float[ifinct];
|
||||
dgMaxVal = new float[ifinct];
|
||||
for (int k = 0; k < ifinct; k++) {
|
||||
private void loadMaxGridValues() {
|
||||
dgMaxCol = new float[numOfExtr];
|
||||
dgMaxRow = new float[numOfExtr];
|
||||
dgMaxVal = new float[numOfExtr];
|
||||
for (int k = 0; k < numOfExtr; k++) {
|
||||
dgMaxCol[k] = xExtr[k];
|
||||
dgMaxRow[k] = yExtr[k];
|
||||
dgMaxVal[k] = vExtr[k];
|
||||
|
@ -616,8 +608,6 @@ public class HILORelativeMinAndMaxLocator {
|
|||
+ gridRow);
|
||||
System.out.println(" Radius:" + gridRadius + " interp:"
|
||||
+ gridInterp);
|
||||
System.out.println(" Max number of highs:" + gridMaxHi
|
||||
+ " Max number of lows:" + gridMaxLo);
|
||||
System.out.println(" Lower Bound on Max:" + gridLowerMax
|
||||
+ " Upper Bound on Max:" + gridUpperMax);
|
||||
System.out.println(" Lower Bound on Min:" + gridLowerMin
|
||||
|
|
|
@ -8,11 +8,6 @@ Eclipse-RegisterBuddy: gov.noaa.nws.ncep.viz.resources, org.apache.velocity, com
|
|||
Eclipse-BuddyPolicy: ext, global
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
com.raytheon.viz.pointdata;bundle-version="1.11.17",
|
||||
org.geotools;bundle-version="2.5.2",
|
||||
javax.measure;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.colormap;bundle-version="1.11.17",
|
||||
com.raytheon.uf.viz.core;bundle-version="1.11.17",
|
||||
com.raytheon.viz.core;bundle-version="1.11.17",
|
||||
gov.noaa.nws.ncep.ui.pgen;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.viz.resources,
|
||||
|
@ -23,11 +18,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
gov.noaa.nws.ncep.edex.common;bundle-version="1.0.0",
|
||||
com.raytheon.viz.ui;bundle-version="1.11.22",
|
||||
gov.noaa.nws.ncep.viz.ui.display;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.viz.localization;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.serialization,
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1161",
|
||||
gov.noaa.nws.ncep.common.log;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.viz.gempak;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.viz.gempak.nativelib;bundle-version="1.0.0",
|
||||
|
@ -37,20 +28,10 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|||
Export-Package: gov.noaa.nws.ncep.viz.rsc.ncgrid,
|
||||
gov.noaa.nws.ncep.viz.rsc.ncgrid.contours,
|
||||
gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc
|
||||
Import-Package: com.raytheon.viz.core.contours.util,
|
||||
com.raytheon.uf.common.comm,
|
||||
com.raytheon.uf.common.dataplugin.level,
|
||||
com.raytheon.uf.common.derivparam.tree,
|
||||
com.raytheon.uf.common.pointdata,
|
||||
com.raytheon.uf.viz.derivparam.data,
|
||||
com.raytheon.uf.viz.derivparam.inv,
|
||||
com.raytheon.uf.viz.derivparam.library,
|
||||
com.raytheon.uf.viz.derivparam.tree,
|
||||
com.raytheon.viz.grid.inv,
|
||||
Import-Package: com.raytheon.uf.common.comm,
|
||||
com.raytheon.viz.core.contours.util,
|
||||
com.sun.jna,
|
||||
com.sun.jna.ptr,
|
||||
gov.noaa.nws.ncep.common.log.logger,
|
||||
gov.noaa.nws.ncep.common.tools,
|
||||
gov.noaa.nws.ncep.viz.gempak.grid.inv,
|
||||
gov.noaa.nws.ncep.viz.gempak.grid.mapper,
|
||||
gov.noaa.nws.ncep.viz.gempak.grid.units
|
||||
|
|
|
@ -36,6 +36,8 @@ public class ContourAttributes {
|
|||
|
||||
private String text;
|
||||
|
||||
private String colors;
|
||||
|
||||
public String getGlevel() {
|
||||
return glevel;
|
||||
}
|
||||
|
@ -164,7 +166,8 @@ public class ContourAttributes {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param clrbar the clrbar to set
|
||||
* @param clrbar
|
||||
* the clrbar to set
|
||||
*/
|
||||
public final void setClrbar(String clrbar) {
|
||||
this.clrbar = clrbar;
|
||||
|
@ -178,25 +181,37 @@ public class ContourAttributes {
|
|||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colors
|
||||
*/
|
||||
public String getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
public void setColors(String colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public boolean isMatch(ContourAttributes attr) {
|
||||
boolean match = false;
|
||||
if ( this.glevel.trim().equalsIgnoreCase(attr.getGlevel())&&
|
||||
this.gvcord.trim().equalsIgnoreCase(attr.getGvcord()) &&
|
||||
this.skip.trim().equalsIgnoreCase(attr.getSkip()) &&
|
||||
this.filter.trim().equalsIgnoreCase(attr.getFilter()) &&
|
||||
this.scale.trim().equalsIgnoreCase(attr.getScale()) &&
|
||||
this.gdpfun.trim().equalsIgnoreCase(attr.getGdpfun()) &&
|
||||
this.type.trim().equalsIgnoreCase(attr.getType())&&
|
||||
this.cint.trim().equalsIgnoreCase(attr.getCint()) &&
|
||||
this.line.trim().equalsIgnoreCase(attr.getLine()) &&
|
||||
this.fint.trim().equalsIgnoreCase(attr.getFint()) &&
|
||||
this.fline.trim().equalsIgnoreCase(attr.getFline()) &&
|
||||
this.hilo.trim().equalsIgnoreCase(attr.getHilo()) &&
|
||||
this.hlsym.trim().equalsIgnoreCase(attr.getHlsym()) &&
|
||||
this.wind.trim().equalsIgnoreCase(attr.getWind()) &&
|
||||
this.marker.trim().equalsIgnoreCase(attr.getMarker()) &&
|
||||
this.clrbar.trim().equalsIgnoreCase(attr.getClrbar()) &&
|
||||
this.text.trim().equalsIgnoreCase(attr.getText())) {
|
||||
if (this.glevel.trim().equalsIgnoreCase(attr.getGlevel())
|
||||
&& this.gvcord.trim().equalsIgnoreCase(attr.getGvcord())
|
||||
&& this.skip.trim().equalsIgnoreCase(attr.getSkip())
|
||||
&& this.filter.trim().equalsIgnoreCase(attr.getFilter())
|
||||
&& this.scale.trim().equalsIgnoreCase(attr.getScale())
|
||||
&& this.gdpfun.trim().equalsIgnoreCase(attr.getGdpfun())
|
||||
&& this.type.trim().equalsIgnoreCase(attr.getType())
|
||||
&& this.cint.trim().equalsIgnoreCase(attr.getCint())
|
||||
&& this.line.trim().equalsIgnoreCase(attr.getLine())
|
||||
&& this.fint.trim().equalsIgnoreCase(attr.getFint())
|
||||
&& this.fline.trim().equalsIgnoreCase(attr.getFline())
|
||||
&& this.hilo.trim().equalsIgnoreCase(attr.getHilo())
|
||||
&& this.hlsym.trim().equalsIgnoreCase(attr.getHlsym())
|
||||
&& this.wind.trim().equalsIgnoreCase(attr.getWind())
|
||||
&& this.marker.trim().equalsIgnoreCase(attr.getMarker())
|
||||
&& this.clrbar.trim().equalsIgnoreCase(attr.getClrbar())
|
||||
&& this.text.trim().equalsIgnoreCase(attr.getText())
|
||||
&& this.colors.trim().equalsIgnoreCase(attr.getColors())) {
|
||||
match = true;
|
||||
}
|
||||
return match;
|
||||
|
|
|
@ -129,6 +129,8 @@ import com.vividsolutions.jts.linearref.LocationIndexedLine;
|
|||
* Sep 17, 2013 #1036 S. Gurung Added TEXT attribute related changes to create labels with various parameters
|
||||
* Oct 30, 2013 #1045 S. Gurung Fix for FINT/FLINE parsing issues
|
||||
* Aug 27, 2013 2262 bsteffen Convert to use new StrmPak.
|
||||
* Apr 23, 2014 #856 pswamy Missing color fill in grid diagnostics.
|
||||
* Apr 30, 2014 862 pswamy Grid Precipitable Water Contour Labels needs two decimal points
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -619,7 +621,7 @@ public class ContourSupport {
|
|||
}
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0.#");
|
||||
DecimalFormat df = new DecimalFormat("0.##");
|
||||
double[] loc = { 0.0, 0.0 };
|
||||
|
||||
if (actualLength > 0) {
|
||||
|
@ -1154,10 +1156,17 @@ public class ContourSupport {
|
|||
if (!(fint.equalsIgnoreCase(cint))) {
|
||||
fvalues = FINT.parseFINT(fint, zoomLevelIndex,
|
||||
cntrData.minValue, cntrData.getMaxValue());
|
||||
} else if (contourGroup.cvalues != null) {
|
||||
} else {
|
||||
if ((contourGroup.cvalues != null)
|
||||
&& (contourGroup.cvalues.size() != 0)) {
|
||||
fvalues = contourGroup.cvalues;
|
||||
} else {
|
||||
fvalues = FINT.parseFINT(fint, zoomLevelIndex,
|
||||
cntrData.minValue, cntrData.getMaxValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contourGroup.fvalues.size() == 0 && fvalues != null) {
|
||||
contourGroup.fvalues.addAll(fvalues);
|
||||
} else if (contourGroup.fvalues.size() > 0) {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
******************************************************************************************/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ncgrid.contours;
|
||||
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
@ -42,8 +44,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
/**
|
||||
* Display grid point values
|
||||
*
|
||||
|
@ -55,6 +55,7 @@ import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
|||
* June, 2010 164 M. Li Initial creation
|
||||
* October,2011 X. Guo Display grid point in GRID_CENTER
|
||||
* Apr, 2013 B. Yin Don't plot missing values
|
||||
* 02/04/2014 936 T. Lee Implemented textSize
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,11 +73,13 @@ public class GridPointValueDisplay implements IRenderable {
|
|||
|
||||
private RGB color;
|
||||
|
||||
private int textSize;
|
||||
|
||||
private FloatBuffer displayValues;
|
||||
|
||||
private IFont font;
|
||||
|
||||
public GridPointValueDisplay(FloatBuffer values, RGB color,
|
||||
public GridPointValueDisplay(FloatBuffer values, RGB color, int textSize,
|
||||
IMapDescriptor descriptor, ISpatialObject gridLocation) {
|
||||
|
||||
this.displayValues = values;
|
||||
|
@ -84,6 +87,7 @@ public class GridPointValueDisplay implements IRenderable {
|
|||
this.gridGeometryOfGrid = MapUtil.getGridGeometry(gridLocation);
|
||||
this.gridDims = new int[] { gridLocation.getNx(), gridLocation.getNy() };
|
||||
this.color = color;
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -100,7 +104,8 @@ public class GridPointValueDisplay implements IRenderable {
|
|||
if (paintProps.isZooming()) {
|
||||
return;
|
||||
}
|
||||
font = target.initializeFont("Monospace", 10,
|
||||
|
||||
font = target.initializeFont("Monospace", textSize,
|
||||
new IFont.Style[] { IFont.Style.BOLD });
|
||||
|
||||
IExtent screenExtentInPixels = paintProps.getView().getExtent();
|
||||
|
@ -122,7 +127,8 @@ public class GridPointValueDisplay implements IRenderable {
|
|||
for (int i = 0; i < gridDims[0]; i += interv + 1) {
|
||||
|
||||
for (int j = 0; j < gridDims[1]; j += interv + 1) {
|
||||
if (displayValues.get((i + (j * this.gridDims[0])) ) == IDecoderConstantsN.GRID_MISSING) continue;
|
||||
if (displayValues.get((i + (j * this.gridDims[0]))) == IDecoderConstantsN.GRID_MISSING)
|
||||
continue;
|
||||
|
||||
ReferencedCoordinate c = new ReferencedCoordinate(
|
||||
new Coordinate(i, j), this.gridGeometryOfGrid,
|
||||
|
|
|
@ -20,10 +20,12 @@ import com.raytheon.uf.common.geospatial.ISpatialObject;
|
|||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
|
||||
import com.raytheon.uf.common.geospatial.ReferencedObject.Type;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderable;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
|
@ -40,7 +42,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 24, 2010 363 X. Guo Initial creation
|
||||
* Aut 17, 2012 655 B. Hebbard Added paintProps as parameter to IDisplayable draw (2)
|
||||
* Aug 17, 2012 655 B. Hebbard Added paintProps as parameter to IDisplayable draw (2)
|
||||
* Apr 22, 2014 1129 B. Hebbard Handle maxHi/maxLo here (instead of HILORelativeMinAndMaxLocator) to make extent-sensitive
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -58,6 +61,12 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
|
||||
private HILORelativeMinAndMaxLocator hiloLocator;
|
||||
|
||||
// Maximum number of highs to display
|
||||
private int maxHi;
|
||||
|
||||
// Maximum number of lows to display
|
||||
private int maxLo;
|
||||
|
||||
private TextStringParser textMarkerString;
|
||||
|
||||
private TextStringParser textValueString;
|
||||
|
@ -66,7 +75,7 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
|
||||
private SymbolLocationSet gridPointLoSymbolSet = null;
|
||||
|
||||
// Hi/L symbol overtical/horizontal offset parameters
|
||||
// Hi/Lo symbol vertical/horizontal offset parameters
|
||||
private double symbolHiHight = 0.0;
|
||||
|
||||
private double symbolLoHight = 0.0;
|
||||
|
@ -80,13 +89,15 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
Rectangle2D charSize;
|
||||
|
||||
public GridRelativeHiLoDisplay(HILOBuilder hiloBuild,
|
||||
HILORelativeMinAndMaxLocator hiloLocator,
|
||||
HILORelativeMinAndMaxLocator hiloLocator, int maxHi, int maxLo,
|
||||
TextStringParser markerStr, TextStringParser valueStr,
|
||||
IMapDescriptor descriptor, ISpatialObject gridLocation) {
|
||||
this.descriptor = descriptor;
|
||||
this.gridGeometryOfGrid = MapUtil.getGridGeometry(gridLocation);
|
||||
this.hiloBuild = hiloBuild;
|
||||
this.hiloLocator = hiloLocator;
|
||||
this.maxHi = maxHi;
|
||||
this.maxLo = maxLo;
|
||||
this.textMarkerString = markerStr;
|
||||
this.textValueString = valueStr;
|
||||
if (ContourSupport.getCentralMeridian(descriptor) == 0.0) {
|
||||
|
@ -137,7 +148,7 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
}
|
||||
|
||||
if (hiloBuild.getSymbolHiPlotValue()) {
|
||||
plotGridHiValue(target);
|
||||
plotGridHiValue(target, paintProps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +172,7 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
}
|
||||
|
||||
if (hiloBuild.getSymbolLoPlotValue()) {
|
||||
plotGridLoValue(target);
|
||||
plotGridLoValue(target, paintProps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,8 +193,10 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
new IFont.Style[] { IFont.Style.BOLD });
|
||||
charSize = target.getStringBounds(font, "N");
|
||||
symbolHiHight = charSize.getHeight() * charPix;
|
||||
PixelExtent correctedExtent = getCorrectedExtent(paintProps);
|
||||
|
||||
for (int i = 0; i < tmp1.length; i++) {
|
||||
int pointsPlotted = 0;
|
||||
for (int i = 0; i < tmp1.length && pointsPlotted < maxHi; i++) {
|
||||
|
||||
ReferencedCoordinate c = new ReferencedCoordinate(
|
||||
new Coordinate((double) tmp1[i] - 1,
|
||||
|
@ -191,13 +204,17 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
Type.GRID_CENTER);
|
||||
try {
|
||||
double[] d = this.descriptor.worldToPixel(new double[] {
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x - xOffset: c.asLatLon().x,
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x
|
||||
- xOffset : c.asLatLon().x,
|
||||
(double) c.asLatLon().y });
|
||||
|
||||
if (correctedExtent.contains(d[0], d[1])) {
|
||||
target.drawString(font, text, d[0], d[1], 0.0,
|
||||
TextStyle.NORMAL, hiloBuild.getColorHi(),
|
||||
HorizontalAlignment.CENTER,
|
||||
VerticalAlignment.MIDDLE, 0.0);
|
||||
pointsPlotted++;
|
||||
}
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -226,8 +243,10 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
new IFont.Style[] { IFont.Style.BOLD });
|
||||
charSize = target.getStringBounds(font, "N");
|
||||
symbolLoHight = charSize.getHeight() * charPix;
|
||||
PixelExtent correctedExtent = getCorrectedExtent(paintProps);
|
||||
|
||||
for (int i = 0; i < tmp1.length; i++) {
|
||||
int pointsPlotted = 0;
|
||||
for (int i = 0; i < tmp1.length && pointsPlotted < maxLo; i++) {
|
||||
|
||||
ReferencedCoordinate c = new ReferencedCoordinate(
|
||||
new Coordinate((double) tmp1[i] - 1,
|
||||
|
@ -236,13 +255,17 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
try {
|
||||
|
||||
double[] d = this.descriptor.worldToPixel(new double[] {
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x - xOffset: c.asLatLon().x,
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x
|
||||
- xOffset : c.asLatLon().x,
|
||||
(double) c.asLatLon().y });
|
||||
// System.out.println("Low longitude: " + c.asLatLon().x );
|
||||
if (correctedExtent.contains(d[0], d[1])) {
|
||||
target.drawString(font, text, d[0], d[1], 0.0,
|
||||
TextStyle.NORMAL, hiloBuild.getColorLo(),
|
||||
HorizontalAlignment.CENTER,
|
||||
VerticalAlignment.MIDDLE, 0.0);
|
||||
pointsPlotted++;
|
||||
}
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -256,8 +279,11 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
|
||||
/**
|
||||
* Plot High grid values
|
||||
*
|
||||
* @param paintProps
|
||||
*/
|
||||
private void plotGridHiValue(IGraphicsTarget target) throws VizException {
|
||||
private void plotGridHiValue(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
float[] tmp1 = hiloLocator.getMaxColPositions();
|
||||
|
||||
if (tmp1.length > 0) {
|
||||
|
@ -273,7 +299,10 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
// offY += charSize.getHeight()*charPix;
|
||||
offY = charSize.getHeight() * vertRatio;
|
||||
}
|
||||
for (int i = 0; i < tmp1.length; i++) {
|
||||
PixelExtent correctedExtent = getCorrectedExtent(paintProps);
|
||||
|
||||
int pointsPlotted = 0;
|
||||
for (int i = 0; i < tmp1.length && pointsPlotted < maxHi; i++) {
|
||||
|
||||
String text = convertFloat2String(tmp3[i],
|
||||
hiloBuild.getSymbolHiNumOfDecPls());
|
||||
|
@ -283,13 +312,16 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
Type.GRID_CENTER);
|
||||
try {
|
||||
double[] d = this.descriptor.worldToPixel(new double[] {
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x - xOffset: c.asLatLon().x,
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x
|
||||
- xOffset : c.asLatLon().x,
|
||||
(double) c.asLatLon().y });
|
||||
|
||||
if (correctedExtent.contains(d[0], d[1])) {
|
||||
target.drawString(font, text, d[0], d[1] + offY, 0.0,
|
||||
TextStyle.NORMAL, hiloBuild.getColorHi(),
|
||||
HorizontalAlignment.CENTER,
|
||||
VerticalAlignment.MIDDLE, 0.0);
|
||||
pointsPlotted++;
|
||||
}
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -303,8 +335,11 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
|
||||
/**
|
||||
* Plot Low grid values
|
||||
*
|
||||
* @param paintProps
|
||||
*/
|
||||
private void plotGridLoValue(IGraphicsTarget target) throws VizException {
|
||||
private void plotGridLoValue(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
float[] tmp1 = hiloLocator.getMinColPositions();
|
||||
|
||||
if (tmp1.length > 0) {
|
||||
|
@ -320,7 +355,10 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
charSize = target.getStringBounds(font, "N");
|
||||
offY = charSize.getHeight() * vertRatio;
|
||||
}
|
||||
for (int i = 0; i < tmp1.length; i++) {
|
||||
|
||||
PixelExtent correctedExtent = getCorrectedExtent(paintProps);
|
||||
int pointsPlotted = 0;
|
||||
for (int i = 0; i < tmp1.length && pointsPlotted < maxLo; i++) {
|
||||
|
||||
String text = convertFloat2String(tmp3[i],
|
||||
hiloBuild.getSymbolLoNumOfDecPls());
|
||||
|
@ -330,13 +368,16 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
Type.GRID_CENTER);
|
||||
try {
|
||||
double[] d = this.descriptor.worldToPixel(new double[] {
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x - xOffset: c.asLatLon().x,
|
||||
(double) c.asLatLon().x > 180 ? c.asLatLon().x
|
||||
- xOffset : c.asLatLon().x,
|
||||
(double) c.asLatLon().y });
|
||||
|
||||
if (correctedExtent.contains(d[0], d[1])) {
|
||||
target.drawString(font, text, d[0], d[1] + offY, 0.0,
|
||||
TextStyle.NORMAL, hiloBuild.getColorLo(),
|
||||
HorizontalAlignment.CENTER,
|
||||
VerticalAlignment.MIDDLE, 0.0);
|
||||
pointsPlotted++;
|
||||
}
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -348,6 +389,26 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
}
|
||||
}
|
||||
|
||||
private PixelExtent getCorrectedExtent(PaintProperties paintProps) {
|
||||
|
||||
// Get view extent, for clipping purposes
|
||||
|
||||
IExtent extent = paintProps.getView().getExtent();
|
||||
|
||||
double extentMaxX = (extent.getMaxX() < 0 ? 0 : extent.getMaxX());
|
||||
double extentMinX = (extent.getMinX() < 0 ? 0 : extent.getMinX());
|
||||
double extentMaxY = (extent.getMaxY() < 0 ? 0 : extent.getMaxY());
|
||||
double extentMinY = (extent.getMinY() < 0 ? 0 : extent.getMinY());
|
||||
extentMaxX = (extentMaxX > 19999 ? 19999 : extentMaxX);
|
||||
extentMinX = (extentMinX > 19999 ? 19999 : extentMinX);
|
||||
extentMaxY = (extentMaxY > 9999 ? 9999 : extentMaxY);
|
||||
extentMinY = (extentMinY > 9999 ? 9999 : extentMinY);
|
||||
|
||||
PixelExtent correctedExtent = new PixelExtent(extentMinX, extentMaxX,
|
||||
extentMinY, extentMaxY);
|
||||
return correctedExtent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Hi/Lo Symbol set
|
||||
*/
|
||||
|
@ -539,6 +600,8 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
+ ((hiloBuild.getSymbolHiPlotValue()) ? "T" : "F"));
|
||||
System.out.println(" precision\t\t"
|
||||
+ hiloBuild.getSymbolHiNumOfDecPls());
|
||||
System.out.println(" Limit number of visible maxima to display:"
|
||||
+ maxHi);
|
||||
float[] tmp = hiloLocator.getMaxColPositions();
|
||||
if (tmp.length > 0) {
|
||||
System.out.println(" Number of maxima found:" + tmp.length);
|
||||
|
@ -581,6 +644,8 @@ public class GridRelativeHiLoDisplay implements IRenderable {
|
|||
+ ((hiloBuild.getSymbolLoPlotValue()) ? "T" : "F"));
|
||||
System.out.println(" precision\t\t"
|
||||
+ hiloBuild.getSymbolLoNumOfDecPls());
|
||||
System.out.println(" Limit number of visible minima to display:"
|
||||
+ maxLo);
|
||||
tmp = hiloLocator.getMinColPositions();
|
||||
if (tmp.length > 0) {
|
||||
System.out.println(" Number of minima found:" + tmp.length);
|
||||
|
|
|
@ -146,9 +146,10 @@ public class GriddedVectorDisplay extends AbstractGriddedDisplay<Coordinate> {
|
|||
lineWidth = 1;
|
||||
String windAttr = attrs.getWind();
|
||||
if (windAttr != null && !windAttr.isEmpty()) {
|
||||
if (windAttr.contains("bk")) {
|
||||
windAttr = windAttr.replace("bk", "");
|
||||
}
|
||||
|
||||
// TTR 880, remove all chars except 0-9,.,/
|
||||
windAttr = windAttr.replaceAll("[^0-9./]", "");
|
||||
|
||||
String[] attr = windAttr.trim().split("/");
|
||||
colorIndex = Integer.parseInt(attr[0].trim());
|
||||
if (attr.length >= 2 && !attr[1].trim().isEmpty()) {
|
||||
|
|
|
@ -7,7 +7,6 @@ package gov.noaa.nws.ncep.viz.rsc.ncgrid.dgdriv;
|
|||
import gov.noaa.nws.ncep.common.log.logger.NcepLogger;
|
||||
import gov.noaa.nws.ncep.common.log.logger.NcepLoggerManager;
|
||||
import gov.noaa.nws.ncep.edex.common.dataRecords.NcFloatDataRecord;
|
||||
import gov.noaa.nws.ncep.viz.gempak.grid.inv.NcGridInventory;
|
||||
import gov.noaa.nws.ncep.viz.gempak.grid.jna.GridDiag;
|
||||
import gov.noaa.nws.ncep.viz.gempak.grid.jna.GridDiag.gempak;
|
||||
import gov.noaa.nws.ncep.viz.gempak.grid.units.GempakGridParmInfoLookup;
|
||||
|
@ -25,30 +24,28 @@ import gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc.NcgridResourceData;
|
|||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.measure.converter.ConversionException;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.comm.CommunicationException;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.grid.dataquery.GridQueryAssembler;
|
||||
import com.raytheon.uf.common.dataplugin.grid.datastorage.GridDataRetriever;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
import com.raytheon.uf.common.geospatial.util.GridGeometryWrapChecker;
|
||||
import com.raytheon.uf.common.gridcoverage.Corner;
|
||||
|
@ -60,7 +57,6 @@ import com.raytheon.uf.common.gridcoverage.PolarStereoGridCoverage;
|
|||
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.units.UnitConv;
|
||||
import com.raytheon.uf.viz.core.comm.Connector;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
import com.sun.jna.Native;
|
||||
|
@ -122,6 +118,8 @@ import com.sun.jna.ptr.IntByReference;
|
|||
* 09/26/2012 X. Guo Fixed missing value problems
|
||||
* 04/26/2013 B. Yin Fixed the world wrap problems
|
||||
* 11/2013 845 T. Lee Implemented parameter scaling
|
||||
* 04/11/2014 981 D.Sushon Code cleanup, enforce explicit use of curly-brackets {}
|
||||
* 04/14/2014 S. Gilbert Remove dataUri from query - cleanup old unused methods.
|
||||
* </pre>
|
||||
*
|
||||
* @author tlee
|
||||
|
@ -135,7 +133,7 @@ public class Dgdriv {
|
|||
|
||||
private static GridDiag gd;
|
||||
|
||||
private String gdfile, gdpfun, gdattim, glevel, gvcord, scale, garea, proj,
|
||||
private String gdfile, gdpfun, gdattim, glevel, gvcord, scale, garea,
|
||||
dataSource;
|
||||
|
||||
private boolean scalar, arrowVector, flop, flip;
|
||||
|
@ -150,8 +148,6 @@ public class Dgdriv {
|
|||
|
||||
private ArrayList<DataTime> dataForecastTimes;
|
||||
|
||||
private static Connector conn;
|
||||
|
||||
private NcgridDataCache cacheData;
|
||||
|
||||
private static NcgribLogger ncgribLogger = NcgribLogger.getInstance();;
|
||||
|
@ -197,7 +193,6 @@ public class Dgdriv {
|
|||
gvcord = "";
|
||||
scale = "";
|
||||
garea = "";
|
||||
proj = "";
|
||||
ncgribPreferences = null;
|
||||
subgSpatialObj = null;
|
||||
scalar = false;
|
||||
|
@ -205,12 +200,6 @@ public class Dgdriv {
|
|||
flop = true;
|
||||
flip = true;
|
||||
dataForecastTimes = new ArrayList<DataTime>();
|
||||
try {
|
||||
conn = Connector.getInstance();
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setResourceData(NcgridResourceData rscData) {
|
||||
|
@ -267,10 +256,6 @@ public class Dgdriv {
|
|||
this.garea = garea.toUpperCase();
|
||||
}
|
||||
|
||||
public void setProj(String proj) {
|
||||
this.proj = proj;
|
||||
}
|
||||
|
||||
public void setDataSource(String dataSource) {
|
||||
this.dataSource = dataSource.trim().toUpperCase();
|
||||
if (this.dataSource.contains("GEMPAK")) {
|
||||
|
@ -407,11 +392,15 @@ public class Dgdriv {
|
|||
@Override
|
||||
public boolean callback(String msg) {
|
||||
String sep = "::";
|
||||
if (!nativeLogging)
|
||||
if (!nativeLogging) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int lvl = checkNativeLoggerLevel(msg);
|
||||
if (lvl > nativeLogLevel)
|
||||
if (lvl > nativeLogLevel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.contains("|debug")) {
|
||||
String logMessage = msg.split("\\|")[0] + ":"
|
||||
+ msg.split(sep)[1];
|
||||
|
@ -457,7 +446,6 @@ public class Dgdriv {
|
|||
float[] rData;
|
||||
if (gData == null) {
|
||||
addData = true;
|
||||
// rData = retrieveData(dataURI);
|
||||
rData = retrieveDataFromRetriever(dataURI);
|
||||
if (rData == null) {
|
||||
errorURI = msg;
|
||||
|
@ -492,9 +480,10 @@ public class Dgdriv {
|
|||
// logger.info ("*****flip grid data*****");
|
||||
gd.gem.db_returndata(flipData(rData, nx, ny),
|
||||
datSize);
|
||||
} else
|
||||
} else {
|
||||
gd.gem.db_returndata(checkMissingData(rData),
|
||||
datSize);
|
||||
}
|
||||
} else {
|
||||
logger.debug("retrieve data size(" + rDataSize
|
||||
+ ") mismatch with navigation nx=" + nx
|
||||
|
@ -555,7 +544,6 @@ public class Dgdriv {
|
|||
try {
|
||||
// logger.debug("request datauri for:" + msg );
|
||||
long t0 = System.currentTimeMillis();
|
||||
// String dataURI = getDataURI(msg);
|
||||
String dataURI = getDataURIFromAssembler(msg);
|
||||
gd.gem.db_returnduri(dataURI);
|
||||
long t1 = System.currentTimeMillis();
|
||||
|
@ -634,7 +622,6 @@ public class Dgdriv {
|
|||
*/
|
||||
this.gdfile = getTaggedGdfile();
|
||||
proces = true;
|
||||
// System.out.println();
|
||||
|
||||
/*
|
||||
* TODO Work around solution - need to find away to set logging level
|
||||
|
@ -718,15 +705,16 @@ public class Dgdriv {
|
|||
if (!isEns) {
|
||||
gd.gem.db_wsetevtname_(gdfile.split(":")[1], iret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gd.gem.dgc_nfil_(gdfile, "", iret);
|
||||
|
||||
if (iret.getValue() != 0) {
|
||||
gd.gem.erc_wmsg("DG", iret, "", ier);
|
||||
proces = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long t06 = System.currentTimeMillis();
|
||||
// System.out.println("dgc_nfil took " + (t06-t05));
|
||||
logger.debug("dgc_nfil took: " + (t06 - t05));
|
||||
|
@ -792,7 +780,9 @@ public class Dgdriv {
|
|||
* if (proces) { gd.gem.dgc_fixa_ ( garea, proj, gareabuf, prjbuf,
|
||||
* iret); if ( iret.getValue () != 0 ) { gd.gem.erc_wmsg ("DG", iret,
|
||||
* "", ier); proces = false; } }
|
||||
*/long t09 = System.currentTimeMillis();
|
||||
*/
|
||||
|
||||
long t09 = System.currentTimeMillis();
|
||||
logger.debug("dgc_fixa took: " + (t09 - t09a));
|
||||
|
||||
/*
|
||||
|
@ -840,6 +830,7 @@ public class Dgdriv {
|
|||
proces = false;
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("kx:" + kx.getValue() + " ky:" + ky.getValue());
|
||||
float[] ugrid = null;
|
||||
float[] vgrid = null;
|
||||
|
@ -898,8 +889,9 @@ public class Dgdriv {
|
|||
if (flop) {
|
||||
// logger.info ("====flop grid data 1=====");
|
||||
fds.setXdata(flopData(ugrid, igx.getValue(), igy.getValue()));
|
||||
} else
|
||||
} else {
|
||||
fds.setXdata(revertGempakData2CAVE(ugrid));
|
||||
}
|
||||
fds.setDimension(2);
|
||||
fds.setSizes(new long[] { igx.getValue(), igy.getValue() });
|
||||
fds.setVector(false);
|
||||
|
@ -912,8 +904,9 @@ public class Dgdriv {
|
|||
if (flop) {
|
||||
// logger.info ("====flop grid data =====");
|
||||
fds.setYdata(flopData(vgrid, igx.getValue(), igy.getValue()));
|
||||
} else
|
||||
} else {
|
||||
fds.setYdata(revertGempakData2CAVE(vgrid));
|
||||
}
|
||||
fds.setDimension(2);
|
||||
fds.setSizes(new long[] { igx.getValue(), igy.getValue() });
|
||||
fds.setVector(true);
|
||||
|
@ -925,7 +918,6 @@ public class Dgdriv {
|
|||
long t1 = System.currentTimeMillis();
|
||||
logger.debug("Scaling took: " + (t1 - t013));
|
||||
// System.out.println("Scaling took:" + (t1-t013));
|
||||
// printInfoMessage(t1 - t0);
|
||||
return fds;
|
||||
} else {
|
||||
/*
|
||||
|
@ -945,7 +937,6 @@ public class Dgdriv {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void prepareGridDTInfo() {
|
||||
|
@ -960,7 +951,7 @@ public class Dgdriv {
|
|||
+ "_db";
|
||||
}
|
||||
IntByReference iret = new IntByReference(0);
|
||||
// System.out.println();
|
||||
|
||||
gd.gem.db_seta2dtinfo_(alias, path, template, iret);
|
||||
|
||||
}
|
||||
|
@ -998,7 +989,7 @@ public class Dgdriv {
|
|||
if (perturbationNum != null) {
|
||||
sba.append(":" + perturbationNum);
|
||||
}
|
||||
// System.out.println();
|
||||
|
||||
sba.append("|");
|
||||
sbt.append(getEnsembleTemplate(ensName, perturbationNum));
|
||||
sbt.append("|");
|
||||
|
@ -1031,7 +1022,7 @@ public class Dgdriv {
|
|||
String template = sbt.toString().substring(0,
|
||||
sbt.toString().length() - 1);
|
||||
IntByReference iret = new IntByReference(0);
|
||||
// System.out.println();
|
||||
|
||||
logger.debug("prepareEnsembleDTInfo: alias=" + alias + ", path=" + path
|
||||
+ ",template=" + template);
|
||||
gd.gem.db_seta2dtinfo_(alias, path, template, iret);
|
||||
|
@ -1080,36 +1071,6 @@ public class Dgdriv {
|
|||
logger.debug("getEnsembleTemplate(" + ensTemplate + ") for(" + ensName
|
||||
+ "," + perturbationNum + ")");
|
||||
return ensTemplate;
|
||||
/*
|
||||
* StringBuilder query = new StringBuilder();
|
||||
* query.append("import GempakEnsembleTemplateGenerator\n");
|
||||
* query.append(
|
||||
* "query = GempakEnsembleTemplateGenerator.GempakEnsembleTemplateGenerator('grid')\n"
|
||||
* ); query.append("query.setEnsembleName('" + ensName + "')\n"); if (
|
||||
* perturbationNum != null ) { //
|
||||
* query.append("query.setEnsembleEventName('" +
|
||||
* perturbationNum.toLowerCase() + "')\n");
|
||||
* query.append("query.setEnsemblePerturbationNumber('" +
|
||||
* Integer.parseInt(perturbationNum) + "')\n"); }
|
||||
*
|
||||
* query.append("return query.execute()\n");
|
||||
*
|
||||
* String scriptToRun = query.toString(); long t0 =
|
||||
* System.currentTimeMillis();
|
||||
*
|
||||
* Object[] pdoList; try { pdoList = conn.connect(scriptToRun, null,
|
||||
* 60000); String ensTemplate = (String) pdoList[0]; long t1 =
|
||||
* System.currentTimeMillis(); //
|
||||
* System.out.println("\tgetEnsembleTemplate took: " + (t1-t0));
|
||||
* logger.info("getEnsembleTemplate("+ ensTemplate +") took: " +
|
||||
* (t1-t0)); return ensTemplate; } catch (VizException e) { // TODO
|
||||
* Auto-generated catch block e.printStackTrace(); return null; }
|
||||
*/
|
||||
}
|
||||
|
||||
private String getEnsTime(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
return string;
|
||||
}
|
||||
|
||||
private String getTaggedGdfile() {
|
||||
|
@ -1132,7 +1093,7 @@ public class Dgdriv {
|
|||
this.gdfileOriginal.indexOf("{") + 1,
|
||||
this.gdfileOriginal.indexOf("}")).split(",");
|
||||
StringBuilder strb = new StringBuilder();
|
||||
// System.out.println();
|
||||
|
||||
for (int igd = 0; igd < gdfileArray.length; igd++) {
|
||||
strb.append(tag);
|
||||
strb.append(gdfileArray[igd]);
|
||||
|
@ -1500,89 +1461,12 @@ public class Dgdriv {
|
|||
return outGridFlopped;
|
||||
}
|
||||
|
||||
private String getEnsTimes() {
|
||||
String tmp1 = this.gdfile.substring(this.gdfile.indexOf("{") + 1,
|
||||
this.gdfile.indexOf("}"));
|
||||
String[] tmp = tmp1.split(",");
|
||||
String tmp2 = "";
|
||||
for (String st : tmp) {
|
||||
String tmp3[] = st.split("\\|");
|
||||
tmp2 = tmp2 + tmp3[1];
|
||||
tmp2 = tmp2 + "|";
|
||||
|
||||
}
|
||||
String returnStr = tmp2.substring(0, tmp2.length() - 1);
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
private void printInfoMessage(long t) {
|
||||
String gdFile;
|
||||
if (this.gdfile.startsWith("{") && this.gdfile.endsWith("}")) {
|
||||
gdFile = this.gdfile.substring(this.gdfile.indexOf("{") + 1,
|
||||
this.gdfile.indexOf("}"));
|
||||
} else {
|
||||
gdFile = this.gdfile;
|
||||
}
|
||||
StringBuilder toprint = new StringBuilder();
|
||||
// System.out.print ( "\nCalculating " + gdFile.toUpperCase() + " ");
|
||||
toprint.append("Requesting " + gdFile.toUpperCase() + " ");
|
||||
|
||||
/*
|
||||
* if (this.vector) { // System.out.print(this.gvect.toUpperCase());
|
||||
* toprint.append(this.gvect.toUpperCase()); } else { //
|
||||
* System.out.print(this.gfunc.toUpperCase());
|
||||
* toprint.append(this.gfunc.trim().toUpperCase()); }
|
||||
*/
|
||||
toprint.append(this.gdpfun.trim().toUpperCase());
|
||||
|
||||
// System.out.print ( " ^" + this.gdattim + " @" + this.glevel + " %" +
|
||||
// this.gvcord.toUpperCase());
|
||||
// System.out.print (" has taken --> " + t + " ms\n");
|
||||
// //System.out.println("\nMin: " + resultMin + " Max: " + resultMax
|
||||
// + "\n");
|
||||
toprint.append(" ^" + this.gdattim + " @" + this.glevel + " %"
|
||||
+ this.gvcord.toUpperCase());
|
||||
toprint.append(" from " + this.dataSource + " took: " + t + " ms\n");
|
||||
// toprint.append("\nMin: " + resultMin + " Max: " + resultMax +
|
||||
// "\n");
|
||||
// System.out.println(toprint.toString());
|
||||
logger.debug(toprint.toString());
|
||||
|
||||
}
|
||||
|
||||
private static float[] retrieveData(String dataURI) throws VizException {
|
||||
|
||||
long t001 = System.currentTimeMillis();
|
||||
IDataRecord dr = null;
|
||||
|
||||
try {
|
||||
String fileName = getFilename(dataURI);
|
||||
String dataset = "Data";
|
||||
Request request = Request.ALL;
|
||||
|
||||
IDataStore ds = DataStoreFactory.getDataStore(new File(fileName));
|
||||
dr = ds.retrieve("", dataURI + "/" + dataset, request);
|
||||
// dr = ds.retrieve(dataURI ,dataset, request);
|
||||
float[] data = (float[]) dr.getDataObject();
|
||||
long t002 = System.currentTimeMillis();
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
logger.info("***Reading " + dataURI + " from hdf5 took: "
|
||||
+ (t002 - t001));
|
||||
// System.out.println("Reading from hdf5 took: " + (t002-t001));
|
||||
return data;
|
||||
} catch (Exception e) {
|
||||
throw new VizException("Error retrieving data for record:"
|
||||
+ dataURI, e);
|
||||
}
|
||||
}
|
||||
|
||||
int scale_parm = 1;
|
||||
|
||||
private float[] retrieveDataFromRetriever(String dataURI)
|
||||
throws VizException {
|
||||
|
||||
long t001 = System.currentTimeMillis();
|
||||
IDataRecord dr = null;
|
||||
// create GridDataRetriever using datauri
|
||||
// setUnit for parameter
|
||||
// setWorldWrapColumns (1);
|
||||
|
@ -1610,29 +1494,33 @@ public class Dgdriv {
|
|||
// ignore deserializer exception.use default units
|
||||
}
|
||||
long t002 = System.currentTimeMillis();
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
logger.info("***Initialize GridDataRetriever for " + dataURI
|
||||
+ " took: " + (t002 - t001));
|
||||
}
|
||||
try {
|
||||
t001 = System.currentTimeMillis();
|
||||
FloatDataRecord dataRecord = dataRetriever.getDataRecord();
|
||||
float[] data = dataRecord.getFloatData();
|
||||
|
||||
if (isWorldWrap) {
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
logger.info("===new coverage nx:"
|
||||
+ dataRetriever.getCoverage().getNx() + " ny:"
|
||||
+ dataRetriever.getCoverage().getNy());
|
||||
}
|
||||
setSubgSpatialObj((ISpatialObject) dataRetriever.getCoverage());
|
||||
}
|
||||
t002 = System.currentTimeMillis();
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
logger.info("***Reading " + dataURI + " from hdf5 took: "
|
||||
+ (t002 - t001) + ", return size:" + data.length);
|
||||
}
|
||||
return data;
|
||||
} catch (StorageException s) {
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
logger.info("???? getDataRecord --- throw StorageException");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1648,14 +1536,14 @@ public class Dgdriv {
|
|||
String fhrs = tmStr[2].substring(tmStr[2].indexOf("(") + 1,
|
||||
tmStr[2].indexOf(")"));
|
||||
String fhStr;
|
||||
if (fhrs == null)
|
||||
if (fhrs == null) {
|
||||
fhStr = "000";
|
||||
else {
|
||||
} else {
|
||||
int number = 0;
|
||||
try {
|
||||
number = Integer.parseInt(fhrs);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
//
|
||||
}
|
||||
fhStr = forecastHourFormat.format(number);
|
||||
}
|
||||
|
@ -1681,8 +1569,9 @@ public class Dgdriv {
|
|||
// + File.separator + sb.toString());
|
||||
// }
|
||||
|
||||
if (file != null)
|
||||
if (file != null) {
|
||||
filename = file.getAbsolutePath();
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
@ -1913,16 +1802,21 @@ public class Dgdriv {
|
|||
|
||||
private String executeScript(String scriptToRun) throws VizException {
|
||||
|
||||
if (scriptToRun == null)
|
||||
if (scriptToRun == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.debug("executeScript: scriptToRun=" + scriptToRun);
|
||||
String[] parms = scriptToRun.split("\\|");
|
||||
if (parms.length < 4)
|
||||
if (parms.length < 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String modelName = parms[0];
|
||||
String dbTag = parms[1];
|
||||
String eventName = parms[2];
|
||||
String tmStr = constructTimeStr(parms[3]);
|
||||
// String tmStr = constructTimeStr(parms[3]);
|
||||
DataTime dtime = constructDataTime(parms[3]);
|
||||
|
||||
// logger.info("executeScript:modelname=" + modelName + " dbTag=" +dbTag
|
||||
// + " eventName="+eventName + " time=" + tmStr);
|
||||
|
@ -1935,15 +1829,17 @@ public class Dgdriv {
|
|||
rcMap.put(GridDBConstants.ENSEMBLE_ID_QUERY, new RequestConstraint(
|
||||
eventName, ConstraintType.EQUALS));
|
||||
}
|
||||
rcMap.put(GridDBConstants.DATA_URI_QUERY, new RequestConstraint(tmStr,
|
||||
ConstraintType.LIKE));
|
||||
|
||||
rcMap.put(GridDBConstants.DATA_TIME_QUERY,
|
||||
new RequestConstraint(dtime.getURIString(),
|
||||
ConstraintType.EQUALS));
|
||||
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.addRequestField(GridDBConstants.REF_TIME_QUERY);
|
||||
request.addRequestField(GridDBConstants.FORECAST_TIME_QUERY);
|
||||
request.setDistinct(true);
|
||||
request.setConstraints(rcMap);
|
||||
long t0 = System.currentTimeMillis();
|
||||
|
||||
String retFileNames = "";
|
||||
try {
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
|
@ -1956,6 +1852,7 @@ public class Dgdriv {
|
|||
// empty list to simplify code
|
||||
responseList = new ArrayList<Map<String, Object>>(0);
|
||||
}
|
||||
|
||||
String prefix = modelName + "_" + dbTag + "_" + eventName + "_";
|
||||
for (int i = 0; i < responseList.size(); i++) {
|
||||
Object fhrValue = responseList.get(i).get(
|
||||
|
@ -1971,201 +1868,69 @@ public class Dgdriv {
|
|||
String dt = dts[0].replace("-", "");
|
||||
|
||||
String hh = dts[1].split(":")[0];
|
||||
if (retFileNames.length() > 0)
|
||||
if (retFileNames.length() > 0) {
|
||||
retFileNames = retFileNames + "|";
|
||||
}
|
||||
|
||||
retFileNames = retFileNames + prefix + dt + hh + "f"
|
||||
+ forecastHourFormat.format(fhr);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (VizException e) {
|
||||
|
||||
//
|
||||
}
|
||||
return retFileNames;
|
||||
}
|
||||
|
||||
private String constructTimeStr(String gempakTimeStr) {
|
||||
String gempakTimeStrCycle = gempakTimeStr.split("f")[0];
|
||||
gempakTimeStrCycle = gempakTimeStrCycle.replace("[0-9]", "%");
|
||||
if (gempakTimeStrCycle.length() < 10)
|
||||
return null;
|
||||
/*
|
||||
* Convert Gempak time string YYMMDD/HHMMfHHH to DataTime
|
||||
*/
|
||||
private DataTime constructDataTime(String gempakTimeStr) {
|
||||
|
||||
String gempakTimeStrFFF = gempakTimeStr.split("f")[1];
|
||||
gempakTimeStrFFF = gempakTimeStrFFF.replace("[0-9]", "%");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd/HH");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
String[] times = gempakTimeStr.split("f");
|
||||
|
||||
DataTime dt;
|
||||
|
||||
String timeStr;
|
||||
try {
|
||||
int fhr = Integer.parseInt(gempakTimeStrFFF) / 3600;
|
||||
|
||||
timeStr = gempakTimeStrCycle.substring(0, 4) + "-"
|
||||
+ gempakTimeStrCycle.substring(4, 6) + "-"
|
||||
+ gempakTimeStrCycle.substring(6, 8) + "_"
|
||||
+ gempakTimeStrCycle.substring(8, 10) + "%_(" + fhr + ")%";
|
||||
} catch (NumberFormatException e) {
|
||||
timeStr = gempakTimeStrCycle.substring(0, 4) + "-"
|
||||
+ gempakTimeStrCycle.substring(4, 6) + "-"
|
||||
+ gempakTimeStrCycle.substring(6, 8) + "_"
|
||||
+ gempakTimeStrCycle.substring(8, 10) + "%_("
|
||||
+ gempakTimeStrFFF;
|
||||
}
|
||||
return timeStr;
|
||||
Date date = sdf.parse(times[0]);
|
||||
int fhr = Integer.parseInt(times[1]) * 3600;
|
||||
dt = new DataTime(date, fhr);
|
||||
} catch (Exception e) {
|
||||
dt = null;
|
||||
}
|
||||
|
||||
private String getDataURI(String parameters) throws VizException {
|
||||
long t0 = System.currentTimeMillis();
|
||||
return dt;
|
||||
}
|
||||
|
||||
String datauri = cacheData.getDataURI(parameters);
|
||||
if (datauri != null) {
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
long t00 = System.currentTimeMillis();
|
||||
logger.info("++++ getDataURI for(" + parameters
|
||||
+ ") from cache took: " + (t00 - t0));
|
||||
}
|
||||
return datauri;
|
||||
}
|
||||
// get all param/vcord units
|
||||
// call GridQueryAssembler to get request constrains
|
||||
|
||||
String[] parmList = parameters.split("\\|");
|
||||
logger.debug("enter getDataUri - parameters:" + parameters);
|
||||
HashMap<String, RequestConstraint> rcMap = new HashMap<String, RequestConstraint>();
|
||||
rcMap.put(GridDBConstants.PLUGIN_NAME, new RequestConstraint(
|
||||
GridDBConstants.GRID_TBL_NAME));
|
||||
rcMap.put(GridDBConstants.MODEL_NAME_QUERY, new RequestConstraint(
|
||||
parmList[0]));
|
||||
|
||||
if (!parmList[1].isEmpty()) {
|
||||
if (isEnsCategory) {
|
||||
if (!parmList[1].equalsIgnoreCase("null"))
|
||||
rcMap.put(GridDBConstants.ENSEMBLE_ID_QUERY,
|
||||
new RequestConstraint(parmList[1]));
|
||||
} else {
|
||||
if (gridRscData.getEnsembelMember() != null) {
|
||||
rcMap.put(GridDBConstants.ENSEMBLE_ID_QUERY,
|
||||
new RequestConstraint(parmList[1]));
|
||||
} else {
|
||||
rcMap.put(GridDBConstants.EVENT_NAME_QUERY,
|
||||
new RequestConstraint(parmList[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
rcMap.put(GridDBConstants.PARAMETER_QUERY, new RequestConstraint(
|
||||
parmList[2]));
|
||||
rcMap.put(GridDBConstants.LEVEL_ID_QUERY, new RequestConstraint(
|
||||
parmList[3]));
|
||||
|
||||
// This is now querying modelInfo.level.levelonevalue (a Double) instead
|
||||
// of glevel1 (an int)
|
||||
// so to get the constraint to work we will need ".0"
|
||||
// TODO : hack until we do this the right way.
|
||||
// private String constructTimeStr(String gempakTimeStr) {
|
||||
// String gempakTimeStrCycle = gempakTimeStr.split("f")[0];
|
||||
// gempakTimeStrCycle = gempakTimeStrCycle.replace("[0-9]", "%");
|
||||
// if (gempakTimeStrCycle.length() < 10) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
String ll1 = null, ll2 = null;
|
||||
if (parmList[4].contains(":")) {
|
||||
ll1 = parmList[4].split(":")[0];
|
||||
ll2 = parmList[4].split(":")[1];
|
||||
} else {
|
||||
ll1 = parmList[4];
|
||||
}
|
||||
if (ll1 == null && ll2 == null)
|
||||
return null;
|
||||
if (ll1 != null) {
|
||||
rcMap.put(GridDBConstants.LEVEL_ONE_QUERY, new RequestConstraint(
|
||||
ll1 + ".0"));
|
||||
}
|
||||
if (ll2 != null) {
|
||||
rcMap.put(GridDBConstants.LEVEL_TWO_QUERY, new RequestConstraint(
|
||||
ll2 + ".0"));
|
||||
}
|
||||
|
||||
// request all the params stored in the inventory.
|
||||
ArrayList<String> rslts = NcGridInventory.getInstance()
|
||||
.searchNcGridInventory(
|
||||
rcMap,
|
||||
NcGridInventory.getInstance().inventoryParamNames
|
||||
.toArray(new String[0]));// GridDBConstants.LEVEL_TWO_QUERY
|
||||
// );
|
||||
|
||||
long t11 = System.currentTimeMillis();
|
||||
if (rslts == null || rslts.isEmpty()) {
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
logger.info("???????query NcGridInventory DB return NULL for ("
|
||||
+ parmList[0] + "," + parmList[1] + "," + parmList[2]
|
||||
+ "," + parmList[3] + "," + parmList[4] + ")===");
|
||||
return null;
|
||||
}
|
||||
if (ncgribLogger.enableDiagnosticLogs())
|
||||
logger.info("NcGridInventory.searchNcGridInventory:rslts="
|
||||
+ rslts.toString() + " took: " + (t11 - t0));
|
||||
|
||||
String[] tmpStr = rslts.get(0).split("/");
|
||||
|
||||
// HACK: the inventory uses modelInfo.level to store the levels because
|
||||
// they are in the URI and not glevels
|
||||
// but the uengin script won't work querying the
|
||||
// modelInfo.level.leveltwovalue (???) so we have to query
|
||||
// glevel2 (an int) instead of the double modelInfo.level
|
||||
|
||||
String lvl1 = tmpStr[6];
|
||||
String lvl2 = tmpStr[7];
|
||||
if (lvl2.equals(Level.getInvalidLevelValueAsString())) {
|
||||
lvl2 = "-9999.0";
|
||||
}
|
||||
|
||||
String refTimeg = parmList[5].toUpperCase().split("F")[0];
|
||||
String refTime = GempakGrid.dattimToDbtime(refTimeg);
|
||||
refTime = refTime.substring(0, refTime.length() - 2);
|
||||
String fcstTimeg = parmList[5].toUpperCase().split("F")[1];
|
||||
String fcstTime = Integer
|
||||
.toString(((Integer.parseInt(fcstTimeg)) * 3600));
|
||||
|
||||
rcMap.remove(GridDBConstants.LEVEL_TWO_QUERY);
|
||||
rcMap.remove(GridDBConstants.LEVEL_ONE_QUERY);
|
||||
rcMap.put(GridDBConstants.LEVEL_TWO_QUERY, new RequestConstraint(lvl2));
|
||||
rcMap.put(GridDBConstants.LEVEL_ONE_QUERY, new RequestConstraint(lvl1));
|
||||
|
||||
rcMap.put(GridDBConstants.REF_TIME_QUERY,
|
||||
new RequestConstraint(refTime));
|
||||
rcMap.put(GridDBConstants.FORECAST_TIME_QUERY, new RequestConstraint(
|
||||
fcstTime));
|
||||
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.addRequestField(GridDBConstants.DATA_URI_QUERY);
|
||||
request.setConstraints(rcMap);
|
||||
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
// extract list of results
|
||||
List<Map<String, Object>> responseList = null;
|
||||
if (response != null) {
|
||||
responseList = response.getResults();
|
||||
} else {
|
||||
// empty list to simplify code
|
||||
responseList = new ArrayList<Map<String, Object>>(0);
|
||||
}
|
||||
if (responseList.size() > 0) {
|
||||
Object dURI = responseList.get(0).get(
|
||||
GridDBConstants.DATA_URI_QUERY);
|
||||
if (dURI != null && dURI instanceof String) {
|
||||
datauri = (String) dURI;
|
||||
}
|
||||
}
|
||||
long t1 = System.currentTimeMillis();
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
if (datauri != null)
|
||||
logger.info("### getDataURI(" + datauri + ") for(" + parameters
|
||||
+ ") reftime:" + refTime + "("
|
||||
+ Integer.parseInt(fcstTimeg) + ") took: " + (t1 - t0));
|
||||
else
|
||||
logger.info("??? getDataURI(null) for(" + parameters
|
||||
+ ") reftime:" + refTime + "("
|
||||
+ Integer.parseInt(fcstTimeg) + ") took: " + (t1 - t0));
|
||||
}
|
||||
|
||||
// datauri = rec.getDataURI();
|
||||
if (datauri != null)
|
||||
cacheData.addDataURI(parameters, datauri);
|
||||
return datauri;
|
||||
}
|
||||
// String gempakTimeStrFFF = gempakTimeStr.split("f")[1];
|
||||
// gempakTimeStrFFF = gempakTimeStrFFF.replace("[0-9]", "%");
|
||||
//
|
||||
// String timeStr;
|
||||
// try {
|
||||
// int fhr = Integer.parseInt(gempakTimeStrFFF) / 3600;
|
||||
//
|
||||
// timeStr = gempakTimeStrCycle.substring(0, 4) + "-"
|
||||
// + gempakTimeStrCycle.substring(4, 6) + "-"
|
||||
// + gempakTimeStrCycle.substring(6, 8) + "_"
|
||||
// + gempakTimeStrCycle.substring(8, 10) + "%_(" + fhr + ")%";
|
||||
// } catch (NumberFormatException e) {
|
||||
// timeStr = gempakTimeStrCycle.substring(0, 4) + "-"
|
||||
// + gempakTimeStrCycle.substring(4, 6) + "-"
|
||||
// + gempakTimeStrCycle.substring(6, 8) + "_"
|
||||
// + gempakTimeStrCycle.substring(8, 10) + "%_("
|
||||
// + gempakTimeStrFFF;
|
||||
// }
|
||||
// return timeStr;
|
||||
// }
|
||||
|
||||
private String getDataURIFromAssembler(String parameters)
|
||||
throws VizException {
|
||||
|
@ -2186,31 +1951,27 @@ public class Dgdriv {
|
|||
logger.info("++++ getRequestConstraint for(" + parameters
|
||||
+ ") took: " + (t01 - t0));
|
||||
}
|
||||
if (rcMap == null)
|
||||
if (rcMap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
t0 = System.currentTimeMillis();
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.addRequestField(GridDBConstants.DATA_URI_QUERY);
|
||||
// request.addRequestField(GridDBConstants.DATA_URI_QUERY);
|
||||
request.setConstraints(rcMap);
|
||||
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
// extract list of results
|
||||
List<Map<String, Object>> responseList = null;
|
||||
if (response != null) {
|
||||
responseList = response.getResults();
|
||||
PluginDataObject[] pdos = response
|
||||
.getEntityObjects(PluginDataObject.class);
|
||||
if (pdos.length > 0) {
|
||||
datauri = pdos[0].getDataURI();
|
||||
} else {
|
||||
// empty list to simplify code
|
||||
responseList = new ArrayList<Map<String, Object>>(0);
|
||||
}
|
||||
if (responseList.size() > 0) {
|
||||
Object dURI = responseList.get(0).get(
|
||||
GridDBConstants.DATA_URI_QUERY);
|
||||
if (dURI != null && dURI instanceof String) {
|
||||
datauri = (String) dURI;
|
||||
}
|
||||
datauri = null;
|
||||
// System.out.println(request);
|
||||
// System.out.println("NOTHING FOUND!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
}
|
||||
|
||||
long t1 = System.currentTimeMillis();
|
||||
if (ncgribLogger.enableDiagnosticLogs()) {
|
||||
String[] parmList = parameters.split("\\|");
|
||||
|
@ -2218,21 +1979,21 @@ public class Dgdriv {
|
|||
String refTime = GempakGrid.dattimToDbtime(refTimeg);
|
||||
refTime = refTime.substring(0, refTime.length() - 2);
|
||||
String fcstTimeg = parmList[5].toUpperCase().split("F")[1];
|
||||
String fcstTime = Integer
|
||||
.toString(((Integer.parseInt(fcstTimeg)) * 3600));
|
||||
if (datauri != null)
|
||||
if (datauri != null) {
|
||||
logger.info("### getDataURIFromAssembler(" + datauri + ") for("
|
||||
+ parameters + ") reftime:" + refTime + "("
|
||||
+ Integer.parseInt(fcstTimeg) + ") took: " + (t1 - t0));
|
||||
else
|
||||
} else {
|
||||
logger.info("??? getDataURIFromAssembler(null) for("
|
||||
+ parameters + ") reftime:" + refTime + "("
|
||||
+ Integer.parseInt(fcstTimeg) + ") took: " + (t1 - t0));
|
||||
}
|
||||
}
|
||||
|
||||
// datauri = rec.getDataURI();
|
||||
if (datauri != null)
|
||||
if (datauri != null) {
|
||||
cacheData.addDataURI(parameters, datauri);
|
||||
}
|
||||
return datauri;
|
||||
}
|
||||
|
||||
|
@ -2257,8 +2018,10 @@ public class Dgdriv {
|
|||
StringBuilder sba = new StringBuilder();
|
||||
String[] gdfileArray = gdfile1.substring(gdfile1.indexOf("{") + 1,
|
||||
gdfile1.indexOf("}")).split(",");
|
||||
if (gdfileArray.length == 0)
|
||||
if (gdfileArray.length == 0) {
|
||||
return gdfile1;
|
||||
}
|
||||
|
||||
sba.append("{");
|
||||
for (int igd = 0; igd < gdfileArray.length; igd++) {
|
||||
if (!gdfileArray[igd].contains(":")) {
|
||||
|
@ -2293,8 +2056,9 @@ public class Dgdriv {
|
|||
if (cnt == members.size()) {
|
||||
sba.append(String.valueOf(mbrWt + weight
|
||||
- sumWts));
|
||||
} else
|
||||
} else {
|
||||
sba.append(String.valueOf(mbrWt));
|
||||
}
|
||||
sba.append("%");
|
||||
}
|
||||
sba.append(model);
|
||||
|
@ -2304,18 +2068,20 @@ public class Dgdriv {
|
|||
sba.append("|");
|
||||
sba.append(cycleTime);
|
||||
}
|
||||
if (cnt < members.size())
|
||||
if (cnt < members.size()) {
|
||||
sba.append(",");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sba.append(gdfileArray[igd]);
|
||||
}
|
||||
} else {
|
||||
sba.append(gdfileArray[igd]);
|
||||
}
|
||||
if (igd < (gdfileArray.length - 1))
|
||||
if (igd < (gdfileArray.length - 1)) {
|
||||
sba.append(",");
|
||||
}
|
||||
}
|
||||
sba.append("}");
|
||||
return sba.toString();
|
||||
}
|
||||
|
@ -2346,6 +2112,7 @@ public class Dgdriv {
|
|||
queryList.put(GridDBConstants.DATA_TIME_QUERY,
|
||||
new RequestConstraint(dataForecastTimes.get(0).toString()));
|
||||
}
|
||||
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.addRequestField(GridDBConstants.NAVIGATION_QUERY);
|
||||
request.setLimit(1);
|
||||
|
@ -2361,6 +2128,7 @@ public class Dgdriv {
|
|||
// empty list to simplify code
|
||||
responseList = new ArrayList<Map<String, Object>>(0);
|
||||
}
|
||||
|
||||
ISpatialObject cov = null;
|
||||
if (responseList.size() > 0) {
|
||||
Object spatialObj = responseList.get(0).get(
|
||||
|
@ -2374,24 +2142,9 @@ public class Dgdriv {
|
|||
navStr = getGridNavigationContent(cov);
|
||||
}
|
||||
} catch (VizException e) {
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/*
|
||||
* LayerProperty prop = new LayerProperty();
|
||||
* prop.setDesiredProduct(ResourceType.PLAN_VIEW); try {
|
||||
* prop.setEntryQueryParameters(queryList, false);
|
||||
* prop.setNumberOfImages(1);
|
||||
*
|
||||
* String script = null; script = ScriptCreator.createScript(prop);
|
||||
*
|
||||
* if (script == null) { return null; }
|
||||
* //System.out.println("HERESMYQUERY: "+script); Object[] pdoList =
|
||||
* Connector.getInstance().connect(script, null, 60000); if ( pdoList
|
||||
* !=null && pdoList.length>0 ) { ISpatialObject cov = ((GridRecord)
|
||||
* pdoList[0]).getLocation(); navStr = getGridNavigationContent ( cov);
|
||||
* } } catch( VizException e) { return null; }
|
||||
*/
|
||||
return navStr;
|
||||
}
|
||||
|
||||
|
@ -2429,8 +2182,9 @@ public class Dgdriv {
|
|||
|
||||
if (!parmList[1].isEmpty()) {
|
||||
if (isEnsCategory) {
|
||||
if (!parmList[1].equalsIgnoreCase("null"))
|
||||
if (!parmList[1].equalsIgnoreCase("null")) {
|
||||
qAssembler.setEnsembleId(parmList[1]);
|
||||
}
|
||||
} else {
|
||||
if (gridRscData.getEnsembelMember() != null) {
|
||||
qAssembler.setEnsembleId(parmList[1]);
|
||||
|
@ -2450,6 +2204,7 @@ public class Dgdriv {
|
|||
scale_vcord = (int) Math.pow(10, Integer
|
||||
.valueOf(gempakVcordInfo.getParmScale((parmList[3]))));
|
||||
} catch (NumberFormatException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2460,8 +2215,9 @@ public class Dgdriv {
|
|||
} else {
|
||||
ll1 = parmList[4];
|
||||
}
|
||||
if (ll1 == null && ll2 == null)
|
||||
if (ll1 == null && ll2 == null) {
|
||||
return null;
|
||||
}
|
||||
if (ll1 != null) {
|
||||
Double level1;
|
||||
try {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,19 +4,15 @@
|
|||
package gov.noaa.nws.ncep.viz.rsc.ncscat.rsc;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
||||
/**
|
||||
* NcscatMode - Enum class to centralize and encapsulate all the things
|
||||
* that vary among different satellite and data feed types.
|
||||
* NcscatMode - Enum class to centralize and encapsulate all the things that
|
||||
* vary among different satellite and data feed types.
|
||||
*
|
||||
* //TODO: Consider moving this information entirely to the
|
||||
* bundle and/or preferences (.xml/.prm) files, so
|
||||
* the Java code can be completely agnostic about
|
||||
* satellite data types; would allow extended
|
||||
* 'configurability', at the expense of slightly
|
||||
* longer bundle/preference files...
|
||||
* //TODO: Consider moving this information entirely to the bundle and/or
|
||||
* preferences (.xml/.prm) files, so the Java code can be completely agnostic
|
||||
* about satellite data types; would allow extended 'configurability', at the
|
||||
* expense of slightly longer bundle/preference files...
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
*
|
||||
|
@ -27,6 +23,7 @@ import java.util.EnumSet;
|
|||
* 02 Jun 2010 235B B. Hebbard Initial creation.
|
||||
* 03 Feb 2011 235E B. Hebbard Add support for ambiguity variants.
|
||||
* 16 Aug 2012 B. Hebbard Add OSCAT / OSCAT_HI
|
||||
* 11 Apr 2014 1128 B. Hebbard Add longitudeCoding field; change wind sense from boolean to enum.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -36,27 +33,45 @@ import java.util.EnumSet;
|
|||
|
||||
public enum NcscatMode {
|
||||
|
||||
QUIKSCAT ( 76, true, ByteOrder.BIG_ENDIAN ),
|
||||
QUIKSCAT_HI ( 152, true, ByteOrder.BIG_ENDIAN ),
|
||||
ASCAT ( 42, false, ByteOrder.BIG_ENDIAN ),
|
||||
ASCAT_HI ( 82, false, ByteOrder.BIG_ENDIAN ),
|
||||
EXASCT ( 42, false, ByteOrder.LITTLE_ENDIAN ),
|
||||
EXASCT_HI ( 82, false, ByteOrder.LITTLE_ENDIAN ),
|
||||
OSCAT ( 36, true, ByteOrder.BIG_ENDIAN ),
|
||||
OSCAT_HI ( 76, true, ByteOrder.LITTLE_ENDIAN ),
|
||||
WSCAT ( 79, true, ByteOrder.LITTLE_ENDIAN ),
|
||||
UNKNOWN ( 76, true, ByteOrder.BIG_ENDIAN );
|
||||
// @formatter:off
|
||||
QUIKSCAT ( 76, WindDirectionSense.METEOROLOGICAL, LongitudeCoding.UNSIGNED, ByteOrder.BIG_ENDIAN ),
|
||||
QUIKSCAT_HI ( 152, WindDirectionSense.METEOROLOGICAL, LongitudeCoding.UNSIGNED, ByteOrder.BIG_ENDIAN ),
|
||||
ASCAT ( 42, WindDirectionSense.OCEANOGRAPHIC, LongitudeCoding.UNSIGNED, ByteOrder.BIG_ENDIAN ),
|
||||
ASCAT_HI ( 82, WindDirectionSense.OCEANOGRAPHIC, LongitudeCoding.UNSIGNED, ByteOrder.BIG_ENDIAN ),
|
||||
EXASCT ( 42, WindDirectionSense.OCEANOGRAPHIC, LongitudeCoding.UNSIGNED, ByteOrder.LITTLE_ENDIAN ),
|
||||
EXASCT_HI ( 82, WindDirectionSense.OCEANOGRAPHIC, LongitudeCoding.UNSIGNED, ByteOrder.LITTLE_ENDIAN ),
|
||||
OSCAT ( 36, WindDirectionSense.METEOROLOGICAL, LongitudeCoding.UNSIGNED, ByteOrder.BIG_ENDIAN ),
|
||||
OSCAT_HI ( 76, WindDirectionSense.METEOROLOGICAL, LongitudeCoding.UNSIGNED, ByteOrder.LITTLE_ENDIAN ),
|
||||
WSCAT ( 79, WindDirectionSense.METEOROLOGICAL, LongitudeCoding.SIGNED, ByteOrder.LITTLE_ENDIAN ),
|
||||
UNKNOWN ( 76, WindDirectionSense.METEOROLOGICAL, LongitudeCoding.UNSIGNED, ByteOrder.BIG_ENDIAN );
|
||||
// @formatter:on
|
||||
|
||||
private int pointsPerRow; // number of Wind Vector Cell in each scan row
|
||||
// across satellite track
|
||||
|
||||
private WindDirectionSense windDirectionSense; // is the numeric wind
|
||||
// direction the "from"
|
||||
// (METEOROLOGICAL)
|
||||
// direction, or the "to"
|
||||
// (OCEANOGRAPHIC) direction?
|
||||
|
||||
private LongitudeCoding longitudeCoding; // is the two-byte value a SIGNED
|
||||
// (-18000 -- +18000) or UNSIGNED
|
||||
// (0 -- 36000) representation of
|
||||
// the (scaled by 100) longitude
|
||||
// east of Greenwich?
|
||||
|
||||
private int pointsPerRow ; // number of Wind Vector Cell in each scan row across satellite track
|
||||
private boolean isWindFrom ; // is the numeric wind direction the "from" (meteorological) direction?
|
||||
private ByteOrder byteOrder; // endianess of data in the byte stream
|
||||
//TODO: could add more here, to simplify (switch) code with more table driven logic. But see above note about .xml/.prm...
|
||||
|
||||
// TODO: could add more here, to simplify (switch) code with more table
|
||||
// driven logic. But see above note about .xml/.prm...
|
||||
|
||||
// Constructor
|
||||
NcscatMode (int pointsPerRow, boolean isWindFrom, ByteOrder byteOrder) {
|
||||
NcscatMode(int pointsPerRow, WindDirectionSense windDirectionSense,
|
||||
LongitudeCoding longitudeCoding, ByteOrder byteOrder) {
|
||||
this.pointsPerRow = pointsPerRow;
|
||||
this.isWindFrom = isWindFrom;
|
||||
this.windDirectionSense = windDirectionSense;
|
||||
this.longitudeCoding = longitudeCoding;
|
||||
this.byteOrder = byteOrder;
|
||||
}
|
||||
|
||||
|
@ -64,8 +79,12 @@ public enum NcscatMode {
|
|||
return pointsPerRow;
|
||||
}
|
||||
|
||||
public boolean isWindFrom() {
|
||||
return isWindFrom ;
|
||||
public WindDirectionSense getWindDirectionSense() {
|
||||
return windDirectionSense;
|
||||
}
|
||||
|
||||
public LongitudeCoding getLongitudeCoding() {
|
||||
return longitudeCoding;
|
||||
}
|
||||
|
||||
public ByteOrder getByteOrder() {
|
||||
|
@ -80,12 +99,22 @@ public enum NcscatMode {
|
|||
// TODO: Remove ambiguity number??
|
||||
try {
|
||||
returnValue = valueOf(name);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO: Signal unrecognized Ncscat mode string
|
||||
returnValue = UNKNOWN;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public enum WindDirectionSense { // numeric direction value gives...
|
||||
METEOROLOGICAL, // degrees FROM which wind is blowing
|
||||
OCEANOGRAPHIC // degrees TO which wind is blowing
|
||||
}
|
||||
|
||||
public enum LongitudeCoding { // 2-byte wvc_lon (Wind Vector Cell -
|
||||
// longitude) field is (x0.01 deg)...
|
||||
SIGNED, // SIGNED short (-18000..+18000)
|
||||
UNSIGNED // UNSIGNED short (0..36000 east of Greenwich)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsResource;
|
|||
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResource;
|
||||
import gov.noaa.nws.ncep.viz.resources.colorBar.ColorBarResource;
|
||||
import gov.noaa.nws.ncep.viz.resources.colorBar.ColorBarResourceData;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ncscat.rsc.NcscatMode.LongitudeCoding;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ncscat.rsc.NcscatMode.WindDirectionSense;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.ColorBar;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.NCMapDescriptor;
|
||||
|
||||
|
@ -38,15 +40,14 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
import com.raytheon.uf.viz.core.HDF5Util;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.geom.PixelCoordinate;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
@ -73,6 +74,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* 17 Aug 2012 655 B. Hebbard Added paintProps as parameter to IDisplayable draw
|
||||
* 12/19/2012 #960 Greg Hull override propertiesChanged() to update colorBar.
|
||||
* 30 May 2013 B. Hebbard Merge changes by RTS in OB13.3.1 for DataStoreFactory.getDataStore(...)
|
||||
* 11 Apr 2014 1128 B. Hebbard Prevent overflow if unsigned longitude >= 327.68W (32768)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,8 +82,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class NcscatResource extends
|
||||
AbstractNatlCntrsResource<NcscatResourceData, NCMapDescriptor> implements
|
||||
INatlCntrsResource {
|
||||
AbstractNatlCntrsResource<NcscatResourceData, NCMapDescriptor>
|
||||
implements INatlCntrsResource {
|
||||
|
||||
// DEBUG boolean OVERRIDErainQcFlag = true;
|
||||
// DEBUG boolean OVERRIDEhighWindSpeedFlag = true;
|
||||
|
@ -93,9 +95,11 @@ public class NcscatResource extends
|
|||
private Unit<?> windSpeedUnits = NonSI.KNOT;
|
||||
|
||||
protected ColorBarResource cbar1Resource;
|
||||
|
||||
protected ResourcePair cbar1RscPair;
|
||||
|
||||
protected ColorBarResource cbar2Resource;
|
||||
|
||||
protected ResourcePair cbar2RscPair;
|
||||
|
||||
private class FrameData extends AbstractFrameData {
|
||||
|
@ -119,7 +123,7 @@ public class NcscatResource extends
|
|||
}
|
||||
|
||||
else {
|
||||
// ...convert into point data suitable for paint, grouped by rows...
|
||||
// ...convert to point data for paint, grouped by rows...
|
||||
ArrayList<NcscatRowData> rowsDataFromPdo = processHDF5Data(hdf5Data);
|
||||
// ...and add to existing row data for this frame
|
||||
frameRows.addAll(rowsDataFromPdo);
|
||||
|
@ -133,15 +137,15 @@ public class NcscatResource extends
|
|||
File location = HDF5Util.findHDF5Location(nsRecord);
|
||||
|
||||
// TODO... Investigate: Why is the following statement needed?
|
||||
// Starting in OB13.5.3, the PDO (nsRecord) has a non-null, but bogus,
|
||||
// value in its dataURI field at this point (and earlier,
|
||||
// Starting in OB13.5.3, the PDO (nsRecord) has a non-null, but
|
||||
// bogus, value in its dataURI field at this point (and earlier,
|
||||
// as soon as it is deserialized after return from the metadata
|
||||
// query). nsRecord.getDataURI() below will get this bad value, leading
|
||||
// to failure on the ds.retrieve(...). Instead we force it to
|
||||
// synthesize the dataURI -- which getDataURI() does correctly --
|
||||
// by setting the field to null first. But why is this happening,
|
||||
// and why only in OB13.5.3, and why only for some resources...? (bh)
|
||||
// (see also NTRANS resource)
|
||||
// query). nsRecord.getDataURI() below will get this bad value,
|
||||
// leading to failure on the ds.retrieve(...). Instead we force
|
||||
// it to synthesize the dataURI -- which getDataURI() does
|
||||
// correctly -- by setting the field to null first. But why is
|
||||
// this happening, and why only in OB13.5.3, and why only for
|
||||
// some resources...? (bh) (see also NTRANS resource)
|
||||
nsRecord.setDataURI(null); // force getDataURI() to construct one
|
||||
|
||||
String group = nsRecord.getDataURI();
|
||||
|
@ -167,10 +171,11 @@ public class NcscatResource extends
|
|||
|
||||
private ArrayList<NcscatRowData> processHDF5Data(byte[] hdf5Msg) {
|
||||
|
||||
// Note: This code lifted from NcscatProcessing.processHDFData, modified
|
||||
// to (1) return point data in structures already optimized for paint()
|
||||
// and (2) preserve intermediate organization by rows. Some further
|
||||
// optimization may be desirable. (TODO)
|
||||
// Note: This code lifted from NcscatProcessing.processHDFData,
|
||||
// modified to (1) return point data in structures already
|
||||
// optimized for paint() and (2) preserve intermediate
|
||||
// organization by rows. Some further optimization may
|
||||
// be desirable. (TODO)
|
||||
|
||||
final int shortsPerPoint = 9;
|
||||
final int bytesPerPoint = 2 * shortsPerPoint;
|
||||
|
@ -215,11 +220,10 @@ public class NcscatResource extends
|
|||
// sPointObj.setIb3(byteBuffer.getShort(j+16));
|
||||
byteNumber += bytesPerPoint;
|
||||
// returnList.add(sPointObj);
|
||||
// Above code put things into a NcscatPoint (common with decoder);
|
||||
// now convert to a NcscatPointData (local class) optimized for
|
||||
// display via paint(), and add to the row
|
||||
// Above code put things into a NcscatPoint (common with
|
||||
// decoder); now convert to a NcscatPointData (local class)
|
||||
// optimized for display via paint(), and add to the row
|
||||
rowData.points.add(new NcscatPointData(sPointObj));
|
||||
// sPointObj
|
||||
} // for
|
||||
|
||||
ji = byteNumber;
|
||||
|
@ -236,9 +240,10 @@ public class NcscatResource extends
|
|||
}
|
||||
|
||||
// Structure containing displayable information for a
|
||||
// singpointData.rainQcFlag && ncscatResourceData.use2ndColorForRainEnablele
|
||||
// displayable element -- that is, a single point observation.
|
||||
|
||||
// @formatter:off
|
||||
|
||||
private class NcscatPointData {
|
||||
Coordinate location; // lat/lon of this point
|
||||
float direction; // "from" direction in bulletin
|
||||
|
@ -254,22 +259,32 @@ public class NcscatResource extends
|
|||
// (For example, don't want to flip direction at every paint().)
|
||||
|
||||
public NcscatPointData(NcscatPoint point) {
|
||||
location = new Coordinate(point.getLon() / 100.0,
|
||||
point.getLat() / 100.0);
|
||||
// TODO: Probably OK to leave as is, but...
|
||||
if (location.x > 180.0f) // deal with possible...
|
||||
location.x -= 360.0f;
|
||||
if (location.x < -180.0f) // ...novel longitude coding
|
||||
location.x += 360.0f;
|
||||
int scaledLatitude = point.getLat(); // signed int from signed short
|
||||
int scaledLongitude = point.getLon(); // signed int from either signed short, OR...
|
||||
if (ncscatMode.getLongitudeCoding() == LongitudeCoding.UNSIGNED) {
|
||||
if (scaledLongitude < 0) { // ...*unsigned* short
|
||||
scaledLongitude += 65536; // aka 1<<16
|
||||
}
|
||||
if (scaledLongitude > 18000) { // unsigned longitude comes in as 0--360 east of Greenwich
|
||||
scaledLongitude -= 36000; // convert to -180 -- +180
|
||||
}
|
||||
}
|
||||
location = new Coordinate(scaledLongitude / 100.0, // de-scale and float
|
||||
scaledLatitude / 100.0);
|
||||
|
||||
direction = point.getIdr() / 100.0f;
|
||||
if (ncscatMode.isWindFrom()) {
|
||||
direction = direction > 180.0f ? // reverse direction sense
|
||||
// some (but not all) data sources require us to...
|
||||
if (ncscatMode.getWindDirectionSense() == WindDirectionSense.METEOROLOGICAL) {
|
||||
direction = direction > 180.0f ? // ...reverse direction sense
|
||||
direction - 180.0f
|
||||
: direction + 180.0f;
|
||||
}
|
||||
|
||||
speed = point.getIsp() / 100.0f;
|
||||
speed *= (3600.0f / 1852.0f); // m/s --> kt //TODO: Use Unit conversions...?
|
||||
|
||||
int qualityBits = point.getIql();
|
||||
|
||||
switch (ncscatMode) {
|
||||
case QUIKSCAT:
|
||||
case QUIKSCAT_HI:
|
||||
|
@ -305,7 +320,10 @@ public class NcscatResource extends
|
|||
lowWindSpeedFlag = false;
|
||||
availRedunFlag = false;
|
||||
break;
|
||||
case OSCAT: // Don't have...
|
||||
case OSCAT_HI: // ...these flags
|
||||
case UNKNOWN:
|
||||
default:
|
||||
rainQcFlag = false;
|
||||
highWindSpeedFlag = false;
|
||||
lowWindSpeedFlag = false;
|
||||
|
@ -323,10 +341,13 @@ public class NcscatResource extends
|
|||
return (bits & mask) != 0;
|
||||
}
|
||||
}
|
||||
// @formatter:on
|
||||
|
||||
// Structure grouping displayable information for a single row element
|
||||
//
|
||||
private class NcscatRowData {
|
||||
Calendar rowTime; // timestamp on this row
|
||||
|
||||
ArrayList<NcscatPointData> points; // individual points in row
|
||||
|
||||
public NcscatRowData(Calendar rowTime) {
|
||||
|
@ -363,21 +384,26 @@ public class NcscatResource extends
|
|||
ncscatResourceData.setNcscatMode();
|
||||
ncscatMode = ncscatResourceData.getNcscatMode();
|
||||
queryRecords();
|
||||
// create a system resource for the colorBar and add it to the resource list.
|
||||
// create a system resource for the colorBar and add it to the resource
|
||||
// list.
|
||||
//
|
||||
cbar1RscPair = ResourcePair.constructSystemResourcePair(
|
||||
new ColorBarResourceData( ncscatResourceData.getColorBar1() ) );
|
||||
cbar1RscPair = ResourcePair
|
||||
.constructSystemResourcePair(new ColorBarResourceData(
|
||||
ncscatResourceData.getColorBar1()));
|
||||
|
||||
getDescriptor().getResourceList().add(cbar1RscPair);
|
||||
getDescriptor().getResourceList().instantiateResources( getDescriptor(), true );
|
||||
getDescriptor().getResourceList().instantiateResources(getDescriptor(),
|
||||
true);
|
||||
|
||||
cbar1Resource = (ColorBarResource) cbar1RscPair.getResource();
|
||||
|
||||
cbar2RscPair = ResourcePair.constructSystemResourcePair(
|
||||
new ColorBarResourceData( ncscatResourceData.getColorBar2() ) );
|
||||
cbar2RscPair = ResourcePair
|
||||
.constructSystemResourcePair(new ColorBarResourceData(
|
||||
ncscatResourceData.getColorBar2()));
|
||||
|
||||
getDescriptor().getResourceList().add(cbar2RscPair);
|
||||
getDescriptor().getResourceList().instantiateResources( getDescriptor(), true );
|
||||
getDescriptor().getResourceList().instantiateResources(getDescriptor(),
|
||||
true);
|
||||
|
||||
cbar2Resource = (ColorBarResource) cbar2RscPair.getResource();
|
||||
|
||||
|
@ -435,33 +461,45 @@ public class NcscatResource extends
|
|||
double speed = 0.0;
|
||||
double direction = 0.0;
|
||||
|
||||
// ...or option-dependent values invariant across all points
|
||||
float lineWidth = (float) (ncscatResourceData.arrowWidth * 1.0); // tune to match NMAP
|
||||
double sizeScale = ncscatResourceData.arrowSize * 0.135; // tune to match NMAP
|
||||
double arrowHeadSize = ncscatResourceData.headSize * 0.2; // tune to match NMAP
|
||||
double rainQcCircleRadiusPixels = ncscatResourceData.arrowSize / screenToWorldRatio * 0.46; // tune to match NMAP
|
||||
// ...or option-dependent values invariant across all points.
|
||||
// Note constants in the following are "tuned" to match NMAP
|
||||
float lineWidth = (float) (ncscatResourceData.arrowWidth * 1.0);
|
||||
double sizeScale = ncscatResourceData.arrowSize * 0.135;
|
||||
double arrowHeadSize = ncscatResourceData.headSize * 0.2;
|
||||
double rainQcCircleRadiusPixels = ncscatResourceData.arrowSize
|
||||
/ screenToWorldRatio * 0.46;
|
||||
|
||||
// Arrow type
|
||||
String pgenCategory = "Vector";
|
||||
String pgenType = ncscatResourceData.arrowStyle.getPgenType();
|
||||
VectorType vc = ncscatResourceData.arrowStyle.getVectorType();
|
||||
boolean directionOnly = ncscatResourceData.arrowStyle.getDirectionOnly();
|
||||
boolean directionOnly = ncscatResourceData.arrowStyle
|
||||
.getDirectionOnly();
|
||||
|
||||
// TODO: Unify this with above. For now, do some arrow-style-specific fine tuning...
|
||||
// TODO: Unify this with above. For now, do some arrow-style-specific
|
||||
// fine tuning...
|
||||
switch (ncscatResourceData.arrowStyle) {
|
||||
case DIRECTIONAL_ARROW:
|
||||
case REGULAR_ARROW:
|
||||
sizeScale *= 1.5;
|
||||
break;
|
||||
case WIND_BARB:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// User tells us how many rows -- and points within each row -- to
|
||||
// *skip* in between ones that get displayed; add one to get full
|
||||
// cycle interval...
|
||||
int interval = ncscatResourceData.skipEnable ? ncscatResourceData.skipValue + 1
|
||||
// ...OR if skip option not selected, auto-compute interval (1<=x<=6) based on
|
||||
// zoom and user-specified density (i.e., selectable progressive disclosure)
|
||||
: Math.max(Math.min((int) (50 / screenToWorldRatio / ncscatResourceData.densityValue), 6), 1);
|
||||
// ...OR if skip option not selected, auto-compute interval
|
||||
// (1<=x<=6) based on zoom and user-specified density
|
||||
// (i.e., selectable progressive disclosure)
|
||||
: Math.max(
|
||||
Math.min(
|
||||
(int) (50 / screenToWorldRatio / ncscatResourceData.densityValue),
|
||||
6), 1);
|
||||
// /System.out.println("interval = " + interval);
|
||||
// /System.out.println("S:W = " + screenToWorldRatio +
|
||||
// / " interval = " + interval +
|
||||
|
@ -470,16 +508,16 @@ public class NcscatResource extends
|
|||
// minute once
|
||||
|
||||
// Loop through the (preprocessed) NCSCAT data records
|
||||
// (This should be fast.)
|
||||
|
||||
ArrayList<NcscatRowData> frameRows = currFrameData.frameRows;
|
||||
|
||||
// Loop over ROWS in the satellite track...
|
||||
|
||||
for (int rowCount = 0; rowCount < frameRows.size(); rowCount++) {
|
||||
for (int rowNumber = 0; rowNumber < frameRows.size(); rowNumber++) {
|
||||
|
||||
NcscatRowData rowData = frameRows.get(rowCount);
|
||||
NcscatRowData rowData = frameRows.get(rowNumber);
|
||||
|
||||
boolean displayRow = (rowCount % interval == 0);
|
||||
boolean displayRow = (rowNumber % interval == 0);
|
||||
|
||||
// Loop over POINTS in this row...
|
||||
|
||||
|
@ -488,16 +526,15 @@ public class NcscatResource extends
|
|||
double yAtMaxXOfRow = 0.0;
|
||||
double yAtMinXOfRow = 0.0;
|
||||
|
||||
for (int pointCount = 0; pointCount < rowData.points.size(); pointCount += interval) {
|
||||
for (int pointNumber = 0; pointNumber < rowData.points.size(); pointNumber += interval) {
|
||||
|
||||
// DEBUG pointData.rainQcFlag=OVERRIDErainQcFlag;
|
||||
// DEBUG pointData.highWindSpeedFlag=OVERRIDEhighWindSpeedFlag;
|
||||
// DEBUG pointData.lowWindSpeedFlag=OVERRIDElowWindSpeedFlag;
|
||||
// DEBUG pointData.availRedunFlag=OVERRIDEavailRedunFlag;
|
||||
|
||||
// Display point if consistent with skip interval, data flags,
|
||||
// and user options...
|
||||
NcscatPointData pointData = rowData.points.get(pointCount);
|
||||
// If point is consistent with data flags and user options...
|
||||
NcscatPointData pointData = rowData.points.get(pointNumber);
|
||||
if ((!pointData.availRedunFlag || ncscatResourceData.availabilityFlagEnable)
|
||||
&& (!pointData.rainQcFlag || ncscatResourceData.rainFlagEnable)
|
||||
&& (!pointData.highWindSpeedFlag || ncscatResourceData.highWindSpeedEnable)
|
||||
|
@ -509,14 +546,29 @@ public class NcscatResource extends
|
|||
// ...and is currently in visible range
|
||||
if (locPix != null
|
||||
&& correctedExtent.contains(locPix[0], locPix[1])) {
|
||||
// Remember left- and right-most point locations of row,
|
||||
// for possible time stamp line -- *even if we are not
|
||||
// displaying the points in this row*
|
||||
if (locPix[0] > maxXOfRow) {
|
||||
maxXOfRow = locPix[0];
|
||||
yAtMaxXOfRow = locPix[1];
|
||||
}
|
||||
if (locPix[0] < minXOfRow) {
|
||||
minXOfRow = locPix[0];
|
||||
yAtMinXOfRow = locPix[1];
|
||||
}
|
||||
if (displayRow) {
|
||||
// Now we are "go" to display the point (build its
|
||||
// wind vector and, if applicable, draw associated
|
||||
// circle)
|
||||
speed = pointData.speed;
|
||||
direction = pointData.direction;
|
||||
ColorBar colorBarToUse = pointData.rainQcFlag
|
||||
&& ncscatResourceData.use2ndColorForRainEnable ? colorBar2
|
||||
: colorBar1;
|
||||
color = getColorForSpeed(speed, colorBarToUse);
|
||||
colors = new Color[] { new Color(color.red, color.green, color.blue) };
|
||||
colors = new Color[] { new Color(color.red,
|
||||
color.green, color.blue) };
|
||||
windVectors.add(new Vector(null, colors, lineWidth,
|
||||
sizeScale, clear, location, vc, speed,
|
||||
direction, arrowHeadSize, directionOnly,
|
||||
|
@ -526,18 +578,12 @@ public class NcscatResource extends
|
|||
PixelCoordinate pixelLoc = new PixelCoordinate(
|
||||
descriptor.worldToPixel(new double[] {
|
||||
location.x, location.y }));
|
||||
target.drawCircle(pixelLoc.getX(), pixelLoc.getY(), pixelLoc.getZ(),
|
||||
rainQcCircleRadiusPixels, color, lineWidth);
|
||||
target.drawCircle(pixelLoc.getX(),
|
||||
pixelLoc.getY(), pixelLoc.getZ(),
|
||||
rainQcCircleRadiusPixels, color,
|
||||
lineWidth);
|
||||
}
|
||||
}
|
||||
if (locPix[0] > maxXOfRow) {
|
||||
maxXOfRow = locPix[0];
|
||||
yAtMaxXOfRow = locPix[1];
|
||||
}
|
||||
if (locPix[0] < minXOfRow) {
|
||||
minXOfRow = locPix[0];
|
||||
yAtMinXOfRow = locPix[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -556,15 +602,16 @@ public class NcscatResource extends
|
|||
minuteOfDay != lastTimestampedMinute) {
|
||||
// Draw time line/string for the first row within that minute,
|
||||
// IF any point of that row is within visible range.
|
||||
// (Note: *Not* the same as the first row with visible point
|
||||
// within that minute.)
|
||||
// (Note: This is *not* the same as the first row with visible
|
||||
// point within that minute.)
|
||||
lastTimestampedMinute = minuteOfDay; // Been here; done this
|
||||
if (maxXOfRow - minXOfRow <= 2000
|
||||
&& // TODO: Find a better way to prevent wraparound
|
||||
// Visible?
|
||||
correctedExtent.contains(minXOfRow, yAtMinXOfRow)
|
||||
&& correctedExtent.contains(maxXOfRow, yAtMaxXOfRow)) {
|
||||
// Draw line across track -- or as much as is currently visible...
|
||||
// Draw line across track -- or as much as is currently
|
||||
// visible...
|
||||
target.drawLine(minXOfRow, yAtMinXOfRow, 0.0, maxXOfRow,
|
||||
yAtMaxXOfRow, 0.0,
|
||||
ncscatResourceData.timeStampColor,
|
||||
|
@ -588,10 +635,12 @@ public class NcscatResource extends
|
|||
|
||||
font.dispose();
|
||||
|
||||
// Display wind vectors for all points
|
||||
// Draw the combined wind vectors for all points
|
||||
|
||||
DisplayElementFactory df = new DisplayElementFactory(target, getNcMapDescriptor());
|
||||
ArrayList<IDisplayable> displayEls = df.createDisplayElements(windVectors, paintProps);
|
||||
DisplayElementFactory df = new DisplayElementFactory(target,
|
||||
getNcMapDescriptor());
|
||||
ArrayList<IDisplayable> displayEls = df.createDisplayElements(
|
||||
windVectors, paintProps);
|
||||
for (IDisplayable each : displayEls) {
|
||||
each.draw(target, paintProps);
|
||||
each.dispose();
|
||||
|
@ -618,20 +667,23 @@ public class NcscatResource extends
|
|||
|
||||
public void resourceAttrsModified() {
|
||||
// update the colorbarPainters with possibly new colorbars
|
||||
boolean isCbar2Enabled =
|
||||
(getDescriptor().getResourceList().indexOf( cbar2RscPair ) != -1 );
|
||||
boolean isCbar2Enabled = (getDescriptor().getResourceList().indexOf(
|
||||
cbar2RscPair) != -1);
|
||||
//
|
||||
if (ncscatResourceData.use2ndColorForRainEnable && !isCbar2Enabled) {
|
||||
cbar2RscPair = ResourcePair.constructSystemResourcePair(
|
||||
new ColorBarResourceData( ncscatResourceData.getColorBar2() ) );
|
||||
cbar2RscPair = ResourcePair
|
||||
.constructSystemResourcePair(new ColorBarResourceData(
|
||||
ncscatResourceData.getColorBar2()));
|
||||
|
||||
getDescriptor().getResourceList().add(cbar2RscPair);
|
||||
getDescriptor().getResourceList().instantiateResources( getDescriptor(), true );
|
||||
getDescriptor().getResourceList().instantiateResources(
|
||||
getDescriptor(), true);
|
||||
|
||||
cbar2Resource = (ColorBarResource) cbar2RscPair.getResource();
|
||||
}
|
||||
else if( !ncscatResourceData.use2ndColorForRainEnable && isCbar2Enabled ) {
|
||||
// this will cause the ResourceCatalog to dispose of the resource so we will
|
||||
} else if (!ncscatResourceData.use2ndColorForRainEnable
|
||||
&& isCbar2Enabled) {
|
||||
// this will cause the ResourceCatalog to dispose of the resource so
|
||||
// we will
|
||||
// need to create a new one here.
|
||||
getDescriptor().getResourceList().remove(cbar2RscPair);
|
||||
cbar2RscPair = null;
|
||||
|
@ -663,6 +715,7 @@ public class NcscatResource extends
|
|||
if (fd == null || fd.getFrameTime() == null || fd.frameRows.size() == 0) {
|
||||
return legendString + "-No Data";
|
||||
}
|
||||
return legendString + " "+ NmapCommon.getTimeStringFromDataTime( fd.getFrameTime(), "/");
|
||||
return legendString + " "
|
||||
+ NmapCommon.getTimeStringFromDataTime(fd.getFrameTime(), "/");
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
|
@ -28,4 +28,3 @@ public interface INcCommand {
|
|||
IDescriptor descriptor, ImageBuilder ib) throws VizException;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,39 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginMetafile;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginPicture;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginPictureBody;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CGM;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CGMDisplay;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CgmException;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourIndexPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourModel;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourSelectionMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourValueExtent;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Command;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeWidthSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EndMetafile;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EndPicture;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.IBeginMetafileNameExtractor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ICgmExtractor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ICommandListener;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.IndexPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.IntegerPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineWidthSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MarkerSizeSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Message;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Messages;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.RealPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.RestrictedTextType;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ScalingMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ScalingMode.Mode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCExtent;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCIntegerPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCRealPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCType;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.BufferedInputStream;
|
||||
|
@ -48,22 +81,22 @@ import java.util.zip.GZIPInputStream;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.*;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ScalingMode.*;
|
||||
|
||||
/**
|
||||
* @author bhebbard adapted from CGM.java by BBN
|
||||
*
|
||||
*/
|
||||
public class NcCGM extends CGM implements Cloneable {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
private List<Command> commands;
|
||||
|
||||
private final List<ICommandListener> commandListeners = new ArrayList<ICommandListener>();
|
||||
|
||||
private final static int INITIAL_NUM_COMMANDS = 500;
|
||||
|
||||
private final static int MAX_COMMANDS_PER_IMAGE = 999999;
|
||||
|
||||
public NcCGM() {
|
||||
|
@ -79,11 +112,11 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
String cgmFilename = cgmFile.getName();
|
||||
if (cgmFilename.endsWith(".cgm.gz") || cgmFilename.endsWith(".cgmz")) {
|
||||
inputStream = new GZIPInputStream(new FileInputStream(cgmFile));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inputStream = new FileInputStream(cgmFile);
|
||||
}
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(inputStream));
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(
|
||||
inputStream));
|
||||
read(in);
|
||||
in.close();
|
||||
}
|
||||
|
@ -95,29 +128,31 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
Command c;
|
||||
do {
|
||||
if (com++ > MAX_COMMANDS_PER_IMAGE) {
|
||||
logger.error("Exceeded maxiumum CGM commands (" +
|
||||
MAX_COMMANDS_PER_IMAGE +
|
||||
") for one image; adding EndPicture command automatically]");
|
||||
logger.error("Exceeded maxiumum CGM commands ("
|
||||
+ MAX_COMMANDS_PER_IMAGE
|
||||
+ ") for one image; adding EndPicture command automatically]");
|
||||
c = new EndPicture(0, 5, 0, in);
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
c = NcCommand.read(in);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
c = null;
|
||||
logger.error("Exception occurred interpreting CGM bytecode");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (c == null) continue; // or should we add as null command?
|
||||
if (c == null)
|
||||
continue; // or should we add as null command?
|
||||
|
||||
if (c instanceof NcLineWidth || c instanceof NcTextAlignment) {
|
||||
logger.info("[CGM command #" + com + " completed] " + c.toString());
|
||||
logger.info("[CGM command #" + com + " completed] "
|
||||
+ c.toString());
|
||||
}
|
||||
|
||||
logger.debug("[CGM command #" + com + " completed] " + c.toString());
|
||||
logger.debug("[CGM command #" + com + " completed] "
|
||||
+ c.toString());
|
||||
|
||||
for (ICommandListener listener : this.commandListeners) {
|
||||
listener.commandProcessed(c);
|
||||
|
@ -126,7 +161,6 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
// get rid of all arguments after we read them
|
||||
c.cleanUpArguments();
|
||||
|
||||
|
||||
this.commands.add(c);
|
||||
|
||||
if (c instanceof EndMetafile) {
|
||||
|
@ -134,10 +168,11 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
}
|
||||
if (c instanceof EndPicture) {
|
||||
logger.debug("[CGM EndPicture command: Picture is completed]");
|
||||
}
|
||||
else if (!(c instanceof INcCommand)) {
|
||||
if (!(c instanceof BeginPicture) && !(c instanceof BeginPictureBody)) {
|
||||
logger.warn("Unsupported CGM command encountered -- " + c +"]");
|
||||
} else if (!(c instanceof INcCommand)) {
|
||||
if (!(c instanceof BeginPicture)
|
||||
&& !(c instanceof BeginPictureBody)) {
|
||||
logger.warn("Unsupported CGM command encountered -- " + c
|
||||
+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,8 +220,8 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
if (c instanceof BeginMetafile) {
|
||||
// the CGM files will be cut at the begin meta file command
|
||||
if (currentFileName != null) {
|
||||
dumpToFile(outputDir, extractor, channel, startPosition,
|
||||
currentPosition, currentFileName);
|
||||
dumpToFile(outputDir, extractor, channel,
|
||||
startPosition, currentPosition, currentFileName);
|
||||
}
|
||||
startPosition = currentPosition;
|
||||
BeginMetafile beginMetafile = (BeginMetafile) c;
|
||||
|
@ -199,8 +234,7 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
dumpToFile(outputDir, extractor, channel, startPosition,
|
||||
currentPosition, currentFileName);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (randomAccessFile != null) {
|
||||
randomAccessFile.close();
|
||||
}
|
||||
|
@ -213,10 +247,10 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
throws IOException {
|
||||
// dump the CGM file
|
||||
MappedByteBuffer byteBuffer = channel.map(
|
||||
FileChannel.MapMode.READ_ONLY, startPosition,
|
||||
currentPosition - startPosition);
|
||||
writeFile(byteBuffer, outputDir, extractor
|
||||
.extractFileName(currentFileName));
|
||||
FileChannel.MapMode.READ_ONLY, startPosition, currentPosition
|
||||
- startPosition);
|
||||
writeFile(byteBuffer, outputDir,
|
||||
extractor.extractFileName(currentFileName));
|
||||
// don't forget to regularly clear the messages that
|
||||
// we're not really using here
|
||||
Messages.getInstance().reset();
|
||||
|
@ -270,8 +304,7 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
dumpToStream(extractor, channel, startPosition,
|
||||
currentPosition, currentFileName);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (randomAccessFile != null) {
|
||||
randomAccessFile.close();
|
||||
}
|
||||
|
@ -317,8 +350,7 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
FileChannel channel = out.getChannel();
|
||||
channel.write(byteBuffer);
|
||||
out.close();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
|
@ -327,7 +359,9 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
|
||||
/**
|
||||
* Adds the given listener to the list of command listeners
|
||||
* @param listener The listener to add
|
||||
*
|
||||
* @param listener
|
||||
* The listener to add
|
||||
*/
|
||||
public void addCommandListener(ICommandListener listener) {
|
||||
this.commandListeners.add(listener);
|
||||
|
@ -385,6 +419,7 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
|
||||
/**
|
||||
* Returns the size of the CGM graphic.
|
||||
*
|
||||
* @return The dimension or null if no {@link VDCExtent} command was found.
|
||||
*/
|
||||
public Dimension getSize() {
|
||||
|
@ -393,8 +428,11 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the CGM graphic taking into account a specific DPI setting
|
||||
* @param dpi The DPI value to use
|
||||
* Returns the size of the CGM graphic taking into account a specific DPI
|
||||
* setting
|
||||
*
|
||||
* @param dpi
|
||||
* The DPI value to use
|
||||
* @return The dimension or null if no {@link VDCExtent} command was found.
|
||||
*/
|
||||
public Dimension getSize(double dpi) {
|
||||
|
@ -408,7 +446,8 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
if (scalingMode != null) {
|
||||
Mode mode = scalingMode.getMode();
|
||||
if (ScalingMode.Mode.METRIC.equals(mode)) {
|
||||
double metricScalingFactor = scalingMode.getMetricScalingFactor();
|
||||
double metricScalingFactor = scalingMode
|
||||
.getMetricScalingFactor();
|
||||
if (metricScalingFactor != 0) {
|
||||
// 1 inch = 25,4 millimeter
|
||||
factor = (dpi * metricScalingFactor) / 25.4;
|
||||
|
@ -416,8 +455,10 @@ public class NcCGM extends CGM implements Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
int width = (int)Math.ceil((Math.abs(extent[1].x - extent[0].x) * factor));
|
||||
int height = (int)Math.ceil((Math.abs(extent[1].y - extent[0].y) * factor));
|
||||
int width = (int) Math
|
||||
.ceil((Math.abs(extent[1].x - extent[0].x) * factor));
|
||||
int height = (int) Math
|
||||
.ceil((Math.abs(extent[1].y - extent[0].y) * factor));
|
||||
|
||||
return new Dimension(width, height);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterHeight;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -15,16 +18,15 @@ import com.raytheon.uf.viz.core.drawables.IFont.Style;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterHeight;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
*/
|
||||
public class NcCharacterHeight extends CharacterHeight implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
/**
|
||||
* @param ec
|
||||
|
@ -39,8 +41,15 @@ public class NcCharacterHeight extends CharacterHeight implements INcCommand {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, com.raytheon.uf.viz.core.drawables.IDescriptor, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CircleElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
@ -13,7 +13,6 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableCircle;
|
||||
import com.raytheon.uf.viz.core.DrawableString;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
|
@ -25,7 +24,9 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
*/
|
||||
public class NcCircleElement extends CircleElement implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
/**
|
||||
* @param ec
|
||||
|
@ -34,13 +35,21 @@ public class NcCircleElement extends CircleElement implements INcCommand {
|
|||
* @param in
|
||||
* @throws IOException
|
||||
*/
|
||||
public NcCircleElement(int ec, int eid, int l, DataInput in) throws IOException {
|
||||
public NcCircleElement(int ec, int eid, int l, DataInput in)
|
||||
throws IOException {
|
||||
super(ec, eid, l, in);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, com.raytheon.uf.viz.core.drawables.IDescriptor, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
|
@ -54,9 +63,12 @@ public class NcCircleElement extends CircleElement implements INcCommand {
|
|||
dc.setCoordinates(newpoint[0], newpoint[1]);
|
||||
dc.radius = this.radius;
|
||||
// dc.screenRadius = this.radius;
|
||||
dc.filled = true; //TODO -- SJ says this is what was intended; not encoded in CGM?
|
||||
dc.numberOfPoints = 6; // 8? 16? lower values improve performance (a lot)
|
||||
dc.basics.color = ib.currentLineColor; //TODO use currentCircleColor? or...?
|
||||
dc.filled = true; // TODO -- SJ says this is what was intended; not
|
||||
// encoded in CGM?
|
||||
dc.numberOfPoints = 6; // 8? 16? lower values improve performance (a
|
||||
// lot)
|
||||
dc.basics.color = ib.currentLineColor; // TODO use currentCircleColor?
|
||||
// or...?
|
||||
ib.circles.add(dc);
|
||||
// target.drawCircle(dc);
|
||||
// logger.debug("Circle has been drawn -- " + this);
|
||||
|
|
|
@ -28,24 +28,106 @@
|
|||
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Point2D;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.AlternateCharacterSetIndex;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ApplicationData;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.AttributeElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BackgroundColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginApplicationStructureBody;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginMetafile;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginPicture;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginPictureBody;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BeginTileArray;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.BitonalTile;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CellArray;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterCodingAnnouncer;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterExpansionFactor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterOrientation;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterSetIndex;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterSetList;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CharacterSpacing;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CircularArc3Point;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CircularArc3PointClose;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CircularArcCentre;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.CircularArcCentreClose;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ClipIndicator;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ClipRectangle;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourIndexPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourModel;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourSelectionMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourTable;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ColourValueExtent;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Command;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ControlElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.DelimiterElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.DeviceViewportSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.DisjointPolyline;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeCap;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeJoin;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeType;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeVisibility;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeWidth;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EdgeWidthSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ElementClass;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EllipseElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EllipticalArc;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EllipticalArcClose;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EndApplicationStructure;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EndMetafile;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EndPicture;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.EndTileArray;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Escape;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ExternalElements;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.FontList;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.GraphicalPrimitiveElements;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.HatchIndex;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.IndexPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.IntegerPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.InteriorStyleSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineAndEdgeTypeDefinition;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineCap;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineJoin;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineType;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineWidthSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MarkerColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MarkerSize;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MarkerSizeSpecificationMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MarkerType;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MaximumColourIndex;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MaximumVDCExtent;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MessageCommand;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MetafileDefaultsReplacement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MetafileDescription;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MetafileDescriptorElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MetafileElementList;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.MetafileVersion;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.NamePrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.NoOp;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.PictureDescriptorElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.PolyBezier;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.PolyMarker;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.PolygonSet;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.RealPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.RectangleElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.RestrictedText;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.RestrictedTextType;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.ScalingMode;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextPath;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Tile;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCExtent;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCIntegerPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCRealPrecision;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.VDCType;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.*;
|
||||
|
||||
/**
|
||||
* Base class for all the CGM commands.
|
||||
* <p>
|
||||
|
@ -60,7 +142,9 @@ import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.*;
|
|||
*/
|
||||
public class NcCommand extends Command implements Cloneable {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
public NcCommand(int ec, int eid, int l, DataInput in) throws IOException {
|
||||
super(ec, eid, l, in);
|
||||
|
@ -69,17 +153,19 @@ public class NcCommand extends Command implements Cloneable {
|
|||
|
||||
/**
|
||||
* Reads one command from the given input stream.
|
||||
* @param in Where to read the command from
|
||||
*
|
||||
* @param in
|
||||
* Where to read the command from
|
||||
* @return The command or {@code null} if the end of stream was found
|
||||
* @throws IOException On I/O error
|
||||
* @throws IOException
|
||||
* On I/O error
|
||||
*/
|
||||
public static Command read(DataInput in) throws IOException {
|
||||
int k;
|
||||
try {
|
||||
k = in.readUnsignedByte();
|
||||
k = (k << 8) | in.readUnsignedByte();
|
||||
}
|
||||
catch (EOFException e) {
|
||||
} catch (EOFException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -90,7 +176,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
return readCommand(in, ec, eid, l);
|
||||
}
|
||||
|
||||
protected static Command readCommand(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
protected static Command readCommand(DataInput in, int ec, int eid, int l)
|
||||
throws IOException {
|
||||
switch (ElementClass.getElementClass(ec)) {
|
||||
|
||||
case DELIMITER_ELEMENTS: // 0
|
||||
|
@ -133,8 +220,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 0
|
||||
private static Command readDelimiterElements(DataInput in, int ec, int eid, int l)
|
||||
throws IOException {
|
||||
private static Command readDelimiterElements(DataInput in, int ec, int eid,
|
||||
int l) throws IOException {
|
||||
// Delimiter elements
|
||||
switch (DelimiterElement.getElement(eid)) {
|
||||
|
||||
|
@ -213,7 +300,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 1
|
||||
private static Command readMetaFileDescriptorElements(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
private static Command readMetaFileDescriptorElements(DataInput in, int ec,
|
||||
int eid, int l) throws IOException {
|
||||
switch (MetafileDescriptorElement.getElement(eid)) {
|
||||
|
||||
case METAFILE_VERSION: // 1
|
||||
|
@ -289,7 +377,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 2
|
||||
private static Command readPictureDescriptorElements(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
private static Command readPictureDescriptorElements(DataInput in, int ec,
|
||||
int eid, int l) throws IOException {
|
||||
switch (PictureDescriptorElement.getElement(eid)) {
|
||||
// 2, 1
|
||||
case SCALING_MODE:
|
||||
|
@ -367,7 +456,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 3
|
||||
private static Command readControlElements(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
private static Command readControlElements(DataInput in, int ec, int eid,
|
||||
int l) throws IOException {
|
||||
switch (ControlElement.getElement(eid)) {
|
||||
case VDC_INTEGER_PRECISION:
|
||||
return new VDCIntegerPrecision(ec, eid, l, in);
|
||||
|
@ -384,7 +474,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 4
|
||||
private static Command readGraphicalPrimitiveElements(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
private static Command readGraphicalPrimitiveElements(DataInput in, int ec,
|
||||
int eid, int l) throws IOException {
|
||||
switch (GraphicalPrimitiveElements.getElement(eid)) {
|
||||
|
||||
case POLYLINE: // 1
|
||||
|
@ -475,7 +566,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 5
|
||||
private static Command readAttributeElements(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
private static Command readAttributeElements(DataInput in, int ec, int eid,
|
||||
int l) throws IOException {
|
||||
switch (AttributeElement.getElement(eid)) {
|
||||
case LINE_BUNDLE_INDEX: // 1
|
||||
// TODO unsupported(ec, eid);
|
||||
|
@ -622,7 +714,8 @@ public class NcCommand extends Command implements Cloneable {
|
|||
}
|
||||
|
||||
// Class: 7
|
||||
private static Command readExternalElements(DataInput in, int ec, int eid, int l) throws IOException {
|
||||
private static Command readExternalElements(DataInput in, int ec, int eid,
|
||||
int l) throws IOException {
|
||||
switch (ExternalElements.getElement(eid)) {
|
||||
case MESSAGE: // 1
|
||||
return new MessageCommand(ec, eid, l, in);
|
||||
|
|
|
@ -3,17 +3,18 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import java.io.*;
|
||||
import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.FillColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.FillColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
|
@ -26,10 +27,9 @@ public class NcFillColour extends FillColour implements INcCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps, IDescriptor descriptor, ImageBuilder ib)
|
||||
throws VizException {
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
ib.currentFillColor = GempakColor.convertToRGB(this.colorIndex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import java.io.*;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.InteriorStyle;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -13,16 +17,15 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.InteriorStyle;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
*/
|
||||
public class NcInteriorStyle extends InteriorStyle implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
/**
|
||||
* @param ec
|
||||
|
@ -37,13 +40,18 @@ public class NcInteriorStyle extends InteriorStyle implements INcCommand {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor, ImageBuilder ib)
|
||||
throws VizException {
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
switch (this.style) {
|
||||
case SOLID: // TODO: For now, SOLID is assumed for all filled polygons
|
||||
break;
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -11,10 +15,6 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
|
@ -29,8 +29,7 @@ public class NcLineColour extends LineColour implements INcCommand {
|
|||
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor,
|
||||
ImageBuilder ib) throws VizException {
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
ib.currentLineColor = GempakColor.convertToRGB(this.colorIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineWidth;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -11,9 +14,6 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.LineWidth;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
|
@ -32,13 +32,18 @@ public class NcLineWidth extends LineWidth implements INcCommand {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor,
|
||||
ImageBuilder ib) throws VizException {
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
ib.currentLineWidth = this.width / 1.0; // TODO ??
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.PolygonElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
|
@ -25,17 +24,15 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.geom.LineString;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.PolygonElement;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
*/
|
||||
public class NcPolygonElement extends PolygonElement implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
static List<double[]> currentDraw = new ArrayList<double[]>();
|
||||
|
||||
|
@ -57,10 +54,10 @@ public class NcPolygonElement extends PolygonElement implements INcCommand {
|
|||
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor, ImageBuilder ib)
|
||||
throws VizException {
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
|
||||
if (ib.shadedShapeReady) return; // work already done
|
||||
if (ib.shadedShapeReady)
|
||||
return; // work already done
|
||||
|
||||
PathIterator pi = this.polygon.getPathIterator(null);
|
||||
|
||||
|
@ -83,29 +80,34 @@ public class NcPolygonElement extends PolygonElement implements INcCommand {
|
|||
|
||||
}
|
||||
|
||||
private void processCurrentSegment(PathIterator pi, IShadedShape shadedShape,
|
||||
ImageBuilder ib) {
|
||||
private void processCurrentSegment(PathIterator pi,
|
||||
IShadedShape shadedShape, ImageBuilder ib) {
|
||||
double[] coordinates = new double[6];
|
||||
|
||||
int type = pi.currentSegment(coordinates);
|
||||
switch (type) {
|
||||
case PathIterator.SEG_MOVETO:
|
||||
//System.out.println("move to " + coordinates[0] + ", " + coordinates[1]);
|
||||
// System.out.println("move to " + coordinates[0] + ", " +
|
||||
// coordinates[1]);
|
||||
currentDraw.clear();
|
||||
currentDraw.add(ib.scalePoint(coordinates));
|
||||
break;
|
||||
case PathIterator.SEG_LINETO:
|
||||
//System.out.println("line to " + coordinates[0] + ", " + coordinates[1]);
|
||||
// System.out.println("line to " + coordinates[0] + ", " +
|
||||
// coordinates[1]);
|
||||
currentDraw.add(ib.scalePoint(coordinates));
|
||||
break;
|
||||
case PathIterator.SEG_QUADTO:
|
||||
//System.out.println("quadratic to " + coordinates[0] + ", " + coordinates[1] + ", "
|
||||
// System.out.println("quadratic to " + coordinates[0] + ", " +
|
||||
// coordinates[1] + ", "
|
||||
// + coordinates[2] + ", " + coordinates[3]);
|
||||
// TODO -- error / not supported
|
||||
break;
|
||||
case PathIterator.SEG_CUBICTO:
|
||||
//System.out.println("cubic to " + coordinates[0] + ", " + coordinates[1] + ", "
|
||||
// + coordinates[2] + ", " + coordinates[3] + ", " + coordinates[4] + ", " + coordinates[5]);
|
||||
// System.out.println("cubic to " + coordinates[0] + ", " +
|
||||
// coordinates[1] + ", "
|
||||
// + coordinates[2] + ", " + coordinates[3] + ", " + coordinates[4]
|
||||
// + ", " + coordinates[5]);
|
||||
// TODO -- error / not supported
|
||||
break;
|
||||
case PathIterator.SEG_CLOSE:
|
||||
|
@ -116,20 +118,19 @@ public class NcPolygonElement extends PolygonElement implements INcCommand {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void terminatePolygon(IShadedShape shadedShape, ImageBuilder ib) {
|
||||
if (currentDraw.size() > 1) {
|
||||
Coordinate[] coords = new Coordinate[currentDraw.size()];
|
||||
for (int j = 0; j < currentDraw.size(); j++) {
|
||||
coords[j] = new Coordinate(currentDraw.get(j)[0],
|
||||
1000.000 - //TODO why?
|
||||
coords[j] = new Coordinate(currentDraw.get(j)[0], 1000.000 - // TODO
|
||||
// why?
|
||||
currentDraw.get(j)[1]);
|
||||
}
|
||||
LineString[] lineStrings = new LineString[] { gf.createLineString(coords) };
|
||||
LineString[] lineStrings = new LineString[] { gf
|
||||
.createLineString(coords) };
|
||||
shadedShape.addPolygon(lineStrings, ib.currentFillColor);
|
||||
}
|
||||
currentDraw.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Polyline;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder.WireframeKey;
|
||||
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
@ -15,12 +19,11 @@ import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Polyline;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
public class NcPolyline extends Polyline implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
static List<double[]> currentDraw = new ArrayList<double[]>();
|
||||
|
||||
|
@ -31,63 +34,74 @@ public class NcPolyline extends Polyline implements INcCommand {
|
|||
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor, ImageBuilder ib)
|
||||
throws VizException {
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
|
||||
IWireframeShape wireframeForThisColor = ib.wireframes.get(ib.currentLineColor);
|
||||
WireframeKey key = ib.new WireframeKey(ib.currentLineColor,
|
||||
ib.currentLineWidth);
|
||||
|
||||
if (wireframeForThisColor == null) {
|
||||
wireframeForThisColor = target.createWireframeShape(false, descriptor);
|
||||
ib.wireframes.put(ib.currentLineColor, wireframeForThisColor);
|
||||
IWireframeShape wireframeForThisKey = ib.wireframes.get(key);
|
||||
|
||||
if (wireframeForThisKey == null) {
|
||||
wireframeForThisKey = target
|
||||
.createWireframeShape(false, descriptor);
|
||||
ib.wireframes.put(key, wireframeForThisKey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PathIterator pi = this.path.getPathIterator(null);
|
||||
|
||||
while (pi.isDone() == false) {
|
||||
processCurrentSegment(pi, wireframeForThisColor, ib);
|
||||
processCurrentSegment(pi, wireframeForThisKey, ib);
|
||||
pi.next();
|
||||
}
|
||||
|
||||
// if no close command
|
||||
if (currentDraw.size() > 1) {
|
||||
wireframeForThisColor.addLineSegment(currentDraw.toArray(new double[0][0]));
|
||||
wireframeForThisKey.addLineSegment(currentDraw
|
||||
.toArray(new double[0][0]));
|
||||
}
|
||||
currentDraw.clear();
|
||||
|
||||
}
|
||||
public static void processCurrentSegment(PathIterator pi, IWireframeShape wireframeForThisColor, ImageBuilder ib) {
|
||||
|
||||
public static void processCurrentSegment(PathIterator pi,
|
||||
IWireframeShape wireframeForThisKey, ImageBuilder ib) {
|
||||
double[] coordinates = new double[6];
|
||||
|
||||
int type = pi.currentSegment(coordinates);
|
||||
switch (type) {
|
||||
case PathIterator.SEG_MOVETO:
|
||||
//System.out.println("move to " + coordinates[0] + ", " + coordinates[1]);
|
||||
// System.out.println("move to " + coordinates[0] + ", " +
|
||||
// coordinates[1]);
|
||||
if (currentDraw.size() > 1) {
|
||||
wireframeForThisColor.addLineSegment(currentDraw.toArray(new double[0][0]));
|
||||
wireframeForThisKey.addLineSegment(currentDraw
|
||||
.toArray(new double[0][0]));
|
||||
}
|
||||
currentDraw.clear();
|
||||
currentDraw.add(ib.scalePoint(coordinates));
|
||||
break;
|
||||
case PathIterator.SEG_LINETO:
|
||||
//System.out.println("line to " + coordinates[0] + ", " + coordinates[1]);
|
||||
// System.out.println("line to " + coordinates[0] + ", " +
|
||||
// coordinates[1]);
|
||||
currentDraw.add(ib.scalePoint(coordinates));
|
||||
break;
|
||||
case PathIterator.SEG_QUADTO:
|
||||
//System.out.println("quadratic to " + coordinates[0] + ", " + coordinates[1] + ", "
|
||||
// System.out.println("quadratic to " + coordinates[0] + ", " +
|
||||
// coordinates[1] + ", "
|
||||
// + coordinates[2] + ", " + coordinates[3]);
|
||||
// TODO -- error / not supported
|
||||
break;
|
||||
case PathIterator.SEG_CUBICTO:
|
||||
//System.out.println("cubic to " + coordinates[0] + ", " + coordinates[1] + ", "
|
||||
// + coordinates[2] + ", " + coordinates[3] + ", " + coordinates[4] + ", " + coordinates[5]);
|
||||
// System.out.println("cubic to " + coordinates[0] + ", " +
|
||||
// coordinates[1] + ", "
|
||||
// + coordinates[2] + ", " + coordinates[3] + ", " + coordinates[4]
|
||||
// + ", " + coordinates[5]);
|
||||
// TODO -- error / not supported
|
||||
break;
|
||||
case PathIterator.SEG_CLOSE:
|
||||
// System.out.println("close");
|
||||
if (currentDraw.size() > 1) {
|
||||
wireframeForThisColor.addLineSegment(currentDraw.toArray(new double[0][0]));
|
||||
wireframeForThisKey.addLineSegment(currentDraw
|
||||
.toArray(new double[0][0]));
|
||||
}
|
||||
currentDraw.clear();
|
||||
break;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Text;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
@ -38,13 +38,19 @@ public class NcText extends Text implements INcCommand {
|
|||
* @throws IOException
|
||||
*/
|
||||
public NcText(int ec, int eid, int l, DataInput in) throws IOException {
|
||||
// To handle little-endian strings, we need to bump an odd length ("l") parameter
|
||||
// up one to make it even (ending on two-byte CGM word boundary), so that we
|
||||
// To handle little-endian strings, we need to bump an odd length ("l")
|
||||
// parameter
|
||||
// up one to make it even (ending on two-byte CGM word boundary), so
|
||||
// that we
|
||||
// get the last character. (Will be flipped into place later.) Note that
|
||||
// special case of l=31 indicates "long form" (string length >=31 char, to
|
||||
// be specified in following 2-byte integer), so the parent constructor for
|
||||
// Command has also been modified to interpret l=32 fed up to it as a signal
|
||||
// to handle as l=31, then "bump" the long-form length it reads (from next
|
||||
// special case of l=31 indicates "long form" (string length >=31 char,
|
||||
// to
|
||||
// be specified in following 2-byte integer), so the parent constructor
|
||||
// for
|
||||
// Command has also been modified to interpret l=32 fed up to it as a
|
||||
// signal
|
||||
// to handle as l=31, then "bump" the long-form length it reads (from
|
||||
// next
|
||||
// 2 bytes) up to even value if needed.
|
||||
super(ec, eid, (l + 1) / 2 * 2, in);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextAlignment;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -14,16 +17,15 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextAlignment;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
*/
|
||||
public class NcTextAlignment extends TextAlignment implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
/**
|
||||
* @param ec
|
||||
|
@ -38,27 +40,36 @@ public class NcTextAlignment extends TextAlignment implements INcCommand {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, com.raytheon.uf.viz.core.drawables.IDescriptor, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
IDescriptor descriptor, ImageBuilder ib) throws VizException {
|
||||
|
||||
// Map/convert CGM-style text alignments to their IGraphicsTarget equivalents.
|
||||
// Map/convert CGM-style text alignments to their IGraphicsTarget
|
||||
// equivalents.
|
||||
|
||||
switch (this.horizontalAlignment) {
|
||||
case NORMAL_HORIZONTAL:
|
||||
// TODO: Following is sort of a hack, to deal with the way legacy
|
||||
// NTRANS metafiles are created by the NC driver code. A horizontal
|
||||
// alignment of CENTER appears to be coded (intentionally or otherwise)
|
||||
// in the legacy generated CGM by a *vertical* alignment value of CAP.
|
||||
// alignment of CENTER appears to be coded (intentionally or
|
||||
// otherwise)
|
||||
// in the legacy generated CGM by a *vertical* alignment value of
|
||||
// CAP.
|
||||
// Might want to investigate, and possibly bring legacy code to CGM
|
||||
// compliance.
|
||||
if (this.verticalAlignment == TextAlignment.VerticalAlignment.CAP) {
|
||||
ib.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.CENTER;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ib.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -11,10 +15,6 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.common.ui.color.GempakColor;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextColour;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
|
@ -34,8 +34,15 @@ public class NcTextColour extends TextColour implements INcCommand {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, com.raytheon.uf.viz.core.drawables.IDescriptor, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextFontIndex;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -14,16 +17,16 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.TextFontIndex;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder;
|
||||
|
||||
/**
|
||||
* @author bhebbard
|
||||
*
|
||||
*/
|
||||
public class NcTextFontIndex extends TextFontIndex implements INcCommand {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
private static boolean notWarned = true;
|
||||
|
||||
/**
|
||||
|
@ -39,8 +42,15 @@ public class NcTextFontIndex extends TextFontIndex implements INcCommand {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, com.raytheon.uf.viz.core.drawables.IDescriptor, gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand#paint(com.raytheon.uf
|
||||
* .viz.core.IGraphicsTarget,
|
||||
* com.raytheon.uf.viz.core.drawables.PaintProperties,
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor,
|
||||
* gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.NtransResource.ImageBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps,
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package gov.noaa.nws.ncep.viz.rsc.ntrans.rsc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableCircle;
|
||||
import com.raytheon.uf.viz.core.DrawableString;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 30, 2014 bhebbard Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bhebbard
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
public class ImageBuilder {
|
||||
|
||||
// This class holds the state of the image while it's under
|
||||
// construction by sequential execution of the CGM commands.
|
||||
|
||||
public class WireframeKey {
|
||||
public RGB color;
|
||||
|
||||
public double width;
|
||||
|
||||
public WireframeKey(RGB color, double width) {
|
||||
this.color = color;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + getOuterType().hashCode();
|
||||
result = prime * result + ((color == null) ? 0 : color.hashCode());
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(width);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
WireframeKey other = (WireframeKey) obj;
|
||||
if (!getOuterType().equals(other.getOuterType()))
|
||||
return false;
|
||||
if (color == null) {
|
||||
if (other.color != null)
|
||||
return false;
|
||||
} else if (!color.equals(other.color))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(width) != Double
|
||||
.doubleToLongBits(other.width))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private ImageBuilder getOuterType() {
|
||||
return ImageBuilder.this;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<WireframeKey, IWireframeShape> wireframes = new HashMap<WireframeKey, IWireframeShape>();
|
||||
|
||||
public RGB currentLineColor = new RGB(255, 255, 255);
|
||||
|
||||
public double currentLineWidth = 1.0;
|
||||
|
||||
public List<DrawableString> strings = new ArrayList<DrawableString>();
|
||||
|
||||
public RGB currentTextColor = new RGB(255, 255, 255);
|
||||
|
||||
public IFont currentFont = null;
|
||||
|
||||
public TextStyle textStyle = TextStyle.NORMAL;
|
||||
|
||||
public HorizontalAlignment horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
|
||||
public VerticalAlignment verticalAlignment = VerticalAlignment.TOP;
|
||||
|
||||
public List<DrawableCircle> circles = new ArrayList<DrawableCircle>();
|
||||
|
||||
public RGB currentCircleColor = new RGB(255, 0, 0);
|
||||
|
||||
public IShadedShape shadedShape;
|
||||
|
||||
public RGB currentFillColor = new RGB(0, 255, 0);
|
||||
|
||||
public boolean shadedShapeReady = false; // if true, shaded shape
|
||||
// constructed on
|
||||
// first paint of this frame
|
||||
// are already saved
|
||||
// (in PictureInfo), and so we
|
||||
// can skip
|
||||
// regeneration on subsequent
|
||||
// paints
|
||||
|
||||
public double scale = 1.0;
|
||||
|
||||
public double scaleNoZoom = 1.0;
|
||||
|
||||
public double[] scalePoint(double[] oldpoint) {
|
||||
return scalePoint(oldpoint[0], oldpoint[1]);
|
||||
}
|
||||
|
||||
public double[] scalePointNoZoom(double[] oldpoint) {
|
||||
return scalePointNoZoom(oldpoint[0], oldpoint[1]);
|
||||
}
|
||||
|
||||
public double[] scalePoint(double x, double y) {
|
||||
double[] newpoint = new double[2];
|
||||
newpoint[0] = x * scale;
|
||||
newpoint[1] = 1000.000 - y * scale; // TODO: Avoid hardcoding 1000
|
||||
return newpoint;
|
||||
}
|
||||
|
||||
public double[] scalePointNoZoom(double x, double y) {
|
||||
double[] newpoint = new double[2];
|
||||
newpoint[0] = x * scaleNoZoom; // TODO plus translation
|
||||
newpoint[1] = 1000.000 - y * scaleNoZoom; // TODO plus translation
|
||||
return newpoint;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,12 +4,12 @@ import gov.noaa.nws.ncep.common.dataplugin.ntrans.NtransRecord;
|
|||
import gov.noaa.nws.ncep.viz.common.ui.NmapCommon;
|
||||
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsResource;
|
||||
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResource;
|
||||
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsResource.IRscDataObject;
|
||||
import gov.noaa.nws.ncep.viz.resources.manager.ResourceName;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.jcgm.Command;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.INcCommand;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.NcCGM;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.ncgm.NcText;
|
||||
import gov.noaa.nws.ncep.viz.rsc.ntrans.rsc.ImageBuilder.WireframeKey;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.NCNonMapDescriptor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -18,34 +18,23 @@ import java.io.DataInputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.DrawableCircle;
|
||||
import com.raytheon.uf.viz.core.HDF5Util;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceType;
|
||||
import com.raytheon.uf.viz.core.DrawableCircle;
|
||||
import com.raytheon.uf.viz.core.DrawableString;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
|
||||
import com.raytheon.uf.viz.core.comm.Connector;
|
||||
|
@ -55,6 +44,8 @@ import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
|||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceType;
|
||||
|
||||
/**
|
||||
* NtransResource - Resource for Display of NTRANS Metafiles.
|
||||
|
@ -70,14 +61,15 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
* 30 Apr 2013 838 B. Hebbard IOC version (for OB13.4.1)
|
||||
* 30 May 2013 838 B. Hebbard Update for compatibility with changes by RTS in OB13.3.1
|
||||
* [ DataStoreFactory.getDataStore(...) parameter ]
|
||||
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bhebbard
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData, NCNonMapDescriptor>
|
||||
public class NtransResource extends
|
||||
AbstractNatlCntrsResource<NtransResourceData, NCNonMapDescriptor>
|
||||
implements INatlCntrsResource {
|
||||
|
||||
private NtransResourceData ntransResourceData;
|
||||
|
@ -86,17 +78,25 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
private IFont font = null;
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); //TODO static better??
|
||||
private final Log logger = LogFactory.getLog(this.getClass()); // TODO
|
||||
// static
|
||||
// better??
|
||||
|
||||
private class NtransDisplayablePictureInfo { // CGM calls it a "picture".
|
||||
// This is just a container holding the ready-to-paint information for
|
||||
// a single NTRANS image.
|
||||
NtransRecord ntransRecord; // the metadata record (PDO)
|
||||
|
||||
NcCGM cgm; // constructed "jcgm" representation of the image
|
||||
public IShadedShape shadedShape; // shaded shapes (filled polygons) get special
|
||||
// handling due to memory (heap runaway) issues;
|
||||
// once generated (at first paint), cache here
|
||||
// for future paints, instead of regenerating each time
|
||||
|
||||
public IShadedShape shadedShape; // shaded shapes (filled polygons) get
|
||||
// special
|
||||
// handling due to memory (heap
|
||||
// runaway) issues;
|
||||
// once generated (at first paint),
|
||||
// cache here
|
||||
// for future paints, instead of
|
||||
// regenerating each time
|
||||
|
||||
public NtransDisplayablePictureInfo(NtransRecord nr, NcCGM nc) {
|
||||
ntransRecord = nr;
|
||||
|
@ -113,7 +113,8 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
private class FrameData extends AbstractFrameData {
|
||||
|
||||
// FrameData holds the displayable information for a single frame (time).
|
||||
// FrameData holds the displayable information for a single frame
|
||||
// (time).
|
||||
NtransDisplayablePictureInfo pictureInfo;
|
||||
|
||||
public FrameData(DataTime frameTime, int timeInt) {
|
||||
|
@ -131,8 +132,10 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
if (pictureInfo != null) {
|
||||
|
||||
System.out.println("adding record to frame that has already been populated");
|
||||
// add code here to check if the new data is a better time match. if not then discard and
|
||||
System.out
|
||||
.println("adding record to frame that has already been populated");
|
||||
// add code here to check if the new data is a better time
|
||||
// match. if not then discard and
|
||||
// if so dispose of the existing data and process the new record
|
||||
return false;
|
||||
}
|
||||
|
@ -170,22 +173,23 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
long t2 = System.currentTimeMillis();
|
||||
cgm.read(di);
|
||||
long t3 = System.currentTimeMillis();
|
||||
logger.info("CGM image " + nr.getImageByteCount() +
|
||||
" bytes retrieved from HDF5 in " + (t1-t0) + " ms"
|
||||
logger.info("CGM image " + nr.getImageByteCount()
|
||||
+ " bytes retrieved from HDF5 in " + (t1 - t0) + " ms"
|
||||
+ " and parsed in " + (t3 - t2) + " ms");
|
||||
} catch (Exception e) {
|
||||
logger.info("CGM image " + nr.getImageByteCount() +
|
||||
" bytes retrieved from HDF5 in " + (t1-t0) + " ms");
|
||||
logger.info("CGM image " + nr.getImageByteCount()
|
||||
+ " bytes retrieved from HDF5 in " + (t1 - t0) + " ms");
|
||||
logger.error("EXCEPTION occurred interpreting CGM"
|
||||
+ " for metafile " + nr.getMetafileName()
|
||||
+ " product " + nr.getProductName());
|
||||
+ " for metafile " + nr.getMetafileName() + " product "
|
||||
+ nr.getProductName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Endianess revisited
|
||||
|
||||
if (flipped) { // if we shuffled the bytes before parsing...
|
||||
flipStrings(cgm); // ...then unshuffle the strings (now we know where they are)
|
||||
flipStrings(cgm); // ...then unshuffle the strings (now we know
|
||||
// where they are)
|
||||
}
|
||||
|
||||
// TODO Add optional (cool) debug dump of CGM representation
|
||||
|
@ -222,7 +226,8 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
// to failure on the ds.retrieve(...). Instead we force it to
|
||||
// synthesize the dataURI -- which getDataURI() does correctly --
|
||||
// by setting the field to null first. But why is this happening,
|
||||
// and why only in OB13.5.3, and why only for some resources...? (bh)
|
||||
// and why only in OB13.5.3, and why only for some resources...?
|
||||
// (bh)
|
||||
// (see also NCSCAT resource)
|
||||
nr.setDataURI(null); // force it to construct one
|
||||
|
||||
|
@ -231,8 +236,10 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
String dataset = "NTRANS";
|
||||
|
||||
// get filename and directory for IDataStore
|
||||
//String dir = nr.getHDFPathProvider().getHDFPath(nr.getPluginName(), nr);
|
||||
//String filename = nr.getHDFPathProvider().getHDFFileName(nr.getPluginName(), nr);
|
||||
// String dir =
|
||||
// nr.getHDFPathProvider().getHDFPath(nr.getPluginName(), nr);
|
||||
// String filename =
|
||||
// nr.getHDFPathProvider().getHDFFileName(nr.getPluginName(), nr);
|
||||
// File file = new File(dir, filename);
|
||||
|
||||
// ...and retrieve it
|
||||
|
@ -245,14 +252,14 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
// dr = ds.retrieve(uri);
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error("[EXCEPTION occurred retrieving CGM"
|
||||
+ " for metafile " + nr.getMetafileName()
|
||||
+ " product " + nr.getProductName() + "]");
|
||||
+ " for metafile " + nr.getMetafileName() + " product "
|
||||
+ nr.getProductName() + "]");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (StorageException e) {
|
||||
logger.error("[EXCEPTION occurred retrieving CGM"
|
||||
+ " for metafile " + nr.getMetafileName()
|
||||
+ " product " + nr.getProductName() + "]");
|
||||
+ " for metafile " + nr.getMetafileName() + " product "
|
||||
+ nr.getProductName() + "]");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -271,62 +278,6 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
public class ImageBuilder {
|
||||
|
||||
// This class holds the state of the image while it's under
|
||||
// construction by sequential execution of the CGM commands.
|
||||
|
||||
public Map<RGB,IWireframeShape> wireframes = new HashMap<RGB,IWireframeShape>();
|
||||
public RGB currentLineColor = new RGB(255,255,255);
|
||||
public double currentLineWidth = 1.0;
|
||||
|
||||
public List<DrawableString> strings = new ArrayList<DrawableString>();
|
||||
public RGB currentTextColor = new RGB(255,255,255);
|
||||
public IFont currentFont = null;
|
||||
public TextStyle textStyle = TextStyle.NORMAL;
|
||||
public HorizontalAlignment horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
public VerticalAlignment verticalAlignment = VerticalAlignment.TOP;
|
||||
|
||||
public List<DrawableCircle> circles = new ArrayList<DrawableCircle>();
|
||||
public RGB currentCircleColor = new RGB(255, 0, 0);
|
||||
|
||||
public IShadedShape shadedShape;
|
||||
public RGB currentFillColor = new RGB(0, 255, 0);
|
||||
|
||||
public boolean shadedShapeReady = false; // if true, shaded shape constructed on
|
||||
// first paint of this frame are already saved
|
||||
// (in PictureInfo), and so we can skip
|
||||
// regeneration on subsequent paints
|
||||
|
||||
public double scale = 1.0;
|
||||
public double scaleNoZoom = 1.0;
|
||||
|
||||
public double[] scalePoint (double[] oldpoint) {
|
||||
return scalePoint (oldpoint[0],oldpoint[1]);
|
||||
}
|
||||
|
||||
public double[] scalePointNoZoom (double[] oldpoint) {
|
||||
return scalePointNoZoom (oldpoint[0],oldpoint[1]);
|
||||
}
|
||||
|
||||
public double[] scalePoint(double x, double y) {
|
||||
double[] newpoint = new double[2];
|
||||
newpoint[0] = x * scale;
|
||||
newpoint[1] = 1000.000 - y * scale; // TODO: Avoid hardcoding 1000
|
||||
return newpoint;
|
||||
}
|
||||
|
||||
public double[] scalePointNoZoom(double x, double y) {
|
||||
double[] newpoint = new double[2];
|
||||
newpoint[0] = x * scaleNoZoom; // TODO plus translation
|
||||
newpoint[1] = 1000.000 - y * scaleNoZoom; // TODO plus translation
|
||||
return newpoint;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create an NTRANS Metafile display resource.
|
||||
*
|
||||
|
@ -338,13 +289,18 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
ntransResourceData = (NtransResourceData) resourceData;
|
||||
|
||||
// set the legend from the metafileName and productName
|
||||
// NOTE : this assumes that the request type of EQUALS (ie only one kind of metafileName and productName) (??)
|
||||
// NOTE : this assumes that the request type of EQUALS (ie only one kind
|
||||
// of metafileName and productName) (??)
|
||||
//
|
||||
if( ntransResourceData.getMetadataMap().containsKey("metafileName") &&
|
||||
ntransResourceData.getMetadataMap().containsKey("productName") ) {
|
||||
legendStr =
|
||||
" " + ntransResourceData.getMetadataMap().get("metafileName").getConstraintValue() +
|
||||
" / " + ntransResourceData.getMetadataMap().get("productName").getConstraintValue();
|
||||
if (ntransResourceData.getMetadataMap().containsKey("metafileName")
|
||||
&& ntransResourceData.getMetadataMap().containsKey(
|
||||
"productName")) {
|
||||
legendStr = " "
|
||||
+ ntransResourceData.getMetadataMap().get("metafileName")
|
||||
.getConstraintValue()
|
||||
+ " / "
|
||||
+ ntransResourceData.getMetadataMap().get("productName")
|
||||
.getConstraintValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,11 +308,13 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
return (AbstractFrameData) new FrameData(frameTime, timeInt);
|
||||
}
|
||||
|
||||
// query all the data in the db matching the request constraints (ie modelName, metaFile, and productName)
|
||||
// query all the data in the db matching the request constraints (ie
|
||||
// modelName, metaFile, and productName)
|
||||
// and also match the selected cycle time.
|
||||
//
|
||||
public void initResource(IGraphicsTarget grphTarget) throws VizException {
|
||||
// set initial display values from resource attributes (as if after modification)
|
||||
// set initial display values from resource attributes (as if after
|
||||
// modification)
|
||||
// resourceAttrsModified();
|
||||
long t0 = System.currentTimeMillis();
|
||||
|
||||
|
@ -364,10 +322,11 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
// set the constraints for the query.
|
||||
String[] dts = rscName.getCycleTime().toString().split(" ");
|
||||
String cycleTimeStr = dts[0] + " " + dts[1].substring(0, dts[1].length()-2);
|
||||
String cycleTimeStr = dts[0] + " "
|
||||
+ dts[1].substring(0, dts[1].length() - 2);
|
||||
|
||||
HashMap<String, RequestConstraint> reqConstraintsMap =
|
||||
new HashMap<String, RequestConstraint>( ntransResourceData.getMetadataMap() );
|
||||
HashMap<String, RequestConstraint> reqConstraintsMap = new HashMap<String, RequestConstraint>(
|
||||
ntransResourceData.getMetadataMap());
|
||||
|
||||
RequestConstraint timeConstraint = new RequestConstraint(cycleTimeStr);
|
||||
reqConstraintsMap.put("dataTime.refTime", timeConstraint);
|
||||
|
@ -375,7 +334,8 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
LayerProperty prop = new LayerProperty();
|
||||
prop.setDesiredProduct(ResourceType.PLAN_VIEW);
|
||||
prop.setEntryQueryParameters(reqConstraintsMap, false);
|
||||
prop.setNumberOfImages(15000); // TODO: max # records ?? should we cap this ?
|
||||
prop.setNumberOfImages(15000); // TODO: max # records ?? should we cap
|
||||
// this ?
|
||||
String script = null;
|
||||
script = ScriptCreator.createScript(prop);
|
||||
|
||||
|
@ -393,39 +353,41 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
//
|
||||
setAllFramesAsPopulated();
|
||||
|
||||
logger.info("Metadata records for " + this.newRscDataObjsQueue.size() +
|
||||
" images retrieved from DB in " +
|
||||
(System.currentTimeMillis()-t0) + " ms");
|
||||
logger.info("Metadata records for " + this.newRscDataObjsQueue.size()
|
||||
+ " images retrieved from DB in "
|
||||
+ (System.currentTimeMillis() - t0) + " ms");
|
||||
}
|
||||
|
||||
public void paintFrame(AbstractFrameData frameData, IGraphicsTarget target, PaintProperties paintProps) throws VizException {
|
||||
public void paintFrame(AbstractFrameData frameData, IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
|
||||
FrameData fd = (FrameData) frameData;
|
||||
|
||||
if (target != null && paintProps != null) {
|
||||
NtransDisplayablePictureInfo pictureInfo = fd.pictureInfo;
|
||||
|
||||
if (pictureInfo == null) return;
|
||||
if (pictureInfo == null)
|
||||
return;
|
||||
|
||||
// Paint it
|
||||
|
||||
if (this.font == null) {
|
||||
this.font = target.initializeFont("Monospace", 12, new IFont.Style[] { Style.BOLD});
|
||||
this.font = target.initializeFont("Monospace", 12,
|
||||
new IFont.Style[] { Style.BOLD });
|
||||
}
|
||||
ImageBuilder ib = new ImageBuilder();
|
||||
|
||||
ib.currentFont = this.font;
|
||||
ib.scale = 1000.000 / (double) pictureInfo.ntransRecord.getImageSizeX(); //TODO avoid hardcoding 1000
|
||||
ib.scale = 1000.000 / (double) pictureInfo.ntransRecord
|
||||
.getImageSizeX(); // TODO avoid hardcoding 1000
|
||||
if (pictureInfo.shadedShape != null) {
|
||||
// if we've saved shaded shapes from a previous paint, NcPolygonElement
|
||||
// if we've saved shaded shapes from a previous paint,
|
||||
// NcPolygonElement
|
||||
// can skip generating them all over again
|
||||
ib.shadedShapeReady = true;
|
||||
}
|
||||
else {
|
||||
ib.shadedShape = target.createShadedShape(
|
||||
false, // mutable
|
||||
descriptor.getGridGeometry(),
|
||||
false); // tesselate
|
||||
} else {
|
||||
ib.shadedShape = target.createShadedShape(false, // mutable
|
||||
descriptor.getGridGeometry(), false); // tesselate
|
||||
}
|
||||
|
||||
double screenToWorldRatio = paintProps.getCanvasBounds().width
|
||||
|
@ -434,7 +396,8 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
ib.scaleNoZoom = ib.scale * paintProps.getZoomLevel();
|
||||
|
||||
IExtent screenExtent = paintProps.getView().getExtent();
|
||||
IExtent mapExtent = new PixelExtent(descriptor.getGridGeometry().getGridRange());
|
||||
IExtent mapExtent = new PixelExtent(descriptor.getGridGeometry()
|
||||
.getGridRange());
|
||||
|
||||
for (Command c : pictureInfo.cgm.getCommands()) {
|
||||
if (c instanceof INcCommand) {
|
||||
|
@ -444,33 +407,38 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
// Shaded Shape (filled polygons) was deferred. Paint it now.
|
||||
|
||||
// if first paint of this image, save away shaded shape for future use
|
||||
// if first paint of this image, save away shaded shape for future
|
||||
// use
|
||||
if (!ib.shadedShapeReady /* OR pictureInfo.shadedShape == null */) {
|
||||
ib.shadedShape.compile();
|
||||
//pictureInfo.completedShadedShapes = ib.shadedShapes.toArray(new IShadedShape[ib.shadedShapes.size()]);
|
||||
// pictureInfo.completedShadedShapes =
|
||||
// ib.shadedShapes.toArray(new
|
||||
// IShadedShape[ib.shadedShapes.size()]);
|
||||
pictureInfo.shadedShape = ib.shadedShape;
|
||||
ib.shadedShapeReady = true;
|
||||
}
|
||||
float alpha = 1.0f; // TODO verify
|
||||
float brightness = 1.0f;
|
||||
target.drawShadedShape(pictureInfo.shadedShape, alpha, brightness);
|
||||
//TODO now that we don't dispose on each paint, need to do on resource termination?
|
||||
// TODO now that we don't dispose on each paint, need to do on
|
||||
// resource termination?
|
||||
// for (IShadedShape ss : ib.shadedShapes) {
|
||||
// ss.dispose();
|
||||
// }
|
||||
|
||||
// Wireframes were deferred. Paint them now.
|
||||
|
||||
for (RGB color : ib.wireframes.keySet()) {
|
||||
IWireframeShape wireframeForThisColor = ib.wireframes.get(color);
|
||||
if (wireframeForThisColor == null) {
|
||||
for (WireframeKey key : ib.wireframes.keySet()) {
|
||||
IWireframeShape wireframeForThisKey = ib.wireframes.get(key);
|
||||
if (wireframeForThisKey == null) {
|
||||
// TODO assert
|
||||
}
|
||||
else {
|
||||
wireframeForThisColor.compile();
|
||||
//TODO to be correct, should be lineWidth in effect at individual wireframe paints
|
||||
target.drawWireframeShape(wireframeForThisColor, color, (float) ib.currentLineWidth);
|
||||
wireframeForThisColor.dispose();
|
||||
} else {
|
||||
wireframeForThisKey.compile();
|
||||
// TODO to be correct, should be lineWidth in effect at
|
||||
// individual wireframe paints
|
||||
target.drawWireframeShape(wireframeForThisKey, key.color,
|
||||
(float) key.width);
|
||||
wireframeForThisKey.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,33 +448,32 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
|
||||
// Circles were deferred. Paint them now.
|
||||
|
||||
target.drawCircle(ib.circles.toArray(new DrawableCircle[ib.circles.size()]));
|
||||
target.drawCircle(ib.circles.toArray(new DrawableCircle[ib.circles
|
||||
.size()]));
|
||||
|
||||
/* -- Greg's handy outline box...
|
||||
|
||||
RGB color = new RGB( 250, 10, 10 );
|
||||
|
||||
if( font == null ) {
|
||||
font = target.initializeFont("Monospace", 14, new IFont.Style[] { IFont.Style.BOLD});
|
||||
}
|
||||
PixelCoordinate textLoc = new PixelCoordinate( 500, 500, 0 );
|
||||
target.drawString(font,
|
||||
"CGM IMAGE", textLoc.getX(),
|
||||
textLoc.getY(), 0.0,
|
||||
TextStyle.NORMAL,
|
||||
new RGB( 255, 255, 200 ),
|
||||
HorizontalAlignment.CENTER,
|
||||
VerticalAlignment.MIDDLE, 0.0);
|
||||
|
||||
target.drawLine(0.0f, 0.0f, 0.0f, 0.0f, 1000.0f, 0.0f, color, 1.0f );
|
||||
target.drawLine(0.0f, 0.0f, 0.0f, 1000.0f, 0.0f, 0.0f, color, 1.0f );
|
||||
target.drawLine(1000.0f, 0.0f, 0.0f, 1000.0f, 1000.0f, 0.0f, color, 1.0f );
|
||||
target.drawLine(0.0f, 1000.0f, 0.0f, 1000.0f, 1000.0f, 0.0f, color, 1.0f );
|
||||
color = new RGB(0,255,0);
|
||||
target.drawLine(10.0f, 10.0f, 10.0f, 10.0f, 990.0f, 10.0f, color, 1.0f );
|
||||
target.drawLine(10.0f, 10.0f, 10.0f, 990.0f, 10.0f, 10.0f, color, 1.0f );
|
||||
target.drawLine(990.0f, 10.0f, 10.0f, 990.0f, 990.0f, 10.0f, color, 1.0f );
|
||||
target.drawLine(10.0f, 990.0f, 10.0f, 990.0f, 990.0f, 10.0f, color, 1.0f );
|
||||
/*
|
||||
* -- Greg's handy outline box...
|
||||
*
|
||||
* RGB color = new RGB( 250, 10, 10 );
|
||||
*
|
||||
* if( font == null ) { font = target.initializeFont("Monospace",
|
||||
* 14, new IFont.Style[] { IFont.Style.BOLD}); } PixelCoordinate
|
||||
* textLoc = new PixelCoordinate( 500, 500, 0 );
|
||||
* target.drawString(font, "CGM IMAGE", textLoc.getX(),
|
||||
* textLoc.getY(), 0.0, TextStyle.NORMAL, new RGB( 255, 255, 200 ),
|
||||
* HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE, 0.0);
|
||||
*
|
||||
* target.drawLine(0.0f, 0.0f, 0.0f, 0.0f, 1000.0f, 0.0f, color,
|
||||
* 1.0f ); target.drawLine(0.0f, 0.0f, 0.0f, 1000.0f, 0.0f, 0.0f,
|
||||
* color, 1.0f ); target.drawLine(1000.0f, 0.0f, 0.0f, 1000.0f,
|
||||
* 1000.0f, 0.0f, color, 1.0f ); target.drawLine(0.0f, 1000.0f,
|
||||
* 0.0f, 1000.0f, 1000.0f, 0.0f, color, 1.0f ); color = new
|
||||
* RGB(0,255,0); target.drawLine(10.0f, 10.0f, 10.0f, 10.0f, 990.0f,
|
||||
* 10.0f, color, 1.0f ); target.drawLine(10.0f, 10.0f, 10.0f,
|
||||
* 990.0f, 10.0f, 10.0f, color, 1.0f ); target.drawLine(990.0f,
|
||||
* 10.0f, 10.0f, 990.0f, 990.0f, 10.0f, color, 1.0f );
|
||||
* target.drawLine(10.0f, 990.0f, 10.0f, 990.0f, 990.0f, 10.0f,
|
||||
* color, 1.0f );
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -530,8 +497,7 @@ public class NtransResource extends AbstractNatlCntrsResource<NtransResourceData
|
|||
@Override
|
||||
public String getName() {
|
||||
FrameData fd = (FrameData) getCurrentFrame();
|
||||
if (fd == null || fd.getFrameTime() == null
|
||||
|| fd.pictureInfo == null
|
||||
if (fd == null || fd.getFrameTime() == null || fd.pictureInfo == null
|
||||
|| fd.pictureInfo.cgm == null) {
|
||||
return legendStr + "-No Data";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<resourceGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<resource>
|
||||
<loadProperties>
|
||||
</loadProperties>
|
||||
<properties isSystemResource="false" isBlinking="false"
|
||||
isMapLayer="false" isHoverOn="false" isVisible="true" />
|
||||
<resourceData xsi:type="NC-PlotResourceData"
|
||||
retrieveData="false" isUpdatingOnMetadataOnly="false"
|
||||
isRequeryNecessaryOnTimeMatch="false">
|
||||
<legendColor>${legendColor}</legendColor>
|
||||
<legendString>${legendString}</legendString>
|
||||
<spiFile>${spiFile}</spiFile>
|
||||
<levelKey>Surface</levelKey>
|
||||
<plotDensity>${plotDensity}</plotDensity>
|
||||
|
||||
${plotModel}
|
||||
|
||||
${conditionalFilter}
|
||||
|
||||
<frameSpan>${frameSpan}</frameSpan>
|
||||
<timeMatchMethod>${timeMatchMethod}</timeMatchMethod>
|
||||
<timelineGenMethod>${timelineGenMethod}</timelineGenMethod>
|
||||
<dfltNumFrames>${dfltNumFrames}</dfltNumFrames>
|
||||
<dfltTimeRange>${dfltTimeRange}</dfltTimeRange>
|
||||
|
||||
<metadataMap>
|
||||
<mapping key="matrixType">
|
||||
<constraint constraintValue="${matrixType}" constraintType="IN" />
|
||||
</mapping>
|
||||
<mapping key="pluginName">
|
||||
<constraint constraintValue="${pluginName}" constraintType="EQUALS" />
|
||||
</mapping>
|
||||
</metadataMap>
|
||||
</resourceData>
|
||||
</resource>
|
||||
</resourceGroup>
|
|
@ -19,6 +19,11 @@
|
|||
editDialogClass="gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.EditPlotDataAttrsDialog"
|
||||
name="UpperAirPlot">
|
||||
</nc-resource>
|
||||
<nc-resource
|
||||
class="gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.PlotResourceData"
|
||||
editDialogClass="gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.EditPlotDataAttrsDialog"
|
||||
name="MatrixPlot">
|
||||
</nc-resource>
|
||||
|
||||
</extension>
|
||||
<extension
|
||||
|
@ -181,6 +186,54 @@
|
|||
paramType="IMPLEMENTATION_PARAM">
|
||||
</nc-resourceParameter>
|
||||
|
||||
<nc-resourceParameter
|
||||
paramClass="PlotModel"
|
||||
paramName="plotModel"
|
||||
paramType="EDITABLE_ATTRIBUTE"
|
||||
ncResourceName="MatrixPlot">
|
||||
</nc-resourceParameter>
|
||||
<nc-resourceParameter
|
||||
paramClass="java.lang.Integer"
|
||||
paramName="plotDensity"
|
||||
paramType="EDITABLE_ATTRIBUTE"
|
||||
defaultValue="20"
|
||||
ncResourceName="MatrixPlot">
|
||||
</nc-resourceParameter>
|
||||
<nc-resourceParameter
|
||||
paramClass="ConditionalFilter"
|
||||
paramName="conditionalFilter"
|
||||
defaultValue=""
|
||||
paramType="EDITABLE_ATTRIBUTE"
|
||||
ncResourceName="MatrixPlot">
|
||||
</nc-resourceParameter>
|
||||
|
||||
<nc-resourceParameter
|
||||
ncResourceName="MatrixPlot"
|
||||
paramClass="String"
|
||||
paramName="matrixType"
|
||||
paramType="REQUEST_CONSTRAINT">
|
||||
</nc-resourceParameter>
|
||||
<nc-resourceParameter
|
||||
ncResourceName="MatrixPlot"
|
||||
paramClass="String"
|
||||
paramName="spiFile"
|
||||
paramType="IMPLEMENTATION_PARAM">
|
||||
</nc-resourceParameter>
|
||||
<nc-resourceParameter
|
||||
ncResourceName="MatrixPlot"
|
||||
paramClass="String"
|
||||
paramName="legendString"
|
||||
defaultValue="MatrixPlot"
|
||||
paramType="IMPLEMENTATION_PARAM">
|
||||
</nc-resourceParameter>
|
||||
<nc-resourceParameter
|
||||
ncResourceName="MatrixPlot"
|
||||
paramClass="RGB"
|
||||
paramName="legendColor"
|
||||
defaultValue="RGB {155, 155, 155}"
|
||||
paramType="IMPLEMENTATION_PARAM">
|
||||
</nc-resourceParameter>
|
||||
|
||||
|
||||
</extension>
|
||||
|
||||
|
|
|
@ -927,7 +927,7 @@ public class NcPlotImageCreator {
|
|||
Collection<Station> stnColl, String plotUnit,
|
||||
double symbolSize, Color[] windVectorColorArray,
|
||||
String metPrm1, String metPrm2, PlotModelElement pme) {
|
||||
Tracer.print("> Entry " + Tracer.shortTimeString(this.dataTime)
|
||||
Tracer.printX("> Entry " + Tracer.shortTimeString(this.dataTime)
|
||||
+ " with " + stnColl.size() + " stations" + " metPrm1 "
|
||||
+ metPrm1 + " metPrm2 " + metPrm2);
|
||||
Map<Coordinate, IVector> localVectorPosToVectorMap = new HashMap<Coordinate, IVector>(
|
||||
|
@ -1040,7 +1040,7 @@ public class NcPlotImageCreator {
|
|||
}
|
||||
}
|
||||
ss.release();
|
||||
Tracer.print("< Exit " + Tracer.shortTimeString(this.dataTime));
|
||||
Tracer.printX("< Exit " + Tracer.shortTimeString(this.dataTime));
|
||||
|
||||
return localVectorPosToVectorMap;
|
||||
}
|
||||
|
@ -1050,7 +1050,7 @@ public class NcPlotImageCreator {
|
|||
double symbolSize, Color[] windVectorColorArray,
|
||||
double[] stationLoc) {
|
||||
|
||||
Tracer.print("> Entry");
|
||||
Tracer.printX("> Entry");
|
||||
AbstractMetParameter windSpeed = null, windDir = null;
|
||||
|
||||
Vector vector = null;
|
||||
|
@ -1089,7 +1089,7 @@ public class NcPlotImageCreator {
|
|||
|
||||
e.printStackTrace();
|
||||
}
|
||||
Tracer.print("< Exit" + " returning "
|
||||
Tracer.printX("< Exit" + " returning "
|
||||
+ ((vector == null) ? "NULL" : "a vector"));
|
||||
|
||||
return vector;
|
||||
|
|
|
@ -27,6 +27,7 @@ import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.TimeLogger;
|
|||
import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.Tracer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -34,6 +35,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
|
@ -63,9 +66,12 @@ import com.raytheon.viz.pointdata.PointDataRequest;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/20/2013?? 988 Archana.S Initial creation.
|
||||
* 02/26/2014 1061 B. Hebbard Don't block on JobPool cancel, so CAVE doesn't freeze if resource unloaded during long retrieval
|
||||
* 04/01/2014 1040 B. Hebbard In requestUpperAirData, (1) clear displayStationPlotBoolList for each new station, (2) call cond filter check with newInstance vs. metPrm
|
||||
* 04/08/2014 1127 B. Hebbard In requestSurfaceData, exclude only those obs returned from HDF5 that don't match desired time; fix dataTime association; removed redundant dataTimes from constraint
|
||||
*/
|
||||
|
||||
public class NcPlotModelHdf5DataRequestor {
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
private Map<String, RequestConstraint> constraintMap;
|
||||
|
@ -118,9 +124,11 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
//
|
||||
private HashMap<String, PlotParameterDefn> prioritySelectionsMap = null;
|
||||
|
||||
private String latDbName = "latitude";
|
||||
private static final String latDbName = "latitude";
|
||||
|
||||
private String lonDbName = "longitude";
|
||||
private static final String lonDbName = "longitude";
|
||||
|
||||
private static final String refTimeDbName = "refTime";
|
||||
|
||||
private Map<String, String> metParamNameToDbNameMap = null;
|
||||
|
||||
|
@ -226,7 +234,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
e.printStackTrace();
|
||||
}
|
||||
Tracer.print("< Exit");
|
||||
|
||||
}
|
||||
|
||||
public ConditionalFilter getConditionalFilter() {
|
||||
|
@ -277,14 +284,11 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
if (!dbParamsMap.containsKey(dbPrmName))
|
||||
dbParamsMap.put(dbPrmName, condColoringParam);
|
||||
}
|
||||
|
||||
setOfCondColoringParamNames.add(thisPlotParamDefn
|
||||
.getMetParamName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Tracer.print("< Exit");
|
||||
}
|
||||
|
@ -323,8 +327,9 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
synchronized (stationSet) {
|
||||
for (Station station : stationSet) {
|
||||
if (station.listOfParamsToPlot == null
|
||||
|| station.listOfParamsToPlot.isEmpty())
|
||||
|| station.listOfParamsToPlot.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Boolean> displayPlotBoolList = new ArrayList<Boolean>(
|
||||
station.listOfParamsToPlot.size());
|
||||
|
@ -378,7 +383,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
condMetParam = addToDerivedParamsList(
|
||||
eachPlotParamDefn.getDeriveParams(),
|
||||
eachPlotParamDefn);
|
||||
|
||||
} else {
|
||||
MetParameterFactory.getInstance().alias(
|
||||
eachPlotParamDefn.getMetParamName(),
|
||||
|
@ -392,22 +396,17 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
dbParamsMap.put(dbParamName, condMetParam);
|
||||
setOfDBParamNamesForHdf5Query.add(dbParamName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
determineParameterNamesForHdf5Query();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Tracer.print("< Exit");
|
||||
|
||||
}
|
||||
|
||||
public Boolean doesStationPassTheFilterForThisMetParam(
|
||||
AbstractMetParameter metPrm) {
|
||||
Tracer.print("> Entry");
|
||||
Tracer.printX("> Entry " + metPrm);
|
||||
Boolean displayStationPlot = true;
|
||||
|
||||
Set<String> condPlotParamNameSet = condFilterMap.keySet();
|
||||
|
@ -423,8 +422,9 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
|
||||
RequestConstraint reqConstraint = condFilterMap
|
||||
.get(condPlotParamName);
|
||||
if (reqConstraint == null)
|
||||
if (reqConstraint == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AbstractMetParameter condMetParam = MetParameterFactory
|
||||
.getInstance().createParameter(
|
||||
|
@ -494,7 +494,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
}
|
||||
}
|
||||
}
|
||||
Tracer.print("< Exit");
|
||||
Tracer.printX("< Exit " + (displayStationPlot ? "YES" : "NO"));
|
||||
|
||||
return displayStationPlot;
|
||||
}
|
||||
|
@ -539,8 +539,9 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
// ??derived
|
||||
if (plotPrmDefn.getDeriveParams() != null) {
|
||||
// TODO Do anything here at all?
|
||||
} else
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (dbParamsMap.containsKey(dbPrmName)) {
|
||||
continue;
|
||||
} else { // if( !dbPrmName.equals("derived" ) ) {
|
||||
|
@ -616,6 +617,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
|
||||
setOfDBParamNamesForHdf5Query.add(latDbName);
|
||||
setOfDBParamNamesForHdf5Query.add(lonDbName);
|
||||
setOfDBParamNamesForHdf5Query.add(refTimeDbName);
|
||||
|
||||
}
|
||||
|
||||
|
@ -640,6 +642,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
|
||||
setOfDBParamNamesForHdf5Query.add(latDbName);
|
||||
setOfDBParamNamesForHdf5Query.add(lonDbName);
|
||||
setOfDBParamNamesForHdf5Query.add(refTimeDbName);
|
||||
|
||||
if (derivedParamsList != null && !derivedParamsList.isEmpty())
|
||||
derivedParamsList.clear();
|
||||
|
@ -891,7 +894,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
}
|
||||
if (this.derivedParamsList != null && !this.derivedParamsList.isEmpty()) {
|
||||
determineDBParamNamesForDerivedParameters();
|
||||
|
||||
}
|
||||
|
||||
this.parameters = new String[setOfDBParamNamesForHdf5Query.size()];
|
||||
|
@ -927,7 +929,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
if (rangeTimeLst.contains(stnTime) == false) {
|
||||
rangeTimeLst.add(stnTime);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
NcSoundingQuery2 sndingQuery;
|
||||
|
@ -998,13 +999,20 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
List<NcSoundingProfile> listOfSoundingProfiles = sndingCube
|
||||
.getSoundingProfileList();
|
||||
if (listOfSoundingProfiles == null
|
||||
|| listOfSoundingProfiles.isEmpty())
|
||||
|| listOfSoundingProfiles.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
synchronized (listOfSoundingProfiles) {
|
||||
for (NcSoundingProfile sndingProfile : listOfSoundingProfiles) {
|
||||
Station currentStation = mapOfStnidsWithStns
|
||||
.get(sndingProfile.getStationId());
|
||||
|
||||
/*
|
||||
* Next station gets a fresh start when considering
|
||||
* conditional filters.
|
||||
*/
|
||||
displayStationPlotBoolList.clear();
|
||||
|
||||
/*
|
||||
* Clear the existing list of parameters to plot in each
|
||||
* station - to guarantee an updated list if there is a
|
||||
|
@ -1037,12 +1045,14 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
for (String dbPrmName : setOfDBParamNamesForHdf5Query) {
|
||||
AbstractMetParameter metPrm = dbParamsMap
|
||||
.get(dbPrmName);
|
||||
if (metPrm == null)
|
||||
if (metPrm == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AbstractMetParameter newInstance = newInstance(metPrm);
|
||||
if (newInstance == null)
|
||||
if (newInstance == null) {
|
||||
continue;
|
||||
}
|
||||
// TODO : the station lat/lon, elev, name and id
|
||||
// should be set in the sounding profile
|
||||
// but currently isn't. So instead we will get the
|
||||
|
@ -1051,14 +1061,15 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
if (soundingParamsMap.containsKey(key)) {
|
||||
AbstractMetParameter queriedParam = soundingParamsMap
|
||||
.get(key);
|
||||
if (newInstance.hasStringValue())
|
||||
if (newInstance.hasStringValue()) {
|
||||
newInstance.setStringValue(queriedParam
|
||||
.getStringValue());
|
||||
else
|
||||
} else {
|
||||
newInstance.setValue(
|
||||
queriedParam.getValue(),
|
||||
queriedParam.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
else if (newInstance.getMetParamName().equals(
|
||||
StationLatitude.class.getSimpleName())) {
|
||||
|
@ -1108,7 +1119,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
if (condFilterMap != null
|
||||
&& !condFilterMap.isEmpty()) {
|
||||
displayStationPlotBoolList
|
||||
.add(doesStationPassTheFilterForThisMetParam(metPrm));
|
||||
.add(doesStationPassTheFilterForThisMetParam(newInstance));
|
||||
}
|
||||
|
||||
// boolean found = false;
|
||||
|
@ -1144,8 +1155,9 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
}
|
||||
AbstractMetParameter clonedDerivedPrm = newInstance(derivedParam);// .getClass().newInstance();
|
||||
|
||||
if (clonedDerivedPrm == null)
|
||||
if (clonedDerivedPrm == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (paramsToPlot.containsKey(derivedParam
|
||||
.getMetParamName())) {
|
||||
|
@ -1179,11 +1191,12 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
.getMetParamName().compareTo(
|
||||
condMetParamName) == 0) {
|
||||
if (condDerivedParamToCheck
|
||||
.hasValidValue())
|
||||
.hasValidValue()) {
|
||||
displayStationPlotBoolList
|
||||
.add(doesStationPassTheFilterForThisMetParam(condDerivedParamToCheck));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1225,18 +1238,20 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
}
|
||||
|
||||
synchronized (mapOfStnidsWithStns) {
|
||||
if (displayStationPlot)
|
||||
if (displayStationPlot) {
|
||||
mapOfStnidsWithStns.put(
|
||||
currentStation.info.stationId,
|
||||
currentStation);
|
||||
else
|
||||
} else {
|
||||
mapOfStnidsWithStns
|
||||
.remove(currentStation.info.stationId);
|
||||
}
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
mapOfStnidsWithStns.put(currentStation.info.stationId,
|
||||
currentStation);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1251,6 +1266,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
Tracer.print("> Entry " + Tracer.shortTimeString(time));
|
||||
|
||||
// sem1.acquireUninterruptibly();
|
||||
|
||||
Map<String, Station> stationMap = new HashMap<String, Station>(
|
||||
listOfStationsRequestingForData.size());
|
||||
if (listOfStationsRequestingForData != null
|
||||
|
@ -1263,32 +1279,29 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
Map<String, RequestConstraint> map = new HashMap<String, RequestConstraint>();
|
||||
|
||||
map.put("pluginName", constraintMap.get("pluginName"));
|
||||
Tracer.print(Tracer.shortTimeString(time) + " putting "
|
||||
Tracer.print(Tracer.shortTimeString(time) + " putting '"
|
||||
+ constraintMap.get("pluginName")
|
||||
+ " as pluginName entry in map");
|
||||
+ "' as pluginName entry in map");
|
||||
|
||||
DataTime[] dt = new DataTime[listSize];
|
||||
String[] stationIds = new String[listSize];
|
||||
RequestConstraint rc = new RequestConstraint();
|
||||
RequestConstraint timeConstraint = new RequestConstraint();
|
||||
timeConstraint.setConstraintType(ConstraintType.IN);
|
||||
rc.setConstraintType(ConstraintType.IN);
|
||||
int index = 0;
|
||||
PluginPlotProperties plotProp = PluginPlotProperties
|
||||
.getPluginProperties(map);
|
||||
Tracer.print(Tracer.shortTimeString(time) + " plotProp "
|
||||
+ plotProp);
|
||||
Map<String, DataTime> stationIdToDataTimeMap = new HashMap<String, DataTime>(
|
||||
listSize);
|
||||
|
||||
synchronized (listOfStationsRequestingForData) {
|
||||
|
||||
for (Station currentStation : listOfStationsRequestingForData) {
|
||||
|
||||
dt[index] = currentStation.info.dataTime;
|
||||
// if( index == 0 ){
|
||||
// System.out.println("\n for the frame " +
|
||||
// time.toString() + "dt[0] = " + dt[0].toString());
|
||||
// }
|
||||
stationIds[index] = currentStation.info.stationId;
|
||||
// Remember association between stationId and its (one!)
|
||||
// matched time for this frame. Will use to filter out
|
||||
// multiple station returns (in case of shared obs
|
||||
// times) later.
|
||||
stationIdToDataTimeMap.put(
|
||||
currentStation.info.stationId,
|
||||
currentStation.info.dataTime);
|
||||
|
||||
if (plotProp.hasDistinctStationId) {
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
|
@ -1296,10 +1309,8 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
+ currentStation.info.stationId
|
||||
+ " plotProp.hasDistinctStationId TRUE; adding stationId to constraint value list ");
|
||||
rc.addToConstraintValueList(currentStation.info.stationId);
|
||||
timeConstraint
|
||||
.addToConstraintValueList(currentStation.info.dataTime
|
||||
.toString());
|
||||
} else
|
||||
// timeConstraint strings added all at once below
|
||||
} else {
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
|
@ -1307,6 +1318,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
+ currentStation.info.dataURI
|
||||
+ " to constraint value list");
|
||||
rc.addToConstraintValueList(currentStation.info.dataURI);
|
||||
}
|
||||
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
|
@ -1319,7 +1331,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
currentStation.info.longitude),
|
||||
currentStation);
|
||||
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1327,36 +1338,18 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " Done with station loop; plotProp.hasDistinctStationId TRUE; adding location.stationId-to-rc entry to map");
|
||||
map.put("location.stationId", rc);
|
||||
// if (dt.length > 1 && !dt[0].equals(dt[1])) { //TODO: wtf?
|
||||
// Tracer.print(Tracer.shortTimeString(time)
|
||||
// + " dt.length ("
|
||||
// + dt.length
|
||||
// + ") > 1 AND dt[0] ("
|
||||
// + dt[0]
|
||||
// + ") != dt[1] ("
|
||||
// + dt[1]
|
||||
// + "); replacing dataTime-to-rc entry in map with RC "
|
||||
// + timeConstraint);
|
||||
// sort data times and remove duplicates...
|
||||
SortedSet<DataTime> allDataTimesSortedSet = new TreeSet<DataTime>(
|
||||
stationIdToDataTimeMap.values());
|
||||
// ...and convert to strings for time request constraint
|
||||
List<String> allDataTimesAsStrings = new ArrayList<String>(
|
||||
allDataTimesSortedSet.size());
|
||||
for (DataTime dt : allDataTimesSortedSet) {
|
||||
allDataTimesAsStrings.add(dt.toString());
|
||||
}
|
||||
timeConstraint
|
||||
.setConstraintValueList(allDataTimesAsStrings);
|
||||
map.put("dataTime", timeConstraint);
|
||||
// } else {
|
||||
// map.remove("dataTime");
|
||||
// String timeStr = new String(dt[0].toString());
|
||||
// RequestConstraint rct = new RequestConstraint(timeStr);
|
||||
// // TODO
|
||||
// // temporary
|
||||
// // for
|
||||
// // debug
|
||||
// Tracer.print(Tracer.shortTimeString(time)
|
||||
// + " dt.length ("
|
||||
// + dt.length
|
||||
// + ") == 0 OR dt[0] ("
|
||||
// + dt[0]
|
||||
// +
|
||||
// ") == dt[1]; replacing dataTime-to-rc entry in map with RC based on timeStr "
|
||||
// + timeStr);
|
||||
// map.put("dataTime", rct);
|
||||
// // map.put("dataTime", new RequestConstraint(timeStr));
|
||||
// }
|
||||
} else {
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " Done with station loop; plotProp.hasDistinctStationId FALSE; putting dataURI-to-rc entry in map with rc "
|
||||
|
@ -1386,7 +1379,7 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
|
||||
int pdcSize = -1;
|
||||
if (pdc == null) {
|
||||
if (dt != null && dt.length > 0) {
|
||||
if (!stationIdToDataTimeMap.isEmpty()) {
|
||||
|
||||
sem1.acquireUninterruptibly();
|
||||
|
||||
|
@ -1397,9 +1390,15 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
+ " Plugin "
|
||||
+ this.plugin
|
||||
+ " Parameters "
|
||||
+ this.parameters + " Stations " + stationIds);
|
||||
+ this.parameters
|
||||
+ " Stations "
|
||||
+ stationIdToDataTimeMap.keySet().toArray(
|
||||
new String[0]));
|
||||
pdc = PointDataRequest.requestPointDataAllLevels(
|
||||
this.plugin, this.parameters, stationIds, map);
|
||||
this.plugin,
|
||||
this.parameters,
|
||||
stationIdToDataTimeMap.keySet().toArray(
|
||||
new String[0]), map);
|
||||
Tracer.print("Done with call PointDataRequest.requestPointDataAllLevels(...) for frame: "
|
||||
+ Tracer.shortTimeString(time)
|
||||
+ "HDF5 query map = "
|
||||
|
@ -1407,20 +1406,27 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
+ " Plugin "
|
||||
+ this.plugin
|
||||
+ " Parameters "
|
||||
+ this.parameters + " Stations " + stationIds);
|
||||
+ this.parameters
|
||||
+ " Stations "
|
||||
+ stationIdToDataTimeMap.keySet().toArray(
|
||||
new String[0]));
|
||||
|
||||
sem1.release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (pdc != null) {
|
||||
Tracer.print("We have a non-null PDC for frame: "
|
||||
+ Tracer.shortTimeString(time)
|
||||
+ "HDF5 query map = " + map + " Plugin "
|
||||
+ this.plugin + " Parameters " + this.parameters
|
||||
+ " Stations " + stationIds + " PDC content: "
|
||||
+ pdc);
|
||||
+ " HDF5 query map = "
|
||||
+ map
|
||||
+ " Plugin "
|
||||
+ this.plugin
|
||||
+ " Parameters "
|
||||
+ Arrays.toString(this.parameters)
|
||||
+ " Stations "
|
||||
+ Arrays.toString(stationIdToDataTimeMap.keySet()
|
||||
.toArray(new String[0])) + " PDC " + pdc);
|
||||
pdcSize = pdc.getAllocatedSz();
|
||||
Tracer.print("PDC for frame "
|
||||
+ Tracer.shortTimeString(time)
|
||||
|
@ -1437,89 +1443,74 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
return stationMap.values();
|
||||
}
|
||||
|
||||
int stationMapSize = stationIds.length;
|
||||
if (pdcSize > stationMapSize) {
|
||||
Tracer.print(Tracer.shortTimeString(time) + " pdcSize "
|
||||
+ pdcSize + " > stationMapSize " + stationMapSize
|
||||
+ " setting pdcSize = stationMapSize");
|
||||
pdcSize = stationMapSize;
|
||||
}
|
||||
Tracer.print("Size of stationMap: " + stationMap.size());
|
||||
Tracer.print("Number of stationIds: "
|
||||
+ stationIdToDataTimeMap.keySet()
|
||||
.toArray(new String[0]).length);
|
||||
Tracer.print("pdcSize: " + pdcSize);
|
||||
|
||||
for (int uriCounter = 0; uriCounter < pdcSize; uriCounter++) {
|
||||
|
||||
PointDataView pdv = pdc.readRandom(uriCounter);
|
||||
if (pdv == null) { // ???
|
||||
if (pdv == null) { // ??
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " PDV is null for station " + uriCounter
|
||||
+ " -- skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
DataTime dataTime = dt[uriCounter];
|
||||
|
||||
String key = new String(formatLatLonKey(
|
||||
pdv.getFloat(latDbName), pdv.getFloat(lonDbName)));
|
||||
|
||||
Station currentStation = stationMap.get(key);
|
||||
if (currentStation == null) {
|
||||
Tracer.print(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " stationMap entry not found for key " + key
|
||||
+ " -- skipping");
|
||||
continue;
|
||||
}
|
||||
// TODO remove
|
||||
boolean jfk = currentStation.info.stationId
|
||||
.equalsIgnoreCase("KJFK");
|
||||
|
||||
String stationId = currentStation.info.stationId;
|
||||
|
||||
DataTime dataTime = stationIdToDataTimeMap.get(stationId);
|
||||
|
||||
DataTime retrievedDataTime = new DataTime(new Date(
|
||||
pdv.getLong(refTimeDbName)));
|
||||
// Since the constraints we use (if
|
||||
// plotProp.hasDistinctStationId) are "stationID" IN
|
||||
// list-of-all-stationIDs -AND- dataTime IN
|
||||
// list-of-all-dataTimes, a station could be retrieved
|
||||
// for more data times than its unique time-matched time
|
||||
// (for this frame) -- IF it happens to share another data
|
||||
// time with another station legitimately time-matched to
|
||||
// that other time. Here we check to make sure the time
|
||||
// we retrieved is the one we wanted for this station;
|
||||
// if not, ignore this obs. (An obs with the desired
|
||||
// time should appear elsewhere in the PDC).
|
||||
if (!dataTime.equals(retrievedDataTime)) {
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " Retrieved dataTime for station "
|
||||
+ stationId + " is " + retrievedDataTime
|
||||
+ " but matched dataTime is " + dataTime
|
||||
+ " -- skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
Semaphore sm = new Semaphore(1);
|
||||
sm.acquireUninterruptibly();
|
||||
synchronized (paramsToPlot) {
|
||||
Set<String> pkeySet = paramsToPlot.keySet();
|
||||
Tracer.printX(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " paramsToPlot for "
|
||||
+ currentStation.info.stationId + ": "
|
||||
+ pkeySet);
|
||||
synchronized (pkeySet) {
|
||||
try {
|
||||
for (String prmToPlotKey : pkeySet) {
|
||||
if (jfk)
|
||||
Tracer.print(Tracer
|
||||
.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " "
|
||||
+ " from pkeySet updating prmToPlot(Key) "
|
||||
+ prmToPlotKey);
|
||||
AbstractMetParameter prmToPlot = paramsToPlot
|
||||
.get(prmToPlotKey);
|
||||
if (prmToPlot != null) {
|
||||
if (jfk)
|
||||
Tracer.print(Tracer
|
||||
.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " "
|
||||
+ " prmToPlot non-null "
|
||||
+ prmToPlot);
|
||||
prmToPlot.setValueToMissing();
|
||||
paramsToPlot.put(prmToPlot.getClass()
|
||||
.getSimpleName(), prmToPlot);
|
||||
} else {
|
||||
if (jfk)
|
||||
Tracer.print(Tracer
|
||||
.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " "
|
||||
+ " from pkeySet updating prmToPlot(Key) "
|
||||
+ " -- prmToPlot is NULL -- skipping!!!");
|
||||
// Tracer... prmToPlot==null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1533,25 +1524,11 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
0);
|
||||
|
||||
synchronized (setOfDBParamNamesForHdf5Query) {
|
||||
Tracer.print(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " setOfDBParamNamesForHdf5Query for "
|
||||
+ currentStation.info.stationId + ": "
|
||||
+ setOfDBParamNamesForHdf5Query);
|
||||
|
||||
for (String dbPrm : setOfDBParamNamesForHdf5Query) {
|
||||
AbstractMetParameter metPrm = dbParamsMap
|
||||
.get(dbPrm);
|
||||
if (metPrm == null) {
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " "
|
||||
+ " NULL metPrm return from dbParamsMap for key -- skipping"
|
||||
+ dbPrm);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1594,57 +1571,20 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
} catch (Exception e) {
|
||||
Tracer.print("param " + dbPrm + " not found.");
|
||||
}
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " " + currentStation.info.stationId
|
||||
+ " " + " before setMetParamFromPDV "
|
||||
+ dbPrm + " " + metPrm);
|
||||
|
||||
/*
|
||||
* Set the value for Met parameters from the
|
||||
* corresponding database value
|
||||
*/
|
||||
setMetParamFromPDV(metPrm, pdv, dbPrm, dataTime);
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " " + currentStation.info.stationId
|
||||
+ " " + " after setMetParamFromPDV "
|
||||
+ dbPrm + " " + metPrm);
|
||||
|
||||
// if(
|
||||
// metPrm.getMetParamName().compareTo("StationID")
|
||||
// == 0 ){
|
||||
// if(metPrm.getStringValue().compareTo(currentStation.info.stationId)
|
||||
// != 0 ){
|
||||
// System.out.println("ttd");
|
||||
// }
|
||||
// }
|
||||
|
||||
if (paramsToPlot.containsKey(metPrm
|
||||
.getMetParamName())) {
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " "
|
||||
+ " paramsToPlot contains metPrm; putting "
|
||||
+ metPrm.getMetParamName()
|
||||
+ " into paramsToPlot");
|
||||
paramsToPlot.put(metPrm.getMetParamName(),
|
||||
metPrm);
|
||||
}
|
||||
|
||||
dbParamsMap.put(dbPrm, metPrm);
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " " + currentStation.info.stationId
|
||||
+ " " + " after put " + dbPrm + " "
|
||||
+ metPrm + " into dbParamsMap");
|
||||
|
||||
if (condFilterMap != null
|
||||
&& !condFilterMap.isEmpty()) {
|
||||
|
@ -1708,12 +1648,12 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
.getMetParamName().compareTo(
|
||||
condMetParamName) == 0) {
|
||||
if (condDerivedParamToCheck
|
||||
.hasValidValue())
|
||||
.hasValidValue()) {
|
||||
displayStationPlotBoolList
|
||||
.add(doesStationPassTheFilterForThisMetParam(condDerivedParamToCheck));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1725,22 +1665,10 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
*/
|
||||
if (!currentStation.listOfParamsToPlot.isEmpty()) {
|
||||
currentStation.listOfParamsToPlot.clear();
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " CLEARING nonempty listOfParamsToPlot for "
|
||||
+ currentStation.info.stationId);
|
||||
}
|
||||
sm.acquireUninterruptibly();
|
||||
metParamsToDisplay = new ArrayList<AbstractMetParameter>(
|
||||
paramsToPlot.values());
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time) + " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " metParamsToDisplay for "
|
||||
+ currentStation.info.stationId + " "
|
||||
+ metParamsToDisplay);
|
||||
synchronized (metParamsToDisplay) {
|
||||
try {
|
||||
for (AbstractMetParameter metParam : metParamsToDisplay) {
|
||||
|
@ -1755,36 +1683,11 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
* the AbstractMetParametervalues from
|
||||
* paramsToPlot
|
||||
*/
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " " + " trying to add metParam "
|
||||
+ metParam);
|
||||
AbstractMetParameter newPrm = newInstance(metParam);
|
||||
if (newPrm == null) {
|
||||
if (jfk)
|
||||
Tracer.print(Tracer
|
||||
.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " "
|
||||
+ " newPrm NULL from newInstance -- skipping!!! "
|
||||
+ metParam);
|
||||
continue;
|
||||
}
|
||||
currentStation.listOfParamsToPlot.add(newPrm);
|
||||
if (jfk)
|
||||
Tracer.print(Tracer.shortTimeString(time)
|
||||
+ " "
|
||||
+ Tracer.shortTimeString(dataTime)
|
||||
+ " "
|
||||
+ currentStation.info.stationId
|
||||
+ " " + " added newPrm " + newPrm);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -1820,7 +1723,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
*/
|
||||
|
||||
if (condFilterMap != null && !condFilterMap.isEmpty()) {
|
||||
|
||||
displayStationPlot = true;
|
||||
synchronized (displayStationPlotBoolList) {
|
||||
for (Boolean b : displayStationPlotBoolList) {
|
||||
|
@ -1829,16 +1731,16 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
}
|
||||
|
||||
synchronized (stationMap) {
|
||||
if (displayStationPlot)
|
||||
if (displayStationPlot) {
|
||||
stationMap.put(key, currentStation);
|
||||
else
|
||||
} else {
|
||||
stationMap.remove(key);
|
||||
}
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
stationMap.put(key, currentStation);
|
||||
}
|
||||
|
||||
// if( currentStation.info.stationId.compareTo("KJFK") == 0
|
||||
// || currentStation.info.stationId.compareTo("KEYW") == 0 )
|
||||
// System.out.println( "\nFor frame: " + time.toString() +
|
||||
// " stn dataTime: "
|
||||
// + currentStation.info.dataTime.toString() +":"
|
||||
|
@ -1873,7 +1775,6 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
|
||||
}
|
||||
} catch (VizException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -1881,7 +1782,11 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
|
||||
// sem1.release();
|
||||
|
||||
Tracer.print("< Exit " + Tracer.shortTimeString(time));
|
||||
String stations = "";
|
||||
for (Station s : stationMap.values()) {
|
||||
stations += (" " + s.info.stationId);
|
||||
}
|
||||
Tracer.print("< Exit " + Tracer.shortTimeString(time) + stations);
|
||||
|
||||
return (stationMap.values());
|
||||
}
|
||||
|
@ -1995,8 +1900,9 @@ public class NcPlotModelHdf5DataRequestor {
|
|||
.getMetParamName()) == 0) {
|
||||
|
||||
AbstractMetParameter newPrm = newInstance(thisCondColorParam);
|
||||
if (newPrm == null)
|
||||
if (newPrm == null) {
|
||||
continue;
|
||||
}
|
||||
currentStation.setOfConditionalColorParams.add(newPrm);
|
||||
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ public final class ProgressiveDisclosure {
|
|||
}
|
||||
|
||||
public synchronized boolean checkAndUpdateProgDisclosureProperties() {
|
||||
Tracer.print("> Entry");
|
||||
Tracer.printX("> Entry");
|
||||
boolean update = updateNextPaint;
|
||||
|
||||
final IDisplayPane activePane = NcDisplayMngr
|
||||
|
@ -261,7 +261,7 @@ public final class ProgressiveDisclosure {
|
|||
VizApp.runSync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Tracer.print("> Entry");
|
||||
Tracer.printX("> Entry");
|
||||
if (activePane != null) {
|
||||
canvasBounds = activePane.getBounds();
|
||||
|
||||
|
@ -341,7 +341,7 @@ public final class ProgressiveDisclosure {
|
|||
// if(canvasBounds.height != progDiscTask.canvasWidth)
|
||||
|
||||
updateNextPaint = false;
|
||||
Tracer.print("< Exit");
|
||||
Tracer.printX("< Exit");
|
||||
return update;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -129,6 +129,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Added code to plot stations within 25% of the area outside of the current display area.
|
||||
* 05/20/2013 988 Archana.S Refactored this class for performance improvement
|
||||
* 11/07/2013 sgurung Added fix for "no data for every other frame" issue (earlier fix was added to 13.5.2 on 10/24/2013)
|
||||
* 03/18/2013 1064 B. Hebbard Added handling of matrixType request constraint, for PAFM
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
|
@ -984,7 +985,7 @@ public class NcPlotResource2 extends
|
|||
|
||||
public void paintFrame(AbstractFrameData fd, final IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
Tracer.print("> Entry");
|
||||
Tracer.printX("> Entry");
|
||||
currPaintProp = paintProps;
|
||||
if (fd == null)
|
||||
return;
|
||||
|
@ -1146,7 +1147,7 @@ public class NcPlotResource2 extends
|
|||
+ frameData.getShortFrameTime());
|
||||
}
|
||||
ss.release();
|
||||
Tracer.print("< Exit");
|
||||
Tracer.printX("< Exit");
|
||||
}
|
||||
|
||||
public void initResource(IGraphicsTarget aTarget) throws VizException {
|
||||
|
@ -1185,13 +1186,13 @@ public class NcPlotResource2 extends
|
|||
}
|
||||
|
||||
protected AbstractFrameData createNewFrame(DataTime frameTime, int timeInt) {
|
||||
Tracer.print("> Entry");
|
||||
Tracer.print("> Entry " + Tracer.shortTimeString(frameTime));
|
||||
FrameData newFrame = new FrameData(frameTime, timeInt);
|
||||
if (df == null)
|
||||
if (df == null) // TODO why do this here??
|
||||
df = new DisplayElementFactory(NcDisplayMngr
|
||||
.getActiveNatlCntrsEditor().getActiveDisplayPane()
|
||||
.getTarget(), getDescriptor());
|
||||
Tracer.print("< Exit");
|
||||
Tracer.print("< Exit " + Tracer.shortTimeString(frameTime));
|
||||
return newFrame;
|
||||
}
|
||||
|
||||
|
@ -1761,9 +1762,22 @@ public class NcPlotResource2 extends
|
|||
FrameData firstFrame = (FrameData) getFrame(datatimeList.get(0));
|
||||
String tableName = this.metadataMap.get("pluginName")
|
||||
.getConstraintValue();
|
||||
String query = "select distinct(" + tableName + ".forecastTime), "
|
||||
String matrixType = null;
|
||||
RequestConstraint matrixTypeRC = this.metadataMap.get("matrixType");
|
||||
if (matrixTypeRC != null) {
|
||||
matrixType = matrixTypeRC.getConstraintValue();
|
||||
}
|
||||
String query = "";
|
||||
if (matrixType == null || matrixType.isEmpty()) {
|
||||
query = "select distinct(" + tableName + ".forecastTime), "
|
||||
+ tableName + ".rangeEnd" + " from " + tableName
|
||||
+ " where reftime = '" + cycleTimeStr + "';";
|
||||
} else {
|
||||
query = "select distinct(" + tableName + ".forecastTime), "
|
||||
+ tableName + ".rangeEnd" + " from " + tableName
|
||||
+ " where matrixtype = '" + matrixType + "'"
|
||||
+ " AND reftime = '" + cycleTimeStr + "';";
|
||||
}
|
||||
try {
|
||||
List<Object[]> results = null;
|
||||
results = DirectDbQuery.executeQuery(query, "metadata",
|
||||
|
@ -1845,6 +1859,14 @@ public class NcPlotResource2 extends
|
|||
frameRCMap.put("pluginName",
|
||||
metadataMap
|
||||
.get("pluginName"));
|
||||
|
||||
matrixTypeRC = this.metadataMap
|
||||
.get("matrixType"); // redundant?
|
||||
if (matrixTypeRC != null) {
|
||||
frameRCMap.put("matrixType",
|
||||
matrixTypeRC);
|
||||
}
|
||||
|
||||
frameRCMap
|
||||
.put("dataTime.fcstTime",
|
||||
new RequestConstraint(
|
||||
|
|
|
@ -38,7 +38,9 @@ package gov.noaa.nws.ncep.viz.rsc.plotdata.rsc;
|
|||
|
||||
import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.NcPlotResource2.Station;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -50,6 +52,9 @@ import java.util.Date;
|
|||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
public class Tracer {
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
// save it static to have it available on every call
|
||||
|
||||
private static Method m;
|
||||
|
@ -60,9 +65,8 @@ public class Tracer {
|
|||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
String logFileName = /*
|
||||
* "/export/cdbsrv/bhebbard/pointdatadisplay/" +
|
||||
*/dateFormat.format(cal.getTime());
|
||||
String logFileName = "/export/cdbsrv/bhebbard/pointdatadisplay/"
|
||||
+ dateFormat.format(cal.getTime());
|
||||
|
||||
private static PrintWriter writer = null;
|
||||
|
||||
|
@ -95,37 +99,41 @@ public class Tracer {
|
|||
}
|
||||
|
||||
public static void print(String message) {
|
||||
if (enabled) {
|
||||
long elapsedTime = 0;
|
||||
if (startTime < 0) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
DateFormat dateFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd-HH-mm-ss");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String logFileName = /*
|
||||
* "/export/cdbsrv/bhebbard/pointdatadisplay/"
|
||||
* +
|
||||
*/dateFormat.format(cal.getTime());
|
||||
/*
|
||||
* try { writer = new PrintWriter(logFileName, "UTF-8"); } catch
|
||||
* (FileNotFoundException e) { // TODO Auto-generated catch block.
|
||||
* Please revise as // appropriate. //
|
||||
* statusHandler.handle(Priority.PROBLEM, //
|
||||
* e.getLocalizedMessage(), e); System.out.println("[" +
|
||||
* "FileNotFoundException" + "] " + message); } catch
|
||||
* (UnsupportedEncodingException e) { // TODO Auto-generated catch
|
||||
* block. Please revise as // appropriate. //
|
||||
* statusHandler.handle(Priority.PROBLEM, //
|
||||
* e.getLocalizedMessage(), e); System.out.println("[" +
|
||||
* "UnsupportedEncodingException" + "] " + message); }
|
||||
* System.out.println("[Logging to " + logFileName + "]");
|
||||
*/
|
||||
String logFileName = "/export/cdbsrv/bhebbard/pointdatadisplay/"
|
||||
+ dateFormat.format(cal.getTime());
|
||||
try {
|
||||
writer = new PrintWriter(logFileName, "UTF-8");
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
// statusHandler.handle(Priority.PROBLEM,
|
||||
// e.getLocalizedMessage(), e);
|
||||
System.out.println("[" + "FileNotFoundException" + "] "
|
||||
+ message);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
// statusHandler.handle(Priority.PROBLEM,
|
||||
// e.getLocalizedMessage(), e);
|
||||
System.out.println("[" + "UnsupportedEncodingException"
|
||||
+ "] " + message);
|
||||
}
|
||||
System.out.println("[Logging to " + logFileName + "]");
|
||||
startTime = System.nanoTime();
|
||||
} else {
|
||||
elapsedTime = (System.nanoTime() - startTime) / 1000000;
|
||||
}
|
||||
/*
|
||||
* System.out.println("[" + elapsedTime + getMethodName(1) + "] " +
|
||||
* message); writer.println("[" + elapsedTime + getMethodName(1) + "] "
|
||||
* + message);
|
||||
*/
|
||||
System.out.println("[" + elapsedTime + getMethodName(1) + "] "
|
||||
+ message);
|
||||
writer.println("[" + elapsedTime + getMethodName(1) + "] "
|
||||
+ message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void printX(String message) {
|
||||
|
@ -139,7 +147,7 @@ public class Tracer {
|
|||
Date frameDate = dt.getRefTime();
|
||||
DecimalFormat df = new DecimalFormat("00");
|
||||
String returnString = Integer.toString(frameDate.getDate()) + "/"
|
||||
+ df.format(frameDate.getHours() + 5) // TODOhorror!!
|
||||
+ df.format(frameDate.getHours() + 4) // TODOhorror!!
|
||||
+ df.format(frameDate.getMinutes());
|
||||
if (dt.getFcstTime() != 0) {
|
||||
returnString += "(" + dt.getFcstTime() + ")";
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
|
|||
import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences;
|
||||
import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences.DataMappingEntry;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.units.counts.DerivedWVPixel;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.units.goes.PolarPrecipWaterPixel;
|
||||
|
@ -115,6 +116,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* satellite projections in the McidasFileBasedTileSet
|
||||
* 05/20/2013 862 ghull implement IAreaProviderCapable
|
||||
* Nov 14, 2013 2393 bclement changed how numLevels is calculated for mcidas
|
||||
* 03/12/2014 920 pswamy Implemented changes to fix GINI VIS image display problems.
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -193,11 +195,16 @@ public abstract class AbstractSatelliteResource extends
|
|||
.getPDO();
|
||||
|
||||
if (!(satRec instanceof ISpatialEnabled)) {
|
||||
if (satRec instanceof SatelliteRecord) {
|
||||
gridGeom = baseGeom = ((SatelliteRecord) satRec)
|
||||
.getGridGeometry();
|
||||
} else {
|
||||
System.out
|
||||
.println("AbstractSatelliteResource.updateFrameData: PDO "
|
||||
+ satRec.getClass().toString()
|
||||
+ " doesn't implement ISpatialEnabled");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (baseCoverage == null) {
|
||||
baseCoverage = ((ISpatialEnabled) satRec)
|
||||
|
@ -207,6 +214,8 @@ public abstract class AbstractSatelliteResource extends
|
|||
frameCoverage = ((ISpatialEnabled) satRec)
|
||||
.getSpatialObject();
|
||||
}
|
||||
gridGeom = baseGeom = MapUtil
|
||||
.getGridGeometry(getSpatialObject());
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
|
@ -234,8 +243,6 @@ public abstract class AbstractSatelliteResource extends
|
|||
/*
|
||||
* for remapped projections such as MER, LCC, STR
|
||||
*/
|
||||
gridGeom = baseGeom = MapUtil
|
||||
.getGridGeometry(getSpatialObject());
|
||||
tileSet = baseTile = new McidasFileBasedTileSet(
|
||||
satRec, "Data", numLevels, 256, gridGeom,
|
||||
AbstractSatelliteResource.this,
|
||||
|
@ -431,6 +438,8 @@ public abstract class AbstractSatelliteResource extends
|
|||
} else {
|
||||
dataUnit = new GenericPixel();
|
||||
}
|
||||
} else if (this instanceof GiniSatResource) {
|
||||
dataUnit = null;
|
||||
} else
|
||||
dataUnit = new GenericPixel();
|
||||
|
||||
|
@ -507,8 +516,15 @@ public abstract class AbstractSatelliteResource extends
|
|||
|
||||
} else {
|
||||
numLevels = 1;
|
||||
int newSzX = ((ISpatialEnabled) record).getSpatialObject().getNx();
|
||||
int newSzY = ((ISpatialEnabled) record).getSpatialObject().getNy();
|
||||
int newSzX = 0;
|
||||
int newSzY = 0;
|
||||
if (record instanceof ISpatialEnabled) {
|
||||
newSzX = ((ISpatialEnabled) record).getSpatialObject().getNx();
|
||||
newSzY = ((ISpatialEnabled) record).getSpatialObject().getNy();
|
||||
} else if (record instanceof SatelliteRecord) {
|
||||
newSzX = ((SatelliteRecord) record).getCoverage().getNx();
|
||||
newSzY = ((SatelliteRecord) record).getCoverage().getNy();
|
||||
}
|
||||
|
||||
while ((newSzX > 512 && newSzY > 512)) {
|
||||
newSzX /= 2;
|
||||
|
|
|
@ -3,6 +3,7 @@ package gov.noaa.nws.ncep.viz.tools.plotModelMngr;
|
|||
import gov.noaa.nws.ncep.viz.common.ui.UserEntryDialog;
|
||||
import gov.noaa.nws.ncep.viz.rsc.plotdata.plotModels.PlotModelMngr;
|
||||
import gov.noaa.nws.ncep.viz.rsc.plotdata.plotModels.elements.PlotModel;
|
||||
import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.EditPlotModelComposite;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -19,12 +20,11 @@ import org.eclipse.swt.widgets.Dialog;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.EditPlotModelComposite;
|
||||
|
||||
/**
|
||||
* UI for editing Plot Models.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
|
@ -33,6 +33,8 @@ import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.EditPlotModelComposite;
|
|||
* 12/05/2009 217 Greg Hull Use EditPlotModelComposite
|
||||
* 07/26/2010 285 Q. Zhou modified editPlotModelComposit
|
||||
* 03/08/2011 425 Greg Hull add a Save As button
|
||||
* 03/10/2013 921 S. Russell TTR 921. Commented out "Save" button
|
||||
* 03/11/2013 921 S. Russell TTR 921. Append "COPY" during "Save As"
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,7 +44,12 @@ import gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.EditPlotModelComposite;
|
|||
public class EditPlotModelDialog extends Dialog {
|
||||
|
||||
protected Shell shell;
|
||||
|
||||
protected String dlgTitle = "Edit Plot Model";
|
||||
|
||||
// TTR 921
|
||||
protected String pltmdlnmsffx = "COPY";
|
||||
|
||||
protected boolean ok = false;
|
||||
|
||||
private PlotModel editedPlotModel = null;
|
||||
|
@ -90,20 +97,15 @@ public class EditPlotModelDialog extends Dialog {
|
|||
}
|
||||
});
|
||||
|
||||
Button saveBtn = new Button( okCanComp, SWT.PUSH );
|
||||
saveBtn.setText(" Save ");
|
||||
fd = new FormData();
|
||||
fd.width = 80;
|
||||
fd.bottom = new FormAttachment( 100, -5 );
|
||||
fd.left = new FormAttachment( 50, -40 );
|
||||
saveBtn.setLayoutData( fd );
|
||||
|
||||
saveBtn.addSelectionListener( new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
ok=true;
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
/*
|
||||
* // TTR 921 Button saveBtn = new Button( okCanComp, SWT.PUSH );
|
||||
* saveBtn.setText(" Save "); fd = new FormData(); fd.width = 80;
|
||||
* fd.bottom = new FormAttachment( 100, -5 ); fd.left = new
|
||||
* FormAttachment( 50, -40 ); saveBtn.setLayoutData( fd );
|
||||
*
|
||||
* saveBtn.addSelectionListener( new SelectionAdapter() { public void
|
||||
* widgetSelected(SelectionEvent e) { ok=true; shell.dispose(); } });
|
||||
*/
|
||||
|
||||
Button saveAsBtn = new Button(okCanComp, SWT.PUSH);
|
||||
saveAsBtn.setText("Save As...");
|
||||
|
@ -116,11 +118,10 @@ public class EditPlotModelDialog extends Dialog {
|
|||
saveAsBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
String pmname = editedPlotModel.getName() + pltmdlnmsffx;
|
||||
|
||||
// pop up a dialog to prompt for the new name
|
||||
UserEntryDialog entryDlg = new UserEntryDialog( shell,
|
||||
"Save As",
|
||||
"Save Plot Model As:",
|
||||
editedPlotModel.getName() );
|
||||
UserEntryDialog entryDlg = new UserEntryDialog(shell, "Save As", "Save Plot Model As:", pmname);
|
||||
String newPltMdlName = entryDlg.open();
|
||||
|
||||
if (newPltMdlName == null || // cancel pressed
|
||||
|
@ -130,13 +131,10 @@ public class EditPlotModelDialog extends Dialog {
|
|||
|
||||
// if this plotModel already exists, prompt to overwrite
|
||||
//
|
||||
if( PlotModelMngr.getInstance().getPlotModel(
|
||||
editedPlotModel.getPlugin(), newPltMdlName ) != null ) {
|
||||
if (PlotModelMngr.getInstance().getPlotModel(editedPlotModel.getPlugin(), newPltMdlName) != null) {
|
||||
|
||||
MessageDialog confirmDlg = new MessageDialog(shell, "Confirm", null,
|
||||
"A '"+newPltMdlName+"' Plot Model already exists.\n\nDo you want to overwrite it?",
|
||||
MessageDialog.QUESTION,
|
||||
new String[]{"Yes", "No"}, 0);
|
||||
MessageDialog confirmDlg = new MessageDialog(shell, "Confirm", null, "A '" + newPltMdlName + "' Plot Model already exists.\n\nDo you want to overwrite it?",
|
||||
MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0);
|
||||
confirmDlg.open();
|
||||
|
||||
if (confirmDlg.getReturnCode() == MessageDialog.CANCEL) {
|
||||
|
@ -154,11 +152,9 @@ public class EditPlotModelDialog extends Dialog {
|
|||
}
|
||||
|
||||
public void open() {
|
||||
open( getParent().getLocation().x +10,
|
||||
getParent().getLocation().y +10);
|
||||
open(getParent().getLocation().x + 10, getParent().getLocation().y + 10);
|
||||
}
|
||||
|
||||
|
||||
public Object open(int x, int y) {
|
||||
Display display = getParent().getDisplay();
|
||||
|
||||
|
@ -181,4 +177,3 @@ public class EditPlotModelDialog extends Dialog {
|
|||
public void initWidgets() {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -20,13 +19,14 @@ import org.junit.Test;
|
|||
* values is generated correctly.
|
||||
* 15-Jun-2010 174 Archana.S Updated test-cases per changes in the code design
|
||||
* 02-Aug-2010 174 Archana.S Updated test-cases per changes in the code design
|
||||
* 07-Apr-2014 TTR-938 D. Sushon Added test to verify TTR-938 fix,
|
||||
* removed assertEquals for cases that are massaged/handled upstream
|
||||
* </pre>
|
||||
*
|
||||
* @author Archana.S
|
||||
* @version 1
|
||||
*/
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
// TODO fix? @Ignore
|
||||
public class CINTTest {
|
||||
|
||||
private static final double ALLOWABLE_DOUBLE_DELTA = 0.0001;
|
||||
|
@ -47,14 +47,16 @@ public class CINTTest {
|
|||
* contourInterval/minContourValue/maxContourValue
|
||||
*/
|
||||
public void testPositiveContourIntervalWithMinMaxValues() {
|
||||
testCaseNumber = 1;
|
||||
// testCaseNumber = 1;
|
||||
|
||||
CINT cint = new CINT("10/0.5/9");
|
||||
CINT cint = new CINT("10/.5/9");
|
||||
|
||||
assertEquals(cint.isCINTStringParsed(), true);
|
||||
testList = new ArrayList<Double>(Arrays.asList(0.5, 9.0));
|
||||
testList = new ArrayList<Double>(Arrays.asList(.5, 9.));// Collections.emptyList();
|
||||
keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
|
||||
assertEquals(keySetList, testList);
|
||||
// assertEquals(testList, keySetList);// this is a special case that
|
||||
// can't be correctly handled at this level, upstream code provides full
|
||||
// range when a value is unknown
|
||||
assertEquals(cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL)
|
||||
.doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
|
||||
assertEquals(cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL)
|
||||
|
@ -367,7 +369,9 @@ public class CINTTest {
|
|||
assertEquals(cint.isCINTStringParsed(), true);
|
||||
testList = new ArrayList<Double>(Arrays.asList(-0.6));
|
||||
keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
|
||||
// assertEquals(keySetList,testList);
|
||||
// assertEquals(keySetList,testList); //this test needs to be handled
|
||||
// upstream, if no min/max range specified, CINT can't see what the
|
||||
// data's range is
|
||||
|
||||
System.out.println("=====================Test-Case " + testCaseNumber
|
||||
+ "a ========================");
|
||||
|
@ -385,7 +389,9 @@ public class CINTTest {
|
|||
|
||||
testList2 = new ArrayList<Double>(Arrays.asList(0.7));
|
||||
keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
|
||||
// assertEquals(keySetList,testList);
|
||||
// assertEquals(keySetList,testList); //this test needs to be handled
|
||||
// upstream, if no min/max range specified, CINT can't see what the
|
||||
// data's range is
|
||||
|
||||
System.out.println("=====================Test-Case " + testCaseNumber
|
||||
+ "b ========================");
|
||||
|
@ -418,8 +424,10 @@ public class CINTTest {
|
|||
.doubleValue(), 10, ALLOWABLE_DOUBLE_DELTA);
|
||||
assertEquals(cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
|
||||
.doubleValue(), 70, ALLOWABLE_DOUBLE_DELTA);
|
||||
//
|
||||
testList = new ArrayList<Double>(Arrays.asList(10.0, 30.0, 50.0, 60.0));
|
||||
// testList = new ArrayList<Double>(Arrays.asList(10.0, 30.0, 50.0,
|
||||
// 60.0));<-- as inherited, doesn't look right or agree w/legacy/testin;
|
||||
// fixing to:
|
||||
testList = new ArrayList<Double>(Arrays.asList(20.0, 40.0, 60.0));
|
||||
keySetList = cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
|
||||
assertEquals(keySetList, testList);
|
||||
|
||||
|
@ -542,7 +550,8 @@ public class CINTTest {
|
|||
assertEquals(cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL)
|
||||
.doubleValue(), 20, ALLOWABLE_DOUBLE_DELTA);
|
||||
testList = new ArrayList<Double>(Arrays.asList(5.0, 10.0, 15.0, 20.0));
|
||||
// assertEquals(cint2.getContourValuesList(),testList);
|
||||
assertEquals(cint2.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL),
|
||||
testList);
|
||||
|
||||
System.out.println("=====================Test-Case " + testCaseNumber
|
||||
+ "b========================");
|
||||
|
@ -799,14 +808,12 @@ public class CINTTest {
|
|||
ALLOWABLE_DOUBLE_DELTA);
|
||||
assertEquals(0.0000001, cint.getContourInterval(CINT.FIFTH_ZOOM_LEVEL)
|
||||
.doubleValue(), ALLOWABLE_DOUBLE_DELTA);
|
||||
// testList = new ArrayList<Double>(Arrays.asList(0.00009999));
|
||||
// keySetList =
|
||||
// cint.getContourValuesListAsDouble(CINT.FOURTH_ZOOM_LEVEL);
|
||||
testList = new ArrayList<Double>(Arrays.asList(0.00009999));
|
||||
keySetList = cint.getContourValuesListAsDouble(CINT.FOURTH_ZOOM_LEVEL);
|
||||
// assertEquals(testList, keySetList);
|
||||
testList = new ArrayList<Double>(Arrays.asList(0.0000001));
|
||||
keySetList = cint.getContourValuesListAsDouble(CINT.FIFTH_ZOOM_LEVEL);
|
||||
// assertEquals(testList, keySetList);
|
||||
// testList = new ArrayList<Double>(Arrays.asList(0.0000001));
|
||||
// keySetList =
|
||||
// cint.getContourValuesListAsDouble(CINT.FIFTH_ZOOM_LEVEL);
|
||||
assertEquals(testList, keySetList);
|
||||
testList = new ArrayList<Double>(Arrays.asList(-6.0, -4.0, -2.0, 0.0,
|
||||
2.0, 4.0, 6.0, 30.0, 50.0, 60.0, 80.0));
|
||||
keySetList = cint.getUniqueSortedContourValuesFromAllZoomLevels();
|
||||
|
@ -830,6 +837,8 @@ public class CINTTest {
|
|||
System.out
|
||||
.println("The unique contour values sorted in ascending order: "
|
||||
+ cint.getUniqueSortedContourValuesFromAllZoomLevelsAsString());
|
||||
|
||||
testCaseNumber++;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -859,6 +868,8 @@ public class CINTTest {
|
|||
+ cint.getCintHashMap(CINT.FOURTH_ZOOM_LEVEL));
|
||||
System.out.println("The HashMap at 5th zoom level"
|
||||
+ cint.getCintHashMap(CINT.FIFTH_ZOOM_LEVEL));
|
||||
|
||||
testCaseNumber++;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -875,6 +886,67 @@ public class CINTTest {
|
|||
CINT cint = new CINT("2/-6/6/3 > > 60=abc; 80=def > > ");
|
||||
System.out.println("Is CINT String parsed correctly? "
|
||||
+ cint.isCINTStringParsed());
|
||||
assertEquals(false, cint.isCINTStringParsed());
|
||||
|
||||
testCaseNumber++;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTTR938() {
|
||||
{
|
||||
CINT cint = new CINT("1/-23.5/-22.5");
|
||||
System.out.println("=====================Test-Case "
|
||||
+ testCaseNumber
|
||||
+ ", retest TTR 938 ========================");
|
||||
System.out.println("The input string = "
|
||||
+ cint.getUserInputString());
|
||||
System.out.println("Is the contour data string parsed correctly? "
|
||||
+ cint.isCINTStringParsed());
|
||||
assertEquals(cint.isCINTStringParsed(), true);
|
||||
System.out.println("Contour Interval = "
|
||||
+ cint.getContourInterval(CINT.FIRST_ZOOM_LEVEL));
|
||||
System.out.println("Minimum Contour Level = "
|
||||
+ cint.getMinContourValue(CINT.FIRST_ZOOM_LEVEL));
|
||||
System.out.println("Maximum Contour Level = "
|
||||
+ cint.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL));
|
||||
List<Double> contourList = cint
|
||||
.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
|
||||
System.out
|
||||
.println("Contour values list as double= " + contourList);
|
||||
System.out.println("Set of contour values with padding digits = "
|
||||
+ cint.getContourLabelsForZoomLevel(CINT.FIRST_ZOOM_LEVEL));
|
||||
System.out.println("HashMap at first zoom level = "
|
||||
+ cint.getCintHashMap(CINT.FIRST_ZOOM_LEVEL));
|
||||
|
||||
assertEquals(-23.0,
|
||||
cint.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL)
|
||||
.get(0), ALLOWABLE_DOUBLE_DELTA);
|
||||
}
|
||||
|
||||
CINT cint2 = new CINT("1/22.5/23.5");
|
||||
System.out.println("The input string = "
|
||||
+ cint2.getUserInputString());
|
||||
System.out.println("Is the contour data string parsed correctly? "
|
||||
+ cint2.isCINTStringParsed());
|
||||
assertEquals(cint2.isCINTStringParsed(), true);
|
||||
System.out.println("Contour Interval = "
|
||||
+ cint2.getContourInterval(CINT.FIRST_ZOOM_LEVEL));
|
||||
System.out.println("Minimum Contour Level = "
|
||||
+ cint2.getMinContourValue(CINT.FIRST_ZOOM_LEVEL));
|
||||
System.out.println("Maximum Contour Level = "
|
||||
+ cint2.getMaxContourValue(CINT.FIRST_ZOOM_LEVEL));
|
||||
List<Double> contourList = cint2
|
||||
.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL);
|
||||
System.out.println("Contour values list as double= " + contourList);
|
||||
System.out.println("Set of contour values with padding digits = "
|
||||
+ cint2.getContourLabelsForZoomLevel(CINT.FIRST_ZOOM_LEVEL));
|
||||
System.out.println("HashMap at first zoom level = "
|
||||
+ cint2.getCintHashMap(CINT.FIRST_ZOOM_LEVEL));
|
||||
assertEquals(23.0,
|
||||
cint2.getContourValuesListAsDouble(CINT.FIRST_ZOOM_LEVEL)
|
||||
.get(0), ALLOWABLE_DOUBLE_DELTA);
|
||||
|
||||
testCaseNumber++;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,31 +2,27 @@ package gov.noaa.nws.ncep.gempak.parameters.intext;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* TEXT format: size/font/width/hwflgs
|
||||
* TEXT format: size/font/width/hwflgs (used by HLSYM) OR size/font/width/border/rotation/justification/hwflgs (used by TEXT)
|
||||
*
|
||||
*/
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class TextStringParserTest {
|
||||
private static int testCaseNumber=1;
|
||||
|
||||
@Test
|
||||
public void testTextInputStringParse1 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with blank string----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with blank string----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("");
|
||||
|
||||
if ( ! txt.isTextParsed()) {
|
||||
assertEquals (txt.isTextParsed(),false);
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
}
|
||||
testCaseNumber ++;
|
||||
|
@ -35,8 +31,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse2 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with sizes----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with sizes----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("1.286");
|
||||
|
||||
|
@ -48,11 +44,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 2);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -65,8 +59,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse3 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with size name ----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size name ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("tin");
|
||||
|
||||
|
@ -78,11 +72,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 2);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -95,8 +87,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse4 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with size/font ----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/font ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("1.286/2");
|
||||
|
||||
|
@ -108,11 +100,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 2);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -125,8 +115,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse5 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with size/invalid font ----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/invalid font ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("1.286/5");
|
||||
|
||||
|
@ -138,11 +128,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 2);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -155,8 +143,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse6 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with size/ font / width ----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/ font / width ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("1.714/3/8");
|
||||
|
||||
|
@ -168,11 +156,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 8);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -185,8 +171,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse7 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with size/ font / width /hw flag ----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/ font / width /hw flag ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("2.429/2/8/HW");
|
||||
|
||||
|
@ -198,11 +184,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 8);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -215,8 +199,8 @@ public class TextStringParserTest {
|
|||
@Test
|
||||
public void testHLSYMInputStringParse8 () {
|
||||
|
||||
System.out.println("------------------Test-case " + testCaseNumber
|
||||
+ " with size/ font / width /hw flag ----------------");
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/ font / width /hw flag ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("2.429/2/8/SW");
|
||||
|
||||
|
@ -228,11 +212,9 @@ public class TextStringParserTest {
|
|||
assertEquals (txt.getTextWidth(), 8);
|
||||
assertEquals (txt.getTextHWFlag(), "SW");
|
||||
|
||||
System.out.println("--User Input Text parameter:"
|
||||
+ txt.getInputTextString());
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println(" Symbol/Marker size : "
|
||||
+ txt.getSymbolMarkerSize());
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
|
@ -241,4 +223,69 @@ public class TextStringParserTest {
|
|||
|
||||
testCaseNumber ++;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTEXTInputStringParse9 () {
|
||||
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/ font/ widthborder/ rotation/ justification /hw flag ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("2.429/3/8/221/N/L/HW");
|
||||
|
||||
if ( txt.isTextParsed() ) {
|
||||
assertEquals (txt.isTextParsed(),true);
|
||||
assertEquals (txt.getTextSize(), 34);
|
||||
assertEquals (txt.getTextFont(), 3);
|
||||
assertEquals (txt.getTextWidth(), 8);
|
||||
assertEquals (txt.getTextBorder(), 221);
|
||||
assertEquals (txt.getTextRotation(), 'N');
|
||||
assertEquals (txt.getTextJustification(), 'L');
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
System.out.println ( " Text border : " + txt.getTextBorder() );
|
||||
System.out.println ( " Text rotation : " + txt.getTextRotation() );
|
||||
System.out.println ( " Text justification : " + txt.getTextJustification() );
|
||||
System.out.println ( " Text hwflg : " + txt.getTextHWFlag() );
|
||||
}
|
||||
|
||||
testCaseNumber ++;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTEXTInputStringParse10 () {
|
||||
|
||||
System.out.println("------------------Test-case "+ testCaseNumber +" with size/ font/ widthborder/ rotation/ justification /hw flag ----------------");
|
||||
|
||||
|
||||
TextStringParser txt = new TextStringParser("1/23/8////HW");
|
||||
|
||||
if ( txt.isTextParsed() ) {
|
||||
assertEquals (txt.isTextParsed(),true);
|
||||
assertEquals (txt.getTextSize(), 14);
|
||||
//assertEquals (txt.getTextFont(), 3);
|
||||
//assertEquals (txt.getTextStyle(), 2);
|
||||
assertEquals (txt.getTextWidth(), 8);
|
||||
assertEquals (txt.getTextHWFlag(), "HW");
|
||||
|
||||
System.out.println ( "--User Input Text parameter:" + txt.getInputTextString() );
|
||||
System.out.println ( "-----------------------------" );
|
||||
System.out.println ( " Symbol/Marker size : " + txt.getSymbolMarkerSize() );
|
||||
System.out.println ( " Text size : " + txt.getTextSize() );
|
||||
System.out.println ( " Text font : " + txt.getTextFont() );
|
||||
System.out.println ( " Text style : " + txt.getTextStyle() );
|
||||
System.out.println ( " Text width : " + txt.getTextWidth() );
|
||||
System.out.println ( " Text border : " + txt.getTextBorder() );
|
||||
System.out.println ( " Text rotation : " + txt.getTextRotation() );
|
||||
System.out.println ( " Text justification : " + txt.getTextJustification() );
|
||||
System.out.println ( " Text hwflg : " + txt.getTextHWFlag() );
|
||||
}
|
||||
|
||||
testCaseNumber ++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue