From 2229efee72c7ab0bda32726fc198564d2b08be26 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 7 Feb 2017 22:14:13 -0700
Subject: [PATCH] AK sites and polys

---
 etc/nshm/map-alaska.geojson                   |  19 ++
 etc/nshm/sites-alaska.csv                     |  27 ++
 etc/nshm/sites-alaska.geojson                 | 291 ++++++++++++++++++
 etc/nshm/sites-nshmp.csv                      |  26 ++
 etc/nshm/sites-nshmp.geojson                  | 286 +++++++++++++++++
 src/org/opensha2/internal/NshmpSite.java      |  53 +++-
 src/org/opensha2/internal/NshmpSiteFiles.java |  15 +-
 7 files changed, 712 insertions(+), 5 deletions(-)
 create mode 100644 etc/nshm/map-alaska.geojson
 create mode 100644 etc/nshm/sites-alaska.csv
 create mode 100644 etc/nshm/sites-alaska.geojson

diff --git a/etc/nshm/map-alaska.geojson b/etc/nshm/map-alaska.geojson
new file mode 100644
index 000000000..cdbf3df6c
--- /dev/null
+++ b/etc/nshm/map-alaska.geojson
@@ -0,0 +1,19 @@
+{
+  "type": "FeatureCollection",
+  "features": [
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Polygon",
+        "coordinates": [[
+            [ -200.0, 48.0 ],
+            [ -125.0, 72.0 ]
+          ]]
+      },
+      "properties": {
+        "spacing": 0.1,
+        "title": "Alaska"
+      }
+    }
+  ]
+}
diff --git a/etc/nshm/sites-alaska.csv b/etc/nshm/sites-alaska.csv
new file mode 100644
index 000000000..7f1b85d75
--- /dev/null
+++ b/etc/nshm/sites-alaska.csv
@@ -0,0 +1,27 @@
+name,                            lon,    lat
+Adak AK,                     -176.65,  51.90
+Anchorage AK,                -149.90,  61.20
+Barrow AK,                   -156.75,  71.30
+Bethel AK,                   -161.80,  60.80
+Delta Junction AK,           -145.70,  64.00
+Dillingham AK,               -158.45,  59.05
+Dutch Harbor AK,             -166.55,  53.90
+Evansville AK,               -151.50,  66.90
+Fairbanks AK,                -147.70,  64.85
+Glennallen AK,               -145.55,  62.10
+Haines AK,                   -135.45,  59.25
+Homer AK,                    -151.50,  59.65
+Juneau AK,                   -134.40,  58.30
+Kenai AK,                    -151.25,  60.55
+Ketchikan AK,                -131.65,  55.35
+Kodiak AK,                   -152.40,  57.80
+Kotzebue AK,                 -162.60,  66.90
+McGrath AK,                  -155.60,  62.95
+Nome AK,                     -165.40,  64.50
+Paxson AK,                   -145.50,  63.05
+Prudhoe Bay AK,              -148.35,  70.25
+Sitka AK,                    -135.35,  57.05
+Tok AK,                      -143.00,  63.30
+Valdez AK,                   -146.35,  61.15
+Wasilla AK,                  -149.45,  61.60
+Yakutat AK,                  -139.70,  59.55
diff --git a/etc/nshm/sites-alaska.geojson b/etc/nshm/sites-alaska.geojson
new file mode 100644
index 000000000..28b96440e
--- /dev/null
+++ b/etc/nshm/sites-alaska.geojson
@@ -0,0 +1,291 @@
+{
+  "type": "FeatureCollection",
+  "features": [
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-176.65, 51.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Adak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.9, 61.2]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Anchorage AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-156.75, 71.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Barrow AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-161.8, 60.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Bethel AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.7, 64.0]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Delta Junction AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-158.45, 59.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dillingham AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-166.55, 53.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dutch Harbor AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Evansville AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-147.7, 64.85]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Fairbanks AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.55, 62.1]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Glennallen AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.45, 59.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Haines AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 59.65]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Homer AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-134.4, 58.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Juneau AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.25, 60.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kenai AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-131.65, 55.35]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Ketchikan AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-152.4, 57.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kodiak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-162.6, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kotzebue AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-155.6, 62.95]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "McGrath AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-165.4, 64.5]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Nome AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.5, 63.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Paxson AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-148.35, 70.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Prudhoe Bay AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.35, 57.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Sitka AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-143.0, 63.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Tok AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-146.35, 61.15]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Valdez AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.45, 61.6]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Wasilla AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-139.7, 59.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Yakutat AK"
+      }
+    }
+  ]
+}
diff --git a/etc/nshm/sites-nshmp.csv b/etc/nshm/sites-nshmp.csv
index 1bc6a43f1..78fcb66d7 100644
--- a/etc/nshm/sites-nshmp.csv
+++ b/etc/nshm/sites-nshmp.csv
@@ -1,4 +1,30 @@
 name,                            lon,    lat
