From 150cd546027c4798b8848949c1290caee972d1f1 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Fri, 22 Mar 2013 16:21:45 -0500 Subject: [PATCH] Issue #1817 BOX issue with only having HUC0 in template Change-Id: I4dee15d72c1a5b56bbb3d04c7a74f292d6ff87b8 Former-commit-id: c2b9bd1024aab4db422cf7ee1527456b8fe3a82d [formerly 58a37d1e44c68dbfe42a67aa885bf3732cd50e60] [formerly d114302b06372081a2a3751cf2f224d89516146d [formerly f0641a4771b6816944f38d1ec51b0356b983e2f4]] Former-commit-id: d114302b06372081a2a3751cf2f224d89516146d Former-commit-id: 3cdd8f8ed27515f2c1641114befcb9b1ee07cbc4 --- .../common/dataplugin/ffmp/FFMPTemplates.java | 33 ++++++++++++++++--- .../uf/common/dataplugin/ffmp/FFMPUtils.java | 9 +++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java index 38487367b7..fefb4571df 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java @@ -85,6 +85,7 @@ import com.vividsolutions.jts.io.WKBReader; * 02/01/13 1569 D.Hladky Constants * 03/01/13 DR13228 G. Zhang Add VGB county and related code * 02/20/13 1635 D. Hladky Constants + * 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up. * * * @author dhladky @@ -250,11 +251,35 @@ public class FFMPTemplates { "No configuration file found, default settings applied"); // we use 4 because it is the 90% solution as a start point for - // the analysis - ArrayList hucParams = FFMPUtils.getHucParameters(4, + // the analysis. Added check to make sure at least 2 HUC layers are created. + int preliminarystart = 4; + // first crack + ArrayList hucParams = FFMPUtils.getHucParameters(preliminarystart, primaryCWA.getCwa()); - setHucDepthStart(hucParams.get(0)); - setTotalHucLevels(hucParams.get(1)); + int startDepth = hucParams.get(0); + int numlevels = hucParams.get(1); + int i = 1; + // recursively call until we have two layers + while (numlevels < 2) { + int checkDepth = preliminarystart - i; + hucParams = FFMPUtils.getHucParameters(checkDepth, + primaryCWA.getCwa()); + startDepth = hucParams.get(0); + numlevels = hucParams.get(1); + i++; + + // safety value in case it just won't work with this shape + if (checkDepth == 0) { + // bail, won't work + statusHandler + .handle(Priority.ERROR, + "Cannot create a good template. There are not enough unique HUC's to create more than 1 layer."); + return; + } + } + + setHucDepthStart(startDepth); + setTotalHucLevels(numlevels); setExtents(20000.0); setVirtual(true); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java index 0f60283353..9f98071a4b 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java @@ -83,6 +83,7 @@ import com.vividsolutions.jts.io.WKTWriter; * 06/18/12 DR 15108 G. Zhang Fix County FIPS 4-digit issue * 01/02/13 DR 1569 D. Hladky constants, arraylist to list and moved common menthods here * 03/01/13 DR 13228 G. Zhang Add state for VGB query and related code + * 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up. * * @author dhladky * @version 1 @@ -304,18 +305,20 @@ public class FFMPUtils { int startDepth = prelimstartDepth; for (int i = 0; i < pfafs.length; i++) { - int depth = pfafs[i].indexOf("0"); + int depth = pfafs[i].substring(prelimstartDepth).indexOf("0"); + depth = prelimstartDepth + depth; if (depth > maxDepth) { maxDepth = depth; } } - + // do an 80% analysis to find min (startDepth) if (pfafs.length > 0) { for (int myMinDepth = maxDepth; myMinDepth > 0; myMinDepth--) { int ilevelcount = 0; for (int i = 0; i < pfafs.length; i++) { - int idepth = pfafs[i].indexOf("0"); + int idepth = pfafs[i].substring(prelimstartDepth).indexOf("0"); + idepth = prelimstartDepth + idepth; if (idepth >= myMinDepth) { ilevelcount++; }