Interactive interface for browsing global, full-resolution satellite imagery
WV-2093 Implement EONET's Magnitude field in Events (#3823)
Jason Hurley7643a168ef66
diff --git a/web/css/events.css b/web/css/events.cssindex 0ecd4e141..b2accf0a2 100644--- a/web/css/events.css+++ b/web/css/events.css@@ -89,14 +89,20 @@.map-item-list li.item p {color: #666;-}-.map-item-list li.item p a {- display: block;- clear: both;- margin: 4px 0 6px;- position: relative;- padding-left: 15px;+ &.magnitude {+ display: inline-block;+ margin-left: 5px;+ padding: 0;+ }++ a {+ display: block;+ clear: both;+ margin: 4px 0 6px;+ position: relative;+ padding-left: 15px;+ }}.wv-eventslist li.item ul li.dates {diff --git a/web/js/components/sidebar/event.js b/web/js/components/sidebar/event.jsindex 3bbf331bf..2aa1d67fd 100644--- a/web/js/components/sidebar/event.js+++ b/web/js/components/sidebar/event.js@@ -63,6 +63,13 @@ function Event (props) {>{event.geometry.map((geometry, index) => {const date = util.toISOStringDate(geometry.date);+ function magnitudeOutput() {+ const magnitudeUnit = geometry.magnitudeUnit ? geometry.magnitudeUnit : null;+ const magnitudeValue = geometry.magnitudeValue ? geometry.magnitudeValue.toLocaleString() : null;+ if (!magnitudeUnit && !magnitudeValue) return;+ const magnitudeDisplay = magnitudeUnit === 'kts' ? 'Wind Speed: ' : 'Surface Area: ';+ return `${magnitudeDisplay} ${magnitudeValue} ${magnitudeUnit}`;+ }return (<li key={`${event.id}-${date}`} className="dates"><a@@ -78,6 +85,9 @@ function Event (props) {>{formatDisplayDate(date)}</a>+ <p className="magnitude">+ {magnitudeOutput()}+ </p></li>);})}diff --git a/web/js/map/natural-events/cluster.js b/web/js/map/natural-events/cluster.jsindex f95a8e83d..45a45d232 100644--- a/web/js/map/natural-events/cluster.js+++ b/web/js/map/natural-events/cluster.js@@ -45,7 +45,7 @@ const secondClusterObj = naturalEventsClusterCreateObject(); // Cluster after se* @param {String} date* @return {Object} geoJSON point*/-export const clusterPointToGeoJSON = (id, coordinates, date) => ({+export const clusterPointToGeoJSON = (id, coordinates, date, { magnitudeUnit, magnitudeValue }) => ({type: 'Feature',properties: {id: `${id}-${date}`,@@ -55,6 +55,8 @@ export const clusterPointToGeoJSON = (id, coordinates, date) => ({geometry: {type: 'Point',coordinates,+ magnitudeUnit,+ magnitudeValue,},});@@ -108,15 +110,16 @@ export const getClusters = ({ geometry, id }, proj, selectedDate, map) => {id,coordinates,date,+ geom,);afterSelected = true;} else if (!afterSelected) {geoJSONPointsBeforeSelected.push(- clusterPointToGeoJSON(id, coordinates, date),+ clusterPointToGeoJSON(id, coordinates, date, geom),);} else {geoJSONPointsAfterSelected.push(- clusterPointToGeoJSON(id, coordinates, date),+ clusterPointToGeoJSON(id, coordinates, date, geom),);}});diff --git a/web/js/map/natural-events/util.js b/web/js/map/natural-events/util.jsindex a18794791..a57e58457 100644--- a/web/js/map/natural-events/util.js+++ b/web/js/map/natural-events/util.js@@ -15,8 +15,20 @@ export const getTrackPoint = function(proj, clusterPoint, isSelected, callback)const overlayEl = document.createElement('div');const circleEl = document.createElement('div');const textEl = document.createElement('span');- const { properties } = clusterPoint;+ const { properties, geometry } = clusterPoint;const content = document.createTextNode(formatDisplayDate(properties.date));++ const { magnitudeValue, magnitudeUnit } = geometry;+ const magnitudeContent = document.createElement('div');+ if (magnitudeUnit && magnitudeValue) {+ const superscriptUnit = document.createElement('sup');+ superscriptUnit.append('2');+ const formattedMagnitudeUnit = magnitudeUnit === 'kts' ? ' kts' : ' NM';+ magnitudeContent.append(magnitudeValue.toLocaleString());+ magnitudeContent.append(formattedMagnitudeUnit);+ if (formattedMagnitudeUnit === ' NM') magnitudeContent.append(superscriptUnit);+ }+const { date } = properties;const eventID = properties.event_id;let { coordinates } = clusterPoint.geometry;@@ -32,6 +44,7 @@ export const getTrackPoint = function(proj, clusterPoint, isSelected, callback)callback(eventID, date);};textEl.appendChild(content);+ textEl.appendChild(magnitudeContent);textEl.className = 'track-marker-date';circleEl.className = `track-marker track-marker-${date}`;circleEl.id = `track-marker-${date}`;