14.1.1-6 baseline

Former-commit-id: 0cb2978c13 [formerly 7029e583ef36bf746fddda316ba011e27ed766b4]
Former-commit-id: 6067af4252
This commit is contained in:
Steve Harris 2013-11-06 14:08:33 -05:00
parent af2707389c
commit 26da1ce793
60 changed files with 5148 additions and 5750 deletions

View file

@ -161,4 +161,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -5,7 +5,7 @@
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=cmce_avgspr
modelName=cmce-avgspr
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>

View file

@ -5,7 +5,7 @@
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=ecens_avgspr
modelName=ecens-avgspr
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>

View file

@ -5,7 +5,7 @@
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=ecmwf_hr
modelName=ecmwf-hr
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>

View file

@ -5,7 +5,7 @@
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=gefs_avgspr
modelName=gefs-avgspr
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resourceDefnName>NAVGEM_NT</resourceDefnName>
<inventoryEnabled>false</inventoryEnabled>
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=navgem
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>10</dfltFrameCount>
<dfltTimeRange>48</dfltTimeRange>
<dfltGeogArea>XY</dfltGeogArea>
</ResourceDefinition>

View file

@ -0,0 +1,2 @@
! No real attributes for NTRANS
color= RGB {255,255,255}

View file

@ -5,7 +5,7 @@
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=opc_ens
modelName=opc-ens
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resourceDefnName>OTHER_NT</resourceDefnName>
<inventoryEnabled>false</inventoryEnabled>
<resourceCategory>NTRANS</resourceCategory>
<resourceParameters>
pluginName=ntrans
modelName=other
</resourceParameters>
<rscImplementation>NTRANS</rscImplementation>
<subTypeGenerator>metafileName,productName</subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>10</dfltFrameCount>
<dfltTimeRange>48</dfltTimeRange>
<dfltGeogArea>XY</dfltGeogArea>
</ResourceDefinition>

View file

@ -0,0 +1,2 @@
! No real attributes for NTRANS
color= RGB {255,255,255}

View file

@ -345,6 +345,9 @@
<ResourceDefinitionFilter isEnabled="true" rscDefnName="NAMVER_NT">
<filters>Forecast,NTRANS</filters>
</ResourceDefinitionFilter>
<ResourceDefinitionFilter isEnabled="true" rscDefnName="NAVGEM_NT">
<filters>Forecast,NTRANS</filters>
</ResourceDefinitionFilter>
<ResourceDefinitionFilter isEnabled="true" rscDefnName="NOGAPS_NT">
<filters>Forecast,NTRANS</filters>
</ResourceDefinitionFilter>
@ -357,6 +360,9 @@
<ResourceDefinitionFilter isEnabled="true" rscDefnName="OPC_ENS_NT">
<filters>Forecast,NTRANS</filters>
</ResourceDefinitionFilter>
<ResourceDefinitionFilter isEnabled="true" rscDefnName="OTHER_NT">
<filters>Forecast,NTRANS</filters>
</ResourceDefinitionFilter>
<ResourceDefinitionFilter isEnabled="true" rscDefnName="RAP_NT">
<filters>Forecast,NTRANS</filters>
</ResourceDefinitionFilter>

153
cave/build/static/linux/cave/awips2VisualizeUtility.sh Executable file → Normal file
View file

@ -1,37 +1,150 @@
#!/bin/bash
#
#
# 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.
#
# This script will kill any running AlertViz and/or
# CAVE processes whenever the user logs off.
# SOFTWARE HISTORY
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# July 10 2013 DR 16111 dhuffman Initial creation
#
#
# @author dhuffman
# @version 1.0
# This script will kill any running AlertViz and/or Cave
# processes when a user logs off.
if [ ! -f ${HOME}/vizUtility.log ]; then
touch ${HOME}/vizUtility.log
touch ${HOME}/vizUtility.log
else
echo "" >> ${HOME}/vizUtility.log
echo "" >> ${HOME}/vizUtility.log
fi
# Find all CAVE processes.
date >> ${HOME}/vizUtility.log
function findAlertvizProcesses {
# Find all the alertviz processes.
echo "Searching for alertviz processes." >> ${HOME}/vizUtility.log
zpid=` ps u -u $USER | grep '[a]lertviz' | awk '{print $2}' `
npid=` echo $zpid | wc -w `
if [ $npid -le 0 ]
then
echo "There are no alertviz processes found." >> ${HOME}/vizUtility.log
date >> ${HOME}/vizUtility.log
fi
}
function findAlertvizShProcesses {
# Find all the alertviz.sh processes.
echo "Searching for alertviz.sh processes." >> ${HOME}/vizUtility.log
zpid=` ps u -u $USER | grep '[a]lertviz.sh' | awk '{print $2}' `
npid=` echo $zpid | wc -w `
if [ $npid -le 0 ]
then
echo "There are no alertviz.sh processes found." >> ${HOME}/vizUtility.log
date >> ${HOME}/vizUtility.log
fi
}
function findCaveProcesses {
# Find all the Cave processes.
echo "Searching for cave processes." >> ${HOME}/vizUtility.log
for pid in `ps aux | grep [c]ave | awk '{print $2}'`;
zpid=` ps u -u $USER | grep '[c]ave' | awk '{print $2}' `
npid=` echo $zpid | wc -w `
if [ $npid -le 0 ]
then
echo "There are no cave processes found." >> ${HOME}/vizUtility.log
date >> ${HOME}/vizUtility.log
fi
}
# First let's attempt to kill the processes quickly which will work if the computer is not burdened.
findAlertvizShProcesses
for pid in $zpid
do
kill -9 ${pid}
echo "Killing 'cave' process with pid ${pid}." >> ${HOME}/vizUtility.log
echo "Attempting to kill 'alertviz.sh' process with pid ${pid}." >> ${HOME}/vizUtility.log
kill ${pid} 2>> ${HOME}/vizUtility.log
done
# Find the alertviz.sh script.
echo "Searching for the alertviz.sh script." >> ${HOME}/vizUtility.log
for pid in `ps aux | grep [a]lertviz.sh | awk '{print $2}'`;
findAlertvizProcesses
for pid in $zpid
do
kill -9 ${pid}
echo "Killing 'alertviz.sh' process with pid ${pid}." >> ${HOME}/vizUtility.log
echo "Attempting to kill 'alertviz' process with pid ${pid}." >> ${HOME}/vizUtility.log
kill ${pid} 2>> ${HOME}/vizUtility.log
done
# Find the AlertViz process.
echo "Searching for the alertviz process." >> ${HOME}/vizUtility.log
for pid in `ps aux | grep [a]lertviz | awk '{print $2}'`;
findCaveProcesses
for pid in $zpid
do
kill -9 ${pid}
echo "Killing 'alertviz' process with pid ${pid}." >> ${HOME}/vizUtility.log
echo "Attempting to kill 'cave' process with pid ${pid}." >> ${HOME}/vizUtility.log
kill ${pid} 2>> ${HOME}/vizUtility.log
done
echo "FINISHED" >> ${HOME}/vizUtility.log
exit 0
# Second let's be resolute in our assurances that these processes are killed.
# Please review the paperwork included in DR 16111 for an unabridged explanation.
findAlertvizShProcesses
# Lets loop until we are sure all the alertviz.sh processes are killed or we
# have looped too many times.
ntoomany=2002
while [[ $npid -ne 0 && $ntoomany -ne 0 ]]
do
for pid in $zpid
do
echo "Attempting to kill 'alertviz.sh' process with pid ${pid}." >> ${HOME}/vizUtility.log
kill -9 ${pid} 2>> ${HOME}/vizUtility.log
done
npid=0
((ntoomany-=1))
if [ $ntoomany -le 1 ]
then
echo "The kill alertviz portion of this script $0 has been unable preform its duties. 02" >> ${HOME}/vizUtility.log
break
fi
sleep 1
findAlertvizShProcesses
done
# Let's give the SIGTERM a chance if it has not had enough time yet.
sleep 1
findAlertvizProcesses
for pid in $zpid
do
echo "Attempting to kill 'alertviz' process with pid ${pid}." >> ${HOME}/vizUtility.log
kill -9 ${pid} 2>> ${HOME}/vizUtility.log
done
findCaveProcesses
for pid in $zpid
do
echo "Attempting to kill 'cave' process with pid ${pid}." >> ${HOME}/vizUtility.log
kill -9 ${pid} 2>> ${HOME}/vizUtility.log
done
date >> ${HOME}/vizUtility.log
echo >> ${HOME}/vizUtility.log

View file

@ -36,12 +36,6 @@
version="0.0.0"
unpack="false"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.eclipse.core.runtime"
download-size="0"

View file

@ -1027,8 +1027,8 @@ in|.0394|.0| 4 | |f5.2|@.|8000F0FF| |13|\
-->
<styleRule>
<paramLevelMatches>
<parameter>TP24hr </parameter>
<parameter>TP36hr </parameter>
<parameter>TP24hr</parameter>
<parameter>TP36hr</parameter>
</paramLevelMatches>
<contourStyle>
<displayUnits>in</displayUnits>

View file

@ -485,4 +485,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -172,9 +172,9 @@ import com.vividsolutions.jts.geom.Point;
* Jun 27, 2013 2152 njensen More thorough disposeInternal()
* Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL
* Jul 17, 2013 2197 njensen Improved speed of getName()
* Oct 18, 2013 DR 16151 gzhang Used getAverageValue() for QPF Graph.
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
@ -3157,9 +3157,9 @@ public class FFMPResource extends
getDataKey(), null, oldestRefTime, FFMPRecord.ALL,
basinPfaf);
Float qpfFloat = qpfBasin.getValue(monitor.getQpfWindow()
.getBeforeTime(), monitor.getQpfWindow().getAfterTime());
//Float qpfFloat = qpfBasin.getValue(monitor.getQpfWindow()
//.getBeforeTime(), monitor.getQpfWindow().getAfterTime());
Float qpfFloat = qpfBasin.getAverageValue(monitor.getQpfWindow().getAfterTime(),monitor.getQpfWindow().getBeforeTime() ); // DR 16151
fgd.setQpfValue(qpfFloat);
ArrayList<Double> qpfTimes = new ArrayList<Double>();

View file

