diff --git a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/data/ScienceBaseInfo.java b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/data/ScienceBaseInfo.java index 61b6fb97be0a106431e149894ce4bceab1945501..a57b2422537863b90b4404d86dfadfd4eb2b6e2a 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/data/ScienceBaseInfo.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/data/ScienceBaseInfo.java @@ -3,14 +3,21 @@ package gov.usgs.earthquake.nshmp.netcdf.data; public class ScienceBaseInfo { final String id; + final String file; final CatalogFileInfo[] files; final String scienceBaseVersion; final String title; final String url; - ScienceBaseInfo(String id, CatalogFileInfo[] files, String scienceBaseVersion, String title, + ScienceBaseInfo( + String id, + String file, + CatalogFileInfo[] files, + String scienceBaseVersion, + String title, String url) { this.id = id; + this.file = file; this.files = files; this.scienceBaseVersion = scienceBaseVersion; this.title = title; @@ -28,5 +35,4 @@ public class ScienceBaseInfo { this.vs30 = vs30; } } - } diff --git a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/NetcdfWsUtils.java b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/NetcdfWsUtils.java index be973c511e50b720dae084d523f25a59d5e50101..79dafabeadec0284ad344845b51910568287f8f0 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/NetcdfWsUtils.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/NetcdfWsUtils.java @@ -3,11 +3,18 @@ package gov.usgs.earthquake.nshmp.netcdf.www; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; +import java.lang.reflect.Type; import java.util.logging.Logger; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import gov.usgs.earthquake.nshmp.Maths; +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.www.Response; @@ -27,6 +34,7 @@ public class NetcdfWsUtils { .registerTypeAdapter(Imt.class, new EnumSerializer<Imt>()) .registerTypeAdapter(NehrpSiteClass.class, new EnumSerializer<NehrpSiteClass>()) .registerTypeAdapter(Double.class, new NaNSerializer()) + .registerTypeAdapter(Location.class, new LocationSerializer()) .disableHtmlEscaping() .serializeNulls() .setPrettyPrinting() @@ -56,4 +64,16 @@ public class NetcdfWsUtils { return UPPER_UNDERSCORE.to(UPPER_CAMEL, name()); } } + + public static final class LocationSerializer implements JsonSerializer<Location> { + + @Override + public JsonElement serialize(Location location, Type type, JsonSerializationContext context) { + JsonObject jObj = new JsonObject(); + jObj.addProperty("longitude", Maths.round(location.longitude, 5)); + jObj.addProperty("latitude", Maths.round(location.latitude, 5)); + + return jObj; + } + } } diff --git a/src/main/resources/hazard-example.nc b/src/main/resources/hazard-example.nc index fa9d0d8324e324a529acb7cdeb13a0c42d7ae094..f6336c3f0400bc76c84ba456aac6cfab4493779f 100644 Binary files a/src/main/resources/hazard-example.nc and b/src/main/resources/hazard-example.nc differ diff --git a/src/main/resources/rtsa-example.nc b/src/main/resources/rtsa-example.nc index 67961f49950d8840d29573a5744b9499d71470ef..e9c2864a3a34cb0c629cb7ae485db53cbbb688af 100644 Binary files a/src/main/resources/rtsa-example.nc and b/src/main/resources/rtsa-example.nc differ