From 43553fd8fdc0e26cfa39eb1968c6de139fcaedf5 Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Wed, 16 Mar 2016 17:02:21 -0600
Subject: [PATCH] updated site builder to clean and truncate site names

---
 etc/README.md                   |  2 ++
 src/org/opensha2/calc/Site.java | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/etc/README.md b/etc/README.md
index 6f852a99e..acc7daa4d 100644
--- a/etc/README.md
+++ b/etc/README.md
@@ -2,4 +2,6 @@ See the [examples](examples) directory as a starting point for command-line use
 
 [Matlab](matlab) shows how to take advantage of the ground motion model implementations in `nshmp-haz`.
 
+[Nshm](nshm) contains site lists and map polygons commonly used by the USGS NSHMP.
+
 [Peer](peer) is a collection of simple source models that are used for testing.
diff --git a/src/org/opensha2/calc/Site.java b/src/org/opensha2/calc/Site.java
index 9bff69fdc..2989469be 100644
--- a/src/org/opensha2/calc/Site.java
+++ b/src/org/opensha2/calc/Site.java
@@ -163,9 +163,12 @@ public class Site implements Named {
 
 		private Builder() {}
 
-		/** The name of the {@code Site}. */
+		/**
+		 * The name of the {@code Site}. Prior to setting, the supplied name is
+		 * stripped of commas and truncated at 72 characters.
+		 */
 		public Builder name(String name) {
-			this.name = checkNotNull(name);
+			this.name = cleanName(checkNotNull(name));
 			return this;
 		}
 
@@ -226,6 +229,10 @@ public class Site implements Named {
 
 	}
 
+	private static String cleanName(String name) {
+		return name.replaceAll(",", "").substring(0, 72);
+	}
+
 	/* Json and csv serialization keys */
 	static final class Key {
 		static final String NAME = "name";
-- 
GitLab