From 4b2e459c99f3e19cdf5b459c5820466fbffa5895 Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Tue, 1 Mar 2022 08:23:30 -0700 Subject: [PATCH] logging site data --- .../earthquake/nshmp/model/ModelLoader.java | 8 ++++++-- .../usgs/earthquake/nshmp/model/SiteData.java | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java b/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java index b3e1dcc2..2af32b83 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/ModelLoader.java @@ -60,6 +60,7 @@ import java.util.logging.Logger; import com.google.common.collect.Iterables; import gov.usgs.earthquake.nshmp.Maths; +import gov.usgs.earthquake.nshmp.Text; import gov.usgs.earthquake.nshmp.calc.CalcConfig; import gov.usgs.earthquake.nshmp.fault.FocalMech; import gov.usgs.earthquake.nshmp.geo.json.Feature; @@ -117,14 +118,17 @@ abstract class ModelLoader { static HazardModel load(Path dir) { try { - System.out.println(dir); + System.out.println(dir + Text.NEWLINE); CalcConfig config = readCalcConfig(dir); + SiteData siteData = readSiteData(dir); + System.out.println(siteData); + HazardModel.Builder builder = HazardModel.builder() .info(readModelInfo(dir).orElseThrow()) .config(config) - .siteData(readSiteData(dir)); + .siteData(siteData); /* Process tectonic setting source directories. */ loadTectonicSettings(dir, builder); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/SiteData.java b/src/main/java/gov/usgs/earthquake/nshmp/model/SiteData.java index d34cca8e..83f72e77 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/SiteData.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/SiteData.java @@ -1,5 +1,6 @@ package gov.usgs.earthquake.nshmp.model; +import static gov.usgs.earthquake.nshmp.Text.NEWLINE; import static gov.usgs.earthquake.nshmp.model.Deserialize.ID; import static gov.usgs.earthquake.nshmp.model.Deserialize.MODEL; import static gov.usgs.earthquake.nshmp.model.Deserialize.NAME; @@ -64,7 +65,9 @@ public class SiteData { static SiteData create(Path dir) { Set<Basin> basins = init(dir.resolve(BASIN_DIR), Basin::new); Set<Margin> margins = init(dir.resolve(MARGIN_DIR), Margin::new); - return new SiteData(basins, margins); + return (basins.isEmpty() && margins.isEmpty()) + ? EMPTY + : new SiteData(basins, margins); } /** @@ -101,7 +104,17 @@ public class SiteData { scale, RoundingMode.HALF_UP); } - // @Override + @Override + public String toString() { + StringBuilder sb = new StringBuilder(ModelFiles.SITE_DATA_DIR).append("/"); + if (this == EMPTY) { + return sb.append(" (empty)").toString(); + } + sb.append(NEWLINE); + basins.forEach(basin -> sb.append(" basin: ").append(basin.name).append(NEWLINE)); + margins.forEach(margin -> sb.append(" margin: ").append(margin.name).append(NEWLINE)); + return sb.toString(); + } /** Optional site data values associated with a location. */ public static class Values { -- GitLab