VLab Issue #10352 - Fixed incorrect aviation labels; fixes #10352

Change-Id: Ifcaba656c345706576c7a24733b3f668632a8276

Former-commit-id: e6e340859ce63160f513c875f4bc4f82f58de035
This commit is contained in:
Bingfan Yin 2015-08-27 09:54:20 -04:00
parent 77b4ce8a0b
commit a76cf01fe0
4 changed files with 92 additions and 15 deletions

View file

@ -12,6 +12,7 @@ Import-Package: com.raytheon.uf.common.dataplugin,
com.raytheon.uf.viz.core.drawables,
com.raytheon.uf.viz.core.exception,
com.raytheon.uf.viz.core.map,
com.raytheon.uf.viz.core.point.display,
com.raytheon.uf.viz.core.rsc,
com.raytheon.uf.viz.core.rsc.capabilities,
com.vividsolutions.jts.algorithm,

View file

@ -33,7 +33,6 @@ import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.Polygon;
/**
*
* A class containing all parameters necessary for an outline resource to be
@ -45,6 +44,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 2, 2009 bsteffen Initial creation
* Jul 7, 2015 10352 byin Added labelSymbolId
*
* </pre>
*
@ -76,6 +76,8 @@ public class AdvisoryRecord {
private String label;
private char labelSymbolId = 0;
private String inspectString;
public AdvisoryRecord(Coordinate labelLoc, String label) {
@ -202,8 +204,7 @@ public class AdvisoryRecord {
* @return a new Coordinate at the correct location
*/
public static Coordinate getPointOnCircle(Coordinate center,
double distance,
double angle) {
double distance, double angle) {
while (angle > 180) {
angle -= 360;
}
@ -268,5 +269,12 @@ public class AdvisoryRecord {
return inspectString;
}
public char getLabelSymbolId() {
return labelSymbolId;
}
public void setLabelSymbolId(char labelSymbolId) {
this.labelSymbolId = labelSymbolId;
}
}

View file

@ -47,6 +47,9 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 2, 2009 bsteffen Initial creation
* Jul 7, 2015 10352 byin Display symbols for turb/icing
* and hazard types for IFR/MTOS
*
*
* </pre>
*
@ -56,14 +59,28 @@ import com.vividsolutions.jts.geom.Coordinate;
@XmlAccessorType(XmlAccessType.NONE)
public class AirmetDataAdapter extends AbstractAdvisoryDataAdapter {
private static final String LABEL_FORMAT = "%d%s";
private static final String INSPECT_FORMAT = "Valid UNTIL %02d%02d%02d\n%s";
private static final String REPORT_INDICATOR = "AIRMET";
private static final String SEGMENT_SEPERATOR = "\n. \n";
private static final String TURBULENCE_TYPE = "TURBULENCE";
private static final String ICING_TYPE = "ICING";
private static final String IFR_TYPE = "INSTRUMENT FLIGHT RULES";
private static final String MTN_TYPE = "MOUNTAIN OBSCURATION";
private static final String IFR_LABEL = "IFR";
private static final String MTN_LABEL = "MTOS";
protected static final char TURBULENCE_SYMBOL = '\u007b';
protected static final char ICING_SYMBOL = '\u007e';
private static final float LINE_WIDTH = 1.5f;
private static final LineStyle LINE_STYLE = LineStyle.SOLID;
@ -111,7 +128,6 @@ public class AirmetDataAdapter extends AbstractAdvisoryDataAdapter {
coords[loc.getIndex() - 1] = new Coordinate(loc.getLongitude(),
loc.getLatitude());
}
int updateNumber = parent.getUpdateNumber();
String sequenceId = report.getSequenceID();
if (sequenceId == null) {
sequenceId = "";
@ -134,11 +150,30 @@ public class AirmetDataAdapter extends AbstractAdvisoryDataAdapter {
} else {
segment = "";
}
String label = String.format(LABEL_FORMAT, updateNumber, sequenceId);
String inspectString = String.format(INSPECT_FORMAT, day, hour, min,
segment);
String hazType = report.getHazardType();
;
String label;
if (hazType.equalsIgnoreCase(IFR_TYPE)) {
label = IFR_LABEL;
} else if (hazType.equalsIgnoreCase(MTN_TYPE)) {
label = MTN_LABEL;
} else {
label = "";
}
AdvisoryRecord aRecord = new AdvisoryRecord(coords, label,
inspectString);
if (hazType.equalsIgnoreCase(ICING_TYPE)) {
aRecord.setLabelSymbolId(ICING_SYMBOL);
} else if (hazType.equalsIgnoreCase(TURBULENCE_TYPE)) {
aRecord.setLabelSymbolId(TURBULENCE_SYMBOL);
}
return aRecord;
}

View file

@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
@ -42,12 +43,15 @@ import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.point.display.SymbolLoader;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -75,6 +79,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Jun 13, 2011 9758 cjeanbap Set colorString of AdvisoryResourceData.
* Aug 14, 2014 3523 mapeters Updated deprecated {@link DrawableString#textStyle}
* assignments.
* Jul 7, 2015 10352 byin Added SymbolLoader to plot symbols
* </pre>
*
* @author bsteffen
@ -101,6 +106,8 @@ public class AdvisoryResource extends
private float magnification;
private SymbolLoader symbolLoader;
protected AdvisoryResource(AdvisoryResourceData resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
@ -188,6 +195,7 @@ public class AdvisoryResource extends
font.dispose();
}
this.font = target.initializeFont("Monospace", 10, new Style[] {});
this.symbolLoader = new SymbolLoader();
}
@Override
@ -209,6 +217,7 @@ public class AdvisoryResource extends
}
this.displayedDataTime = curDataTime;
double scale[] = getScale(paintProps);
if (mainShape == null || dottedShape == null || dashedShape == null) {
clearShapes();
@ -283,6 +292,21 @@ public class AdvisoryResource extends
RGB[] colors = new RGB[labels.length];
Arrays.fill(colors, color);
double x = pixelLoc[0];
double y = pixelLoc[1];
if (record.getLabelSymbolId() != 0) {
IImage symbolImg = symbolLoader.getImage(target, color,
(char) record.getLabelSymbolId());
Coordinate ul = new Coordinate(x, y);
Coordinate ur = new Coordinate(x + 12 * scale[0], y);
Coordinate lr = new Coordinate(ur.x, y + 12 * scale[1]);
Coordinate ll = new Coordinate(x, lr.y);
PixelCoverage extent = new PixelCoverage(ul, ur, lr, ll);
target.drawRaster(symbolImg, extent, paintProps);
}
DrawableString dStrings = new DrawableString(labels, colors);
dStrings.font = font;
dStrings.setCoordinates(pixelLoc[0], pixelLoc[1]);
@ -418,4 +442,13 @@ public class AdvisoryResource extends
clearShapes();
}
private double[] getScale(PaintProperties paintProps) {
IExtent extent = paintProps.getView().getExtent();
Rectangle canvasBounds = paintProps.getCanvasBounds();
double[] scale = new double[2];
scale[0] = extent.getWidth() / canvasBounds.width;
scale[1] = extent.getHeight() / canvasBounds.height;
return scale;
}
}