From c82ca169cd63d09ad6c8f22d8d5f01293a9ba6e7 Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Thu, 21 Jul 2022 09:43:16 -0600
Subject: [PATCH] Add hazard request data class

---
 .../nshmp/netcdf/www/RequestHazardCurves.java | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/RequestHazardCurves.java

diff --git a/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/RequestHazardCurves.java b/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/RequestHazardCurves.java
new file mode 100644
index 0000000..58e917a
--- /dev/null
+++ b/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/RequestHazardCurves.java
@@ -0,0 +1,68 @@
+package gov.usgs.earthquake.nshmp.netcdf.www;
+
+import java.util.List;
+
+import gov.usgs.earthquake.nshmp.Text;
+import gov.usgs.earthquake.nshmp.Text.Delimiter;
+import gov.usgs.earthquake.nshmp.geo.Location;
+import gov.usgs.earthquake.nshmp.gmm.Imt;
+import gov.usgs.earthquake.nshmp.gmm.NehrpSiteClass;
+import gov.usgs.earthquake.nshmp.netcdf.Nshm;
+import gov.usgs.earthquake.nshmp.netcdf.reader.NetcdfUtils.Key;
+import gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestData;
+import gov.usgs.earthquake.nshmp.netcdf.www.Request.RequestDataSiteClass;
+
+/**
+ * Request data for hazard services.
+ *
+ * @author U.S. Geological Survey
+ */
+public class RequestHazardCurves {
+
+  static class HazardRequestData extends RequestData {
+    public Nshm nshm;
+
+    HazardRequestData(Nshm nshm, Location site, ResponseFormat format) {
+      super(site, format);
+      this.nshm = nshm;
+    }
+  }
+
+  /**
+   * Request data with site class and imt
+   */
+  static class HazardRequestDataImt extends HazardRequestDataSiteClass {
+    public Imt imt;
+
+    HazardRequestDataImt(Nshm nshm, Location site, NehrpSiteClass siteClass, Imt imt,
+        ResponseFormat format) {
+      super(nshm, site, siteClass, format);
+      this.imt = imt;
+    }
+
+    @Override
+    public String toCsv() {
+      return String.format("%s,%s",
+          super.toCsv(), Text.join(List.of(Key.IMT.toString(), imt.name()), Delimiter.COMMA));
+    }
+  }
+
+  /**
+   * Request data with site class
+   */
+  static class HazardRequestDataSiteClass extends RequestDataSiteClass {
+    public Nshm nshm;
+
+    HazardRequestDataSiteClass(Nshm nshm, Location site, NehrpSiteClass siteClass,
+        ResponseFormat format) {
+      super(site, siteClass, format);
+      this.nshm = nshm;
+    }
+
+    @Override
+    public String toCsv() {
+      return String.format("%s,%s",
+          super.toCsv(), Text.join(List.of(Key.SITE_CLASS.toString(), siteClass), Delimiter.COMMA));
+    }
+  }
+}
-- 
GitLab