+Adak AK,                     -176.65,  51.90
+Anchorage AK,                -149.90,  61.20
+Barrow AK,                   -156.75,  71.30
+Bethel AK,                   -161.80,  60.80
+Delta Junction AK,           -145.70,  64.00
+Dillingham AK,               -158.45,  59.05
+Dutch Harbor AK,             -166.55,  53.90
+Evansville AK,               -151.50,  66.90
+Fairbanks AK,                -147.70,  64.85
+Glennallen AK,               -145.55,  62.10
+Haines AK,                   -135.45,  59.25
+Homer AK,                    -151.50,  59.65
+Juneau AK,                   -134.40,  58.30
+Kenai AK,                    -151.25,  60.55
+Ketchikan AK,                -131.65,  55.35
+Kodiak AK,                   -152.40,  57.80
+Kotzebue AK,                 -162.60,  66.90
+McGrath AK,                  -155.60,  62.95
+Nome AK,                     -165.40,  64.50
+Paxson AK,                   -145.50,  63.05
+Prudhoe Bay AK,              -148.35,  70.25
+Sitka AK,                    -135.35,  57.05
+Tok AK,                      -143.00,  63.30
+Valdez AK,                   -146.35,  61.15
+Wasilla AK,                  -149.45,  61.60
+Yakutat AK,                  -139.70,  59.55
 Atmore AL,                    -87.50,  31.00
 Birmingham AL,                -86.80,  33.50
 El Dorado AR,                 -92.70,  33.20
