Mercurial > dive4elements > river
changeset 6550:7cf3b3bcd439
BedDiffHeightYearGenerator: Correct list size check, in
BedDifferenceYearGenerator do analog refactoring.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 10 Jul 2013 09:31:43 +0200 |
parents | e7eb3c4afcf3 |
children | 8c226c5089e0 |
files | artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java |
diffstat | 2 files changed, 34 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java Tue Jul 09 10:50:33 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java Wed Jul 10 09:31:43 2013 +0200 @@ -133,7 +133,7 @@ } else if (getXBounds(0) == null && getDomainAxisRange() == null) { BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); - if (data.getKms().size() >= 0) { + if (data.getKms().size() > 0) { context.putContextValue("startkm", data.getKms().min()); context.putContextValue("endkm", data.getKms().max()); }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java Tue Jul 09 10:50:33 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java Wed Jul 10 09:31:43 2013 +0200 @@ -86,6 +86,37 @@ }; } + public void setContextBounds(ArtifactAndFacet bundle) { + if (getXBounds(0) != null && getDomainAxisRange() != null) { + Bounds bounds = + calculateZoom(getXBounds(0), getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } + else if (getXBounds(0) != null && getDomainAxisRange() == null) { + context.putContextValue("startkm", getXBounds(0).getLower()); + context.putContextValue("endkm", getXBounds(0).getUpper()); + } + else if (getXBounds(0) == null && getDomainAxisRange() == null) { + BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); + if (data.getKms().size() > 0) { + context.putContextValue("startkm", data.getKms().min()); + context.putContextValue("endkm", data.getKms().max()); + } + else { + logger.warn("No data to define start and end km"); + } + } + else if (getXBounds(0) == null && getDomainAxisRange() != null){ + BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); + Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); + Bounds bounds = + calculateZoom(b, getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } + } + @Override public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { String name = bundle.getFacetName(); @@ -103,29 +134,8 @@ return; } - if (getXBounds(0) != null && getDomainAxisRange() != null) { - Bounds bounds = - calculateZoom(getXBounds(0), getDomainAxisRange()); - context.putContextValue("startkm", bounds.getLower()); - context.putContextValue("endkm", bounds.getUpper()); - } - else if (getXBounds(0) != null && getDomainAxisRange() == null) { - context.putContextValue("startkm", getXBounds(0).getLower()); - context.putContextValue("endkm", getXBounds(0).getUpper()); - } - else if (getXBounds(0) == null && getDomainAxisRange() == null) { - BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); - context.putContextValue("startkm", data.getKms().min()); - context.putContextValue("endkm", data.getKms().max()); - } - else if (getXBounds(0) == null && getDomainAxisRange() != null){ - BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); - Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); - Bounds bounds = - calculateZoom(b, getDomainAxisRange()); - context.putContextValue("startkm", bounds.getLower()); - context.putContextValue("endkm", bounds.getUpper()); - } + setContextBounds(bundle); + Processor processor = new KMIndexProcessor(); Processor woutp = new WOutProcessor(); if (name.equals(BED_DIFFERENCE_YEAR)) {