();
@@ -871,7 +874,8 @@ public class MapManager {
// handle new case
else {
created.add(ean);
- editAreaAttrs.put(ean, info);
+ info.put("editarea", ean);
+ attributes.add(info);
}
tempData.put(ean, mp);
diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/textproducts/AreaDictionaryMaker.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/textproducts/AreaDictionaryMaker.java
index 125638bc4e..ef4d062a1d 100644
--- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/textproducts/AreaDictionaryMaker.java
+++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/textproducts/AreaDictionaryMaker.java
@@ -20,27 +20,36 @@
package com.raytheon.edex.plugin.gfe.textproducts;
import java.io.File;
+import java.io.PrintWriter;
+import java.text.DecimalFormat;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import jep.JepException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import com.raytheon.edex.plugin.gfe.reference.MapManager;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
+import com.raytheon.uf.common.dataquery.db.QueryResult;
+import com.raytheon.uf.common.dataquery.db.QueryResultRow;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
+import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
+import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.util.FileUtil;
+import com.raytheon.uf.edex.database.tasks.SqlQueryTask;
/**
- * TODO Add Description
+ * Code to generate the AreaDictionary for text formatters
*
*
*
@@ -49,6 +58,8 @@ import com.raytheon.uf.common.util.FileUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 4, 2011 wldougher Moved from MapManager
+ * Oct 10, 2014 #3685 randerso Add code to generate the fips2cities and zones2cites
+ * python modules from the GIS database tables
*
*
*
@@ -57,11 +68,61 @@ import com.raytheon.uf.common.util.FileUtil;
*/
public class AreaDictionaryMaker {
- private static final Log theLogger = LogFactory
- .getLog(AreaDictionaryMaker.class);
+ protected static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(AreaDictionaryMaker.class);
+
+ protected static final String FIPS_CITY_QUERY = //
+ "SELECT name, population, ST_Y(city.the_geom), ST_X(city.the_geom) "
+ + "FROM mapdata.city, mapdata.county "
+ + "WHERE county.state = '%1$s' AND substring(fips,3,3) = '%2$s' "
+ + "AND ST_Contains(county.the_geom, city.the_geom) "
+ + "ORDER BY city.name;";
+
+ protected static final String ZONES_CITY_QUERY = //
+ "SELECT city.name, population, ST_Y(city.the_geom), ST_X(city.the_geom) "
+ + "FROM mapdata.city, mapdata.zone "
+ + "WHERE zone.state = '%1$s' AND zone.zone = '%2$s' "
+ + "AND ST_Contains(zone.the_geom, city.the_geom) "
+ + "ORDER BY city.name;";
+
+ protected static final Map PART_OF_STATE;
+ static {
+ PART_OF_STATE = new HashMap<>(30, 1.0f);
+ PART_OF_STATE.put(null, "");
+ PART_OF_STATE.put("bb", "big bend");
+ PART_OF_STATE.put("c", "");
+ PART_OF_STATE.put("cc", "central");
+ PART_OF_STATE.put("E", "");
+ PART_OF_STATE.put("ea", "east");
+ PART_OF_STATE.put("ec", "east central");
+ PART_OF_STATE.put("ee", "eastern");
+ PART_OF_STATE.put("er", "east central upper");
+ PART_OF_STATE.put("eu", "eastern upper");
+ PART_OF_STATE.put("M", "");
+ PART_OF_STATE.put("mi", "middle");
+ PART_OF_STATE.put("nc", "north central");
+ PART_OF_STATE.put("ne", "northeast");
+ PART_OF_STATE.put("nn", "northern");
+ PART_OF_STATE.put("nr", "north central upper");
+ PART_OF_STATE.put("nw", "northwest");
+ PART_OF_STATE.put("pa", "panhandle");
+ PART_OF_STATE.put("pd", "piedmont");
+ PART_OF_STATE.put("sc", "south central");
+ PART_OF_STATE.put("se", "southeast");
+ PART_OF_STATE.put("so", "south");
+ PART_OF_STATE.put("sr", "south central upper");
+ PART_OF_STATE.put("ss", "southern");
+ PART_OF_STATE.put("sw", "southwest");
+ PART_OF_STATE.put("up", "upstate");
+ PART_OF_STATE.put("wc", "west central");
+ PART_OF_STATE.put("wu", "western upper");
+ PART_OF_STATE.put("ww", "western");
+ }
protected IPathManager pathMgr = PathManagerFactory.getPathManager();
+ private Map stateDict;
+
/**
* Generate the AreaDictionary.py and CityLocation.py scripts for site,
* using editAreaAttrs.
@@ -73,14 +134,14 @@ public class AreaDictionaryMaker {
* A Map from edit area names to shape file attributes
*/
public void genAreaDictionary(String site,
- Map> editAreaAttrs) {
- theLogger.info("Area Dictionary generation phase");
+ Map>> editAreaAttrs) {
+ statusHandler.info("Area Dictionary generation phase");
if (site == null) {
throw new IllegalArgumentException("site is null");
}
- if ("".equals(site)) {
+ if (site.isEmpty()) {
throw new IllegalArgumentException("site is an empty string");
}
@@ -89,14 +150,99 @@ public class AreaDictionaryMaker {
}
long t0 = System.currentTimeMillis();
+ genStateDict();
- LocalizationContext cx = pathMgr.getContext(
+ LocalizationContext context = pathMgr.getContext(
+ LocalizationContext.LocalizationType.EDEX_STATIC,
+ LocalizationContext.LocalizationLevel.CONFIGURED);
+ context.setContextName(site);
+
+ List