Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #225 from dnorgaard-usgs/master
Browse files Browse the repository at this point in the history
for #222 and #224
  • Loading branch information
Diana Norgaard authored Jul 31, 2018
2 parents af1d4b7 + 901f7e3 commit 64727d6
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 59 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
* Addition of map option to hide station icons (#124)
* Add RSAM value of selected wave panel period to status bar (#103)
* Fix issue with streaming failing on loss of data (#142)
* Fix issue using WWS instrument time zone (#201)
* Fix multiple event dialog showing up under Window menu (#216)
* Fix problem parsing server response from CWB (#221)
* Support height metadata for FDSN data source (#222)
* Position real-time wave viewer and RSAM viewer when opening layout (#224)
* Updated WWS Client to 1.3.5

## Version 2.8.5 - July 13, 2018
* Support real-time wave viewer in layouts (#40)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public abstract class AbstractChannelInfo {
*/
public abstract double getLongitude();

/**
* Get the elevation.
*
* @return the elevation.
*/
public abstract double getHeight();

/**
* Get the network name.
*
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/gov/usgs/volcanoes/swarm/ChannelGroupInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ public ChannelGroupInfo(String s, GroupsType groupsType) {
* @param location the location name.
* @param latitude the latitude.
* @param longitude the longitude.
* @param elevation the elevation
* @param siteName the site name.
* @param groupsType groups type.
*/
public ChannelGroupInfo(String station, String channel, String network, String location,
double latitude, double longitude, String siteName, GroupsType groupsType) {
super(station, channel, network, location, latitude, longitude, siteName);
double latitude, double longitude, double elevation, String siteName, GroupsType groupsType) {
super(station, channel, network, location, latitude, longitude, elevation, siteName);
this.groupsType = groupsType;
}

Expand Down
39 changes: 27 additions & 12 deletions src/main/java/gov/usgs/volcanoes/swarm/ChannelInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,28 @@ public ChannelInfo(String s) {
String location = "";
double latitude = Double.NaN;
double longitude = Double.NaN;
double elevation = Double.NaN;

String delimiter = s.indexOf('$') == -1 ? " " : "\\$";
String[] ss = s.split(delimiter);
station = ss[0];
if (ss.length > 2) {
channel = ss[1];
network = ss[2];
if (ss.length > 3) {
location = ss[3];
if (ss.length > 4) {
latitude = StationInfo.parseDouble(ss[4]);
if (ss.length > 5) {
longitude = StationInfo.parseDouble(ss[5]);
}
}
}
}
stationInfo = new StationInfo(station, network, latitude, longitude);
if (ss.length > 3) {
location = ss[3];
}
if (ss.length > 4) {
latitude = StationInfo.parseDouble(ss[4]);
}
if (ss.length > 5) {
longitude = StationInfo.parseDouble(ss[5]);
}
if (ss.length > 6) {
elevation = StationInfo.parseDouble(ss[6]);
}
stationInfo = new StationInfo(station, network, latitude, longitude, elevation);
this.channel = channel;
this.location = location;
formattedSCNL = ChannelUtil.getFormattedSCNL(station, channel, network, location);
Expand All @@ -80,12 +84,14 @@ public ChannelInfo(String s) {
* @param network the network name.
* @param location the location name.
* @param latitude the latitude.
* @param elevation the elevation
* @param longitude the longitude.
* @param siteName the site name.
*/
public ChannelInfo(String station, String channel, String network, String location,
double latitude, double longitude, String siteName) {
this(new StationInfo(station, network, latitude, longitude, siteName), channel, location);
double latitude, double longitude, double elevation, String siteName) {
this(new StationInfo(station, network, latitude, longitude, elevation, siteName), channel,
location);
}

/**
Expand Down Expand Up @@ -177,4 +183,13 @@ public String getStation() {
public StationInfo getStationInfo() {
return stationInfo;
}


/**
* Get elevation.
* @see gov.usgs.volcanoes.swarm.AbstractChannelInfo#getHeight()
*/
public double getHeight() {
return stationInfo.getElevation();
}
}
1 change: 1 addition & 0 deletions src/main/java/gov/usgs/volcanoes/swarm/ChannelUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static String addChannel(List<String> channels, AbstractChannelInfo ch,
Metadata md = SwarmConfig.getInstance().getMetadata(formattedScnl, true);
md.updateLongitude(ch.getLongitude());
md.updateLatitude(ch.getLatitude());
md.updateHeight(ch.getHeight());
for (String g : ch.getGroups()) {
md.addGroup(g);
}
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/gov/usgs/volcanoes/swarm/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,32 +415,6 @@ public int compare(Pair<Double, String> o1, Pair<Double, String> o2) {
};
}

/**
* Find nearest stations to point.
* @param metadata map of metadata
* @param pt point
* @param requireDs true if data source required
* @return list of dance and channels
*/
@Deprecated
public static List<Pair<Double, String>> findNearest(Map<String, Metadata> metadata,
Point2D.Double pt, boolean requireDs) {
ArrayList<Pair<Double, String>> result = new ArrayList<Pair<Double, String>>();
synchronized (metadata) {
for (String key : metadata.keySet()) {
Metadata md = metadata.get(key);
if (md.hasLonLat() && (!requireDs || md.source != null)) {
double d = md.distanceTo(pt);
if (!Double.isNaN(d) && d > 0) {
result.add(new Pair<Double, String>(new Double(d), md.channel));
}
}
}
}
Collections.sort(result, getDistanceComparator());
return result.size() == 0 ? null : result;
}

/**
* Find nearest stations to channel.
* @param metadata map of metadata
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/gov/usgs/volcanoes/swarm/StationInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ public static double parseDouble(String s) {

/** The longitude. */
private final double longitude;

/** The height */
private final double elevation;

/** The site name. */
private final String siteName;

public StationInfo(String station, String network, double latitude, double longitude) {
this(station, network, latitude, longitude, (String) null);
public StationInfo(String station, String network, double latitude, double longitude, double elevation) {
this(station, network, latitude, longitude, elevation, (String) null);
}

/**
Expand All @@ -48,14 +51,15 @@ public StationInfo(String station, String network, double latitude, double longi
* @param network network
* @param latitude latitude
* @param longitude longitude
* @param elevation elevation
* @param siteName name
*/
public StationInfo(String station, String network, double latitude, double longitude,
String siteName) {
public StationInfo(String station, String network, double latitude, double longitude, double elevation, String siteName) {
this.station = station;
this.network = network;
this.latitude = latitude;
this.longitude = longitude;
this.elevation = elevation;
this.siteName = siteName != null ? siteName : station;
}

Expand Down Expand Up @@ -110,6 +114,13 @@ public String getStation() {
* @return the string representation of the station information.
*/
public String toString() {
return station + " " + network + " " + latitude + " " + longitude + " " + siteName;
return station + " " + network + " " + latitude + " " + longitude + " " + elevation + " "+ siteName;
}

/**
* @return the elevation
*/
public double getElevation() {
return elevation;
}
}
8 changes: 6 additions & 2 deletions src/main/java/gov/usgs/volcanoes/swarm/SwarmLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import gov.usgs.volcanoes.swarm.internalFrame.SwarmInternalFrames;
import gov.usgs.volcanoes.swarm.map.MapFrame;
import gov.usgs.volcanoes.swarm.rsam.RsamViewSettings;
import gov.usgs.volcanoes.swarm.rsam.RsamViewerFrame;
import gov.usgs.volcanoes.swarm.wave.MultiMonitor;
import gov.usgs.volcanoes.swarm.wave.SwarmMultiMonitors;
import gov.usgs.volcanoes.swarm.wave.WaveClipboardFrame;
import gov.usgs.volcanoes.swarm.wave.WaveViewPanel;
import gov.usgs.volcanoes.swarm.wave.WaveViewSettings;
import gov.usgs.volcanoes.swarm.wave.WaveViewerFrame;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -234,7 +236,8 @@ private void processWaves() {
String channel = cf.getString("channel");
WaveViewSettings wvs = new WaveViewSettings();
wvs.set(cf);
Swarm.openRealtimeWave(sds, channel, wvs);
WaveViewerFrame wvf = Swarm.openRealtimeWave(sds, channel, wvs);
wvf.processStandardLayout(cf);
}
}

Expand Down Expand Up @@ -291,7 +294,8 @@ private void processRsam() {
String channel = cf.getString("channel");
RsamViewSettings setting = new RsamViewSettings();
setting.set(cf);
Swarm.openRsam(sds, channel, setting);
RsamViewerFrame rf = Swarm.openRsam(sds, channel, setting);
rf.processStandardLayout(cf);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,22 @@ public void close() {
* @param location the location.
* @param latitude the latitude.
* @param longitude the longitude.
* @param elevation the elevation
* @param siteName the site name.
* @param groupsType groups type.
* @return the channel information.
*/
protected ChannelInfo createChannelInfo(String station, String channel, String network,
String location, double latitude, double longitude, String siteName, GroupsType groupsType) {
String location, double latitude, double longitude, double elevation, String siteName,
GroupsType groupsType) {
if (currentStation == null) {
if (clearLatLon()) {
latitude = Double.NaN;
longitude = Double.NaN;
elevation = Double.NaN;
}
return new ChannelGroupInfo(station, channel, network, location, latitude, longitude,
elevation,
siteName, groupsType);
} else {
return new ChannelGroupInfo(currentStation, channel, location, groupsType);
Expand All @@ -272,16 +276,18 @@ protected ChannelInfo createChannelInfo(String station, String channel, String n
* @param network the network.
* @param latitude the latitude.
* @param longitude the longitude.
* @param elevation the elevation
* @param siteName the site name.
* @return the station information.
*/
protected StationInfo createStationInfo(String station, String network, double latitude,
double longitude, String siteName) {
double longitude, double elevation, String siteName) {
if (clearLatLon()) {
latitude = Double.NaN;
longitude = Double.NaN;
elevation = Double.NaN;
}
return new StationInfo(station, network, latitude, longitude, siteName);
return new StationInfo(station, network, latitude, longitude, elevation, siteName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ protected void processLine(String line) {
String station = getColumnText(columns, 1);
double latitude = StationInfo.parseDouble(getColumnText(columns, 2));
double longitude = StationInfo.parseDouble(getColumnText(columns, 3));
double elevation = StationInfo.parseDouble(getColumnText(columns, 4));
String siteName = getColumnText(columns, 5);
processStation(createStationInfo(station, network, latitude, longitude, siteName));
processStation(
createStationInfo(station, network, latitude, longitude, elevation, siteName));
}
break;
case CHANNEL:
Expand All @@ -169,8 +171,13 @@ protected void processLine(String line) {
String siteName = null; // site name is not available
double latitude = StationInfo.parseDouble(getColumnText(columns, 4));
double longitude = StationInfo.parseDouble(getColumnText(columns, 5));
processChannel(createChannelInfo(station, channel, network, location, latitude, longitude,
siteName, groupsType));
double elevation = Double.NaN;
if (columns.length > 6) {
elevation = StationInfo.parseDouble(getColumnText(columns, 6));
}
processChannel(
createChannelInfo(station, channel, network, location, latitude, longitude, elevation,
siteName, groupsType));
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ protected boolean checkSchemaVersion(FDSNStationXML staMessage) {
return true;
}
} catch (Exception ex) {
//
}
LOGGER.warn(
"XM schema of this document ({}) does not match this code ({}) , results may be incorrect.",
Expand Down Expand Up @@ -164,15 +165,16 @@ protected void fetch(URL url) throws Exception {
String station = s.getCode();
double latitude = s.getLatitude().getValue();
double longitude = s.getLongitude().getValue();
double elevation = s.getElevation().getValue();

String siteName = null;
if (s.getSite() != null) {
siteName = s.getSite().getName();
}
switch (getLevel()) {
case STATION:
processStation(createStationInfo(station,

network, latitude, longitude, siteName));
network, latitude, longitude, elevation, siteName));
// break;
// case CHANNEL:
// List<Channel> chanList = s.getChannelList();
Expand All @@ -187,8 +189,7 @@ protected void fetch(URL url) throws Exception {
String location = chan.getLocCode();
String channel = chan.getCode();
processChannel(createChannelInfo(station,

channel, network, location, latitude, longitude, siteName, groupsType));
channel, network, location, latitude, longitude, elevation, siteName, groupsType));
}
// break;
// default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void text(String str) throws Exception {}

private double latitude = Double.NaN;
private double longitude = Double.NaN;
private double elevation = Double.NaN;

private String location;
private String network;
Expand Down Expand Up @@ -234,4 +235,9 @@ public String getStation() {
public String getType() {
return type;
}

@Override
public double getHeight() {
return elevation;
}
}
Loading

0 comments on commit 64727d6

Please sign in to comment.