From e8111e33331256c03ba80b67ae00db2b4fd4738c Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Fri, 4 Mar 2016 10:23:33 -0700 Subject: [PATCH] bounds updates --- src/org/opensha2/geo/Bounds.java | 15 ++++++++------ src/org/opensha2/util/NshmpSite.java | 28 +++++++++++++++++++++++---- test/org/opensha2/geo/BoundsTest.java | 7 ++++--- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/org/opensha2/geo/Bounds.java b/src/org/opensha2/geo/Bounds.java index 25ec37df2..37201e6fa 100644 --- a/src/org/opensha2/geo/Bounds.java +++ b/src/org/opensha2/geo/Bounds.java @@ -4,8 +4,8 @@ import java.util.Arrays; import java.util.Objects; /** - * A bounding box specified by a lower-left coordinate ({@link #min()}) and an - * upper-right coordinate ({@link #max()}). + * A rectangular (in Mercator projection) bounding box specified by a lower-left + * coordinate ({@link #min()}) and an upper-right coordinate ({@link #max()}). * * <p>Bounds are 2-dimensional in that the depth component of the corners will * always be 0. @@ -53,15 +53,15 @@ public final class Bounds { max, Location.create(max.lat(), min.lon())); } - + /** * Return the values of this {@code Bounds} object in the form * {@code [min().lon(), min().lat(), max().lon(), max().lat()]}. */ public double[] toArray() { - return new double[] { min.lon(), min.lat(), max.lon(), max.lat()}; + return new double[] { min.lon(), min.lat(), max.lon(), max.lat() }; } - + @Override public boolean equals(Object obj) { if (obj == null) return false; @@ -70,12 +70,15 @@ public final class Bounds { if (min == other.min && max == other.max) return true; return min.equals(other.min) && max.equals(other.max); } - + @Override public int hashCode() { return Objects.hash(min, max); } + /** + * Returns the string representation of {@link #toArray()}. + */ @Override public String toString() { return Arrays.toString(toArray()); diff --git a/src/org/opensha2/util/NshmpSite.java b/src/org/opensha2/util/NshmpSite.java index 983f31f1b..ac6899a36 100644 --- a/src/org/opensha2/util/NshmpSite.java +++ b/src/org/opensha2/util/NshmpSite.java @@ -207,7 +207,8 @@ public enum NshmpSite implements NamedLocation { return loc; } - @Override public String id() { + @Override + public String id() { return this.name(); } @@ -218,11 +219,25 @@ public enum NshmpSite implements NamedLocation { return label.substring(0, stripIndex) + " " + state.name(); } + /** + * The set of sites used to test the Central & Eastern US NSHM. + */ + public static EnumSet<NshmpSite> ceus() { + return EnumSet.range(WASHINGTON_DC, CHEYENNE_WY); + } + + /** + * The set of sites used to test the Western US NSHM. + */ + public static EnumSet<NshmpSite> wus() { + return EnumSet.range(BIG_SUR_CA, YAKIMA_WA); + } + /** * The set of sites corresponding to U.S. national labs and other Dept. of * Energy facilities. */ - public Set<NshmpSite> facilities() { + public static EnumSet<NshmpSite> facilities() { return EnumSet.of( DIABLO_CANYON_CA, SAN_ONOFRE_CA, @@ -233,9 +248,14 @@ public enum NshmpSite implements NamedLocation { } /** - * The set of sites corresponding to the 34 NEHRP test cities. + * The set of sites corresponding to the NEHRP test cities. + * + * <p>This is a list of 34 city sites in the United States with high seismic + * risk as specified in the 2009 edition of the <a + * href="http://www.fema.gov/library/viewRecord.do?id=4103" + * target=_blank">NEHRP Recommended Seismic Provisions</a>. */ - public Set<NshmpSite> nehrpTestCities() { + public static EnumSet<NshmpSite> nehrpTestCities() { return EnumSet.of( // SoCal LOS_ANGELES_CA, diff --git a/test/org/opensha2/geo/BoundsTest.java b/test/org/opensha2/geo/BoundsTest.java index 4a5525ed0..6a9f8ddc0 100644 --- a/test/org/opensha2/geo/BoundsTest.java +++ b/test/org/opensha2/geo/BoundsTest.java @@ -1,8 +1,9 @@ package org.opensha2.geo; -import static org.junit.Assert.*; - -import java.util.Arrays; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertSame; import org.junit.Test; -- GitLab