diff --git a/etc/nshm/sites-nshmp.geojson b/etc/nshm/sites-nshmp.geojson
index 109f585d8..9a6865d0a 100644
--- a/etc/nshm/sites-nshmp.geojson
+++ b/etc/nshm/sites-nshmp.geojson
@@ -1,6 +1,292 @@
 {
   "type": "FeatureCollection",
   "features": [
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-176.65, 51.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Adak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.9, 61.2]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Anchorage AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-156.75, 71.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Barrow AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-161.8, 60.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Bethel AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.7, 64.0]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Delta Junction AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-158.45, 59.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dillingham AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-166.55, 53.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Dutch Harbor AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Evansville AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-147.7, 64.85]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Fairbanks AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.55, 62.1]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Glennallen AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.45, 59.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Haines AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.5, 59.65]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Homer AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-134.4, 58.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Juneau AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-151.25, 60.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kenai AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-131.65, 55.35]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Ketchikan AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-152.4, 57.8]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kodiak AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-162.6, 66.9]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Kotzebue AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-155.6, 62.95]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "McGrath AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-165.4, 64.5]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Nome AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-145.5, 63.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Paxson AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-148.35, 70.25]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Prudhoe Bay AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-135.35, 57.05]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Sitka AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-143.0, 63.3]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Tok AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-146.35, 61.15]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Valdez AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-149.45, 61.6]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Wasilla AK"
+      }
+    },
+    {
+      "type": "Feature",
+      "geometry": {
+        "type": "Point",
+        "coordinates": [-139.7, 59.55]
+      },
+      "properties": {
+        "marker-size": "small",
+        "title": "Yakutat AK"
+      }
+    },
     {
       "type": "Feature",
       "geometry": {
diff --git a/src/org/opensha2/internal/NshmpSite.java b/src/org/opensha2/internal/NshmpSite.java
index 6cdbf0226..6bedd5b81 100644
--- a/src/org/opensha2/internal/NshmpSite.java
+++ b/src/org/opensha2/internal/NshmpSite.java
@@ -201,7 +201,35 @@ public enum NshmpSite implements NamedLocation {
   BLACKSBURG_VA(-80.40, 37.25),
   RICHMOND_VA(-77.45, 37.55),
   CHARLESTON_WV(-81.65, 38.35),
-  MILWAUKEE_WI(-87.90, 43.05);
+  MILWAUKEE_WI(-87.90, 43.05),
+
+  /* Alaska */
+  ADAK_AK(-176.65, 51.9),
+  ANCHORAGE_AK(-149.90, 61.2),
+  BARROW_AK(-156.75, 71.3),
+  BETHEL_AK(-161.80, 60.8),
+  DELTA_JUNCTION_AK(-145.70, 64),
+  DILLINGHAM_AK(-158.45, 59.05),
+  DUTCH_HARBOR_AK(-166.55, 53.9),
+  EVANSVILLE_AK(-151.50, 66.9),
+  FAIRBANKS_AK(-147.70, 64.85),
+  GLENNALLEN_AK(-145.55, 62.1),
+  HAINES_AK(-135.45, 59.25),
+  HOMER_AK(-151.50, 59.65),
+  JUNEAU_AK(-134.40, 58.3),
+  KENAI_AK(-151.25, 60.55),
+  KETCHIKAN_AK(-131.65, 55.35),
+  KODIAK_AK(-152.40, 57.8),
+  KOTZEBUE_AK(-162.60, 66.9),
+  MCGRATH_AK(-155.60, 62.95),
+  NOME_AK(-165.40, 64.5),
+  PAXSON_AK(-145.50, 63.05),
+  PRUDHOE_BAY_AK(-148.35, 70.25),
+  SITKA_AK(-135.35, 57.05),
+  TOK_AK(-143.00, 63.3),
+  VALDEZ_AK(-146.35, 61.15),
+  WASILLA_AK(-149.45, 61.6),
+  YAKUTAT_AK(-139.70, 59.55);
 
   private final Location loc;
   private final UsRegion state;
@@ -228,6 +256,11 @@ public enum NshmpSite implements NamedLocation {
   @Override
   public String toString() {
     String label = Parsing.enumLabelWithSpaces(this, true);
+    if (label.startsWith("Mc")) {
+      StringBuilder sb = new StringBuilder(label);
+      sb.setCharAt(2, Character.toUpperCase(sb.charAt(2))); 
+      label = sb.toString();
+    }
     int stripIndex = label.lastIndexOf(' ');
     return label.substring(0, stripIndex) + " " + state.name();
   }
@@ -257,7 +290,21 @@ public enum NshmpSite implements NamedLocation {
         new Predicate<NshmpSite>() {
           @Override
           public boolean apply(NshmpSite site) {
-            return site.loc.lon() <= -100.0;
+            return site.loc.lon() <= -100.0 && site.loc.lon() >= -125.0;
+          }
+        }), NshmpSite.class);
+  }
+
+  /**
+   * The set of sites used to test the Alaska NSHM.
+   */
+  public static EnumSet<NshmpSite> alaska() {
+    return Sets.newEnumSet(Iterables.filter(
+        EnumSet.allOf(NshmpSite.class),
+        new Predicate<NshmpSite>() {
+          @Override
+          public boolean apply(NshmpSite site) {
+            return site.loc.lon() <= -125.0;
           }
         }), NshmpSite.class);
   }
@@ -340,7 +387,7 @@ public enum NshmpSite implements NamedLocation {
         CHICAGO_IL,
         NEW_YORK_NY);
   }
-  
+
   static class StateComparator implements Comparator<NshmpSite> {
     @Override
     public int compare(NshmpSite s1, NshmpSite s2) {
diff --git a/src/org/opensha2/internal/NshmpSiteFiles.java b/src/org/opensha2/internal/NshmpSiteFiles.java
index 2581fd2cc..aaf970f01 100644
--- a/src/org/opensha2/internal/NshmpSiteFiles.java
+++ b/src/org/opensha2/internal/NshmpSiteFiles.java
@@ -3,6 +3,7 @@ package org.opensha2.internal;
 import static com.google.common.base.Strings.padEnd;
 import static com.google.common.base.Strings.padStart;
 
+import static org.opensha2.internal.NshmpPolygon.AK_CLIP;
 import static org.opensha2.internal.NshmpPolygon.CEUS_CLIP;
 import static org.opensha2.internal.NshmpPolygon.CONTERMINOUS_US;
 import static org.opensha2.internal.NshmpPolygon.CYBERSHAKE;
@@ -67,7 +68,7 @@ final class NshmpSiteFiles {
     writeSites("nureg", EnumSet.allOf(NuregSite.class), DEC3_FMT);
     writeCybershakeSites("cybershake", EnumSet.allOf(CybershakeSite.class));
 
-    // writeNshmpPolys();
+     writeNshmpPolys();
     // writeNshmpSummaryPoly();
     // writeNshmpSites_0p1();
   }
@@ -88,7 +89,16 @@ final class NshmpSiteFiles {
     Path wusOut = EXPORT_DIR.resolve("map-wus.geojson");
     LocationList wusBounds = WUS_CLIP.coordinates();
     writePolyJson(wusOut, "NSHMP Western US", usCoords, 0.1, wusBounds);
-
+    
+    // TODO AK needs to be updated with proper clipping region as above
+    // currently just mercator rectangle
+    writePolyJson(
+        EXPORT_DIR.resolve("map-alaska.geojson"),
+        "Alaska",
+        AK_CLIP.coordinates(),
+        0.1,
+        null);
+    
     writePolyJson(
         EXPORT_DIR.resolve("map-la-basin.geojson"),
         LA_BASIN.toString(),
@@ -227,6 +237,7 @@ final class NshmpSiteFiles {
     writeNshmpSites("ceus", NshmpSite.ceus());
     writeNshmpSites("wus", NshmpSite.wus());
     writeNshmpSites("nrc", NshmpSite.nrc());
+    writeNshmpSites("alaska", NshmpSite.alaska());
     writeSites("nehrp", NshmpSite.nehrp(), DEC2_FMT);
   }
 
-- 
GitLab