add WarningLookups, phensigColors.xml, AbstractWWAResource updates to map values to colors

This commit is contained in:
mjames-upc 2018-12-19 11:02:38 -07:00
parent 2fe3758577
commit ddeed72777
6 changed files with 305 additions and 7 deletions

View file

@ -0,0 +1,35 @@
<bundle>
<displayList>
<displays xsi:type="d2DMapRenderableDisplay"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor">
<resource>
<loadProperties loadWithoutData="true">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID" outlineOn="true"
outlineWidth="4" />
<capability xsi:type="colorableCapability" colorAsString="#ffffff" />
</capabilities>
</loadProperties>
<properties isSystemResource="false" isBlinking="false"
isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="wwaResourceData"
isUpdatingOnMetadataOnly="false"
retrieveData="true"
isRequeryNecessaryOnTimeMatch="true" name="Advisories and Warnings">
<metadataMap>
<mapping key="act">
<constraint constraintValue="NEW,CON,CAN,EXP" constraintType="IN" />
</mapping>
<mapping key="pluginName">
<constraint constraintValue="warning" constraintType="EQUALS" />
</mapping>
</metadataMap>
</resourceData>
</resource>
</descriptor>
</displays>
</displayList>
</bundle>

View file

@ -31,7 +31,8 @@
</mapping> </mapping>
<mapping key="pluginName"> <mapping key="pluginName">
<constraint constraintValue="warning" constraintType="EQUALS" /> <constraint constraintValue="warning" constraintType="EQUALS" />
</mapping> </metadataMap> </mapping>
</metadataMap>
</resourceData> </resourceData>
</resource> </resource>
<resource> <resource>

View file

@ -24,6 +24,9 @@
</contribute> </contribute>
<contribute xsi:type="bundleItem" file="bundles/AllWarnings.xml" <contribute xsi:type="bundleItem" file="bundles/AllWarnings.xml"
menuText="All Warnings" id="warnings"> menuText="All Warnings" id="warnings">
</contribute>
<contribute xsi:type="bundleItem" file="bundles/AllAdvisories.xml"
menuText="All Advisories and Warnings" id="warnings">
</contribute> </contribute>
<contribute xsi:type="separator" id="separator4"/> <contribute xsi:type="separator" id="separator4"/>
<contribute xsi:type="bundleItem" file="bundles/Warnings.xml" <contribute xsi:type="bundleItem" file="bundles/Warnings.xml"
@ -45,4 +48,4 @@
menuText="SPC Svr Wx Plot" id="spcWxPlot"> menuText="SPC Svr Wx Plot" id="spcWxPlot">
</contribute> </contribute>
</menuTemplate> </menuTemplate>

View file