@ -224,6 +224,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 11/05/2012 15477 zhao Trim blank lines in text in Editor when check Syntax
* 01/09/2013 15528 zhao Modified saveFile() and restoreFile()
* 10/24/2013 16478 zhao add syntax check for extra '=' sign
*
* </pre>
*
@ -1959,7 +1960,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
configMgr.setDefaultFontAndColors(applyBtn);
applyBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
public void widgetSelected(SelectionEvent event) {
if (editorTafTabComp.getTextEditorControl().getText() != null
&& !editorTafTabComp.getTextEditorControl().getText()
.isEmpty()) {
@ -1972,6 +1973,13 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
String toolName = toolsCbo.getItem(toolsCbo
.getSelectionIndex());
String bbb = editorTafTabComp.getBBB();
// DR166478
if ( toolName.equals("UseMetarForPrevailing") ) {
if ( checkBasicSyntaxError(true) ) {
return;
}
}
// Setup for python request
AvnSmartToolRequest req = new AvnSmartToolRequest();
@ -2037,7 +2045,106 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
return editorComp;
}
private void syntaxCheck() {
/**
*
* @param doLogMessage
* @return true if error found, otherwise false
*/
private boolean checkBasicSyntaxError(boolean doLogMessage) {
String in = editorTafTabComp.getTextEditorControl().getText();
clearSyntaxErrorLevel();
st = editorTafTabComp.getTextEditorControl();
final Map<StyleRange, String> syntaxMap = new HashMap<StyleRange, String>();
st.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseHover(MouseEvent e) {
st = editorTafTabComp.getTextEditorControl();
Point p = new Point(e.x, e.y);
try {
int offset = st.getOffsetAtLocation(p);
StyleRange[] srs = st.getStyleRanges();
StyleRange sr = null;
for (StyleRange range : srs) {
if (offset >= range.start
&& offset <= (range.start + range.length)) {
sr = range;
break;
}
}
if (sr != null) {
if (syntaxMap != null) {
st.setToolTipText(syntaxMap.get(sr));
}
} else {
st.setToolTipText(null);
}
} catch (Exception ex) {
st.setToolTipText(null);
}
}
});
int tafIndex = in.indexOf("TAF");
int equalSignIndex = in.indexOf("=");
int lastEqualSignIndex = equalSignIndex;
if ( tafIndex < 0 && equalSignIndex < 0 ) { // empty TAF
return false;
}
while (tafIndex > -1 || equalSignIndex > -1) {
if ( tafIndex == -1 || tafIndex > equalSignIndex ) {
int lineIndexOfFirstEqualSign = st.getLineAtOffset(lastEqualSignIndex);
int lineIndexOfSecondEqualSign = st.getLineAtOffset(equalSignIndex);
if ( lineIndexOfFirstEqualSign == lineIndexOfSecondEqualSign ) {
StyleRange sr = new StyleRange(lastEqualSignIndex,1,null,qcColors[3]);
String msg = "Syntax error: there is an extra '=' sign in this line";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return true;
}
int startIndex = lastEqualSignIndex;
while ( !in.substring(startIndex,startIndex+1).matches("[A-Z]") && !in.substring(startIndex,startIndex+1).matches("[0-9]") ) {
startIndex++;
}
int length = 6;
if ( (equalSignIndex-startIndex) < 6 ) {
length = equalSignIndex-startIndex;
}
StyleRange sr = new StyleRange(startIndex,length,null,qcColors[3]);
String msg = "Syntax error: There is an extra '=' sign before this point, or 'TAF' is missing at beginning of TAF";
syntaxMap.put(sr, msg);
st.setStyleRange(null);
st.setStyleRange(sr);
if (doLogMessage) {
msgStatComp.setMessageText(msg, qcColors[3].getRGB());
}
return true;
}
tafIndex = in.indexOf("TAF", tafIndex+1);
lastEqualSignIndex = equalSignIndex;
equalSignIndex = in.indexOf("=", equalSignIndex+1);
}
return false;
}
private void syntaxCheck() {
// Assume editorTafTabComp is for the active tab.
st = editorTafTabComp.getTextEditorControl();
st.setText(st.getText().toUpperCase());

View file

@ -95,6 +95,9 @@ import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector;
* Changes for non-blocking ZoneColorEditorDlg.
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
* Sep 05, 2013 2329 randerso Removed obsolete methods, added ApplyZoneCombo method
* Oct 17, 2013 2481 randerso Fixed regression which cause configured level combinations
* files to not be found. Removed message when combinations file
* not found to match A1.
*
* </pre>
*
@ -781,7 +784,7 @@ public class ZoneCombinerComp extends Composite implements
colorMap = getColorsFromFile();
String comboName = theFile;
if (comboName == null || comboName.isEmpty()) {
if ((comboName == null) || comboName.isEmpty()) {
comboName = getCombinationsFileName();
}
Map<String, Integer> comboDict = loadCombinationsFile(comboName);
@ -911,18 +914,16 @@ public class ZoneCombinerComp extends Composite implements
public Map<String, Integer> loadCombinationsFile(String comboName) {
Map<String, Integer> dict = new HashMap<String, Integer>();
try {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext ctx = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
File localFile = pm.getFile(ctx, FileUtil.join(
CombinationsFileUtil.COMBO_DIR_PATH, comboName + ".py"));
File localFile = PathManagerFactory.getPathManager().getStaticFile(
FileUtil.join(CombinationsFileUtil.COMBO_DIR_PATH,
comboName + ".py"));
List<List<String>> combolist = new ArrayList<List<String>>();
if (localFile != null && localFile.exists()) {
if ((localFile != null) && localFile.exists()) {
combolist = CombinationsFileUtil.init(comboName);
} else {
statusHandler.error("Combinations file does not found: "
+ comboName);
// statusHandler
// .error("Combinations file not found: " + comboName);
}
// reformat combinations into combo dictionary
@ -1004,7 +1005,7 @@ public class ZoneCombinerComp extends Composite implements
@Override
public void applyButtonState(final boolean enabled) {
if (this.applyZoneComboBtn != null
if ((this.applyZoneComboBtn != null)
&& !this.applyZoneComboBtn.isDisposed()) {
VizApp.runAsync(new Runnable() {
@Override
@ -1017,7 +1018,7 @@ public class ZoneCombinerComp extends Composite implements
private boolean buttonState() {
final boolean[] state = { false };
if (this.applyZoneComboBtn != null
if ((this.applyZoneComboBtn != null)
&& !this.applyZoneComboBtn.isDisposed()) {
VizApp.runSync(new Runnable() {
@Override

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.viz.hydro.stationprofile;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
@ -65,6 +66,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 15 Jun 2010 4304 mpduff Added some null checks.
* 30 Nov 2011 11253 lbousaidi used List instead of TreeMap
* 29 Mar 2013 1790 rferrel Make dialog non-blocking.
* 23 Oct 2013 15183 wkwock Fix scales and value format
*
* </pre>
*
@ -327,7 +329,7 @@ public class StationProfileDlg extends CaveSWTDialog {
*/
private void calculateValues() {
double totalElevInc = Math.abs(stationProfData.getElevationFtMax())
+ Math.abs(stationProfData.getElevationFtMin());
- Math.abs(stationProfData.getElevationFtMin());
// Calculate the offset between the elevation points
double offsetDbl = totalElevInc / 5;
@ -608,6 +610,7 @@ public class StationProfileDlg extends CaveSWTDialog {
e.gc.setFont(font);
int fontHeight = (e.gc.getFontMetrics().getHeight());
int fontAveWidth = (e.gc.getFontMetrics().getAverageCharWidth());
DecimalFormat df = new DecimalFormat("#.##");
// List of label position objects
ArrayList<LabelPosition> labelList = new ArrayList<LabelPosition>();
@ -633,16 +636,17 @@ public class StationProfileDlg extends CaveSWTDialog {
// ----------------------------------------
// Draw 0 miles hash and label
e.gc.drawLine(PROFILE_CANVAS_WIDTH / 2, BOTTOM_Y_COORD,
/* e.gc.drawLine(PROFILE_CANVAS_WIDTH / 2, BOTTOM_Y_COORD,
PROFILE_CANVAS_WIDTH / 2, BOTTOM_Y_COORD + RIVER_MILES_HASH);
e.gc.drawString("0", PROFILE_CANVAS_WIDTH / 2 - fontAveWidth / 2,
BOTTOM_Y_COORD + RIVER_MILES_HASH + 3, true);
*/
// Draw 50 miles hash and label
int currMile = 50;
double maxMile = getMaxMile(stationList);
int currMile = (int) Math.ceil(getMinMile(stationList) / 50) * 50;
int x;
int y;
while (Double.compare(mileRange, currMile) > 0) {
while (maxMile > currMile) {
x = calcRiverMileXCoord(currMile);
e.gc.drawLine(x, BOTTOM_Y_COORD, x, BOTTOM_Y_COORD
@ -680,7 +684,6 @@ public class StationProfileDlg extends CaveSWTDialog {
if (stationList != null) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm MM/dd");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
int i = 0;
for (Statprof station : stationList) {
// Skip gage if the river mile is not valid
@ -691,7 +694,6 @@ public class StationProfileDlg extends CaveSWTDialog {
e.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
x = calcRiverMileXCoord(station.getId().getMile());
y = calcElevationYCoord(station.getId().getZd());
i++;
// hash mark at each site
e.gc.drawLine(x, y, x, y + POINT_HASH);
@ -743,7 +745,7 @@ public class StationProfileDlg extends CaveSWTDialog {
HydroDataReport rpt = allReports.get(station.getId().getLid());
if (rpt.getValue() != HydroConstants.MISSING_VALUE) {
label.append(rpt.getValue() + " - ");
label.append(df.format(rpt.getValue()) + " - ");
label.append(sdf.format(rpt.getValidTime()) + ")");
} else {
label.append("MSG/MSG)");
@ -946,8 +948,10 @@ public class StationProfileDlg extends CaveSWTDialog {
mileRange = 10;
}
double maxMile = getMaxMile(stationList);
int xCoord = (int) Math.round((ZERO_MILE_XCOORD + 2)
* (mileRange - riverMile) / mileRange);
* (maxMile - riverMile) / mileRange);
return xCoord;
}

View file

@ -74,6 +74,8 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
* removeDuplicateCoordinate(), computeCoordinate(), adjustPolygon() prolog, and
* removeOverlaidLinesegments(); added alterVertexes() and calcShortestDistance().
* 10/01/2013 DR 16632 Qinglu Lin Fixed the bug in for loop range.
* 10/17/2013 DR 16632 Qinglu Lin Updated removeOverlaidLinesegments().
* 10/18/2013 DR 16632 Qinglu Lin Catch exception thrown when coords length is less than 4 and doing createLinearRing(coords).
* </pre>
*
* @author mschenke
@ -1094,16 +1096,23 @@ public class PolygonUtil {
if (polygon == null) {
return null;
}
if (polygon.getNumPoints() <= 4)
return polygon;
Coordinate[] coords = removeDuplicateCoordinate(polygon.getCoordinates());
GeometryFactory gf = new GeometryFactory();
return gf.createPolygon(gf.createLinearRing(coords), null);
GeometryFactory gf = new GeometryFactory();
try {
polygon = gf.createPolygon(gf.createLinearRing(coords), null);
} catch (Exception e) {
;
}
return polygon;
}
public static Coordinate[] removeDuplicateCoordinate(Coordinate[] verts) {
if (verts == null) {
return null;
}
if (verts.length <= 3)
if (verts.length <= 4)
return verts;
Set<Coordinate> coords = new LinkedHashSet<Coordinate>();
@ -1119,7 +1128,10 @@ public class PolygonUtil {
i += 1;
}
vertices[i] = new Coordinate(vertices[0]);
return vertices;
if (vertices.length <=3)
return verts;
else
return vertices;
}
/**
@ -1271,9 +1283,14 @@ public class PolygonUtil {
}
public static Coordinate[] removeOverlaidLinesegments(Coordinate[] coords) {
if (coords.length <= 4)
return coords;
Coordinate[] expandedCoords = null;
boolean flag = true;
while (flag) {
if (coords.length <= 4) {
return coords;
}
expandedCoords = new Coordinate[coords.length+1];
flag = false;
for (int i = 0; i < coords.length; i++) {

View file

@ -150,6 +150,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Aug 15, 2013 DR 16418 D. Friedman Make dialog visibility match editable state.
* Sep 17, 2013 DR 16496 D. Friedman Make editable state more consistent.
* Oct 01, 2013 DR16612 m.gamazaychikov Fixed inconsistencies with track locking and updateListSelected method
* Oct 29, 2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the pollygon the be used.
* </pre>
*
* @author chammack
@ -1073,6 +1074,12 @@ public class WarngenDialog extends CaveSWTDialog implements
redrawFromWarned();
}
// Need to check again because redraw may have failed.
if (warngenLayer.getWarningArea() == null) {
setInstructions();
return;
}
ProgressMonitorDialog pmd = new ProgressMonitorDialog(Display
.getCurrent().getActiveShell());
pmd.setCancelable(false);

View file

@ -189,6 +189,10 @@ import com.vividsolutions.jts.io.WKTReader;
* 07/26/2013 DR 16450 D. Friedman Fix logic errors when frame count is one.
* 08/19/2013 2177 jsanchez Set a GeneralGridGeometry object in the GeospatialDataList.
* 09/17/2013 DR 16496 D. Friedman Make editable state more consistent.
* 10/01/2013 DR 16632 Qinglu Lin Catch exceptions thrown while doing areaPercent computation and union().
* 10/21/2013 DR 16632 D. Friedman Modify areaPercent exception handling. Fix an NPE.
* Use A1 hatching behavior when no county passes the inclusion filter.
* 10/29/2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the pollygon the be used.
* </pre>
*
* @author mschenke
@ -1605,6 +1609,36 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry oldWarningPolygon = latLonToLocal(state.getOldWarningPolygon());
Geometry oldWarningArea = latLonToLocal(state.getOldWarningArea());
Geometry newHatchedArea = null;
Geometry newUnfilteredArea = null;
boolean useFilteredArea = false;
boolean useFallback = getConfiguration().getHatchedAreaSource().isInclusionFallback();
/*
* The resultant warning area is constructed in one of two ways:
*
* 1. When preservedSelection is null:
*
* If at least one county in hatchedArea passes the inclusion filter,
* the result contains only the counties in hatchedArea that pass the
* inclusion filter. Otherwise, all counties in hatchedArea are
* included.
*
* This behavior reflects A1 baseline template logic. The fallback can
* be disabled by setting AreaSourceConfiguration.isInclusionFallback to
* false.
*
* 2. When preservedSelection is not null:
*
* A county is included in the result if and only if it is contained in
* preservedSelection. If the portion of the county in hatchedArea is
* non-empty, it used. Otherwise, the hatched portion from
* preservedSelection is used.
*
*
* In both cases, when there is an old warning area in effect (i.e., for
* followups), the intersection of hatchedArea and the old warning area
* is used instead of hatchedArea.
*/
Set<String> selectedFips = null;
List<Geometry> selectedGeoms = null;
@ -1666,19 +1700,19 @@ public class WarngenLayer extends AbstractStormTrackResource {
try {
boolean include;
if (selectedFips != null)
if (selectedFips != null) {
include = selectedFips.contains(getFips(f));
else
include = filterArea(f, intersection, true)
useFilteredArea = true;
} else {
boolean passed = filterArea(f, intersection, true);
useFilteredArea = useFilteredArea || passed;
include = (passed || filterAreaSecondChance(f, intersection, true))
&& (oldWarningPolygon == null
|| prepGeom.intersects(oldWarningPolygon) || isOldAreaOutsidePolygon(f));
newUnfilteredArea = union(newUnfilteredArea, intersection);
}
if (include) {
if (newHatchedArea == null) {
newHatchedArea = intersection;
} else {
newHatchedArea = GeometryUtil.union(newHatchedArea,
intersection);
}
newHatchedArea = union(newHatchedArea, intersection);
}
} catch (TopologyException e) {
@ -1690,10 +1724,19 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
}
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea :
useFallback ? newUnfilteredArea : null;
return newHatchedArea != null ? newHatchedArea : new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
}
private static Geometry union(Geometry a, Geometry b) {
if (a != null && b != null)
return GeometryUtil.union(a, b);
else
return a != null ? a : b;
}
private void updateWarnedAreaState(Geometry newHatchedArea,
boolean snapToHatchedArea) throws VizException {
try {
@ -1720,10 +1763,17 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
if (oldWarningArea != null) {
int areaPercent = Double.valueOf(
((oldWarningPolygon.intersection(warningPolygon)
.getArea() / oldWarningArea.getArea()) * 100))
.intValue();
int areaPercent = -1;
try {
areaPercent = Double.valueOf(
((oldWarningPolygon.intersection(warningPolygon)
.getArea() / oldWarningArea.getArea()) * 100))
.intValue();
} catch (Exception e) {
statusHandler.handle(Priority.VERBOSE,
"Error determining amount of overlap with original polygon", e);
areaPercent = 100;
}
if (oldWarningPolygon.intersects(warningPolygon) == false
&& !state.isMarked()) {
// Snap back to polygon
@ -1867,9 +1917,6 @@ public class WarngenLayer extends AbstractStormTrackResource {
* the portion of the feature that is hatched
* @param localCoordinates
* if true, use local CRS; otherwise, use lat/lon
* @param anyAmountOfArea
* if true, ignore the configured criteria and include the
* feature if event a small amount is hatched.
* @return true if the feature should be included
*/
private boolean filterArea(GeospatialData feature,
@ -1878,9 +1925,16 @@ public class WarngenLayer extends AbstractStormTrackResource {
.get(GeospatialDataList.LOCAL_GEOM) : feature.geometry;
double areaOfGeom = (Double) feature.attributes.get(AREA);
if (filterCheck(featureAreaToConsider, geom, areaOfGeom))
return true;
else if (state.getOldWarningArea() != null) {
return filterCheck(featureAreaToConsider, geom, areaOfGeom);
}
private boolean filterAreaSecondChance(GeospatialData feature,
Geometry featureAreaToConsider, boolean localCRS) {
Geometry geom = localCRS ? (Geometry) feature.attributes
.get(GeospatialDataList.LOCAL_GEOM) : feature.geometry;
double areaOfGeom = (Double) feature.attributes.get(AREA);
if (state.getOldWarningArea() != null) {
/*
* Second chance: If the county slipped by the filter in the initial
* warning, allow it now as long as the hatched area is (nearly) the
@ -2225,6 +2279,29 @@ public class WarngenLayer extends AbstractStormTrackResource {
issueRefresh();
// End of DR 15559
state.snappedToArea = true;
} else {
/*
* If redraw failed, do not allow this polygon to be used to
* generate a warning.
*
* Note that this duplicates code from updateWarnedAreaState.
*/
state.strings.clear();
state.setWarningArea(null);
state.geometryChanged = true;
if (dialog != null) {
dialog.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
dialog.setInstructions();
}
});
}
state.resetMarked();
state.geometryChanged = true;
issueRefresh();
statusHandler.handle(Priority.PROBLEM,
"Could not redraw box from warned area");
}
System.out.println("Time to createWarningPolygon: "
+ (System.currentTimeMillis() - t0) + "ms");
@ -2719,17 +2796,23 @@ public class WarngenLayer extends AbstractStormTrackResource {
Polygon oldWarningPolygon = state.getOldWarningPolygon();
Polygon warningPolygon = state.getWarningPolygon();
// TODO: Should this even be null when there is no hatching?
Geometry warningArea = state.getWarningArea();
if (warningArea == null) {
warningArea = new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
}
GeometryFactory gf = new GeometryFactory();
Point point = gf.createPoint(coord);
// potentially adding or removing a county, figure out county
for (GeospatialData f : geoData.features) {
Geometry geom = f.geometry;
if (f.prepGeom.contains(point)) {
String[] gids = GeometryUtil.getGID(geom);
if (GeometryUtil.contains(state.getWarningArea(), point)) {
Geometry newWarningArea;
if (GeometryUtil.contains(warningArea, point)) {
// remove county
Geometry tmp = removeCounty(state.getWarningArea(),
getFips(f));
Geometry tmp = removeCounty(warningArea, getFips(f));
if (tmp.isEmpty()) {
String fip = getFips(f);
if (fip != null && uniqueFip != null
@ -2739,58 +2822,46 @@ public class WarngenLayer extends AbstractStormTrackResource {
break;
}
state.setWarningArea(tmp);
newWarningArea = tmp;
} else {
// add county
String featureFips = getFips(f);
Collection<GeospatialData> dataWithFips = getDataWithFips(featureFips);
if (oldWarningArea != null) {
// for a CON, prevents extra areas to be added
Set<String> fipsIds = getAllFipsInArea(oldWarningArea);
if (fipsIds.contains(featureFips) == false) {
if (fipsIds.contains(featureFips) == false ||
! (oldWarningPolygon.contains(point) == true
|| isOldAreaOutsidePolygon(f))) {
break;
} else if (oldWarningPolygon.contains(point) == true
|| isOldAreaOutsidePolygon(f)) {
// Get intersecting parts for each geom with
// matching fips
List<Geometry> fipsParts = new ArrayList<Geometry>(
dataWithFips.size());
for (GeospatialData g : dataWithFips) {
fipsParts.add(GeometryUtil.intersection(
oldWarningArea, g.geometry));
}
// Create a collection of each part
geom = GeometryUtil.union(fipsParts
.toArray(new Geometry[0]));
if (warningPolygon.contains(point)) {
// If inside warning polygon, intersect
geom = GeometryUtil.intersection(
warningPolygon, geom);
}
if (filterArea(f, geom, false)) {
state.setWarningArea(GeometryUtil.union(
state.getWarningArea(), geom));
}
}
} else {
// add county
if (warningPolygon.contains(point)) {
// add part of county
List<Geometry> parts = new ArrayList<Geometry>(
dataWithFips.size() + 1);
for (GeospatialData data : dataWithFips) {
parts.add(GeometryUtil.intersection(
warningPolygon, data.geometry));
}
geom = geom.getFactory()
.createGeometryCollection(
parts.toArray(new Geometry[0]));
if (!filterArea(f, geom, false))
continue;
}
state.setWarningArea(GeometryUtil.union(
state.getWarningArea(), geom));
}
// Get intersecting parts for each geom with
// matching fips
List<Geometry> fipsParts = new ArrayList<Geometry>(
dataWithFips.size());
for (GeospatialData gd : dataWithFips) {
Geometry g = gd.geometry;
if (oldWarningArea != null) {
g = GeometryUtil.intersection(oldWarningArea, g);
}
fipsParts.add(g);
}
// Create a collection of each part
geom = GeometryUtil.union(fipsParts
.toArray(new Geometry[fipsParts.size()]));
if (warningPolygon.contains(point)) {
// If inside warning polygon, intersect
geom = GeometryUtil.intersection(
warningPolygon, geom);
}
newWarningArea = GeometryUtil.union(
removeCounty(warningArea, featureFips),
geom);
}
state.setWarningArea(filterWarningArea(newWarningArea));
setUniqueFip();
warningAreaChanged();
populateStrings();
issueRefresh();
@ -2803,6 +2874,36 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
}
private Geometry filterWarningArea(Geometry warningArea) {
// TODO: Duplicates logic in createWarnedArea
if (warningArea == null)
return null;
/*
* Note: Currently does not determine if warningArea is valid (i.e., in
* contained in CWA, old warning area, etc.) or has overlapping geometries.
*/
Geometry newHatchedArea = null;
Geometry newUnfilteredArea = null;
boolean useFilteredArea = false;
boolean useFallback = getConfiguration().getHatchedAreaSource().isInclusionFallback();
for (GeospatialData f : geoData.features) {
String gid = GeometryUtil.getPrefix(f.geometry.getUserData());
Geometry warningAreaForFeature = getWarningAreaForGids(Arrays.asList(gid), warningArea);
boolean passed = filterArea(f, warningAreaForFeature, false);
useFilteredArea = useFilteredArea || passed;
if (passed || filterAreaSecondChance(f, warningAreaForFeature, false))
newHatchedArea = union(newHatchedArea, warningAreaForFeature);
newUnfilteredArea = union(newUnfilteredArea, warningAreaForFeature);
}
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea :
useFallback ? newUnfilteredArea : null;
return newHatchedArea != null ? newHatchedArea : new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
}
private String getFips(GeospatialData data) {
return geoAccessor.getFips(data);
}
@ -3124,6 +3225,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
public void setUniqueFip() {
Geometry g = state.getWarningArea();
uniqueFip = null;
if (g != null) {
if (getAllFipsInArea(g).size() == 1) {
Set<String> fips = getAllFipsInArea(g);

View file

@ -89,6 +89,7 @@ import com.raytheon.uf.edex.site.notify.SendSiteActivationNotifications;
* Mar 20, 2013 #1774 randerso Changed to use GFED2DDao
* May 02, 2013 #1969 randerso Moved updateDbs method into IFPGridDatabase
* Sep 13, 2013 2368 rjpeter Used durable jms settings.
* Oct 16, 2013 #2475 dgilling Better error handling for IRT activation.
* </pre>
*
* @author njensen
@ -370,6 +371,7 @@ public class GFESiteActivation implements ISiteActivationListener {
// Doesn't need to be cluster locked
statusHandler.handle(Priority.EVENTA, "Checking ISC configuration...");
boolean isIscActivated = false;
if (config.requestISC()) {
String host = InetAddress.getLocalHost().getCanonicalHostName();
String gfeHost = config.getServerHost();
@ -382,7 +384,15 @@ public class GFESiteActivation implements ISiteActivationListener {
if (host.contains(hostNameToCompare)
&& System.getProperty("edex.run.mode").equals("request")) {
statusHandler.handle(Priority.EVENTA, "Enabling ISC...");
IRTManager.getInstance().enableISC(siteID, config.getMhsid());
try {
IRTManager.getInstance().enableISC(siteID,
config.getMhsid());
isIscActivated = true;
} catch (Exception e) {
statusHandler
.error("Error starting GFE ISC. ISC functionality will be unavailable!!",
e);
}
} else {
statusHandler.handle(Priority.EVENTA,
"ISC Enabled but will use another EDEX instance");
@ -491,7 +501,7 @@ public class GFESiteActivation implements ISiteActivationListener {
};
postActivationTaskExecutor.submit(smartInit);
if (config.tableFetchTime() > 0) {
if (config.tableFetchTime() > 0 && isIscActivated) {
Runnable activateFetchAT = new Runnable() {
@Override

View file

@ -33,10 +33,10 @@ import jep.JepException;
import com.raytheon.edex.plugin.gfe.config.GridDbConfig;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
import com.raytheon.edex.plugin.gfe.server.GridParmManager;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
@ -47,6 +47,7 @@ import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.FileUtil;
/**
@ -60,6 +61,8 @@ import com.raytheon.uf.common.util.FileUtil;
* ------------ ---------- ----------- --------------------------
* 07/14/09 1995 bphillip Initial creation
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
* Oct 16, 2013 2475 dgilling Move logic previously in IrtServer.py
* into this class to avoid Jep memory leak.
*
* </pre>
*
@ -72,14 +75,29 @@ public class GfeIRT extends Thread {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GfeIRT.class);
private static final String PYTHON_INSTANCE = "irt";
/** The site ID associated with this IRT thread */
private final String siteID;
/** The MHS ID associated with this IRT thread */
private final String mhsID;
/** The script file name */
private final String scriptFile;
private final String serverHost;
private final long serverPort;
private final long serverProtocol;
private List<String> parmsWanted;
private final List<Integer> gridDims;
private final String gridProj;
private final List<Double> gridBoundBox;
private List<String> iscWfosWanted;
/** The Python script object */
private PythonScript script;
@ -94,20 +112,83 @@ public class GfeIRT extends Thread {
*
* @param siteID
* The site ID to create the GfeIRT object for
* @throws GfeException
* @throws GfeConfigurationException
* If the GFE configuration for the specified site could not be
* loaded.
*/
public GfeIRT(String mhsid, String siteid) throws GfeException {
public GfeIRT(String mhsid, String siteid) throws GfeConfigurationException {
this.setDaemon(true);
this.siteID = siteid;
this.mhsID = mhsid;
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE);
scriptFile = pathMgr
.getLocalizationFile(cx,
"gfe/isc" + File.separator + "IrtServer.py").getFile()
.getPath();
IFPServerConfig config = IFPServerConfigManager.getServerConfig(siteID);
this.serverHost = config.getServerHost();
this.serverPort = config.getRpcPort();
this.serverProtocol = config.getProtocolVersion();
GridLocation domain = config.dbDomain();
this.gridProj = domain.getProjection().getProjectionID().toString();
this.gridDims = new ArrayList<Integer>(2);
this.gridDims.add(domain.getNy());
this.gridDims.add(domain.getNx());
this.gridBoundBox = new ArrayList<Double>(4);
this.gridBoundBox.add(domain.getOrigin().x);
this.gridBoundBox.add(domain.getOrigin().y);
this.gridBoundBox.add(domain.getExtent().x);
this.gridBoundBox.add(domain.getExtent().y);
this.parmsWanted = config.requestedISCparms();
if (this.parmsWanted.isEmpty()) {
List<DatabaseID> dbs = GridParmManager.getDbInventory(this.siteID)
.getPayload();
for (DatabaseID dbId : dbs) {
if ((dbId.getModelName().equals("ISC"))
&& (dbId.getDbType().equals(""))
&& (dbId.getSiteId().equals(this.siteID))) {
GridDbConfig gdc = config.gridDbConfig(dbId);
this.parmsWanted = gdc.parmAndLevelList();
}
}
config.setRequestedISCparms(this.parmsWanted);
}
statusHandler.info("ParmsWanted: " + this.parmsWanted);
this.iscWfosWanted = config.requestedISCsites();
if (this.iscWfosWanted.isEmpty()) {
List<String> knownSites = config.allSites();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext commonStaticConfig = pathMgr.getContext(
LocalizationType.COMMON_STATIC,
LocalizationLevel.CONFIGURED);
commonStaticConfig.setContextName(this.siteID);
File editAreaDir = pathMgr.getFile(commonStaticConfig,
"gfe/editAreas");
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.trim().matches("ISC_\\p{Alnum}{3}\\.xml");
}
};
List<File> editAreas = FileUtil.listFiles(editAreaDir, filter,
false);
this.iscWfosWanted = new ArrayList<String>();
for (File f : editAreas) {
String name = f.getName().replace("ISC_", "")
.replace(".xml", "");
if (knownSites.contains(name)) {
iscWfosWanted.add(name);
}
}
config.setRequestedISCsites(this.iscWfosWanted);
}
Thread hook = new Thread() {
@Override
public void run() {
@ -123,111 +204,97 @@ public class GfeIRT extends Thread {
@Override
public void run() {
try {
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE);
String scriptPath = pathMgr
.getLocalizationFile(cx, "gfe/isc/IrtAccess.py").getFile()
.getPath();
String includePath = PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCommonPythonIncludePath(),
GfePyIncludeUtil.getIscScriptsIncludePath(),
GfePyIncludeUtil.getGfeConfigIncludePath(siteID));
script = new PythonScript(scriptFile, includePath);
Map<String, Object> args = new HashMap<String, Object>();
GfePyIncludeUtil.getGfeConfigIncludePath(this.siteID));
this.script = new PythonScript(scriptPath, includePath, getClass()
.getClassLoader());
IFPServerConfig config = IFPServerConfigManager
.getServerConfig(siteID);
GridLocation domain = config.dbDomain();
String site = config.getSiteID().get(0);
List<Integer> gridDims = new ArrayList<Integer>();
gridDims.add(domain.getNy());
gridDims.add(domain.getNx());
List<Double> gridBoundBox = new ArrayList<Double>();
gridBoundBox.add(domain.getOrigin().x);
gridBoundBox.add(domain.getOrigin().y);
gridBoundBox.add(domain.getExtent().x);
gridBoundBox.add(domain.getExtent().y);
// determine which parms are wanted
List<String> parmsWanted = config.requestedISCparms();
if (parmsWanted.isEmpty()) {
List<DatabaseID> dbs = GridParmManager.getDbInventory(site)
.getPayload();
for (int i = 0; i < dbs.size(); i++) {
if (dbs.get(i).getModelName().equals("ISC")
&& dbs.get(i).getDbType().equals("")
&& dbs.get(i).getSiteId().equals(site)) {
GridDbConfig gdc = config.gridDbConfig(dbs.get(i));
parmsWanted = gdc.parmAndLevelList();
}
}
}
statusHandler.info("ParmsWanted: " + parmsWanted);
// reset them to actual values
config.setRequestedISCparms(parmsWanted);
// determine isc areas that are wanted
List<String> iscWfosWanted = config.requestedISCsites();
if (iscWfosWanted.isEmpty()) {
List<String> knownSites = config.allSites();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext commonStaticConfig = pathMgr.getContext(
LocalizationType.COMMON_STATIC,
LocalizationLevel.CONFIGURED);
commonStaticConfig.setContextName(site);
File editAreaDir = pathMgr.getFile(commonStaticConfig,
"gfe/editAreas");
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.trim().matches("ISC_\\p{Alnum}{3}\\.xml");
}
};
List<File> editAreas = FileUtil.listFiles(editAreaDir,
filter, false);
String name = "";
for (File f : editAreas) {
name = f.getName().replace("ISC_", "").replace(".xml", "");
if (knownSites.contains(name)) {
iscWfosWanted.add(name);
}
}
config.setRequestedISCsites(iscWfosWanted);
}
args.put("ancfURL", config.iscRoutingTableAddress().get("ANCF"));
args.put("bncfURL", config.iscRoutingTableAddress().get("BNCF"));
args.put("mhsid", config.getMhsid());
args.put("serverHost", config.getServerHost());
args.put("serverPort", config.getRpcPort());
args.put("serverProtocol", config.getProtocolVersion());
args.put("site", site);
args.put("parmsWanted", config.requestedISCparms());
args.put("gridDims", gridDims);
args.put("gridProj", domain.getProjection().getProjectionID()
.toString());
args.put("gridBoundBox", gridBoundBox);
args.put("iscWfosWanted", iscWfosWanted);
boolean regSuccess = (Boolean) script.execute("irtReg", args);
if (!regSuccess) {
statusHandler
.error("Error registering site with IRT server. ISC functionality will be unavailable. Check config and IRT connectivity.");
removeShutdownHook(this.mhsID, this.siteID);
}
Map<String, Object> initArgs = new HashMap<String, Object>(2, 1f);
initArgs.put("ancfURL", config.iscRoutingTableAddress().get("ANCF"));
initArgs.put("bncfURL", config.iscRoutingTableAddress().get("BNCF"));
this.script.instantiatePythonClass(PYTHON_INSTANCE, "IrtAccess",
initArgs);
} catch (GfeConfigurationException e) {
throw new RuntimeException("Could not load GFE configuration", e);
} catch (JepException e) {
statusHandler
.fatal("Error starting GFE ISC. ISC functionality will be unavailable!!",
e);
} catch (GfeException e) {
statusHandler
.fatal("Unable to get Mhs ID. ISC functionality will be unavailable!!",
e);
throw new RuntimeException(
"Could not instantiate IRT python script instance", e);
}
try {
// upon any overall failure, start thread over
while (IRTManager.getInstance().isRegistered(mhsID, siteID)) {
try {
// do initial registration, keep trying until successful
while (IRTManager.getInstance().isRegistered(mhsID, siteID)) {
statusHandler
.info("performing initial IRT registration.");
Map<String, Object> args = new HashMap<String, Object>(
10, 1f);
args.put("mhsid", mhsID);
args.put("serverHost", serverHost);
args.put("serverPort", serverPort);
args.put("serverProtocol", serverProtocol);
args.put("site", siteID);
args.put("parmsWanted", parmsWanted);
args.put("gridDims", gridDims);
args.put("gridProj", gridProj);
args.put("gridBoundBox", gridBoundBox);
args.put("iscWfosWanted", iscWfosWanted);
Boolean okay = (Boolean) script.execute("register",
PYTHON_INSTANCE, args);
if (okay) {
break;
} else if (!IRTManager.getInstance().isRegistered(
mhsID, siteID)) {
break; // exit processing loop
} else {
sleep(3 * TimeUtil.MILLIS_PER_SECOND);
}
}
// if we are here, we had a successful registration, check
// for re-register every few seconds, check the StopIRT flag
// every few seconds
statusHandler.info("initial IRT registration complete.");
while (IRTManager.getInstance().isRegistered(mhsID, siteID)) {
sleep(3 * TimeUtil.MILLIS_PER_SECOND); // wait 3 seconds
Boolean status1 = (Boolean) script.execute(
"checkForReregister", PYTHON_INSTANCE, null);
if (!status1) {
statusHandler.error("FAIL on checkForRegister().");
break; // break out of rereg loop, to cause another
// reg
}
}
} catch (Throwable t) {
statusHandler.error("Exception in IRT register thread.", t);
}
}
// if we get here, we have been told to stop IRT, so we unregister.
// We try only once.
statusHandler.info("FINAL IRT unregister.");
try {
script.execute("unregister", PYTHON_INSTANCE, null);
} catch (JepException e) {
statusHandler.error("Exception unregister IRT.", e);
}
statusHandler.info("FINAL -- exiting IRT registration thread.");
} finally {
if (script != null) {
script.dispose();

View file

@ -105,6 +105,9 @@ import com.raytheon.uf.edex.database.purge.PurgeLogger;
* Changed to call D2DGridDatabase.getDatabase instead of calling
* the constructor directly to ensure the data exists before creating
* the D2DGridDatabase object
* 10/02/13 #2444 randerso Fix error handling when creating IFPGridDatabases.
* DO NOT ATTEMPT TO MERGE THIS CHANGE INTO 14.2 as the GFE
* server code has been significantly refactored.
*
* </pre>
*
@ -1262,9 +1265,15 @@ public class GridParmManager {
db = TopoDatabaseManager.getTopoDatabase(dbId.getSiteId());
} else {
db = new IFPGridDatabase(dbId);
if (db.databaseIsValid()) {
((IFPGridDatabase) db).updateDbs();
try {
db = new IFPGridDatabase(dbId);
if (db.databaseIsValid()) {
((IFPGridDatabase) db).updateDbs();
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error creating IFPGridDatbase for " + dbId, e);
db = null;
}
}
}

View file

@ -44,12 +44,11 @@ from com.raytheon.edex.plugin.gfe.isc import IRTManager
# to interact better with IscScript.
# 05/22/13 1759 dgilling Add missing import to
# makeISCrequest().
# 10/16/13 2475 dgilling Remove unneeded code to handle
# registration with IRT.
#
#
#
# starts the IRT thread and registers.
StopIRT = 0 #flag to shut down the 2nd thread
IRTthread = None #flag to hold the IRTthread object
def logEvent(*msg):
iscUtil.getLogger("irtServer").info(iscUtil.tupleToString(*msg))
@ -188,51 +187,6 @@ def putVTECActiveTable(strTable, xmlPacket):
except:
logProblem("Error executing ingestAT: ", traceback.format_exc())
logEvent("ingesAT command output: ", output)
def initIRT(ancfURL, bncfURL, mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted):
global IRTthread
import threading
IRTthread = threading.Thread(target=irtReg, args=[ancfURL, bncfURL, mhsid,
serverHost, serverPort, serverProtocol, site, parmsWanted, gridDims,
gridProj, gridBoundBox, iscWfosWanted])
IRTthread.setDaemon(True)
IRTthread.start()
# IRT registration thread
def irtReg(ancfURL, bncfURL, mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted):
import IrtAccess, threading
irt = IrtAccess.IrtAccess(ancfURL, bncfURL)
# do initial registration, keep trying until successful
while True:
okay = irt.register(mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted)
if okay:
break
elif StopIRT:
return False#stop this thread
else:
return False
# if we are here, we had a successful registration, check for re-register
# every few seconds, check the StopIRT flag every few seconds
while IRTManager.getInstance().isRegistered(mhsid,site) == True:
time.sleep(3.0) #wait 3 seconds
irt.checkForReregister()
# if we get here, we have been told to stop IRT, so we unregister. We
# try only once.
irt.unregister()
return True
# call from C++ to Python to tell IRT thread to shut itself down
def irtStop():
global StopIRT
StopIRT = True #tells irt thread to exit
if IRTthread:
IRTthread.join() #wait till thread returns then return to caller
# get servers direct call for IRT
def irtGetServers(ancfURL, bncfURL, iscWfosWanted):

View file

@ -4,7 +4,7 @@
<!-- Post Processor definitions for models containing grids needing to be
stitched together -->
<postProcessedModel>
<modelName>UKMET[0-9]{2}|ECMF[0-9]{2}|ENSEMBLE[0-9]{2}|AVN[0-9]{2}
<modelName>UKMET[0-9]{2}|ECMF[0-9]|ENSEMBLE[0-9]{2}|AVN[0-9]{2}
</modelName>
<processorName>EnsembleGridAssembler</processorName>
</postProcessedModel>

View file

@ -67,6 +67,8 @@ import com.raytheon.uf.common.time.DataTime;
* ate Ticket# Engineer Description
* ----------- ---------- ----------- --------------------------
* 9/30/09 vkorolev Initial creation
* 10/16/13 DR 16685 M.Porricelli Add error checking for date
* format
* </pre>
*
* @author vkorolev
@ -74,6 +76,8 @@ import com.raytheon.uf.common.time.DataTime;
*/
public class HydroDecoder<E> extends AbstractDecoder implements IBinaryDecoder {
private static final String BAD_PROPERTY_FMT = "NumberFormatException setting property %s.%s(%s %s)";
private final String PLUGIN_NAME;
@ -201,11 +205,13 @@ public class HydroDecoder<E> extends AbstractDecoder implements IBinaryDecoder {
}
// DataTime = Observation time
Calendar ot = record.getObservationTime();
DataTime dt = new DataTime(ot);
record.setDataTime(dt);
record.setLocation(location);
record.constructDataURI();
retVal.add(record);
if (ot != null){
DataTime dt = new DataTime(ot);
record.setDataTime(dt);
record.setLocation(location);
record.constructDataURI();
retVal.add(record);
}
// logger.info("-------------------------------------------------------");
}
@ -256,14 +262,29 @@ public class HydroDecoder<E> extends AbstractDecoder implements IBinaryDecoder {
if (clazz == String.class) {
val = value.trim();
} else if (clazz == Calendar.class) {
Date ot = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(ot);
val = cal;
Date ot = null;
try {
ot = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.setTime(ot);
val = cal;
} catch(Exception e) {
logger.error("Could not parse date field [" + name + ":" + value + "]");
return;
}
// only numbers
} else {
Double tval = Double.parseDouble(value);
} else {
Double tval = null;
try {
tval = Double.parseDouble(value);
} catch (NumberFormatException nfe) {
String msg = String.format(BAD_PROPERTY_FMT,
cls.getSimpleName(), fld.getName(),
clazz.getSimpleName(), value);
logger.error(msg);
return;
}
if (configFile.containsKey(vunit)) {
Unit<?> inUnit = (Unit<?>) UnitFormat.getUCUMInstance()
.parseObject(configFile.getProperty(vunit));

View file

@ -59,6 +59,9 @@ public class RadarDecompressor {
private static final int Z_DEFLATED = 8;
private static final int DEF_WBITS = 15;
//max buffer for decompressed radar data, DPR is 1346648
private static final int MAXBUF = 2000000;
/** The logger */
private static final transient IUFStatusHandler theHandler = UFStatus
@ -285,21 +288,34 @@ public class RadarDecompressor {
ByteArrayInputStream is = new ByteArrayInputStream(tmpBuf);
BZip2InputStream bis= new BZip2InputStream(is,false);
try {
//use 10x85716 should be safe
byte[] tmpBuf2= new byte[860000];
byte[] tmpBuf2= new byte[MAXBUF];
int actualByte=bis.read(tmpBuf2);
byte[] bigBuf = new byte[0];
int currentSize = 0 ;
//The decompressed size in header don't seems always correct
// and bis.available()
while (actualByte != -1) {
byte[] tmpBuf3 = new byte[bigBuf.length];
System.arraycopy(bigBuf, 0, tmpBuf3, 0, bigBuf.length);
bigBuf = new byte[currentSize+actualByte] ;
System.arraycopy(tmpBuf3, 0, bigBuf, 0, tmpBuf3.length);
System.arraycopy(tmpBuf2, 0, bigBuf, currentSize, actualByte);
currentSize = bigBuf.length;
actualByte=bis.read(tmpBuf2);
}
bis.close();
outBuf = new byte[actualByte+120];
outBuf = new byte[bigBuf.length+120];
//the 120 bytes:description block and symbology block
System.arraycopy(inBuf, offset, outBuf, 0, 8);
byte[] lengthMsg2=ByteBuffer.allocate(4).putInt(outBuf.length).array();
System.arraycopy(lengthMsg2, 0, outBuf, 8, 4);
System.arraycopy(inBuf, offset+8+4, outBuf, 12, 108);
System.arraycopy(tmpBuf2, 0, outBuf, 120, actualByte);
System.arraycopy(bigBuf, 0, outBuf, 120, bigBuf.length);
} catch (Exception e) {
theHandler.handle(Priority.ERROR,
"Failed to decompress " + headers.get("ingestfilename"));
return null;
}
}
return outBuf;

View file

@ -399,4 +399,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -23,6 +23,7 @@ import com.raytheon.uf.common.dataquery.requests.RequestableMetadataMarshaller;
* ------------ ---------- ----------- --------------------------
* Mar 29, 2012 #14691 Qinglu Lin Added feAreaField and its getter and setter, etc.
* Apr 24, 2014 1943 jsanchez Removed unused areaType.
* Oct 23, 2013 DR 16632 D. Friedman Added inclusionFallback field.
*
* </pre>
*
@ -89,6 +90,9 @@ public class AreaSourceConfiguration {
@XmlElement
private double includedWatchAreaBuffer;
@XmlElement
private boolean inclusionFallback = true;
public AreaSourceConfiguration() {
}
@ -271,4 +275,12 @@ public class AreaSourceConfiguration {
this.type = type;
}
public boolean isInclusionFallback() {
return inclusionFallback;
}
public void setInclusionFallback(boolean inclusionFallback) {
this.inclusionFallback = inclusionFallback;
}
}

View file

@ -26,7 +26,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometry;
* ------------ ---------- ----------- --------------------------
* Nov 15, 2010 mschenke Initial creation
* Apr 28, 2013 1955 jsanchez Added an ignoreUserData flag to intersection method.
* Oct 01, 2013 DR 16632 Qinglu Lin Catch exceptions thrown by intersection().
* Oct 21, 2013 DR 16632 D. Friedman Handle zero-length input in union.
*
* </pre>
*
@ -121,13 +121,8 @@ public class GeometryUtil {
if (g1Name == null || g2Name == null || g2Name.equals(g1Name)
|| ignoreUserData) {
Geometry section = null;
try {
section = g1.intersection(g2);
} catch (Exception e) {
; //continue;
}
if (section != null && section.isEmpty() == false) {
Geometry section = g1.intersection(g2);
if (section.isEmpty() == false) {
if (g2.getUserData() != null) {
if (section instanceof GeometryCollection) {
for (int n = 0; n < section.getNumGeometries(); ++n) {
@ -210,7 +205,7 @@ public class GeometryUtil {
*/
public static Geometry union(Geometry... geoms) {
List<Geometry> geometries = new ArrayList<Geometry>(
geoms[0].getNumGeometries() + 1);
geoms.length > 0 ? geoms[0].getNumGeometries() + 1 : 0);
for (Geometry g : geoms) {
buildGeometryList(geometries, g);
}

View file

@ -54,6 +54,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Apr 29, 2011 DR#8986 zhao Read in Counties instead of Forecast Zones
* Feb 21 2012 14413 zhao add code handling "adjacent areas"
* Nov 20 2012 1297 skorolev Cleaned code
* Oct 17 2013 16682 zhao fixed a bug in readConfigXml()
*
* </pre>
*
@ -136,7 +137,7 @@ public abstract class MonitorConfigurationManager {
configXml = configXmltmp;
} catch (Exception e) {
statusHandler.handle(Priority.ERROR,
"No mopnitor area configuration file found", e);
"No monitor area configuration file found", e);
monitorAreaFileExists = false;
}
@ -173,14 +174,14 @@ public abstract class MonitorConfigurationManager {
}
List<String> marineZones = MonitorAreaUtils
.getMarineZones(currentSite);
if (zones.isEmpty()) {
if (!zones.isEmpty()) {
for (String zone : zones) {
AreaIdXML zoneXml = new AreaIdXML();
zoneXml.setAreaId(zone);
zoneXml.setType(ZoneType.REGULAR);
List<StationIdXML> stations = MonitorAreaUtils
.getZoneReportingStationXMLs(zone);
if (stations.isEmpty()) {
if (!stations.isEmpty()) {
for (StationIdXML station : stations) {
zoneXml.addStationIdXml(station);
}
@ -189,14 +190,14 @@ public abstract class MonitorConfigurationManager {
}
}
// add marine zones if any exist
if (marineZones.isEmpty()) {
if (!marineZones.isEmpty()) {
for (String zone : marineZones) {
AreaIdXML zoneXml = new AreaIdXML();
zoneXml.setAreaId(zone);
zoneXml.setType(ZoneType.MARITIME);
List<StationIdXML> stations = MonitorAreaUtils
.getZoneReportingStationXMLs(zone);
if (stations.isEmpty()) {
if (!stations.isEmpty()) {
for (StationIdXML station : stations) {
zoneXml.addStationIdXml(station);
}
@ -211,14 +212,14 @@ public abstract class MonitorConfigurationManager {
if (!adjacentAreaFileExists) {
AdjacentWfoMgr adjMgr = new AdjacentWfoMgr(currentSite);
List<String> zones = adjMgr.getAdjZones();
if (zones.isEmpty()) {
if (!zones.isEmpty()) {
for (String zone : zones) {
AreaIdXML zoneXml = new AreaIdXML();
zoneXml.setAreaId(zone);
zoneXml.setType(ZoneType.REGULAR);
List<StationIdXML> stations = MonitorAreaUtils
.getZoneReportingStationXMLs(zone);
if (stations.isEmpty()) {
if (!stations.isEmpty()) {
for (StationIdXML station : stations) {
zoneXml.addStationIdXml(station);
}

View file

@ -8,7 +8,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="1.0.0",
org.apache.commons.beanutils;bundle-version="1.8.3",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
org.apache.commons.lang;bundle-version="2.3.0"
org.apache.commons.lang;bundle-version="2.3.0",
org.apache.commons.io;bundle-version="2.4.0"
Export-Package: com.raytheon.uf.common.util,
com.raytheon.uf.common.util.algorithm,
com.raytheon.uf.common.util.cache,

View file

@ -30,13 +30,14 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.apache.commons.io.IOUtils;
/**
* Contains common file utilities. Methods are generally static to use without a
* class instance. Methods in class should not log directly; rather they should
@ -54,11 +55,13 @@ import java.util.zip.GZIPOutputStream;
* Jun 28, 2012 0819 djohnson Add write method.
* Jul 06, 2012 798 jkorman Added more robust {@link #copyFile}. Added methods
* to create temporary directories and files.
* 02/15/2013 #1597 randerso Fixed error when copying empty files
* Feb 15, 2013 1597 randerso Fixed error when copying empty files
* Feb 15, 2013 1638 mschenke Moved EOL field from edex.common Util
* Mar 11, 2013 1645 djohnson Added file modification watcher.
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
* May 16, 2013 1966 rferrel Add sizeOfDirectory and listDirFiles method.
* Oct 9, 2013 2467 randerso Change coypFile to use apache instead of FileChannel
* to improve memory utilization
*
* </pre>
*
@ -74,6 +77,9 @@ public class FileUtil {
private static final Pattern VALID_FILENAME = Pattern
.compile("^[A-Za-z0-9._\\- ]+$");
/**
* regex to match both Linux and Windows file separators
*/
public final static String fileSeparatorRegex = "[/\\\\]";
/**
@ -134,7 +140,7 @@ public class FileUtil {
File entry = entries[i];
// If there is no filter or the filter accepts the
// file / directory, add it to the list
if (filter == null || filter.accept(directory, entry.getName())) {
if ((filter == null) || filter.accept(directory, entry.getName())) {
files.add(entry);
}
@ -152,9 +158,12 @@ public class FileUtil {
* List files/directories that match a FileFilter.
*
* @param directory
* source directory
* @param filter
* file filter
* @param recurse
* @return
* true to recursively walk the directory tree
* @return list of files in directory matching filter
*/
public static List<File> listDirFiles(File directory, FileFilter filter,
boolean recurse) {
@ -171,7 +180,7 @@ public class FileUtil {
// Go over entries
for (File entry : entries) {
files.add(entry);
if (recurse && filter != null && entry.isDirectory()) {
if (recurse && (filter != null) && entry.isDirectory()) {
files.addAll(listDirFiles(entry, filter, recurse));
}
}
@ -241,19 +250,7 @@ public class FileUtil {
file));
}
} else {
InputStream in = new FileInputStream(source);
OutputStream out = new FileOutputStream(destination);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
copyFile(source, destination);
}
}
@ -361,24 +358,13 @@ public class FileUtil {
}
/**
* Copy a file to a another file.
* Read the contents of a file into a string
*
* @param fileToCopy
* The source file. This file reference must exist.
* @param outputFile
* The destination file. This file may exist, if so it will be
* overwritten.
* @param file
* file to be read
* @return string containing the file contents
* @throws IOException
* An error occurred while copying the data.
* @throws NullPointerException
* Either the source or target file references are null.
*/
public static void copyFile(File fileToCopy, File outputFile)
throws IOException {
// Copy the entire file.
copyFile(fileToCopy, outputFile, 0);
}
public static String file2String(File file) throws IOException {
return new String(file2bytes(file));
}
@ -415,8 +401,9 @@ public class FileUtil {
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
while ((offset < bytes.length)
&& ((numRead = is
.read(bytes, offset, bytes.length - offset)) >= 0)) {
offset += numRead;
}
@ -500,9 +487,9 @@ public class FileUtil {
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length
- offset)) >= 0) {
while ((offset < bytes.length)
&& ((numRead = is.read(bytes, offset, bytes.length
- offset)) >= 0)) {
offset += numRead;
}
@ -546,6 +533,8 @@ public class FileUtil {
* The data to store
* @param outFile
* The file to write this data
* @param compress
* if true file will be compressed using gzip
* @throws IOException
*/
public static void bytes2File(byte[] outBytes, File outFile,
@ -564,7 +553,7 @@ public class FileUtil {
// only write out buffer at a time
for (int counter = 0; counter < outBytes.length; counter += buffer) {
if ((outBytes.length - counter) - buffer >= 0) {
if (((outBytes.length - counter) - buffer) >= 0) {
out.write(outBytes, counter, buffer);
} else {
out.write(outBytes, counter, (outBytes.length - counter));
@ -627,7 +616,7 @@ public class FileUtil {
String replacement = (File.separatorChar == '\\') ? "\\\\"
: File.separator;
if (aPath != null && aPath.length() > 0) {
if ((aPath != null) && (aPath.length() > 0)) {
return aPath.replaceAll(fileSeparatorRegex, replacement);
} else {
return aPath;
@ -643,9 +632,9 @@ public class FileUtil {
*/
public static String edexPath(String aPath) {
if (aPath != null && aPath.length() > 0) {
if ((aPath != null) && (aPath.length() > 0)) {
// Remove drive letter
if (aPath.length() > 1 && aPath.charAt(1) == ':') {
if ((aPath.length() > 1) && (aPath.charAt(1) == ':')) {
aPath = aPath.substring(2);
}
return aPath.replace("\\", "/");
@ -683,92 +672,68 @@ public class FileUtil {
}
/**
* Copy a file from one location to another. The file copy may begin at some
* specified position within the source file.
* Copy a file to another file.
*
* @param source
* The source file. This file reference must exist.
* @param target
* @param destination
* The destination file. This file may exist, if so it will be
* overwritten.
* @param position
* The start position within the source file where the copy
* operation will begin. The position must be greater than or
* equal to zero, and less than the file length of the source.
* @return Was the required data copied to the target file.
* @throws IOException
* An error occurred while copying the data.
* @throws IllegalArgumentException
* The position is less than zero or greater than the length of
* the source file or either of the source, target files are
* null.
* Either the source or target file references are null.
*/
public static boolean copyFile(File source, File target, int position)
public static void copyFile(File source, File destination)
throws IOException {
boolean status = false;
if (source != null) {
if (target != null) {
if ((position >= 0) && (position <= source.length())) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(source);
FileChannel fci = fis.getChannel();
fos = new FileOutputStream(target);
FileChannel fco = fos.getChannel();
long count = source.length() - position;
long transfered = fci.transferTo(position, count, fco);
// ensure we copied all of the data.
status = (transfered == count);
} finally {
String cause = null;
try {
close(fis);
} catch (IOException e) {
cause = String.format(
"copyFile.source.close[%s][%s]", e
.getClass().getName(), e
.getMessage());
}
try {
close(fos);
} catch (IOException e) {
if (cause == null) {
cause = String.format(
"copyFile.target.close[%s][%s]", e
.getClass().getName(), e
.getMessage());
} else {
cause = String.format(
"%s copyFile.target.close[%s][%s]",
cause, e.getClass().getName(),
e.getMessage());
}
}
// One or more closes failed. Construct and throw an
// exception.
if (cause != null) {
throw new IOException(cause);
}
}
} else {
String msg = String.format(
"position [%d] is out of range. Max is [%d]",
position, source.length());
throw new IllegalArgumentException(msg);
}
} else {
throw new IllegalArgumentException(
"target file reference is null");
}
} else {
if (source == null) {
throw new IllegalArgumentException("source file reference is null");
}
return status;
if (destination == null) {
throw new IllegalArgumentException("target file reference is null");
}
FileInputStream fis = null;
FileOutputStream fos = null;
IOException exception = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(destination);
IOUtils.copyLarge(fis, fos);
} catch (IOException e) {
// close the output stream ignoring any exceptions
close(fos);
fos = null;
// remove the invalid destination file
destination.delete();
exception = new IOException(String.format("Error copying %s to %s",
source.getCanonicalPath(), destination.getCanonicalPath()),
e);
} finally {
// close destination and source files reporting first exception
IOException e = close(fos);
if ((exception == null) && (e != null)) {
exception = new IOException(String.format("Error closing %s",
destination.getCanonicalPath()), e);
}
e = close(fis);
if ((exception == null) && (e != null)) {
exception = new IOException(String.format("Error closing %s",
source.getCanonicalPath()), e);
}
if (exception != null) {
throw exception;
}
}
}
/**
@ -887,13 +852,17 @@ public class FileUtil {
*
* @param c
* An object that needs to be closed.
* @throws IOException
* An error occurred attempting to close the object.
* @return IOException if one occurs or null
*/
public static void close(Closeable c) throws IOException {
private static IOException close(Closeable c) {
if (c != null) {
c.close();
try {
c.close();
} catch (IOException e) {
return e;
}
}
return null;
}
/**

View file

@ -31,10 +31,4 @@
version="0.0.0"
unpack="false"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -41,6 +41,7 @@ import org.apache.commons.logging.LogFactory;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 26, 2009 jkorman Initial creation
* Oct 23, 2013 DR 16674 D. Friedman Prevent infinite loop
*
* </pre>
*
@ -238,8 +239,8 @@ public class InternalReport {
case DATE : {
if(currRpt != null) {
currRpt.subLines.add(r);
reports.remove(r);
}
reports.remove(r);
break;
}
case REMARK : {

View file

@ -1,38 +0,0 @@
#!/usr/bin/ksh
#setenv FXA_HOME /awips/fxa
#setenv LOG_DIR /data/logs/fxa
#source $FXA_HOME/readenv.csh
RUN_FROM_DIR=`dirname $0`
echo "RFD: $RUN_FROM_DIR"
# set up SOME environment variables for WHFS applications
. $RUN_FROM_DIR/../../set_hydro_env
. $RUN_FROM_DIR/../../check_app_context
#set NRLDB_DATA=`/awips/hydroapps/public/bin/get_apps_defaults.LX nrldb_data`
#set NRLDB_LOG=`/awips/hydroapps/public/bin/get_apps_defaults.LX nrldb_log`
#set NRLDB_CONFIG=`/awips/hydroapps/public/bin/get_apps_defaults.LX nrldb_config`
#set WHFS_BIN=`/awips/hydroapps/public/bin/get_apps_defaults.LX whfs_bin_dir`
#cd /awips/hydroapps/whfs/local/data/backup_db/nrldb
export NRLDB_DATA=$(get_apps_defaults nrldb_data)
echo "NRLDB data: $NRLDB_DATA"
export NRLDB_LOG=$(get_apps_defaults nrldb_log)
echo "NRLDB log: $NRLDB_LOG"
export NRLDB_CONFIG=$(get_apps_defaults nrldb_config)
echo "NRLDB config: $NRLDB_CONFIG"
export WHFS_BIN=$(get_apps_defaults whfs_bin_dir)
echo "WHFS_BIN: $WHFS_BIN"
export NRLDBLOGFILE=${NRLDB_LOG}/nrldb.log
export NRLDBTMPFILE=${NRLDB_LOG}/nrldb.tmp
tail -5000 $NRLDBLOGFILE > $NRLDBTMPFILE
mv $NRLDBTMPFILE $NRLDBLOGFILE
${WHFS_BIN}/nrldb.pl -t wfo -u
#

File diff suppressed because it is too large Load diff

View file

@ -1,173 +0,0 @@
#!/bin/sh
###############################################################################
# This script is run at the field office to send ad-hoc updates to the NRLDB
# server, then on to the AHPS CMS. It can be run at any time. It is designed
# to send small, time-sensitive updates to the CMS. It takes two argument
# lists:-table table names (comma-separated) and -lid lid names
# (comma-separated). It parses the arguments, selects the updated data from
# the database and builds an SQL formatted text file for use on the nrldb and
# CMS databases. The SQL file contains a delete staement that deletes the
# pre-existing data for the lid/table combinations, before running the inserts
#
# Usage: send_nrldb_update.sh -table <table1>,<table2>,... -lid <lid1>,<lid2>,...
# Example: send_nrldb_update.sh -table rating,floodstmt -lid BRKM2,CBEM2
#
if [ $# -ne 4 ]
then
echo "Incorrect number of arguments entered: $#"
echo "Correct Arguments are:"
echo "send_nrldb_update.sh -table table1,table2 -lid lid1,lid2"
echo "Any number of tables and lids may be specified, but they need to be in a comma separated list with no spaces between commas and table/lid names"
exit 0
fi
# set up SOME environment variables for NRLDB applications
export apps_dir=/awips2/edex/data/share/hydroapps
export EDEX_HOME=/awips2/edex
export NRLDB_DATA=`get_apps_defaults nrldb_data`
export NRLDB_LOG=$(get_apps_defaults nrldb_log)
export NRLDB_CONFIG=$(get_apps_defaults nrldb_config)
export db_name=$(get_apps_defaults db_name)
export NRLDB_TMP=$(get_apps_defaults nrldb_tmp)
export PGUSER=awips
# get the nrldb host and wfo from the nrldb.conf file/database
nrldb_host=`grep nrldb_host $NRLDB_CONFIG/nrldb.conf | cut -d= -f2 | sed 's/"//g' | sed 's/ //g'`
wfo=`psql -d $db_name -c "select hsa from admin;" | tail -3 | head -1 | sed -e 's/ //g'`
echo `date`
# create the final SQL file that will be sent to the NRLDB host
timestamp=`date +%Y%m%d%H%N`
sql_file="${wfo}_update_${timestamp}.sql"
if [ -f $sql_file ]
then
rm $sql_file
fi
# build the list of tables/lids to send
lid_list="XXXXX"
table_list="XXXXX"
while [ $# -gt 0 ]
do
case "$1" in
-lid) lid_list="$2,";shift;;
-table) table_list="$2,";shift;;
*) break;;
esac
shift
done
# set the last update information for update_nrldb.pl to use
echo `date` > ${NRLDB_LOG}/last_nrldb_update.txt
up_lid_list=`echo $lid_list | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
echo "lid list: $up_lid_list" >> ${NRLDB_LOG}/last_nrldb_update.txt
echo "table_list: $table_list" >> ${NRLDB_LOG}/last_nrldb_update.txt
#loop through the tables/lids
if [ $table_list != "XXXXX" ]
then
pos=1
table="XXXXX"
ltable=`echo $table | wc -m`
while [ $ltable -gt 4 ]
do
table=`echo $table_list | cut -d"," -f$pos`
pos=`expr $pos + 1`
ltable=`echo $table | wc -m`
if [ $ltable -gt 4 ]
then
lid="XXXXX"
lpos=1
llid=`echo $lid | wc -m`
while [ $llid -gt 3 ]
do
lid=`echo $up_lid_list | cut -d"," -f$lpos`
lpos=`expr $lpos + 1`
llid=`echo $lid | wc -m`
if [ $llid -gt 3 ]
then
# fetch the values from the DB and edit them
export PGUSER=awips
touch $NRLDB_TMP/update.txt
chmod ugo+rw $NRLDB_TMP/update.txt
ls -l $NRLDB_TMP/update.txt
psql -d $db_name -c "copy (select * from $table where lid = '$lid') to '$NRLDB_TMP/update.txt' with delimiter '|';"
cp $NRLDB_TMP/update.txt ${NRLDB_DATA}/update.txt
sed -f ${NRLDB_CONFIG}/sed_script.txt ${NRLDB_TMP}/update.txt > ${NRLDB_DATA}/update11.txt
sed -e "s/|/'|'/g" ${NRLDB_DATA}/update11.txt > ${NRLDB_DATA}/update1.txt
sed -e "s/^/insert into $table values('/g" ${NRLDB_DATA}/update1.txt > ${NRLDB_DATA}/update2.txt
sed -e "s/$/');/g" ${NRLDB_DATA}/update2.txt > ${NRLDB_DATA}/update3.txt
sed -e "s/|/,/g" ${NRLDB_DATA}/update3.txt > ${NRLDB_DATA}/update4.txt
if [ -f "${NRLDB_DATA}/update.txt" ]
then
update_lines=`wc -l "${NRLDB_DATA}/update.txt" | cut -d" " -f1`
else
echo "No update file found".
update_lines=0
fi
if [ $update_lines -gt 0 ]
then
if [ $table != "location" -a $table != "riverstat" ]
then
echo "delete from $table where lid = '$lid';" >> ${NRLDB_DATA}/$sql_file
fi
cat ${NRLDB_DATA}/update4.txt >> ${NRLDB_DATA}/$sql_file
fi
# location and riverstat require a special forecast since they have dependent tables via foreign keys
if [ $table = "location" ]
then
sql_stmt="update location set lid = '$lid'"
for col in county coe cpm detail elev hdatum hsa hu lat lon lremark lrevise name network rb rfc sbd sn state waro wfo wsfo type des det post stntype tzone
do
psql -d $db_name -c "select $col from location where lid = '$lid' and $col is not null;" > ${NRLDB_DATA}/update.txt
ct_zero=`grep -c "0 row" ${NRLDB_DATA}/update.txt`
if [ $ct_zero -eq 0 ]
then
export val=`cat ${NRLDB_DATA}/update.txt | head -3 | tail -1 | cut -c2-80`
new_val=`echo "$val" | sed -f ${NRLDB_CONFIG}/sed_script.txt`
sql_stmt="$sql_stmt, $col = '$new_val'"
fi
done
sql_stmt="$sql_stmt where lid = '$lid';"
echo $sql_stmt >> ${NRLDB_DATA}/$sql_file
elif [ $table = "riverstat" ]
then
sql_stmt="update riverstat set lid = '$lid'"
for col in primary_pe bf cb da response_time threshold_runoff fq fs gsno level mile pool por rated lat lon remark rrevise rsource stream tide backwater vdatum action_flow wstg zd ratedat usgs_ratenum uhgdur use_latest_fcst
do
psql -d $db_name -c "select $col from riverstat where lid = '$lid' and $col is not null;" > ${NRLDB_DATA}/update.txt
ct_zero=`grep -c "0 row" ${NRLDB_DATA}/update.txt`
if [ $ct_zero -eq 0 ]
then
export val=`cat ${NRLDB_DATA}/update.txt | head -3 | tail -1 | cut -c2-80`
new_val=`echo "$val" | sed -f ${NRLDB_CONFIG}/sed_script.txt`
sql_stmt="$sql_stmt, $col = '$new_val'"
fi
done
sql_stmt="$sql_stmt where lid = '$lid';"
echo $sql_stmt >> ${NRLDB_DATA}/$sql_file
fi
fi
done
fi
done
# send the SQL file to the NRLDB server
if [ -f ${NRLDB_DATA}/$sql_file ]
then
rsync -av ${NRLDB_DATA}/$sql_file ${nrldb_host}\::nrldb_update/
echo "SQL file: $sql_file created for lids: $up_lid_list and tables: $table_list"
else
echo "No SQL file created. Database contained no entries for lids: $up_lid_list and tables: $table_list"
fi
fi
# remove the temp files to keep the directory clean
for temp_file in ${NRLDB_DATA}/update.txt ${NRLDB_DATA}/update11.txt ${NRLDB_DATA}/update1.txt ${NRLDB_DATA}/update2.txt ${NRLDB_DATA}/update3.txt ${NRLDB_DATA}/update4.txt
do
if [ -f $temp_file ]
then
rm $temp_file
fi
done

View file

@ -1,274 +0,0 @@
#!/usr/bin/perl
################################################################################
# update_nrldb.pl is the GUI for the Ad-Hoc update process. ## This process was put in place so that WFOs could update information #
# between daily runs of the NRLDB update process. The information is #
# collected at the WFO, sent to the NRLDB central server and then forwarded to #
# CMS servers outside of the AWIPS firewall. #
# #
# Developer: Mark Armstrong (OCWWS/HSD) #
# Developed 2011 - Modified for AWIPS2 2013 #
################################################################################
use Tk;
use strict;
use warnings;
use AppConfig qw(:expand :argcount);
use DBI;
$ENV{EDEX_HOME}="/awips2/edex";
$ENV{apps_dir}="/awips2/edex/data/share/hydroapps";
our $BIN_DIR = `get_apps_defaults.LX whfs_bin_dir`;
chomp($BIN_DIR);
our $LOG_DIR = `get_apps_defaults.LX nrldb_log`;
chomp($LOG_DIR);
my $lids;
my $tables;
# Set up some inial configuration. Most of this comes from the hydroGen input file: hg.cfg
$ENV{HYDROGENHOME} = "/awips/hydroapps/HydroGen" if ! defined $ENV{HYDROGENHOME};
my %cfg = ( DEBUG => 0, # debug mode on or off
PEDANTIC => 0, # be patient with warnings/errors
CREATE => 1, # create variables, defining not required...
GLOBAL => { # for all config options unless overridden...
EXPAND => EXPAND_ALL, # expand ~, $ENV{*}, and $(var)
ARGCOUNT => ARGCOUNT_ONE, # each config expects an arg unless overriden...
ARGS => '=s' # each arg is a string unless overriden
}
);
my $config = AppConfig->new(\%cfg); # create config object
$config->define('version',{ ALIAS => 'V',ARGCOUNT => ARGCOUNT_NONE, ARGS => '!',DEFAULT => 0});
$config->define('help',{ ALIAS => 'h',ARGCOUNT => ARGCOUNT_NONE, ARGS => '!',DEFAULT => 0});
$config->define('man',{ ALIAS => 'm',ARGCOUNT => ARGCOUNT_NONE, ARGS => '!',DEFAULT => 0});
$config->define('DBengine',{ VALIDATE => '[\w]+',DEFAULT => "Pg"});
$config->define('DBname',{ VALIDATE => '[\w]+',DEFAULT => "hd_ob8xxx"});
$config->define('DBhost',{ VALIDATE => '[-\w]+',DEFAULT => "dx1f"});
$config->define('DBport',{ ARGS => '=i',DEFAULT => 5432});
$config->define('master',{ VALIDATE => '[.\w]+',DEFAULT => "HGstation"});
$config->define('basedir',{ VALIDATE => '[- /.\w]+',DEFAULT => $ENV{HYDROGENHOME} . "/bin"});
$config->file($ENV{HYDROGENHOME} . "/input/hg.cfg"); # look in user's $HYDROGENHOME to find configured settings
$config->args(\@ARGV); # get config settings from the command-line, overwriting any settings from the file...
my $master = $config->get('master'); # name of DB table or view which holds master list of IDs for which MXD files are to be generated...
my $DBengine = $config->get('DBengine');
my $DBname = $config->get('DBname');
my $DBhost = $config->get('DBhost');
my $DBport = $config->get('DBport');
my $baseDir = `pwd`;
chomp $baseDir;
my $DBstr;
my $wildcard;
#Open a database connection and get the list of LIDs from the IHFS DB
if($DBengine eq "Pg") {
$DBstr = "dbi:$DBengine:dbname=$DBname;host=$DBhost;port=$DBport";
$wildcard = '%';
} else {
$DBstr = "dbi:$DBengine:$DBname";
$wildcard = '*';
}
my $dbh = DBI->connect("$DBstr",undef,undef,{ChopBlanks => 1}) or warn $DBI::errstr;
# creates the list of WFOs based on the HydroGen .xxx_backup files
# and builds the query to create the list of LIDs
my $wfo=`ls -a /awips/hydroapps/HydroGen/ | grep _backup | cut -c2-4`;
my $list_len=length $wfo;
my $num_wfos=$list_len/4;
my $index=1;
my $off=0;
my $wfoid=substr($wfo,$off,3);
my $wfoID=uc $wfoid;
my $wfo_query = "(location.hsa = \'$wfoID\'";
while ($index < $num_wfos){
$off+=4;
$wfoid=substr($wfo,$off,3);
$wfoID=uc $wfoid;
$wfo_query .= " or location.hsa = \'$wfoID\'";
$index++;
}
$wfo_query .= ")";
#my $list_type="river";
our $mw = MainWindow->new;
$mw->title('Ad-Hoc NRLDB Update');
my $lst_lab= $mw->Label(-text => 'Add any Unlisted Locations (comma-separated): ');
my $sql = "select distinct hgstation.lid,location.name,location.hsa from hgstation,location where hgstation.lid = location.lid and $wfo_query order by 3,1;";
# get the list of LIDs
my $qhw = $dbh->prepare("$sql") or warn $DBI::errstr;
our @lid_list; # = ($wildcard);
#get the data from the DB
get_results($qhw,\@lid_list);
#print "ct: " . @lid_list;
#set up a static array with the tables that are allowed for ad-hoc updates
#table_list is the actual name of the DB tables, while tabledesc is a friendlier description that is displayed to the user
our @table_list = ('location','riverstat','crest','floodstmt','hgstation','floodcat','lowwater');
my @tabledesc = ('Location','Riverstat','Crest History','Impacts','HGstation','Flood Categories','Low Water');
$dbh->disconnect();
#manipulate the results of the lid/hsa/name query for better display
my @liddeschsa;
our @lidsend;
$index=0;
my $num_lids=scalar(@lid_list);
while ($index < $num_lids){
my $line = $lid_list[$index];
# print "line: $line\n";
my @results = split('\|',$line);
#my $lid = $lid_list[$index];
my $lid_lid = $results[0];
my $lid_name = $results[1];
my $lid_hsa = $results[2];
# print "lid: $lid_lid name: $lid_name hsa: $lid_hsa\n";
push(@liddeschsa,"$lid_hsa | $lid_lid | $lid_name");
push(@lidsend,$lid_lid);
$index++;
}
# Create the GUI object
#my $mw = MainWindow->new;
#$mw->title('Ad-Hoc NRLDB Update');
#my $lst_lab= $mw->Label(-text => 'Locations List: ');
#my $lst_rad_riv = $mw-> Radiobutton(-text=>'AHPS River Points',
# -value=>'river', -variable=>\$list_type);
#my $lst_rad_precip = $mw-> Radiobutton(-text=>'Precip Points',
# -value=>'precip', -variable=>\$list_type);
# Labels for the LID and table scroll boxes
my $misc_ent = $mw->Entry();
my $label1 = $mw->Label(-text => 'HSA|LID|Location Name');
my $label2 = $mw->Label(-text => 'Tables');
# Create the scroll boxes for the LIDs and tables
my $lb1 = $mw->Scrolled('Listbox',
-scrollbars => 'osoe',-width=>50,
-selectmode => 'multiple', -exportselection=>0);
my $lb2 = $mw->Scrolled('Listbox',
-scrollbars => 'osow',-width=>20,
-selectmode => 'multiple',-exportselection=>0);
# Add the arrays that we want to display in the list boxes
$lb1->insert('end', @liddeschsa);
$lb2->insert('end', @tabledesc);
# Create the buttons
my $exit = $mw->Button(-text => 'Exit',
-command => [$mw => 'destroy']);
my $send = $mw->Button(-text => 'Send',
-command => \&send_button);
my $show_log = $mw->Button(-text => 'Show Log',
-command => \&show_log);
my $update_list = $mw->Button(-text => 'Update List', -command => \&upd_list);
# create the label and text box for the last pdate window
my $status_box = $mw->Text(-width=>20, -height=>3);
my $lb_status = $mw->Label(-width=>20, -height=>3,-text=>"Last Ad-Hoc Update:");
my $last_update = `cat $LOG_DIR/last_nrldb_update.txt`;
$status_box->insert('end',"$last_update");
# Crate the GUI using grid to specify the physical locations of the objects
#$lst_rad_riv->grid(-row=>1, -column=>2, -columnspan=>1);
#$lst_rad_precip->grid(-row=>1, -column=>3, -columnspan=>1);
$label1->grid(-row=>1, -column=>1, -columnspan=>3) ;
$label2->grid(-row=>1, -column=>4) ;
$lb1->grid(-row=>2, -column=>1, -columnspan=>3, -sticky=>"ew") ;#pack;
$lb2->grid(-row=>2, -column=>4, -columnspan=>1, -sticky=>"w") ;#pack;
$lst_lab->grid(-row=>3, -column=>1, -columnspan=>1);
$misc_ent->grid(-row=>3, -column=>2);
$lb_status->grid(-row=>4, -column=>1);
$status_box->grid(-row=>4, -column=>2, -columnspan=>3, -sticky=>"ew");
$send->grid(-row=>5, -column=>1) ;#pack;
$show_log->grid(-row=>5,-column=>2);
$exit->grid(-row=>5, -column=>4) ;#pack;
MainLoop;
# End of main
#
#sub upd_list {
# $mw => 'destroy';
# my $cmd = "${DIR}/update_nrldb.pl.exp $list_type\n";
# print "cmd: $cmd\n";
# system($cmd);
#}
# The Send button functionality function
sub send_button {
# Get the indices of the selected array items
my @LIDindex = $lb1->curselection;
my @Tableindex = $lb2->curselection;
my $index=1;
my $misc_lid = $misc_ent-> get();
# build the lists of LIDs and tables
$tables = $table_list[$Tableindex[0]];
my $numLIDs=@LIDindex;
print "numLIDs: $numLIDs\n";
my $numTables=@Tableindex;
if ($numLIDs > 0){
$lids = $lidsend[$LIDindex[0]];
while ($index < $numLIDs){
$lids .= "," . $lidsend[$LIDindex[$index]];
$index++;
}
$lids .= "," . $misc_lid;
} else {
$lids=$misc_lid;
}
$index=1;
while ($index < $numTables){
$tables .= "," . $table_list[$Tableindex[$index]];
$index++;
}
# print "l0: ${lid_list[$LIDindex[0]]} t0: ${table_list[$Tableindex[0]]} lids: $lids tables: $tables\n";
# Create the call to the script and execute it using system()
my $cmd = "${BIN_DIR}/send_nrldb_update.sh -table $tables -lid $lids > ${LOG_DIR}/send_nrldb_update.log\n";
# print "cmd: $cmd\n";
system($cmd);
# Create a dialog box to inform the user that their data has been sent
my $dsend=$mw->Dialog(-title=>'Sent NRLDB Update',-buttons=>['OK']);
my $text_field="NRLDB Update Sent for LIDs: $lids \n and tables: $tables\n";
# my $addbox=$dsend->('Label',-text=>"$text_field")->pack(-side => 'left',-fill => 'both',-expand => 1);
my $box=$dsend->add('Label',-text=>"$text_field")->pack(-side => 'left',-fill => 'both',-expand => 1);
my $button = $dsend->Show;
}
# This subroutine, copied from Mark Fenbers bless program, takes a db query and returns an array of results
sub get_results
{
my $qh = shift;
my $array = shift;
my $record;
#print "qh: $qh\n";
if(defined $qh) {
if($qh->execute(@_)) {
while($record = $qh->fetchrow_arrayref) {
foreach (@$record) { $_ = "" if ! defined $_; }
push @$array,(join '|',@$record);
}
} else {
warn $DBI::errstr;
# print $qh->errstr;
}
} else { warn "unable to prepare query \"$sql\"\n"; }
}
#This subroutine displays the log from the send script in the form of a dialog box
sub show_log
{
use Tk::Dialog;
my $text_field=`cat ${LOG_DIR}/send_nrldb_update.log`;
my $d = $mw->Dialog(-title=>'Show Log',-buttons => ['OK']);
my $box=$d->add('Label',-text=>"$text_field")->pack(-side => 'left',-fill => 'both',-expand => 1);
my $button = $d->Show;
# exit;
}

View file

@ -1,6 +0,0 @@
dbhost = "dx1f"
dbuser = "awips"
dbpass = ""
nrldb_host = "165.92.28.1"
site = "CCC"
dbname = "hd_ob92ccc"

View file

@ -1,174 +0,0 @@
#NRLDB national configuration file
#
#
[hsa]
fields = ALL
[wfo]
fields = ALL
[state]
fields = ALL
[counties]
fields = ALL
[network]
fields = ALL
[rfc]
fields = ALL
[timezone]
fields = ALL
#[admin]
#fields = ALL
[coopcomms]
fields = ALL
[cooprecip]
fields = ALL
[coopspons]
fields = ALL
[dcpowner]
fields = ALL
#[eligzon]
#fields = ALL
[gagemaint]
fields = ALL
[gageowner]
fields = ALL
[gagetype]
fields = ALL
[proximity]
fields = ALL
[telmtype]
fields = ALL
[telmowner]
fields = ALL
[telmpayor]
fields = ALL
[resowner]
fields = ALL
[damtypes]
fields = ALL
[location]
fields = ALL
[riverstat]
fields = ALL
[benchmark]
fields = lid, bnum, elev, remark
[observer]
fields = ALL
#[zonenum]
#fields = lid, state, zonenum
[reservoir]
fields = ALL
[crest]
fields = ALL
[datum]
fields = ALL
#[dcp]
#fields = ALL
[dcp]
fields = lid, criteria, owner, goes, rptfreq, rptime, notify, obsvfreq, randrept
[descrip]
fields = ALL
[flood]
fields = ALL
[floodcat]
fields = ALL
[floodstmt]
fields = ALL
[gage]
fields = ALL
[lowwater]
fields = ALL
[pub]
fields = ALL
[refer]
fields = ALL
#[telem]
#fields = ALL
[telem]
fields = lid, type, payor, cost, criteria, owner, phone, sensorid, rptfreq, notify, obsvfreq
[rating]
fields = ALL
[ratingshift]
fields = ALL
[contacts]
fields = ALL
[countynum]
fields = ALL
[unitgraph]
fields = ALL
[hgstation]
fields = ALL
#[floodts]
#fields = ALL
[lwstmt]
fields = ALL
[rpffcstgroup]
fields = ALL
[rpffcstpoint]
fields = ALL
[locdatalimits]
fields = lid,pe,dur,monthdaystart,monthdayend,gross_range_min,gross_range_max,reason_range_min,reason_range_max,roc_max
[sshpconfig]
fields = ALL
[shefpe]
fields = ALL
[shefdur]
fields = ALL
#[ingestfilter]
#fields = ALL
[locarea]
fields = ALL

View file

@ -10,6 +10,7 @@
* ------------ ---------- ----------- --------------------------
* 03/2013 B. Hebbard Initial creation
* 04/2013 B. Hebbard IOC version (for OB13.4.1)
* 10/2013 B. Hebbard Modify model name inference from metafile name
*
* This code has been developed by the SIB for use in the AWIPS2 system.
*/
@ -365,6 +366,61 @@ public class NtransDecoder extends AbstractDecoder {
*/
}
private enum Model {
//TODO - Remove this, to make decoder agnostic w.r.t. list of available models.
// We do this temporarily because we don't yet know the possible formats
// of filename strings we're going to be fed, so for now we just look for
// known model names appearing anywhere in the file name.
// NOTE: Sequence is important only insofar as any model name must appear
// after all model names of which it is a proper substring.
// Also, OPC_ENC comes first, since its metafiles may contain other
// model substrings
OPC_ENS,
CMCE_AVGSPR,
CMCE,
CMCVER,
CMC,
CPC,
DGEX,
ECENS_AVGSPR,
ECENS,
ECMWFVER,
ECMWF_HR,
ECMWF,
ENSVER,
FNMOCWAVE,
GDAS,
GEFS_AVGSPR,
GEFS,
GFSP,
GFSVERP,
GFSVER,
GFS,
GHM,
HPCQPF,
HPCVER,
HWRF,
ICEACCR,
JMAP,
JMA,
MEDRT,
NAEFS,
NAM20,
NAM44,
NAMVER,
NAM,
NAVGEM,
NOGAPS,
NWW3P,
NWW3,
RAPP,
RAP,
SREFX,
SST,
UKMETVER,
UKMET,
VAFTAD };
private String inferModel(String fileName) {
// Infer the model name from the file name
@ -387,14 +443,31 @@ public class NtransDecoder extends AbstractDecoder {
fileName.contains("_GFS")) {
modelName = "vaftad";
}
/*
else if (fileName.contains("_2")) {
modelName = fileName.substring(0, fileName.indexOf("_2"));
if (modelName.equals("jma")) {
modelName = "jmap";
}
}
return modelName;
return modelName;
*/
else {
for (Model model : Model.values()) {
if (fileName.toLowerCase().contains(model.name().toLowerCase())) {
modelName = model.name().toLowerCase();
break;
}
}
if (modelName.equals("jma")) {
modelName = "jmap";
}
return modelName;
}
return "other"; // unrecognized
}
private ByteOrder determineEndianess(ByteBuffer byteBuffer) {

View file

@ -41,12 +41,13 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
//import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.vividsolutions.jts.geom.Coordinate;
//import com.raytheon.uf.viz.core.drawables.IRenderable;
/**
* An abstract resource for displays where each grid cell is an individual
* IImage. Handles progressive disclosure algorithm.
@ -68,10 +69,11 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0
*/
public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
public abstract class AbstractGriddedDisplay<T> { // implements IRenderable
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractGriddedDisplay.class);
private static final IUFStatusHandler statusHandler = UFStatus.getHandler(AbstractGriddedDisplay.class);
private final Queue<Coordinate> calculationQueue;
private CalculationJob calculationJob;
@ -89,13 +91,15 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
protected RGB color;
protected int skipx;
protected int skipy;
protected double filter;
protected double magnification = 1.0;
private boolean async = true;
protected boolean[] isPlotted;
/**
@ -105,22 +109,19 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
* @param size
*/
public AbstractGriddedDisplay(IMapDescriptor descriptor,
GeneralGridGeometry gridGeometryOfGrid,int nx, int ny) {
GeneralGridGeometry gridGeometryOfGrid, int nx, int ny) {
this.calculationQueue = new ConcurrentLinkedQueue<Coordinate>();
this.descriptor = descriptor;
this.gridGeometryOfGrid = gridGeometryOfGrid;
// this.size = size;
this.gridDims = new int[] {
nx,
ny };
// this.size = size;
this.gridDims = new int[] { nx, ny };
isPlotted = new boolean[gridDims[0] * gridDims[1]];
}
public void setASync(boolean async) {
@ -134,106 +135,104 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
* com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core
* .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties)
*/
// @Override
public void paint(NcgridResourceData gridRscData, IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
boolean globalModel = isGlobalModel();
/**
* Get filter attribute
// @Override
public void paint(NcgridResourceData gridRscData, IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
boolean globalModel = isGlobalModel();
/**
* Get filter attribute
*/
String den = gridRscData.getFilter();
String noFilter = "";
if (den != null ){
try {
if (den.equalsIgnoreCase("YES") || den.equalsIgnoreCase("Y")) {
filter = 1.0;
}
else if (den.equalsIgnoreCase("NO") || den.equalsIgnoreCase("N") || den.equalsIgnoreCase("")) {
filter = 0.0;
noFilter = "NO";
}
else {
filter = Double.parseDouble(den);
}
if (filter == 0)
noFilter = "NO";
if (filter <0.1)
filter = 0.1;
}
catch (NumberFormatException e) {
System.out.println("The filter is not a double number");
filter = 1.0;
}
}
else {
filter = 1.0;
}
// /**
// * Get skip attribute
// */
//
// String[] skip = null;
// int skipx = 0;
// int skipy = 0;
//
// String skipString = gridRscData.getSkip(); //now for positive skip
// if (skipString != null && noFilter.equalsIgnoreCase("NO")) {
// int ind = skipString.indexOf("/");
// if (ind != -1) {
// skipString = skipString.substring(ind +1);
//
// if (skipString.trim().startsWith("-")) //temp fix for negative value
// skipString = skipString.substring(1);
//
// skip = skipString.split(";");
//
// if (skip != null && skip.length !=0){
// try {
// skipx = Integer.parseInt(skip[0]);
// }
// catch (NumberFormatException e) {
// System.out.println("The skip is not an interger");
// skipx = 0;
// }
//
// if (skip.length ==1 ) {
// skipy = skipx;
// }
// if (skip.length >1 && skip[0] != skip[1]) {
// try {
// skipy = Integer.parseInt(skip[1]);
// }
// catch (NumberFormatException e) {
// System.out.println("The skip is not an interger");
// skipy = skipx;
// }
// }
// }
// else {
// skipx = 0;
// skipy = 0;
// }
// }
// else {
// skipx = 0;
// skipy = 0;
// }
// }
// else {
// skipx = 0;
// skipy = 0;
// }
//
for (int i = 0; i < (gridDims[0] * gridDims[1]); i++)
isPlotted[i] = false;
String den = gridRscData.getFilter();
String noFilter = "";
if (den != null) {
try {
if (den.equalsIgnoreCase("YES") || den.equalsIgnoreCase("Y")) {
filter = 1.0;
} else if (den.equalsIgnoreCase("NO")
|| den.equalsIgnoreCase("N")
|| den.equalsIgnoreCase("")) {
filter = 0.0;
noFilter = "NO";
} else {
filter = Double.parseDouble(den);
}
if (filter == 0)
noFilter = "NO";
if (filter < 0.1)
filter = 0.1;
} catch (NumberFormatException e) {
System.out.println("The filter is not a double number");
filter = 1.0;
}
} else {
filter = 1.0;
}
// /**
// * Get skip attribute
// */
//
// String[] skip = null;
// int skipx = 0;
// int skipy = 0;
//
// String skipString = gridRscData.getSkip(); //now for positive skip
// if (skipString != null && noFilter.equalsIgnoreCase("NO")) {
// int ind = skipString.indexOf("/");
// if (ind != -1) {
// skipString = skipString.substring(ind +1);
//
// if (skipString.trim().startsWith("-")) //temp fix for negative value
// skipString = skipString.substring(1);
//
// skip = skipString.split(";");
//
// if (skip != null && skip.length !=0){
// try {
// skipx = Integer.parseInt(skip[0]);
// }
// catch (NumberFormatException e) {
// System.out.println("The skip is not an interger");
// skipx = 0;
// }
//
// if (skip.length ==1 ) {
// skipy = skipx;
// }
// if (skip.length >1 && skip[0] != skip[1]) {
// try {
// skipy = Integer.parseInt(skip[1]);
// }
// catch (NumberFormatException e) {
// System.out.println("The skip is not an interger");
// skipy = skipx;
// }
// }
// }
// else {
// skipx = 0;
// skipy = 0;
// }
// }
// else {
// skipx = 0;
// skipy = 0;
// }
// }
// else {
// skipx = 0;
// skipy = 0;
// }
//
for (int i = 0; i < (gridDims[0] * gridDims[1]); i++)
isPlotted[i] = false;
// Controls whether to draw images or debugging output on the map
// boolean debug = false;
// boolean debug = false;
this.target = target;
PaintProperties pp = new PaintProperties(paintProps);
@ -242,8 +241,8 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
IExtent viewPixelExtent = paintProps.getView().getExtent();
double ratio = viewPixelExtent.getWidth()
/ paintProps.getCanvasBounds().width;
//double interval = size * .75 * ratio / Math.min(2.0, filter);
// double interval = size * .75 * ratio / Math.min(2.0, filter);
double interval = size * .75 * ratio * filter;
double adjSize = size * ratio * magnification;
@ -284,18 +283,15 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
}
jcount++;
/*
if (debug == true) {
// Draw a red labeled square over the area where
// we will look for grid points
target.drawString(null, icount + "," + jcount, i, j,
0.0, TextStyle.NORMAL, new RGB(255, 0, 0),
HorizontalAlignment.CENTER,
VerticalAlignment.MIDDLE, 0.0);
target.drawRect(new PixelExtent(i - halfInterval, i
+ halfInterval, j - halfInterval, j
+ halfInterval), new RGB(255, 0, 0), 1, 1);
}
*/
* if (debug == true) { // Draw a red labeled square over
* the area where // we will look for grid points
* target.drawString(null, icount + "," + jcount, i, j, 0.0,
* TextStyle.NORMAL, new RGB(255, 0, 0),
* HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE,
* 0.0); target.drawRect(new PixelExtent(i - halfInterval, i
* + halfInterval, j - halfInterval, j + halfInterval), new
* RGB(255, 0, 0), 1, 1); }
*/
// Get a grid coordinate near i, j
ReferencedCoordinate coordToTry = new ReferencedCoordinate(
this.descriptor.getGridGeometry(), new Coordinate(
@ -304,23 +300,27 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
gridGeometryOfGrid, PixelInCell.CELL_CORNER);
gridCell.y = Math.round(gridCell.y);
gridCell.x = Math.round(gridCell.x);
// System.out.println("Look--" + i + " , " + j);
// System.out.println("grid--" + gridCell.x + " , "
// + gridCell.y);
/*
* Convert negative longitude
*/
Coordinate coord = coordToTry.asLatLon();
double x = coord.x;
if (globalModel && x < 0) {
x = x + 360;
x = x + 360;
}
Coordinate newCoord = new Coordinate(x, coord.y);
ReferencedCoordinate newrco = new ReferencedCoordinate(newCoord);
// System.out.println("latlon: " + newCoord);
ReferencedCoordinate newrco = new ReferencedCoordinate(
newCoord);
Coordinate newGridCell = newrco.asGridCell(
gridGeometryOfGrid, PixelInCell.CELL_CORNER);
newGridCell.x = Math.round(newGridCell.x);
/*
* Check for bounds
*/
@ -328,33 +328,33 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
|| (gridCell.y < 0 || gridCell.y >= gridDims[1])) {
thisRow.put(j, i);
continue;
}
ReferencedCoordinate rco = new ReferencedCoordinate(
new Coordinate((int)gridCell.x, (int)gridCell.y),
this.gridGeometryOfGrid, Type.GRID_CORNER);
Coordinate plotLoc = rco.asPixel(this.descriptor.getGridGeometry());
Coordinate gridCell2 = rco.asGridCell(
gridGeometryOfGrid, PixelInCell.CELL_CORNER);
// Coordinate plotLoc = coordToTry.asPixel(this.descriptor
// .getGridGeometry());
new Coordinate((int) gridCell.x, (int) gridCell.y),
this.gridGeometryOfGrid, Type.GRID_CORNER);
Coordinate plotLoc = rco.asPixel(this.descriptor
.getGridGeometry());
Coordinate gridCell2 = rco.asGridCell(gridGeometryOfGrid,
PixelInCell.CELL_CORNER);
// System.out.println("gridcell: " + gridCell);
// System.out.println("gridcell2: " + gridCell2);
// Coordinate plotLoc = coordToTry.asPixel(this.descriptor
// .getGridGeometry());
/*
if (debug == true) {
// draw a blue dot where the gridpoints are found.
target.drawString(null, ".", plotLoc.x, plotLoc.y, 0.0,
TextStyle.NORMAL, new RGB(0, 0, 255),
HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM, 0.0);
}
*/
* if (debug == true) { // draw a blue dot where the
* gridpoints are found. target.drawString(null, ".",
* plotLoc.x, plotLoc.y, 0.0, TextStyle.NORMAL, new RGB(0,
* 0, 255), HorizontalAlignment.CENTER,
* VerticalAlignment.BOTTOM, 0.0); }
*/
// If the real loc of this grid coordinate is close to the
// loc we wanted go with it
if (Math.abs(plotLoc.y - j) < (interval/2)
&& Math.abs(plotLoc.x - i) < (interval/2)) {
if (Math.abs(plotLoc.y - j) < (interval / 2)
&& Math.abs(plotLoc.x - i) < (interval / 2)) {
j = plotLoc.y;
thisRow.put(j, plotLoc.x);
} else {
@ -362,21 +362,24 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
continue;
}
/*
if (debug == true) {
// Draw a green label where the image will actually be
// drawn
target.drawString(null, icount + "," + jcount,
plotLoc.x, plotLoc.y, 0.0, TextStyle.NORMAL,
new RGB(0, 255, 0), HorizontalAlignment.CENTER,
VerticalAlignment.MIDDLE, 0.0);
}
*/
* if (debug == true) { // Draw a green label where the
* image will actually be // drawn target.drawString(null,
* icount + "," + jcount, plotLoc.x, plotLoc.y, 0.0,
* TextStyle.NORMAL, new RGB(0, 255, 0),
* HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE,
* 0.0); }
*/
T oldImage = getImage(gridCell2);
if (oldImage != null) {
// if (debug == false) {
paintImage((int)gridCell.x, (int)gridCell.y, pp, adjSize);
// }
// if (debug == false) {
if (globalModel)
paintGlobalImage((int) gridCell.x,
(int) gridCell.y, pp, adjSize);
else
paintImage((int) gridCell.x, (int) gridCell.y, pp,
adjSize);
// }
} else {
if (async) {
if (!this.calculationQueue.contains(gridCell2)) {
@ -384,17 +387,22 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
}
} else {
T image = createImage(gridCell2);
if (image != null /*&& debug == false*/) {
paintImage((int)gridCell.x, (int)gridCell.y, pp, adjSize);
if (image != null /* && debug == false */) {
if (globalModel)
paintGlobalImage((int) gridCell.x,
(int) gridCell.y, pp, adjSize);
else
paintImage((int) gridCell.x,
(int) gridCell.y, pp, adjSize);
}
}
}
}
}
} //while
} // while
} catch (Exception e) {
throw new VizException("Error occured during paint", e);
}
if (calculationQueue.size() > 0) {
if (this.calculationJob == null) {
this.calculationJob = new CalculationJob();
@ -429,8 +437,13 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
*/
protected abstract void disposeImages();
protected abstract void paintImage(int x, int y, PaintProperties paintProps,
double adjustedSize) throws VizException;
protected abstract void paintImage(int x, int y,
PaintProperties paintProps, double adjustedSize)
throws VizException;
protected abstract void paintGlobalImage(int x, int y,
PaintProperties paintProps, double adjustedSize)
throws VizException;
public void dispose() {
disposeImages();
@ -451,7 +464,7 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
/**
* @param filter
* the filter to set. Changed from density.
* the filter to set. Changed from density.
*/
public boolean setFilter(double filter) {
if (this.filter != filter) {
@ -461,16 +474,15 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
return false;
}
public float getSize() {
return size;
}
return size;
}
public void setSize(float size) {
this.size = size;
}
public void setSize(float size) {
this.size = size;
}
/**
/**
* @param magnification
* the magnification to set
*/
@ -482,38 +494,36 @@ public abstract class AbstractGriddedDisplay<T> { //implements IRenderable
return false;
}
private boolean isGlobalModel() throws VizException {
ReferencedCoordinate newrco0 = new ReferencedCoordinate(
new Coordinate(0, 0),
this.gridGeometryOfGrid, Type.GRID_CORNER);
ReferencedCoordinate newrco1 = new ReferencedCoordinate(
new Coordinate(gridDims[0] - 1, 0),
this.gridGeometryOfGrid, Type.GRID_CORNER);
ReferencedCoordinate newrco2 = new ReferencedCoordinate(
new Coordinate(1, 0),
this.gridGeometryOfGrid, Type.GRID_CORNER);
try {
Coordinate latLon0 = newrco0.asLatLon();
Coordinate latLon1 = newrco1.asLatLon();
Coordinate latLon2 = newrco2.asLatLon();
double dx1 = latLon2.x - latLon0.x;
double dx2 = (360 - latLon1.x) + latLon0.x;
int dx = (int) Math.round(dx2/dx1);
int dlat = (int) Math.round(latLon1.y - latLon0.y);
ReferencedCoordinate newrco0 = new ReferencedCoordinate(new Coordinate(
0, 0), this.gridGeometryOfGrid, Type.GRID_CORNER);
ReferencedCoordinate newrco1 = new ReferencedCoordinate(new Coordinate(
gridDims[0] - 1, 0), this.gridGeometryOfGrid, Type.GRID_CORNER);
ReferencedCoordinate newrco2 = new ReferencedCoordinate(new Coordinate(
1, 0), this.gridGeometryOfGrid, Type.GRID_CORNER);
if (dx <= 2 && dlat == 0) return true;
} catch (Exception e) {
throw new VizException(e);
}
return false;
try {
Coordinate latLon0 = newrco0.asLatLon();
Coordinate latLon1 = newrco1.asLatLon();
Coordinate latLon2 = newrco2.asLatLon();
double dx1 = latLon2.x - latLon0.x;
double dx2 = (360 - latLon1.x) + latLon0.x;
int dx = (int) Math.round(dx2 / dx1);
int dlat = (int) Math.round(latLon1.y - latLon0.y);
if (dx <= 2 && dlat == 0)
return true;
} catch (Exception e) {
throw new VizException(e);
}
return false;
}
/**
* Off UI Thread job for calculating the wind images
*

View file

@ -212,7 +212,8 @@ public class GriddedVectorDisplay extends AbstractGriddedDisplay<Coordinate> {
int idx = x + y * this.gridDims[0];
// System.out.println("paintImage idx==="+idx+" x=="+ijcoord.x+" y====="+ijcoord.y);
// System.out.println("INDEX " + idx + " : " + x + "," + y + " : "
// + gridDims[0] + "," + gridDims[1]);
if (idx < 0 || idx >= (gridDims[0] * gridDims[1])) {
return;
}
@ -623,4 +624,93 @@ public class GriddedVectorDisplay extends AbstractGriddedDisplay<Coordinate> {
}
return match;
}
@Override
/*
* HACK hack hack ... this version of paintImage is being used for global
* grids. I don't think the grid <-> latlon transforms are working, so the
* index calculation has been modified. This is not a good solution, but was
* implemented due to time crunch for 13.5.2
*/
protected void paintGlobalImage(int x, int y, PaintProperties paintProps,
double adjSize) throws VizException {
int adjx = x - 1;
// if (x > 0)
// adjx = 180 + x;
int adjy = y + 1;
if (x > 0) {
adjx++;
adjy = y;
}
int idx = adjx + adjy * this.gridDims[0];
// System.out.println("paintImage idx==="+idx+" x=="+ijcoord.x+" y====="+ijcoord.y);
// System.out.println("INDEX " + idx + " : " + x + "," + y + " : " +
// adjx
// + "," + adjy + " : " + gridDims[0] + "," + gridDims[1]);
if (idx < 0 || idx >= (gridDims[0] * gridDims[1])) {
return;
}
float spd = this.magnitude.get(idx);
float dir = this.direction.get(idx);
if (Float.isNaN(spd) || Float.isNaN(dir)) {
return;
}
if (this.isPlotted[idx]) {
return;
}
ReferencedCoordinate newrco = new ReferencedCoordinate(new Coordinate(
x, y), this.gridGeometryOfGrid, Type.GRID_CENTER);
Coordinate plotLoc = null;
try {
plotLoc = newrco.asPixel(this.descriptor.getGridGeometry());
latLon = newrco.asLatLon();
// System.out.println("plotloc = " + latLon);
if (latLon.x > 180 || latLon.x < -180 || latLon.y < -90
|| latLon.y > 90) {
return;
}
double[] stationLocation = { latLon.x, latLon.y };
double[] stationPixelLocation = this.descriptor
.worldToPixel(stationLocation);
if (stationPixelLocation != null) {
stationPixelLocation[1]--;
double[] newWorldLocation = this.descriptor
.pixelToWorld(stationPixelLocation);
this.gc.setStartingGeographicPoint(stationLocation[0],
stationLocation[1]);
this.gc.setDestinationGeographicPoint(newWorldLocation[0],
newWorldLocation[1]);
}
dir = dir + (float) MapUtil.rotation(latLon, gridLocation);
dir -= this.gc.getAzimuth();
} catch (Exception e) {
throw new VizException(e);
}
dir = (float) Math.toRadians(dir);
switch (displayType) {
case ARROW:
paintArrow(plotLoc, adjSize, spd, dir);
break;
case BARB:
paintBarb(plotLoc, adjSize, spd, dir);
break;
case DUALARROW:
paintDualArrow(plotLoc, adjSize, spd, dir);
break;
default:
throw new VizException("Unsupported disply type: " + displayType);
}
this.isPlotted[idx] = true;
}
}

View file

@ -114,7 +114,7 @@ public class EnsembleSelectComposite extends Composite {
Button isPrimaryButton;
Text[] weightText = new Text[MaxNumOfEnsembleCycles];
Button[] cycleButtons = new Button[MaxNumOfEnsembleCycles];
Button[] cycleButtons = new Button[MaxNumOfEnsembleCycles];
}
public EnsembleSelectComposite( Composite parent ) {
@ -294,7 +294,7 @@ public class EnsembleSelectComposite extends Composite {
// Use the NcGridInventory with constraints on the model/ensembleId
@SuppressWarnings("null")
public Date[] getAvailCycleTimes( Date seldCycleTime, String modelName, String pertNum ) {
HashMap<String, RequestConstraint> reqConstraints =
new HashMap<String, RequestConstraint>();
reqConstraints.put( "pluginName", new RequestConstraint( GridDBConstants.GRID_TBL_NAME ) );
@ -312,20 +312,20 @@ public class EnsembleSelectComposite extends Composite {
reqMsg.setReqConstraintsMap(
(HashMap<String, RequestConstraint>)reqConstraints );
reqMsg.setUniqueValues( true );
Object rslts;
try {
try {
rslts = ThriftClient.sendRequest( reqMsg );
} catch (VizException e) {
System.out.println("Error querying inventory "+inventoryName+" for ensemble "+
" component cycle times:"+e.getMessage() );
return new Date[0];
}
}
if( !(rslts instanceof String[]) ) {
out.println("Inventory Request Failed: "+rslts.toString() );
return new Date[0];
}
}
String[] rsltsList = (String[]) rslts;
DataTime[] dataTimeArr = new DataTime[ rsltsList.length ];
@ -333,7 +333,7 @@ public class EnsembleSelectComposite extends Composite {
for( int i=0 ; i<rsltsList.length ; i++ ) {
dataTimeArr[i] = ( rsltsList[i] == null ?
new DataTime(new Date(0)) : new DataTime( rsltsList[i] ) );
}
}
ArrayList<Date> refTimes = new ArrayList<Date>();
@ -347,14 +347,14 @@ public class EnsembleSelectComposite extends Composite {
if( !refTimes.contains( refTime ) &&
refTime.getTime() <= seldCycleTime.getTime() ) {
refTimes.add( refTime );
}
}
}
Date[] sortedRefTimesArr = refTimes.toArray( new Date[0] );
Arrays.sort( sortedRefTimesArr );
Date[] availCycleTimesArray =
Arrays.copyOf( sortedRefTimesArr, MaxNumOfEnsembleCycles );
Arrays.copyOf( sortedRefTimesArr, sortedRefTimesArr.length );
return availCycleTimesArray;
}

View file

@ -125,6 +125,8 @@ import static java.lang.System.out;
* 10/18/2012 896 sgurung Refactored PlotResource2 to use new generator class: NcPlotDataThreadPool. Added FrameLoaderJob to populate all frames.
* Added code to plot stations within 25% of the area outside of the current display area.
* 05/20/2013 988 Archana.S Refactored this class for performance improvement
* 10/24/2013 sgurung Added fix for "no data for every other frame" issue
*
* </pre>
*
* @author brockwoo
@ -1470,7 +1472,6 @@ public class NcPlotResource2 extends AbstractNatlCntrsResource<PlotResourceData,
for ( int index = frameTimesListSize - 1 ;index >= 0 ; --index){
frameLoaderTask = new FrameLoaderTask( listOfFrameTimes.get( index ) );
frameRetrievalPool.schedule( frameLoaderTask );
--index;
}
}
else{

View file

@ -9,7 +9,7 @@
Name: awips2-eclipse
Summary: AWIPS II Eclipse Distribution
Version: 3.6.1
Version: 3.8.2
Release: 1
Group: AWIPSII
BuildRoot: %{_build_root}
@ -46,6 +46,7 @@ mkdir -p %{_build_root}/awips2/eclipse
%build
%install
mkdir -p %{_build_root}/awips2/eclipse
# The location of the awips2 eclipse source directory will be
# specified as a command line argument. Fail if the specified
# directory cannot be found.
@ -174,4 +175,4 @@ rm -rf ${RPM_BUILD_ROOT}
/awips2/eclipse/epl-v10.html
/awips2/eclipse/icon.xpm
/awips2/eclipse/libcairo-swt.so
/awips2/eclipse/notice.html
/awips2/eclipse/notice.html

View file

@ -0,0 +1,178 @@
#
# AWIPS II Eclipse Spec File
#
# --define arguments:
# %{_uframe_eclipse}
# %{_build_root}
# %{_baseline_workspace}
Name: awips2-eclipse
Summary: AWIPS II Eclipse Distribution
Version: 3.6.1
Release: 1
Group: AWIPSII
BuildRoot: %{_build_root}
URL: N/A
License: N/A
Distribution: N/A
Vendor: Raytheon
Packager: Bryan Kowal
AutoReq: no
provides: awips2-eclipse
%description
AWIPS II Eclipse Distribution - Contains the AWIPS II Eclipse Distribution.
# Turn off the brp-python-bytecompile script
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g')
%prep
# Verify That The User Has Specified A BuildRoot.
if [ "%{_build_root}" = "/tmp" ]
then
echo "An Actual BuildRoot Must Be Specified. Use The --buildroot Parameter."
echo "Unable To Continue ... Terminating"
exit 1
fi
if [ -d %{_build_root} ]; then
rm -rf %{_build_root}
fi
mkdir -p %{_build_root}/awips2/eclipse
%build
%install
mkdir -p %{_build_root}/awips2/eclipse
# The location of the awips2 eclipse source directory will be
# specified as a command line argument. Fail if the specified
# directory cannot be found.
if [ ! -d %{_uframe_eclipse} ]; then
echo "ERROR: Unable To Find The AWIPS II Eclipse Distribution."
echo "Unable To Continue ... Terminating"
exit 1
fi
# Copy the uframe eclipse distribution.
cp -r %{_uframe_eclipse}/* %{_build_root}/awips2/eclipse
# Copy eclipse.sh to our build-directory.
cp %{_baseline_workspace}/rpms/awips2.ade/Installer.eclipse/scripts/* \
%{_build_root}/awips2/eclipse
# delete the basemaps and etc links
rm -f %{_build_root}/awips2/eclipse/basemaps
rm -f %{_build_root}/awips2/eclipse/etc
%pre
JAVA_INSTALL="<Not Installed>"
PYTHON_INSTALL="<Not Installed>"
ANT_INSTALL="<Not Installed>"
INSTALL_PATH="/awips2/java"
if [ -d ${INSTALL_PATH} ]; then
JAVA_INSTALL=${INSTALL_PATH}
fi
INSTALL_PATH="/awips2/python"
if [ -d ${INSTALL_PATH} ]; then
PYTHON_INSTALL=${INSTALL_PATH}
fi
INSTALL_PATH="/awips2/ant"
if [ -d ${INSTALL_PATH} ]; then
ANT_INSTALL=${INSTALL_PATH}
fi
echo -e "\e[1;34m--------------------------------------------------------------------------------\e[m"
echo -e "\e[1;34m\| Installing the AWIPS II Eclipse Distribution...\e[m"
echo -e "\e[1;34m--------------------------------------------------------------------------------\e[m"
echo -e "\e[1;34m Java Detected At: ${JAVA_INSTALL}\e[m"
echo -e "\e[1;34m Python Detected At: ${PYTHON_INSTALL}\e[m"
echo -e "\e[1;34m Ant Detected At: ${ANT_INSTALL}\e[m"
%post
echo -e "\e[1;34m--------------------------------------------------------------------------------\e[m"
echo -e "\e[1;34m\| Creating ADE Eclipse Desktop Shortcut...\e[m"
echo -e "\e[1;34m--------------------------------------------------------------------------------\e[m"
ADE_ECLIPSE_SHORTCUT="ade-eclipse"
SHORTCUT_OWNER="${USER}"
CREATE_SHORTCUT="true"
if [ ! "${SUDO_USER}" = "" ]; then
SHORTCUT_OWNER="${SUDO_USER}"
fi
echo -e "\e[1;34m Creating Shortcut For User: ${SHORTCUT_OWNER}\e[m"
USER_HOME_DIR="~${SHORTCUT_OWNER}"
if [ ! -d ${USER_HOME_DIR} ]; then
USER_HOME_DIR="/home/${SHORTCUT_OWNER}"
echo " (Assuming User Home Directory Is Under '/home')"
fi
if [ ! -d ${USER_HOME_DIR}/Desktop ]; then
echo -e "\e[1;31m ERROR: Unable To Find The User's Desktop!!!"
CREATE_SHORTCUT="false"
fi
if [ "${CREATE_SHORTCUT}" = "true" ]; then
SHORTCUT_TMP="${USER_HOME_DIR}/Desktop/${ADE_ECLIPSE_SHORTCUT}.tmp"
SHORTCUT="${USER_HOME_DIR}/Desktop/${ADE_ECLIPSE_SHORTCUT}.desktop"
if [ -f ${SHORTCUT} ]; then
echo -n " Attempting To Remove The Existing Shortcut ... "
sudo -u ${SHORTCUT_OWNER} rm -f ${SHORTCUT}
if [ ! -f ${SHORTCUT} ]; then
echo -n "SUCCESS"
else
echo -n "FAILURE"
fi
echo ""
fi
sudo -u ${SHORTCUT_OWNER} touch ${SHORTCUT_TMP}
sudo -u ${SHORTCUT_OWNER} chmod 666 ${SHORTCUT_TMP}
echo "[Desktop Entry]" >> ${SHORTCUT_TMP}
echo "Version=1.0" >> ${SHORTCUT_TMP}
echo "Encoding=UTF-8" >> ${SHORTCUT_TMP}
echo "Name=ADE Eclipse" >> ${SHORTCUT_TMP}
echo "GenericName=Eclipse" >> ${SHORTCUT_TMP}
echo "Comment=IDE" >> ${SHORTCUT_TMP}
echo "Exec=/bin/bash -i -c \"xterm -title 'AWIPS II ADE Eclipse' -e '/awips2/eclipse/eclipseShortcutWrap.sh'\"" >> ${SHORTCUT_TMP}
echo "Icon=/awips2/eclipse/icon.xpm" >> ${SHORTCUT_TMP}
echo "Terminal=false" >> ${SHORTCUT_TMP}
echo "Type=Application" >> ${SHORTCUT_TMP}
echo "Categories=Development;IDE;" >> ${SHORTCUT_TMP}
sudo -u ${SHORTCUT_OWNER} mv ${SHORTCUT_TMP} ${SHORTCUT}
sudo -u ${SHORTCUT_OWNER} chmod 644 ${SHORTCUT}
fi
echo -e "\e[1;32m--------------------------------------------------------------------------------\e[m"
echo -e "\e[1;32m\| AWIPS II Eclipse Distribution Installation - COMPLETE\e[m"
echo -e "\e[1;32m--------------------------------------------------------------------------------\e[m"
%preun
%postun
%clean
rm -rf ${RPM_BUILD_ROOT}
%files
%defattr(644,awips,fxalpha,755)
%dir /awips2/eclipse
/awips2/eclipse/*
%defattr(755,awips,fxalpha,755)
/awips2/eclipse/about.html
/awips2/eclipse/artifacts.xml
/awips2/eclipse/eclipse
/awips2/eclipse/eclipse.ini
/awips2/eclipse/eclipse.sh
/awips2/eclipse/eclipseShortcutWrap.sh
/awips2/eclipse/epl-v10.html
/awips2/eclipse/icon.xpm
/awips2/eclipse/libcairo-swt.so
/awips2/eclipse/notice.html

View file

@ -7,11 +7,10 @@
Summary: Pypies Apache HTTP Server
Name: awips2-httpd-pypies
Version: 2.2.15
Release: 15.2.el6
Release: 15.3.el6
URL: http://httpd.apache.org/
Source0: http://archive.apache.org/dist/httpd/httpd-%{version}.tar.gz
Source1: index.html
Source3: httpd-pypies.logrotate
Source4: httpd-pypies.init
Source5: httpd.sysconf
Source10: httpd.conf
@ -360,10 +359,10 @@ mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
install -m755 %{_baseline_workspace}/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies \
${RPM_BUILD_ROOT}/etc/init.d
# install log rotation stuff
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
install -m 644 -p $RPM_SOURCE_DIR/httpd-pypies.logrotate \
$RPM_BUILD_ROOT/etc/logrotate.d/httpd-pypies
# install cron job
mkdir -p ${RPM_BUILD_ROOT}/etc/cron.daily
install -m755 %{_baseline_workspace}/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/cron.daily/pypiesLogCleanup.sh \
${RPM_BUILD_ROOT}/etc/cron.daily
# fix man page paths
sed -e "s|/usr/local/apache2/conf/httpd.conf|/etc/httpd/conf/httpd.conf|" \
@ -561,7 +560,7 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) /awips2/httpd_pypies%{_sysconfdir}/httpd/conf.d/welcome.conf
%config(noreplace) /awips2/httpd_pypies%{_sysconfdir}/httpd/conf/magic
%config(noreplace) %{_sysconfdir}/logrotate.d/httpd-pypies
%{_sysconfdir}/cron.daily/pypiesLogCleanup.sh
%config(noreplace) %{_sysconfdir}/init.d/httpd-pypies
%dir /awips2/httpd_pypies%{_sysconfdir}/httpd/conf.d

View file

@ -480,7 +480,7 @@ HostnameLookups Off
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog logs/error_log
ErrorLog "|/awips2/httpd_pypies/usr/sbin/rotatelogs /awips2/httpd_pypies/var/log/httpd/error_log.%Y.%m.%d 86400"
#
# LogLevel: Control the number of messages logged to the error_log.
@ -522,7 +522,7 @@ LogFormat "%{User-agent}i" agent
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
CustomLog logs/access_log combined
CustomLog "|/awips2/httpd_pypies/usr/sbin/rotatelogs /awips2/httpd_pypies/var/log/httpd/access_log.%Y.%m.%d 86400" combined
#
# Optionally add a line containing the server version and virtual host

View file

@ -0,0 +1,19 @@
#!/bin/bash
# Remove any logs from a week ago, if they exist.
_PYPIES_LOG_DIRECTORY="/awips2/httpd_pypies/var/log/httpd"
_LOG_NAME_PREFIXES=( 'access_log' 'error_log' )
_COUNT_DAYS=( 7 8 9 10 11 12 13 14 )
for day in ${_COUNT_DAYS[*]}; do
_log_date=`date -d "-${day} day" +%Y.%m.%d`
for logPrefix in ${_LOG_NAME_PREFIXES[*]}; do
_log_file="${logPrefix}.${_log_date}"
echo "${_PYPIES_LOG_DIRECTORY}/${_log_file}"
rm -f ${_PYPIES_LOG_DIRECTORY}/${_log_file}
done
done

View file

@ -77,7 +77,7 @@ check13 () {
start() {
source /etc/profile.d/awips2HDF5Tools.sh
echo -n $"Starting logging service:"
nohup su awips -c "$loggingCmd > /tmp/pypiesLoggingService.log 2>&1" > /dev/null 2>&1 &
nohup su awips -c "$loggingCmd > /tmp/pypiesLoggingService.log 2>&1" > /dev/null &
RC=$?
# TODO: need better checks to ensure that the logging service actually keeps
# running after startup.
@ -98,10 +98,30 @@ start() {
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
/awips2/httpd_pypies/usr/sbin/apachectl -k graceful-stop
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
echo -n $"Stopping logging service:"
# Stop the logging process
for pid in `ps aux | grep [l]ogProcess.py | awk '{print $2}'`;
do
kill -9 ${pid}
RC=$?
if [ ${RC} -ne 0 ]; then
failure
return
fi
done
success
echo
}
# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
forcestop() {
echo -n $"Stopping $prog: "
killproc -d 10 $httpd
RETVAL=$?
@ -128,7 +148,7 @@ reload() {
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
/awips2/httpd_pypies/usr/sbin/apachectl -k graceful
RETVAL=$?
fi
echo
@ -142,6 +162,9 @@ case "$1" in
stop)
stop
;;
forcestop)
forcestop
;;
status)
status $httpd
RETVAL=$?
@ -164,7 +187,7 @@ case "$1" in
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
echo $"Usage: $prog {start|stop|forcestop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac

View file

@ -9,7 +9,7 @@
Name: awips2-ldm
Summary: AWIPS II LDM Distribution
Version: %{_ldm_version}
Release: 7
Release: 8
Group: AWIPSII
BuildRoot: /tmp
BuildArch: noarch

View file

@ -307,19 +307,108 @@ if [ "${1}" = "-full" ]; then
exit 0
fi
#if [ "${1}" = "-ade" ]; then
# echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE."
# exit 0
# buildRPM "awips2-eclipse"
#
# exit 0
#fi
if [ "${1}" = "-ade" ]; then
echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE."
exit 0
buildRPM "awips2-eclipse"
buildJava
buildRPM "awips2-ant"
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-h5py"
buildRPM "awips2-python-jimporter"
buildRPM "awips2-python-matplotlib"
buildRPM "awips2-python-nose"
buildRPM "awips2-python-numpy"
buildRPM "awips2-python-pil"
buildRPM "awips2-python-pmw"
buildRPM "awips2-python-pupynere"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python-scientific"
buildRPM "awips2-python-scipy"
buildRPM "awips2-python-tables"
buildRPM "awips2-python-thrift"
buildRPM "awips2-python-tpg"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildRPM "awips2-python-shapely"
buildQPID -ade
if [ $? -ne 0 ]; then
exit 1
fi
# Package the ade.
# Create the containing directory.
ade_directory="awips2-ade-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
if [ -d ${WORKSPACE}/${ade_directory} ]; then
rm -rf ${WORKSPACE}/${ade_directory}
if [ $? -ne 0 ]; then
exit 1
fi
fi
mkdir -p ${WORKSPACE}/${ade_directory}
if [ $? -ne 0 ]; then
exit 1
fi
# Copy the rpms to the directory.
cp -v ${AWIPSII_TOP_DIR}/RPMS/x86_64/* \
${AWIPSII_TOP_DIR}/RPMS/noarch/* \
${WORKSPACE}/${ade_directory}
if [ $? -ne 0 ]; then
exit 1
fi
awips2_ade_directory="${WORKSPACE}/rpms/awips2.ade"
# Copy the install and uninstall script to the directory.
cp -v ${awips2_ade_directory}/tar.ade/scripts/*.sh \
${WORKSPACE}/${ade_directory}
if [ $? -ne 0 ]; then
exit 1
fi
# Build the source jar file
#ade_work_dir="/home/dmsys/Dim12/build/AWIPS2/AWIPS2-ADE-OB14.1.1-CM"
#cd $ade_work_dir
#./build_source_jar.sh
#cp -v /tmp/awips-component/tmp/awips2-ade-baseline-SOURCES.jar ${WORKSPACE}/${ade_directory}
# Tar the directory.
pushd . > /dev/null 2>&1
cd ${WORKSPACE}
tar -cvf ${ade_directory}.tar ${ade_directory}
popd > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
exit 0
fi
if [ "${1}" = "-viz" ]; then
buildRPM "awips2"
buildRPM "awips2-common-base"
buildRPM "awips2-tools"
buildRPM "awips2-cli"
buildRPM "awips2-adapt-native"
unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-httpd-pypies"
buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-rcm"
#buildRPM "awips2-tools"
#buildRPM "awips2-cli"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
@ -330,7 +419,7 @@ if [ "${1}" = "-viz" ]; then
fi
if [ "${1}" = "-edex" ]; then
buildRPM "awips2-common-base"
##buildRPM "awips2-common-base"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@ -340,10 +429,12 @@ if [ "${1}" = "-edex" ]; then
fi
if [ "${1}" = "-custom" ]; then
buildQPID
if [ $? -ne 0 ]; then
exit 1
fi
#buildQPID
#if [ $? -ne 0 ]; then
# exit 1
#fi
buildRPM "awips2-alertviz"
#buildRPM "awips2-eclipse"
exit 0
fi

View file

@ -0,0 +1,406 @@
#!/bin/bash
function buildRPM()
{
# Arguments:
# ${1} == the name of the rpm.
lookupRPM "${1}"
if [ $? -ne 0 ]; then
echo "ERROR: '${1}' is not a recognized AWIPS II RPM."
exit 1
fi
/usr/bin/rpmbuild -ba \
--define '_topdir %(echo ${AWIPSII_TOP_DIR})' \
--define '_baseline_workspace %(echo ${WORKSPACE})' \
--define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \
--define '_awipscm_share %(echo ${AWIPSCM_SHARE})' \
--define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \
--define '_component_version %(echo ${AWIPSII_VERSION})' \
--define '_component_release %(echo ${AWIPSII_RELEASE})' \
--define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \
--define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \
--define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \
--buildroot ${AWIPSII_BUILD_ROOT} \
${RPM_SPECIFICATION}/component.spec
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build RPM ${1}."
exit 1
fi
return 0
}
# This script will build all of the 64-bit rpms.
# Ensure that we are on a machine with the correct architecture.
architecture=`uname -i`
if [ ! "${architecture}" = "x86_64" ]; then
echo "ERROR: This build can only be performed on a 64-bit Operating System."
exit 1
fi
# Determine which directory we are running from.
path_to_script=`readlink -f $0`
dir=$(dirname $path_to_script)
common_dir=`cd ${dir}/../common; pwd;`
if [ $? -ne 0 ]; then
echo "ERROR: Unable to find the common functions directory."
exit 1
fi
# source the common functions.
source ${common_dir}/lookupRPM.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to source the common functions."
exit 1
fi
source ${common_dir}/usage.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to source the common functions."
exit 1
fi
source ${common_dir}/rpms.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to source the common functions."
exit 1
fi
source ${common_dir}/systemInfo.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to retrieve the system information."
exit 1
fi
# prepare the build environment.
source ${dir}/buildEnvironment.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to prepare the build environment."
exit 1
fi
export LIGHTNING=true
# Determine if the optional '-nobinlightning' argument has been specified.
if [ "${2}" = "-nobinlightning" ]; then
LIGHTNING=false
fi
if [ "${1}" = "-64bit" ]; then
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-h5py"
buildRPM "awips2-python-jimporter"
buildRPM "awips2-python-matplotlib"
buildRPM "awips2-python-nose"
buildRPM "awips2-python-numpy"
buildRPM "awips2-python-pil"
buildRPM "awips2-python-pmw"
buildRPM "awips2-python-pupynere"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python-scientific"
buildRPM "awips2-python-scipy"
buildRPM "awips2-python-tables"
buildRPM "awips2-python-thrift"
buildRPM "awips2-python-tpg"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildJava
buildRPM "awips2"
buildRPM "awips2-python-shapely"
buildRPM "awips2-notification"
exit 0
fi
if [ "${1}" = "-rh6" ]; then
buildRPM "awips2-notification"
buildRPM "awips2-common-base"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-hydroapps-shared"
buildJava
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
buildRPM "awips2-python-nose"
buildRPM "awips2-python-pil"
buildRPM "awips2-python-jimporter"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python-thrift"
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-numpy"
buildRPM "awips2-python-pupynere"
buildRPM "awips2-python-h5py"
buildRPM "awips2-python-matplotlib"
buildRPM "awips2-python-scientific"
buildRPM "awips2-python-scipy"
buildRPM "awips2-python-tables"
buildRPM "awips2-python-pmw"
buildRPM "awips2-python-tpg"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-pycairo"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-shapely"
buildRPM "awips2-ant"
buildRPM "awips2-tools"
buildRPM "awips2-postgres"
buildRPM "awips2-pgadmin3"
unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-httpd-pypies"
buildRPM "awips2-httpd-collaboration"
buildQPID
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-ldm"
buildCAVE
if [ $? -ne 0 ]; then
exit 0
fi
buildRPM "awips2-alertviz"
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-ncep-database"
buildRPM "awips2-adapt-native"
buildRPM "awips2-aviation-shared"
buildRPM "awips2-cli"
buildRPM "awips2-edex-environment"
buildRPM "awips2-data.gfe"
buildRPM "awips2-data.hdf5-gfe.climo"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-groovy"
buildRPM "awips2-localapps-environment"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-pypies"
buildRPM "awips2-rcm"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2"
buildOpenfire
exit 0
fi
if [ "${1}" = "-postgres" ]; then
buildRPM "awips2-postgres"
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-ncep-database"
buildRPM "awips2-pgadmin3"
exit 0
fi
if [ "${1}" = "-delta" ]; then
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-cli"
buildRPM "awips2-data.hdf5-gfe.climo"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildRPM "awips2"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-edex-environment"
buildRPM "awips2-notification"
exit 0
fi
if [ "${1}" = "-full" ]; then
# buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-h5py"
buildRPM "awips2-python-jimporter"
buildRPM "awips2-python-matplotlib"
buildRPM "awips2-python-nose"
buildRPM "awips2-python-numpy"
buildRPM "awips2-python-pil"
buildRPM "awips2-python-pmw"
buildRPM "awips2-python-pupynere"
# buildRPM "awips2-python-qpid"
buildRPM "awips2-python-scientific"
buildRPM "awips2-python-scipy"
buildRPM "awips2-python-tables"
buildRPM "awips2-python-thrift"
buildRPM "awips2-python-tpg"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildRPM "awips2-cli"
buildRPM "awips2-data.hdf5-gfe.climo"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildRPM "awips2"
unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-httpd-pypies"
buildJava
buildRPM "awips2-groovy"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-edex-environment"
buildRPM "awips2-notification"
buildRPM "awips2-python-shapely"
buildRPM "awips2-postgres"
buildRPM "awips2-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-ncep-database"
buildRPM "awips2-pgadmin3"
buildRPM "awips2-ldm"
exit 0
fi
if [ "${1}" = "-ade" ]; then
echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE."
exit 0
buildRPM "awips2-eclipse"
exit 0
fi
if [ "${1}" = "-viz" ]; then
buildRPM "awips2"
buildRPM "awips2-common-base"
buildRPM "awips2-tools"
buildRPM "awips2-cli"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
exit 0
fi
if [ "${1}" = "-edex" ]; then
buildRPM "awips2-common-base"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
fi
if [ "${1}" = "-custom" ]; then
buildQPID
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
fi
if [ "${1}" = "-qpid" ]; then
buildRPM "awips2-python-qpid"
buildQPID
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
fi
if [ "${1}" = "-ldm" ]; then
buildRPM "awips2-ldm"
exit 0
fi
if [ "${1}" = "-package" ]; then
repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
if [ -d ${WORKSPACE}/${repository_directory} ]; then
rm -rf ${WORKSPACE}/${repository_directory}
if [ $? -ne 0 ]; then
exit 1
fi
fi
mkdir -p ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
if [ $? -ne 0 ]; then
exit 1
fi
cp -r ${AWIPSII_TOP_DIR}/RPMS/* \
${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
if [ $? -ne 0 ]; then
exit 1
fi
rpms_directory="${WORKSPACE}/rpms"
comps_xml="${rpms_directory}/common/yum/arch.x86_64/comps.xml"
cp -v ${comps_xml} ${WORKSPACE}/${repository_directory}
if [ $? -ne 0 ]; then
exit 1
fi
pushd . > /dev/null
cd ${WORKSPACE}
tar -cvf ${repository_directory}.tar ${repository_directory}
RC=$?
popd > /dev/null
if [ ${RC} -ne 0 ]; then
exit 1
fi
exit 0
fi
usage
exit 0