From 557df47027349c292a0d07fd101e8f9401c005fe Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Sun, 31 Jan 2021 14:46:19 -0700 Subject: [PATCH] gridSourceSet type; zoneForLoc returns optional --- .../usgs/earthquake/nshmp/model/GridLoader.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/model/GridLoader.java b/src/main/java/gov/usgs/earthquake/nshmp/model/GridLoader.java index c4738f2b..863b0c38 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/model/GridLoader.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/model/GridLoader.java @@ -306,7 +306,11 @@ class GridLoader { ? record.getOptionalDouble(Key.MMAX) : OptionalDouble.empty(); - String gridId = zoneForLocation(loc); + Optional<String> gridIdOpt = zoneForLocation(loc); + // if (gridIdOpt.isEmpty()) { + // return; + // } + String gridId = gridIdOpt.orElseThrow(); FeatureData featureData = dataMap.get(gridId); featureData.locations.add(loc); @@ -366,12 +370,15 @@ class GridLoader { return Map.copyOf(modelMfds); } - private String zoneForLocation(Location location) { + // TODO there are probably going to be curcumstances under which + // it is unreasonable to expect that every single point in a smoothed + // seismicity model is contained in a polygon + private Optional<String> zoneForLocation(Location location) { return featureMap.values().stream() .filter(grid -> grid.contains(location)) .map(grid -> grid.name) - .findFirst() - .orElseThrow(); + .findFirst(); + // .orElseThrow(); } } @@ -416,6 +423,7 @@ class GridLoader { } static GridSourceSet createGrid( + SourceType type, SourceConfig.Grid config, Feature feature, List<Location> locations, @@ -433,6 +441,7 @@ class GridLoader { .weight(weight) .gmms(gmms); builder.gridConfig(config); + builder.type(type); props.getDouble(Key.STRIKE).ifPresent(builder::strike); // System.out.println(mfds.get(0).properties().type()); -- GitLab