@ -20,6 +20,7 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
import com.raytheon.uf.common.dataplugin.warning.EmergencyType; import com.raytheon.uf.common.dataplugin.warning.EmergencyType;
import com.raytheon.uf.common.dataplugin.warning.PracticeWarningRecord; import com.raytheon.uf.common.dataplugin.warning.PracticeWarningRecord;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction; import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.uf.common.dataplugin.warning.util.WarningLookups;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
@ -32,6 +33,7 @@ import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
@ -91,6 +93,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
* Oct 16, 2015 4971 bsteffen Do not reverse order of text. * Oct 16, 2015 4971 bsteffen Do not reverse order of text.
* Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling * Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling
* Aug 22, 2016 5842 dgilling Remove dependency on viz.texteditor plugin. * Aug 22, 2016 5842 dgilling Remove dependency on viz.texteditor plugin.
* Dec 19, 2018 ---- mjames@ucar Added phensig color table lookup.
* *
* </pre> * </pre>
* *
@ -367,6 +370,8 @@ public abstract class AbstractWWAResource extends
entry.project = false; entry.project = false;
} }
RGB displaycolor = RGBColors.getRGBColor(getColor(record));
if (entry != null && entry.wireframeShape != null) { if (entry != null && entry.wireframeShape != null) {
LineStyle lineStyle = LineStyle.SOLID; LineStyle lineStyle = LineStyle.SOLID;
if (record.getProductClass() != null if (record.getProductClass() != null
@ -383,7 +388,7 @@ public abstract class AbstractWWAResource extends
target.drawWireframeShape( target.drawWireframeShape(
entry.wireframeShape, entry.wireframeShape,
getCapability(ColorableCapability.class).getColor(), displaycolor,
outlineWidth, lineStyle); outlineWidth, lineStyle);
} else if (entry != null && entry.shadedShape != null) { } else if (entry != null && entry.shadedShape != null) {
target.drawShadedShape(entry.shadedShape, 1); target.drawShadedShape(entry.shadedShape, 1);
@ -406,6 +411,7 @@ public abstract class AbstractWWAResource extends
double mapWidth = descriptor.getMapWidth() double mapWidth = descriptor.getMapWidth()
* paintProps.getZoomLevel() / 1000; * paintProps.getZoomLevel() / 1000;
String[] textToPrint = getText(record, mapWidth); String[] textToPrint = getText(record, mapWidth);
if (warningsFont == null) { if (warningsFont == null) {
warningsFont = target.initializeFont(target warningsFont = target.initializeFont(target
.getDefaultFont().getFontName(), 9, .getDefaultFont().getFontName(), 9,
@ -414,8 +420,7 @@ public abstract class AbstractWWAResource extends
12); 12);
} }
DrawableString params = new DrawableString(textToPrint, DrawableString params = new DrawableString(textToPrint, displaycolor);
color);
params.font = warningsFont; params.font = warningsFont;
params.setCoordinates(d[0], d[1]); params.setCoordinates(d[0], d[1]);
params.horizontalAlignment = HorizontalAlignment.RIGHT; params.horizontalAlignment = HorizontalAlignment.RIGHT;
@ -428,7 +433,7 @@ public abstract class AbstractWWAResource extends
// moves over text to add EMER in a different font // moves over text to add EMER in a different font
textToPrint[1] = String.format("%1$-23" + "s", textToPrint[1] = String.format("%1$-23" + "s",
textToPrint[1]); textToPrint[1]);
params.setText(textToPrint, color); params.setText(textToPrint, displaycolor);
DrawableString emergencyString = new DrawableString( DrawableString emergencyString = new DrawableString(
params); params);
@ -436,7 +441,7 @@ public abstract class AbstractWWAResource extends
d[1] + (paintProps.getZoomLevel()) * 90); d[1] + (paintProps.getZoomLevel()) * 90);
emergencyString.font = emergencyFont; emergencyString.font = emergencyFont;
emergencyString.setText(new String[] { "", "", emergencyString.setText(new String[] { "", "",
" " + EmergencyType.EMER, "" }, color); " " + EmergencyType.EMER, "" }, displaycolor);
target.drawStrings(emergencyString); target.drawStrings(emergencyString);
} }
@ -591,6 +596,12 @@ public abstract class AbstractWWAResource extends
addRecord(sort(pdos)); addRecord(sort(pdos));
} }
protected String getColor(AbstractWarningRecord record){
String phensig = record.getPhensig();
WarningLookups lookup = new WarningLookups();
return lookup.getPhensig(phensig).color;
}
protected String[] getText(AbstractWarningRecord record, double mapWidth) { protected String[] getText(AbstractWarningRecord record, double mapWidth) {
String vid = record.getPhensig(); String vid = record.getPhensig();
String phen = record.getPhen(); String phen = record.getPhen();

View file

@ -0,0 +1,139 @@
package com.raytheon.uf.common.dataplugin.warning.util;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Class for looking up phensig info for warnings/advisories.
*
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- --------- --------------------------------------------
* Dec 19, 2018 mjames Initial creation
*
* </pre>
*
* @author mjames
*/
public class WarningLookups {
private static final IUFStatusHandler theHandler = UFStatus.getHandler(WarningLookups.class);
private static final String LOOKUP_DIR = "warngen";
public static class PhensigValue {
public PhensigValue() {}
public PhensigValue(String name, String color) {
this.name = name;
this.color = color;
}
@XmlAttribute
public String name;
@XmlAttribute
public String color;
}
@XmlAccessorType(XmlAccessType.NONE)
public static abstract class AbstractLookup<K, V> {
public abstract Map<K, V> getMap();
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class PhensigColors extends
AbstractLookup<String, PhensigValue> {
public HashMap<String, PhensigValue> map = new HashMap<>();
@Override
public Map<String, PhensigValue> getMap() {
return map;
}
}
private PhensigColors phensigColorLookup;
public WarningLookups() {
try {
init();
} catch (Exception e) {
theHandler.error("Failed to initialize lookups", e);
}
}
private void init() throws Exception {
JAXBContext context = JAXBContext.newInstance(PhensigColors.class);
Unmarshaller u = context.createUnmarshaller();
phensigColorLookup = load(new PhensigColors(), "phensigColors.xml", u);
}
private static <T extends AbstractLookup<K, V>, K, V> T load(
T combinedLookup, String fileName, Unmarshaller u) {
IPathManager pm = PathManagerFactory.getPathManager();
List<LocalizationContext> contexts = Arrays.asList(pm
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC));
Collections.reverse(contexts);
for (LocalizationContext ctx : contexts) {
File f = pm.getFile(ctx, LOOKUP_DIR + IPathManager.SEPARATOR + fileName);
if (f != null && f.isFile()) {
try {
@SuppressWarnings("unchecked")
T lookup = (T) u.unmarshal(f);
if (!combinedLookup.getClass().isAssignableFrom(
lookup.getClass())) {
throw new Exception(String.format(
"file contains %s' expected %s",
lookup.getClass(), combinedLookup.getClass()));
}
combinedLookup.getMap().putAll(lookup.getMap());
} catch (Exception e) {
theHandler.error(
String.format("%s: %s", f, e.getMessage()), e);
}
}
}
return combinedLookup;
}
public PhensigValue getPhensig(String phensigCode) {
return phensigColorLookup.map.get(phensigCode);
}
private static WarningLookups instance;
public static synchronized WarningLookups getInstance() {
if (instance == null)
instance = new WarningLookups();
return instance;
}
public static synchronized void reload() {
instance = new WarningLookups();
}
}

View file

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<phensigColors>
<map>
<entry><key>AF.W</key><value color="gray" name="Ashfall Warning"></value></entry>
<entry><key>AF.Y</key><value color="gray" name="Ashfall Advisory"></value></entry>
<entry><key>AQ.Y</key><value color="gray" name="Air Quality Alert"></value></entry>
<entry><key>AS.O</key><value color="gray" name="Air Stagnation Outlook"></value></entry>
<entry><key>AS.Y</key><value color="gray" name="Air Stagnation Advisory"></value></entry>
<entry><key>BH.S</key><value color="turquoise" name="Beach Hazards Statement"></value></entry>
<entry><key>BW.Y</key><value color="thistle" name="Brisk Wind Advisory"></value></entry>
<entry><key>BZ.A</key><value color="greenyellow" name="Blizzard Watch"></value></entry>
<entry><key>BZ.W</key><value color="orangered" name="Blizzard Warning"></value></entry>
<entry><key>CF.A</key><value color="mediumaquamarine" name="Coastal Flood Watch"></value></entry>
<entry><key>CF.W</key><value color="forestgreen" name="Coastal Flood Warning"></value></entry>
<entry><key>CF.Y</key><value color="lawngreen" name="Coastal Flood Advisory"></value></entry>
<entry><key>CF.S</key><value color="olivedrab" name="Coastal Flood Statement"></value></entry>
<entry><key>DS.W</key><value color="bisque" name="Dust Storm Warning"></value></entry>
<entry><key>DU.Y</key><value color="darkkhaki" name="Blowing Dust Advisory"></value></entry>
<entry><key>EC.A</key><value color="blue" name="Extreme Cold Watch"></value></entry>
<entry><key>EC.W</key><value color="blue" name="Extreme Cold Warning"></value></entry>
<entry><key>EH.A</key><value color="maroon" name="Excessive Heat Watch"></value></entry>
<entry><key>EH.W</key><value color="mediumvioletred" name="Excessive Heat Warning"></value></entry>
<entry><key>EW.W</key><value color="deeppink" name="Excessive Wind Warning"></value></entry>
<entry><key>FA.A</key><value color="seagreen" name="Flood Watch"></value></entry>
<entry><key>FA.W</key><value color="seagreen" name="Areal Flood Warning"></value></entry>
<entry><key>FA.Y</key><value color="seagreen" name="Areal Flood Advisory"></value></entry>
<entry><key>FF.A</key><value color="limegreen" name="Flash Flood Watch"></value></entry>
<entry><key>FF.S</key><value color="yellowgreen" name="Flash Flood Statement"></value></entry>
<entry><key>FF.W</key><value color="darkred" name="Flash Flood Warning"></value></entry>
<entry><key>FG.Y</key><value color="slategray" name="Dense Fog Advisory"></value></entry>
<entry><key>FL.A</key><value color="seagreen" name="Flood Watch"></value></entry>
<entry><key>FL.W</key><value color="green" name="Flood Warning"></value></entry>
<entry><key>HY.S</key><value color="#00ff7f" name="Hydrological Statement"></value></entry>
<entry><key>FL.S</key><value color="#00ff7f" name="Flood Statement"></value></entry>
<entry><key>FL.Y</key><value color="#00ff7f" name="Flood Advisory"></value></entry>
<entry><key>FR.Y</key><value color="cornflowerblue" name="Frost Advisory"></value></entry>
<entry><key>FW.A</key><value color="navajowhite" name="Fire Weather Watch"></value></entry>
<entry><key>FW.W</key><value color="deeppink" name="Red Flag Warning"></value></entry>
<entry><key>FZ.A</key><value color="royalblue" name="Freeze Watch"></value></entry>
<entry><key>FZ.W</key><value color="cyan" name="Freeze Warning"></value></entry>
<entry><key>GL.A</key><value color="pink" name="Gale Watch"></value></entry>
<entry><key>GL.W</key><value color="#dda0dd" name="Gale Warning"></value></entry>
<entry><key>HF.A</key><value color="darkorchid" name="Hurricane Force Wind Watch"></value></entry>
<entry><key>HF.W</key><value color="#cd5c5c" name="Hurricane Force Wind Warning"></value></entry>
<entry><key>HT.Y</key><value color="#ff7f4e" name="Heat Advisory"></value></entry>
<entry><key>HU.A</key><value color="#ff00ff" name="Hurricane Watch"></value></entry>
<entry><key>HU.S</key><value color="yellow" name="Hurricane Statement"></value></entry>
<entry><key>HU.W</key><value color="#dc143c" name="Hurricane Warning"></value></entry>
<entry><key>HW.A</key><value color="darkgoldenrod" name="High Wind Watch"></value></entry>
<entry><key>HW.W</key><value color="goldenrod" name="High Wind Warning"></value></entry>
<entry><key>HZ.A</key><value color="royalblue" name="Hard Freeze Watch"></value></entry>
<entry><key>HZ.W</key><value color="blue" name="Hard Freeze Warning"></value></entry>
<entry><key>IS.W</key><value color="darkmagenta" name="Ice Storm Warning"></value></entry>
<entry><key>LE.A</key><value color="LightSkyBlue" name="Lake Effect Snow Watch"></value></entry>
<entry><key>LE.W</key><value color="DarkCyan" name="Lake Effect Snow Warning"></value></entry>
<entry><key>LE.Y</key><value color="MediumTurquoise" name="Lake Effect Snow Advisory"></value></entry>
<entry><key>LO.Y</key><value color="maroon" name="Low Water Advisory"></value></entry>
<entry><key>LS.A</key><value color="MediumAquaMarine" name="Lakeshore Flood Watch"></value></entry>
<entry><key>LS.S</key><value color="lawngreen" name="Lakeshore Flood Statement"></value></entry>
<entry><key>LS.W</key><value color="forestgreen" name="Lakeshore Flood Warning"></value></entry>
<entry><key>LS.Y</key><value color="lawngreen" name="Lakeshore Flood Advisory"></value></entry>
<entry><key>LW.Y</key><value color="tan" name="Lake Wind Advisory"></value></entry>
<entry><key>MA.A</key><value color="peachpuff" name="Special Marine Advisory"></value></entry>
<entry><key>MA.S</key><value color="peachpuff" name="Special Marine Statement"></value></entry>
<entry><key>MA.W</key><value color="palevioletred" name="Special Marine Warning"></value></entry>
<entry><key>MF.Y</key><value color="slategray" name="Dense Fog Advisory"></value></entry>
<entry><key>MH.W</key><value color="darkgray" name="Ashfall Warning"></value></entry>
<entry><key>MH.Y</key><value color="dimgray" name="Ashfall Advisory"></value></entry>
<entry><key>MS.Y</key><value color="khaki" name="Dense Smoke Advisory"></value></entry>
<entry><key>RB.Y</key><value color="thistle" name="Small Craft Advisory for rough bar"></value></entry>
<entry><key>RP.S</key><value color="turquoise" name="High Rip Current Risk"></value></entry>
<entry><key>SC.Y</key><value color="thistle" name="Small Craft Advisory"></value></entry>
<entry><key>SE.A</key><value color="darkslateblue" name="Hazardous Seas Watch"></value></entry>
<entry><key>SE.W</key><value color="thistle" name="Hazardous Seas Warning"></value></entry>
<entry><key>SI.Y</key><value color="thistle" name="Small Craft Advisory for winds"></value></entry>
<entry><key>SM.Y</key><value color="khaki" name="Dense Smoke Advisory"></value></entry>
<entry><key>SR.A</key><value color="violet" name="Storm Watch"></value></entry>
<entry><key>SR.W</key><value color="darkorchid" name="Storm Warning"></value></entry>
<entry><key>SS.A</key><value color="#DB7FF7" name="Storm Surge Watch"></value></entry>
<entry><key>SS.W</key><value color="#B524F7" name="Storm Surge Warning"></value></entry>
<entry><key>SU.W</key><value color="forestgreen" name="High Surf Warning"></value></entry>
<entry><key>SU.Y</key><value color="mediumorchid" name="High Surf Advisory"></value></entry>
<entry><key>SV.A</key><value color="palevioletred" name="Severe Thunderstorm Watch"></value></entry>
<entry><key>SV.S</key><value color="aqua" name="Severe Weather Statement"></value></entry>
<entry><key>SV.W</key><value color="orange" name="Severe Thunderstorm Warning"></value></entry>
<entry><key>SW.Y</key><value color="thistle" name="Small Craft Advisory for hazardous seas"></value></entry>
<entry><key>TO.A</key><value color="yellow" name="Tornado Watch"></value></entry>
<entry><key>TO.W</key><value color="red" name="Tornado Warning"></value></entry>
<entry><key>TR.A</key><value color="#f08080" name="Tropical Storm Watch"></value></entry>
<entry><key>TR.W</key><value color="#b22222" name="Tropical Storm Warning"></value></entry>
<entry><key>TS.A</key><value color="fuchsia" name="Tsunami Watch"></value></entry>
<entry><key>TS.W</key><value color="#FD6347" name="Tsunami Warning"></value></entry>
<entry><key>TS.Y</key><value color="chocolate" name="Tsunami Advisory"></value></entry>
<entry><key>TY.A</key><value color="fuchsia" name="Typhoon Watch"></value></entry>
<entry><key>TY.W</key><value color="#FD6347" name="Typhoon Warning"></value></entry>
<entry><key>UP.A</key><value color="RosyBrown" name="Heavy Freezing Spray Watch"></value></entry>
<entry><key>UP.W</key><value color="#00C0FF" name="Heavy Freezing Spray Warning"></value></entry>
<entry><key>UP.Y</key><value color="#00C0FF" name="Freezing Spray Advisory"></value></entry>
<entry><key>WC.A</key><value color="cadetblue" name="Wind Chill Watch"></value></entry>
<entry><key>WC.W</key><value color="lightsteelblue" name="Wind Chill Warning"></value></entry>
<entry><key>WC.Y</key><value color="paleturquoise" name="Wind Chill Advisory"></value></entry>
<entry><key>WI.Y</key><value color="tan" name="Wind Advisory"></value></entry>
<entry><key>WS.A</key><value color="#4682b4" name="Winter Storm Watch"></value></entry>
<entry><key>WS.W</key><value color="hotpink" name="Winter Storm Warning"></value></entry>
<entry><key>WW.Y</key><value color="#7b68ee" name="Winter Weather Advisory"></value></entry>
<entry><key>ZF.Y</key><value color="teal" name="Freezing Fog Advisory"></value></entry>
<entry><key>ZR.Y</key><value color="orchid" name="Freezing Rain Advisory"></value></entry>
</map>
</phensigColors>