Merge branch '9-Wes2Bridge' of ssh://lightning:29418/thunder into 9-Wes2Bridge
Former-commit-id:f1e81b1a95
[formerlyf1e81b1a95
[formerly f0c0e0692dae0ee53a43b714be9dfb6df0f4c7a6]] Former-commit-id:dcc3c7bb59
Former-commit-id:240c3a1806
This commit is contained in:
commit
64c328e151
2 changed files with 768 additions and 728 deletions
|
@ -19,6 +19,10 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.common.dataplugin.airep;
|
package com.raytheon.uf.common.dataplugin.airep;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -62,6 +66,8 @@ import com.vividsolutions.jts.geom.Geometry;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 20080103 384 jkorman Initial Coding.
|
* 20080103 384 jkorman Initial Coding.
|
||||||
* 20080107 720 jkorman remove default assignments from attributes.
|
* 20080107 720 jkorman remove default assignments from attributes.
|
||||||
|
* 20120405 435 dgilling Prevent NullPointerExceptions in
|
||||||
|
* buildMessageData().
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author jkorman
|
* @author jkorman
|
||||||
|
@ -571,66 +577,75 @@ public class AirepRecord extends PluginDataObject implements ISpatialEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildMessageData() {
|
private String buildMessageData() {
|
||||||
String s = "";
|
boolean validLocation = (location != null);
|
||||||
|
|
||||||
String lat = String.valueOf(location.getLatitude());
|
StringBuilder messageData = new StringBuilder("ARP ");
|
||||||
String lon = String.valueOf(location.getLongitude());
|
if (validLocation && getStationId() != null) {
|
||||||
String latDir = location.getLatitude() > 0 ? "N" : "S";
|
messageData.append(getStationId());
|
||||||
String lonDir = location.getLongitude() > 0 ? "E" : "W";
|
|
||||||
String hour = "";
|
|
||||||
String minute = "";
|
|
||||||
if (timeObs != null) {
|
|
||||||
hour = String.valueOf(timeObs.get(Calendar.HOUR_OF_DAY));
|
|
||||||
minute = String.valueOf(timeObs.get(Calendar.MINUTE));
|
|
||||||
}
|
}
|
||||||
String flightLevel = String.valueOf((int) ftToHft.convert(location
|
messageData.append(' ');
|
||||||
.getFlightLevel()));
|
|
||||||
String wind = windDirection != null && windSpeed != null ? String
|
if ((validLocation) && (!Double.isNaN(getLatitude()))
|
||||||
.valueOf(windDirection.intValue())
|
&& (!Double.isNaN(getLongitude()))) {
|
||||||
+ "/"
|
messageData.append(formatLatLon(getLatitude(), true));
|
||||||
+ String.valueOf(windSpeed.intValue()) + "KT" : "";
|
messageData.append(' ');
|
||||||
// String wx = flightWeather != null? WX_MAP.get(flightWeather) : "";
|
messageData.append(formatLatLon(getLongitude(), false));
|
||||||
lat = formatLatLon(lat);
|
messageData.append(' ');
|
||||||
lon = formatLatLon(lon);
|
}
|
||||||
String temperature = "";
|
|
||||||
|
if (timeObs != null) {
|
||||||
|
DateFormat df = new SimpleDateFormat("HHmm");
|
||||||
|
messageData.append(df.format(timeObs.getTime()));
|
||||||
|
}
|
||||||
|
messageData.append(" F");
|
||||||
|
|
||||||
|
if (validLocation && getFlightLevel() != null) {
|
||||||
|
int flightLevel = (int) ftToHft.convert(getFlightLevel());
|
||||||
|
messageData.append(flightLevel);
|
||||||
|
}
|
||||||
|
messageData.append(' ');
|
||||||
|
|
||||||
if (temp != null) {
|
if (temp != null) {
|
||||||
if (temp > 0) {
|
if (temp > 0) {
|
||||||
temperature = "P" + temp.intValue();
|
messageData.append('P');
|
||||||
} else {
|
} else {
|
||||||
temperature = "M"
|
messageData.append('M');
|
||||||
+ String.valueOf(temp.intValue()).substring(1);
|
|
||||||
}
|
}
|
||||||
|
messageData.append(Math.abs(temp.intValue()));
|
||||||
}
|
}
|
||||||
if (hour.length() < 2) {
|
messageData.append(' ');
|
||||||
hour = "0" + hour;
|
|
||||||
|
if ((windDirection != null) && (windSpeed != null)) {
|
||||||
|
messageData.append(windDirection.intValue());
|
||||||
|
messageData.append('/');
|
||||||
|
messageData.append(windSpeed.intValue());
|
||||||
|
messageData.append("KT");
|
||||||
}
|
}
|
||||||
if (minute.length() < 2) {
|
messageData.append("TB");
|
||||||
minute = "0" + minute;
|
|
||||||
}
|
return messageData.toString();
|
||||||
s = "ARP " + location.getStationId() + " " + lat + latDir + " " + lon
|
|
||||||
+ lonDir + " " + hour + minute + " F" + flightLevel + " "
|
|
||||||
+ temperature + " " + wind + "TB";
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatLatLon(String str) {
|
private String formatLatLon(double value, boolean isLatitude) {
|
||||||
str = str.startsWith("-") ? str.substring(1) : str;
|
char dir;
|
||||||
|
if (isLatitude) {
|
||||||
int decimalIndex = str.indexOf(".");
|
if (value > 0) {
|
||||||
|
dir = 'N';
|
||||||
if (decimalIndex != -1) {
|
} else {
|
||||||
String temp = str.substring(decimalIndex + 1);
|
dir = 'S';
|
||||||
if (temp.length() > 3) {
|
}
|
||||||
temp = temp.substring(0, 3);
|
} else {
|
||||||
} else if (temp.length() != 3) {
|
if (value > 0) {
|
||||||
while (temp.length() != 3) {
|
dir = 'E';
|
||||||
temp += "0";
|
} else {
|
||||||
}
|
dir = 'W';
|
||||||
}
|
}
|
||||||
str = str.substring(0, decimalIndex) + temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
DecimalFormat df = new DecimalFormat("###.000");
|
||||||
|
df.setRoundingMode(RoundingMode.DOWN);
|
||||||
|
|
||||||
|
return df.format(Math.abs(value)) + dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue