diff --git a/CHANGES.md b/CHANGES.md index 8e114be6..ef6b00a1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,10 @@ * 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) + * Updated WWS Client to 1.3.5 ## Version 2.8.5 - July 13, 2018 * Support real-time wave viewer in layouts (#40) diff --git a/src/main/java/gov/usgs/volcanoes/swarm/AbstractChannelInfo.java b/src/main/java/gov/usgs/volcanoes/swarm/AbstractChannelInfo.java index bbfc0f17..243e04f6 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/AbstractChannelInfo.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/AbstractChannelInfo.java @@ -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. * diff --git a/src/main/java/gov/usgs/volcanoes/swarm/ChannelGroupInfo.java b/src/main/java/gov/usgs/volcanoes/swarm/ChannelGroupInfo.java index 5855f35b..c7e6895c 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/ChannelGroupInfo.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/ChannelGroupInfo.java @@ -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; } diff --git a/src/main/java/gov/usgs/volcanoes/swarm/ChannelInfo.java b/src/main/java/gov/usgs/volcanoes/swarm/ChannelInfo.java index 0b75db89..81cdc1e1 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/ChannelInfo.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/ChannelInfo.java @@ -49,6 +49,7 @@ 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); @@ -56,17 +57,20 @@ public ChannelInfo(String s) { 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); @@ -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); } /** @@ -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(); + } } diff --git a/src/main/java/gov/usgs/volcanoes/swarm/ChannelUtil.java b/src/main/java/gov/usgs/volcanoes/swarm/ChannelUtil.java index 26836a4c..9842d29a 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/ChannelUtil.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/ChannelUtil.java @@ -36,6 +36,7 @@ public static String addChannel(List 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); } diff --git a/src/main/java/gov/usgs/volcanoes/swarm/Metadata.java b/src/main/java/gov/usgs/volcanoes/swarm/Metadata.java index e0b81e56..ab064283 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/Metadata.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/Metadata.java @@ -415,32 +415,6 @@ public int compare(Pair o1, Pair 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> findNearest(Map metadata, - Point2D.Double pt, boolean requireDs) { - ArrayList> result = new ArrayList>(); - 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(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 diff --git a/src/main/java/gov/usgs/volcanoes/swarm/StationInfo.java b/src/main/java/gov/usgs/volcanoes/swarm/StationInfo.java index c499c588..328487d4 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/StationInfo.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/StationInfo.java @@ -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); } /** @@ -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; } @@ -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; } } diff --git a/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/AbstractWebServiceStationClient.java b/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/AbstractWebServiceStationClient.java index 32f17a21..29db9d47 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/AbstractWebServiceStationClient.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/AbstractWebServiceStationClient.java @@ -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); @@ -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); } /** diff --git a/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationTextClient.java b/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationTextClient.java index 95041d59..8b2a6001 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationTextClient.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationTextClient.java @@ -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: @@ -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: diff --git a/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationXmlClient.java b/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationXmlClient.java index b3d36905..2af43868 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationXmlClient.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/data/fdsnWs/WebServiceStationXmlClient.java @@ -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.", @@ -164,6 +165,8 @@ 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(); @@ -171,8 +174,7 @@ protected void fetch(URL url) throws Exception { switch (getLevel()) { case STATION: processStation(createStationInfo(station, - - network, latitude, longitude, siteName)); + network, latitude, longitude, elevation, siteName)); // break; // case CHANNEL: // List chanList = s.getChannelList(); @@ -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: diff --git a/src/main/java/gov/usgs/volcanoes/swarm/data/seedlink/SeedLinkChannelInfo.java b/src/main/java/gov/usgs/volcanoes/swarm/data/seedlink/SeedLinkChannelInfo.java index 487f6ef5..d1f9be6b 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/data/seedlink/SeedLinkChannelInfo.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/data/seedlink/SeedLinkChannelInfo.java @@ -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; @@ -234,4 +235,9 @@ public String getStation() { public String getType() { return type; } + + @Override + public double getHeight() { + return elevation; + } } diff --git a/src/main/java/gov/usgs/volcanoes/swarm/map/MapMiniPanel.java b/src/main/java/gov/usgs/volcanoes/swarm/map/MapMiniPanel.java index 8d7f3662..f88200cd 100644 --- a/src/main/java/gov/usgs/volcanoes/swarm/map/MapMiniPanel.java +++ b/src/main/java/gov/usgs/volcanoes/swarm/map/MapMiniPanel.java @@ -511,6 +511,7 @@ public String getLabel() { } /** + * Paint. * @see javax.swing.JComponent#paint(java.awt.Graphics) */ public void paint(Graphics g) { @@ -553,6 +554,7 @@ protected void determineSelection(MouseEvent e) { } /** + * Mouse clicked event. * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent e) { @@ -587,11 +589,17 @@ public void setSelected(boolean b) { } /** + * Mouse entered event. * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) */ public void mouseEntered(MouseEvent e) { - MapFrame.getInstance().setStatusText( - activeMetadata.getSCNL().station + ": " + GeoUtils.lonLatToString(activeMetadata.getLonLat())); + String text = + activeMetadata.getSCNL().station + ": " + + GeoUtils.lonLatToString(activeMetadata.getLonLat()); + if (!Double.isNaN(activeMetadata.getHeight()) && activeMetadata.getHeight() != -999.0) { + text += ", " + activeMetadata.getHeight() + " m"; + } + MapFrame.getInstance().setStatusText(text); // setTitleBackground(MOUSEOVER_BACKGROUND); // parent.setSelectedPanel(this); } @@ -607,6 +615,7 @@ public void mouseExited(MouseEvent e) { private int deltaY; /** + * Mouse pressed event. * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent e) { @@ -622,6 +631,7 @@ public void mousePressed(MouseEvent e) { } /** + * Mouse released event. * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent e) { @@ -659,6 +669,7 @@ public void adjustLine() { } /** + * Mouse dragged event. * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) */ public void mouseDragged(MouseEvent e) {