Issue #1817 BOX issue with only having HUC0 in template

Change-Id: I4dee15d72c1a5b56bbb3d04c7a74f292d6ff87b8

Former-commit-id: c2b9bd1024 [formerly 58a37d1e44] [formerly d114302b06 [formerly f0641a4771b6816944f38d1ec51b0356b983e2f4]]
Former-commit-id: d114302b06
Former-commit-id: 3cdd8f8ed2
This commit is contained in:
Dave Hladky 2013-03-22 16:21:45 -05:00
parent a2e5e18810
commit 150cd54602
2 changed files with 35 additions and 7 deletions

View file

@ -85,6 +85,7 @@ import com.vividsolutions.jts.io.WKBReader;
* 02/01/13 1569 D.Hladky Constants * 02/01/13 1569 D.Hladky Constants
* 03/01/13 DR13228 G. Zhang Add VGB county and related code * 03/01/13 DR13228 G. Zhang Add VGB county and related code
* 02/20/13 1635 D. Hladky Constants * 02/20/13 1635 D. Hladky Constants
* 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up.
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -250,11 +251,35 @@ public class FFMPTemplates {
"No configuration file found, default settings applied"); "No configuration file found, default settings applied");
// we use 4 because it is the 90% solution as a start point for // we use 4 because it is the 90% solution as a start point for
// the analysis // the analysis. Added check to make sure at least 2 HUC layers are created.
ArrayList<Integer> hucParams = FFMPUtils.getHucParameters(4, int preliminarystart = 4;
// first crack
ArrayList<Integer> hucParams = FFMPUtils.getHucParameters(preliminarystart,
primaryCWA.getCwa()); primaryCWA.getCwa());
setHucDepthStart(hucParams.get(0)); int startDepth = hucParams.get(0);
setTotalHucLevels(hucParams.get(1)); 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); setExtents(20000.0);
setVirtual(true); setVirtual(true);

View file

@ -83,6 +83,7 @@ import com.vividsolutions.jts.io.WKTWriter;
* 06/18/12 DR 15108 G. Zhang Fix County FIPS 4-digit issue * 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 * 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/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.
* </pre> * </pre>
* @author dhladky * @author dhladky
* @version 1 * @version 1
@ -304,18 +305,20 @@ public class FFMPUtils {
int startDepth = prelimstartDepth; int startDepth = prelimstartDepth;
for (int i = 0; i < pfafs.length; i++) { 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) { if (depth > maxDepth) {
maxDepth = depth; maxDepth = depth;
} }
} }
// do an 80% analysis to find min (startDepth) // do an 80% analysis to find min (startDepth)
if (pfafs.length > 0) { if (pfafs.length > 0) {
for (int myMinDepth = maxDepth; myMinDepth > 0; myMinDepth--) { for (int myMinDepth = maxDepth; myMinDepth > 0; myMinDepth--) {
int ilevelcount = 0; int ilevelcount = 0;
for (int i = 0; i < pfafs.length; i++) { 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) { if (idepth >= myMinDepth) {
ilevelcount++; ilevelcount++;
} }